Commit 79c821dc authored by Thomas Ponweiser's avatar Thomas Ponweiser
Browse files

Halo exchange sample (unstructured grids): fixed some compiler warnings

parent e6335681
...@@ -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);
......
...@@ -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);
......
...@@ -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"};
// ========================================================================== // ==========================================================================
......
...@@ -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
......
...@@ -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)
{ {
......
...@@ -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);
......
...@@ -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(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment