diff --git a/examples/test.c b/examples/test.c index 7985c4453a447e944f6e8ed01db5d9ed677bb174..b8f7c3d812f30f1587999737a9b48441630cd8fd 100644 --- a/examples/test.c +++ b/examples/test.c @@ -752,7 +752,7 @@ int main(int argc, char *argv[]) { /* Initialize the space with this data. */ tic = getticks(); - space_init(&s, dim, parts, N, periodic, h_max); + space_init(&s, dim, parts, N, periodic, h_max, myrank == 0); if (myrank == 0) message("space_init took %.3f ms.", ((double)(getticks() - tic)) / CPU_TPS * 1000); @@ -792,7 +792,7 @@ int main(int argc, char *argv[]) { /* Initialize the engine with this space. */ tic = getticks(); - message("nr_nodes is %i.", nr_nodes); + if (myrank == 0) message("nr_nodes is %i.", nr_nodes); engine_init(&e, &s, dt_max, nr_threads, nr_queues, nr_nodes, myrank, ENGINE_POLICY | engine_policy_steal); if (myrank == 0) @@ -818,8 +818,9 @@ int main(int argc, char *argv[]) { #else write_output_single(&e, &us); #endif - message("writing particle properties took %.3f ms.", - ((double)(getticks() - tic)) / CPU_TPS * 1000); + if (myrank == 0) + message("writing particle properties took %.3f ms.", + ((double)(getticks() - tic)) / CPU_TPS * 1000); fflush(stdout); /* Init the runner history. */ @@ -961,7 +962,7 @@ int main(int argc, char *argv[]) { #endif /* Say goodbye. */ - message("done."); + if (myrank == 0) message("done."); /* All is calm, all is bright. */ return 0; diff --git a/src/engine.c b/src/engine.c index 935b6902e9bdfca6ac364a29d8f971422f893e21..c4f5dccad5c829efd3b1b50211c4f6a06a28e198 100644 --- a/src/engine.c +++ b/src/engine.c @@ -1370,7 +1370,7 @@ void engine_rebuild(struct engine *e) { /* Re-build the space. */ // tic = getticks(); - space_rebuild(e->s, 0.0); + space_rebuild(e->s, 0.0, e->nodeID == 0); // message( "space_rebuild took %.3f ms." , (double)(getticks() - // tic)/CPU_TPS*1000 ); @@ -2041,8 +2041,9 @@ void engine_split(struct engine *e, int *grid) { engine_makeproxies(e); /* Re-allocate the local parts. */ - message("Re-allocating parts array from %i to %i.", s->size_parts, - (int)(s->nr_parts * 1.2)); + if (e->nodeID == 0) + message("Re-allocating parts array from %i to %i.", s->size_parts, + (int)(s->nr_parts * 1.2)); s->size_parts = s->nr_parts * 1.2; struct part *parts_new; struct xpart *xparts_new; @@ -2094,13 +2095,16 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads, for (i = 1; i < maxint; i *= 2) for (j = maxint / i / 2; j < maxint; j += maxint / i) if (j < nr_cores && j != 0) cpuid[k++] = j; -#ifdef WITHMPI - printf("engine_init: cpu map is [ "); + + if (nodeID == 0) { +#ifdef WITH_MPI + message("engine_init: cpu map is [ "); #else - printf("[%03i] engine_init: cpu map is [ ", nodeID); + printf("[%03i] engine_init: cpu map is [ ", nodeID); #endif - for (i = 0; i < nr_cores; i++) printf("%i ", cpuid[i]); - printf("].\n"); + for (i = 0; i < nr_cores; i++) printf("%i ", cpuid[i]); + printf("].\n"); + } } #endif diff --git a/src/space.c b/src/space.c index eeb42f328f3a91439110c832fea93798862869a6..f4d9cda9d367332ea179a5b144fbc9d169c0dd99 100644 --- a/src/space.c +++ b/src/space.c @@ -149,9 +149,10 @@ void space_rebuild_recycle(struct space *s, struct cell *c) { * * @param s The #space. * @param cell_max Maximum cell edge length. + * @param verbose Print messages to stdout or not. */ -void space_regrid(struct space *s, double cell_max) { +void space_regrid(struct space *s, double cell_max, int verbose) { float h_max = s->cell_min / kernel_gamma / space_stretch, dmin; int i, j, k, cdim[3], nr_parts = s->nr_parts; @@ -182,7 +183,7 @@ void space_regrid(struct space *s, double cell_max) { h_max = buff; } #endif - message("h_max is %.3e (cell_max=%.3e).", h_max, cell_max); + if (verbose) message("h_max is %.3e (cell_max=%.3e).", h_max, cell_max); /* Get the new putative cell dimensions. */ for (k = 0; k < 3; k++) @@ -253,7 +254,9 @@ void space_regrid(struct space *s, double cell_max) { } /* Be verbose about the change. */ - message("set cell dimensions to [ %i %i %i ].", cdim[0], cdim[1], cdim[2]); + if (verbose) + message("set cell dimensions to [ %i %i %i ].", cdim[0], cdim[1], + cdim[2]); fflush(stdout); } /* re-build upper-level cells? */ @@ -289,10 +292,11 @@ void space_regrid(struct space *s, double cell_max) { * * @param s The #space in which to update the cells. * @param cell_max Maximal cell size. + * @param verbose Print messages to stdout or not * */ -void space_rebuild(struct space *s, double cell_max) { +void space_rebuild(struct space *s, double cell_max, int verbose) { int j, k, cdim[3], nr_parts = s->nr_parts, nr_gparts = s->nr_gparts; struct cell *restrict c, *restrict cells; @@ -305,7 +309,7 @@ void space_rebuild(struct space *s, double cell_max) { // message( "re)building space..." ); fflush(stdout); /* Re-grid if necessary, or just re-set the cell data. */ - space_regrid(s, cell_max); + space_regrid(s, cell_max, verbose); cells = s->cells; /* Run through the particles and get their cell index. */ @@ -1073,6 +1077,7 @@ struct cell *space_getcell(struct space *s) { * @param N The number of parts in the space. * @param periodic flag whether the domain is periodic or not. * @param h_max The maximal interaction radius. + * @param verbose Print messages to stdout or not * * Makes a grid of edge length > r_max and fills the particles * into the respective cells. Cells containing more than #space_splitsize @@ -1081,7 +1086,7 @@ struct cell *space_getcell(struct space *s) { */ void space_init(struct space *s, double dim[3], struct part *parts, int N, - int periodic, double h_max) { + int periodic, double h_max, int verbose) { /* Store eveything in the space. */ s->dim[0] = dim[0]; @@ -1151,5 +1156,5 @@ void space_init(struct space *s, double dim[3], struct part *parts, int N, if (lock_init(&s->lock) != 0) error("Failed to create space spin-lock."); /* Build the cells and the tasks. */ - space_regrid(s, h_max); + space_regrid(s, h_max, verbose); } diff --git a/src/space.h b/src/space.h index e0bad6773547f813d70943c2ca2703529a0306a8..c12ec46be968d713618c41db5ab1385ed147d33e 100644 --- a/src/space.h +++ b/src/space.h @@ -119,7 +119,7 @@ struct cell *space_getcell(struct space *s); int space_getsid(struct space *s, struct cell **ci, struct cell **cj, double *shift); void space_init(struct space *s, double dim[3], struct part *parts, int N, - int periodic, double h_max); + int periodic, double h_max, int verbose); void space_map_cells_pre(struct space *s, int full, void (*fun)(struct cell *c, void *data), void *data); void space_map_parts(struct space *s, @@ -127,7 +127,7 @@ void space_map_parts(struct space *s, void *data); void space_map_cells_post(struct space *s, int full, void (*fun)(struct cell *c, void *data), void *data); -void space_rebuild(struct space *s, double h_max); +void space_rebuild(struct space *s, double h_max, int verbose); void space_recycle(struct space *s, struct cell *c); void space_split(struct space *s, struct cell *c);