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)
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;
......@@ -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;
*a = *original;
......@@ -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)
{
box_t largest_box, tmp_box, part1, part2;
int i, j, n, child1, child2;
box_t largest_box, part1, part2;
int n, randomize;
boxes[0] = *original;
n = 1;
while(n < n_boxes) {
randomize = n < n_boxes/2;
// take out box with maximum volume and split in two
box_heap_take_first(boxes, &n, &largest_box);
box_split(&largest_box, &part1, &part2);
box_split(&largest_box, &part1, &part2, randomize);
// insert boxes
box_heap_insert(boxes, &n, &part1);
......
......@@ -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);
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);
......
......@@ -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_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"};
// ==========================================================================
......@@ -46,7 +48,7 @@ const char* conf_set_from_args(conf_t *c, int argc, char* argv[])
{"ncells-per-proc", required_argument, NULL, 'n'},
{"ncells", required_argument, NULL, 'N'},
{"edge-length", required_argument, NULL, 'e'},
{"graph", no_argument, &c->transfer_mode, SPARSE_COLLECTIVE},
{"collective", no_argument, &c->transfer_mode, COLLECTIVE},
{"p2p", no_argument, &c->transfer_mode, P2P_DEFAULT},
......@@ -87,7 +89,7 @@ void conf_print(const conf_t *c, FILE *f)
fprintf(f, "Configuration:\n");
fprintf(f, " * Verbosity level: %s (%d)\n", verbosity_levels[i], c->verbosity_level);
fprintf(f, " * Mesh domain (cube): %s\n", box_to_string(&c->global_domain, buf, 128));
fprintf(f, " * Halo transfer mode: %s\n", transfer_mode_strs[c->transfer_mode]);
fprintf(f, " * Halo transfer mode: %s\n", transfer_mode_strs[c->transfer_mode]);
fprintf(f, " * Number of iterations: %d\n", c->n_iterations);
fprintf(f, "\n");
}
......
......@@ -10,7 +10,7 @@ enum verbosity_level_enum
OFF = 0,
INFO = 1,
DEBUG = 2,
TRACE = 3,
TRACE = 3
};
enum transfer_mode_enum
......@@ -19,7 +19,7 @@ enum transfer_mode_enum
COLLECTIVE = 1,
P2P_DEFAULT = 2,
P2P_SYNCHRONOUS = 3,
P2P_READY = 4,
P2P_READY = 4
};
typedef struct
......
......@@ -3,6 +3,7 @@
#include "field.h"
#include "mesh.h"
#include "mpicomm.h"
void int_field_init(int_field_t *field, const conf_t *configuration, const mesh_t *mesh)
{
......
......@@ -2,6 +2,8 @@
#include <stdio.h>
#include "mesh.h"
#include "mpitypes.h"
#include "mpicomm.h"
// ---------------------------------------------- Helper function declarations
......@@ -73,8 +75,7 @@ void mesh_find_neighbors(mesh_t *mesh, const conf_t *configuration, const box_t
int mpi_rank, nprocs;
int i, n;
box_t tmp;
box_t local_domain, extended_local_domain;
box_t remote_domain, extended_remote_domain;
box_t local_domain, extended_local_domain, extended_remote_domain;
box_t halo_incoming, halo_outgoing;
MPI_Comm_rank(mesh->communicator, &mpi_rank);
......
......@@ -62,9 +62,9 @@ void mpi_create_graph_communicator(const mesh_t *mesh, const conf_t *configurati
for(i = 0; i < n_neighbors; i++) {
nb = &mesh->neighbors[i];
neighbor_ranks[i] = mesh->neighbors[i].mpi_rank;
recv_weights[i] = mesh->neighbors[i].halo_incoming.domain.volume;
send_weights[i] = mesh->neighbors[i].halo_outgoing.domain.volume;
neighbor_ranks[i] = nb->mpi_rank;
recv_weights[i] = nb->halo_incoming.domain.volume;
send_weights[i] = nb->halo_outgoing.domain.volume;
}
MPI_Dist_graph_create_adjacent(
......
Markdown is supported
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