Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CodeVault
hpc-kernels
unstructured_grids
Commits
79c821dc
Commit
79c821dc
authored
Jan 21, 2016
by
Thomas Ponweiser
Browse files
Halo exchange sample (unstructured grids): fixed some compiler warnings
parent
e6335681
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
22 additions
and
15 deletions
+22
-15
halo_exchange/box.c
halo_exchange/box.c
+8
-5
halo_exchange/box.h
halo_exchange/box.h
+1
-1
halo_exchange/configuration.c
halo_exchange/configuration.c
+4
-2
halo_exchange/configuration.h
halo_exchange/configuration.h
+2
-2
halo_exchange/field.c
halo_exchange/field.c
+1
-0
halo_exchange/mesh.c
halo_exchange/mesh.c
+3
-2
halo_exchange/mpicomm.c
halo_exchange/mpicomm.c
+3
-3
No files found.
halo_exchange/box.c
View file @
79c821dc
...
@@ -50,7 +50,7 @@ int box_is_empty(const box_t *b)
...
@@ -50,7 +50,7 @@ int box_is_empty(const box_t *b)
return
extents
[
X
]
<=
0
||
extents
[
Y
]
<=
0
||
extents
[
Z
]
<=
0
;
return
extents
[
X
]
<=
0
||
extents
[
Y
]
<=
0
||
extents
[
Z
]
<=
0
;
}
}
void
box_split
(
const
box_t
*
original
,
box_t
*
a
,
box_t
*
b
)
void
box_split
(
const
box_t
*
original
,
box_t
*
a
,
box_t
*
b
,
int
randomize
)
{
{
const
int
*
extents
=
original
->
extents
;
const
int
*
extents
=
original
->
extents
;
...
@@ -66,7 +66,8 @@ void box_split(const box_t *original, box_t *a, box_t *b)
...
@@ -66,7 +66,8 @@ void box_split(const box_t *original, box_t *a, box_t *b)
}
}
}
}
int
ea
=
(
int
)
round
(
max_extent
*
random_split_ratio
());
double
split_ratio
=
randomize
?
random_split_ratio
()
:
0
.
5
;
int
ea
=
(
int
)
round
(
max_extent
*
split_ratio
);
int
eb
=
max_extent
-
ea
;
int
eb
=
max_extent
-
ea
;
*
a
=
*
original
;
*
a
=
*
original
;
...
@@ -82,15 +83,17 @@ void box_split(const box_t *original, box_t *a, box_t *b)
...
@@ -82,15 +83,17 @@ void box_split(const box_t *original, box_t *a, box_t *b)
void
box_decompose
(
const
box_t
*
original
,
int
n_boxes
,
box_t
*
boxes
)
void
box_decompose
(
const
box_t
*
original
,
int
n_boxes
,
box_t
*
boxes
)
{
{
box_t
largest_box
,
tmp_box
,
part1
,
part2
;
box_t
largest_box
,
part1
,
part2
;
int
i
,
j
,
n
,
child1
,
child2
;
int
n
,
randomize
;
boxes
[
0
]
=
*
original
;
boxes
[
0
]
=
*
original
;
n
=
1
;
n
=
1
;
while
(
n
<
n_boxes
)
{
while
(
n
<
n_boxes
)
{
randomize
=
n
<
n_boxes
/
2
;
// take out box with maximum volume and split in two
// take out box with maximum volume and split in two
box_heap_take_first
(
boxes
,
&
n
,
&
largest_box
);
box_heap_take_first
(
boxes
,
&
n
,
&
largest_box
);
box_split
(
&
largest_box
,
&
part1
,
&
part2
);
box_split
(
&
largest_box
,
&
part1
,
&
part2
,
randomize
);
// insert boxes
// insert boxes
box_heap_insert
(
boxes
,
&
n
,
&
part1
);
box_heap_insert
(
boxes
,
&
n
,
&
part1
);
...
...
halo_exchange/box.h
View file @
79c821dc
...
@@ -22,7 +22,7 @@ void box_intersect(const box_t *a, const box_t *b, box_t *intersection);
...
@@ -22,7 +22,7 @@ void box_intersect(const box_t *a, const box_t *b, box_t *intersection);
int
box_is_empty
(
const
box_t
*
b
);
int
box_is_empty
(
const
box_t
*
b
);
void
box_split
(
const
box_t
*
box
,
box_t
*
a
,
box_t
*
b
);
void
box_split
(
const
box_t
*
box
,
box_t
*
a
,
box_t
*
b
,
int
randomize
);
void
box_decompose
(
const
box_t
*
original
,
int
n_boxes
,
box_t
*
boxes
);
void
box_decompose
(
const
box_t
*
original
,
int
n_boxes
,
box_t
*
boxes
);
...
...
halo_exchange/configuration.c
View file @
79c821dc
...
@@ -14,6 +14,8 @@ void set_ncells_per_proc(conf_t *c, double ncells_per_proc);
...
@@ -14,6 +14,8 @@ void set_ncells_per_proc(conf_t *c, double ncells_per_proc);
void
set_ncells_total
(
conf_t
*
c
,
double
ncells_total
);
void
set_ncells_total
(
conf_t
*
c
,
double
ncells_total
);
void
set_global_domain
(
conf_t
*
c
,
int
cube_edge_length
);
void
set_global_domain
(
conf_t
*
c
,
int
cube_edge_length
);
int
log_enabled
(
const
conf_t
*
c
,
int
lvl
);
const
char
*
verbosity_levels
[]
=
{
"OFF"
,
"INFO"
,
"DEBUG"
,
"TRACE"
};
const
char
*
verbosity_levels
[]
=
{
"OFF"
,
"INFO"
,
"DEBUG"
,
"TRACE"
};
// ==========================================================================
// ==========================================================================
...
...
halo_exchange/configuration.h
View file @
79c821dc
...
@@ -10,7 +10,7 @@ enum verbosity_level_enum
...
@@ -10,7 +10,7 @@ enum verbosity_level_enum
OFF
=
0
,
OFF
=
0
,
INFO
=
1
,
INFO
=
1
,
DEBUG
=
2
,
DEBUG
=
2
,
TRACE
=
3
,
TRACE
=
3
};
};
enum
transfer_mode_enum
enum
transfer_mode_enum
...
@@ -19,7 +19,7 @@ enum transfer_mode_enum
...
@@ -19,7 +19,7 @@ enum transfer_mode_enum
COLLECTIVE
=
1
,
COLLECTIVE
=
1
,
P2P_DEFAULT
=
2
,
P2P_DEFAULT
=
2
,
P2P_SYNCHRONOUS
=
3
,
P2P_SYNCHRONOUS
=
3
,
P2P_READY
=
4
,
P2P_READY
=
4
};
};
typedef
struct
typedef
struct
...
...
halo_exchange/field.c
View file @
79c821dc
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include "field.h"
#include "field.h"
#include "mesh.h"
#include "mesh.h"
#include "mpicomm.h"
void
int_field_init
(
int_field_t
*
field
,
const
conf_t
*
configuration
,
const
mesh_t
*
mesh
)
void
int_field_init
(
int_field_t
*
field
,
const
conf_t
*
configuration
,
const
mesh_t
*
mesh
)
{
{
...
...
halo_exchange/mesh.c
View file @
79c821dc
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
#include <stdio.h>
#include <stdio.h>
#include "mesh.h"
#include "mesh.h"
#include "mpitypes.h"
#include "mpicomm.h"
// ---------------------------------------------- Helper function declarations
// ---------------------------------------------- Helper function declarations
...
@@ -73,8 +75,7 @@ void mesh_find_neighbors(mesh_t *mesh, const conf_t *configuration, const box_t
...
@@ -73,8 +75,7 @@ void mesh_find_neighbors(mesh_t *mesh, const conf_t *configuration, const box_t
int
mpi_rank
,
nprocs
;
int
mpi_rank
,
nprocs
;
int
i
,
n
;
int
i
,
n
;
box_t
tmp
;
box_t
tmp
;
box_t
local_domain
,
extended_local_domain
;
box_t
local_domain
,
extended_local_domain
,
extended_remote_domain
;
box_t
remote_domain
,
extended_remote_domain
;
box_t
halo_incoming
,
halo_outgoing
;
box_t
halo_incoming
,
halo_outgoing
;
MPI_Comm_rank
(
mesh
->
communicator
,
&
mpi_rank
);
MPI_Comm_rank
(
mesh
->
communicator
,
&
mpi_rank
);
...
...
halo_exchange/mpicomm.c
View file @
79c821dc
...
@@ -62,9 +62,9 @@ void mpi_create_graph_communicator(const mesh_t *mesh, const conf_t *configurati
...
@@ -62,9 +62,9 @@ void mpi_create_graph_communicator(const mesh_t *mesh, const conf_t *configurati
for
(
i
=
0
;
i
<
n_neighbors
;
i
++
)
{
for
(
i
=
0
;
i
<
n_neighbors
;
i
++
)
{
nb
=
&
mesh
->
neighbors
[
i
];
nb
=
&
mesh
->
neighbors
[
i
];
neighbor_ranks
[
i
]
=
mesh
->
neighbors
[
i
].
mpi_rank
;
neighbor_ranks
[
i
]
=
nb
->
mpi_rank
;
recv_weights
[
i
]
=
mesh
->
neighbors
[
i
].
halo_incoming
.
domain
.
volume
;
recv_weights
[
i
]
=
nb
->
halo_incoming
.
domain
.
volume
;
send_weights
[
i
]
=
mesh
->
neighbors
[
i
].
halo_outgoing
.
domain
.
volume
;
send_weights
[
i
]
=
nb
->
halo_outgoing
.
domain
.
volume
;
}
}
MPI_Dist_graph_create_adjacent
(
MPI_Dist_graph_create_adjacent
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment