diff --git a/src/cell.c b/src/cell.c index a8e23dee838f2bf00493ea876a2e5271f8ed3b0b..ca66c85b04a953f44fa56a91e303a1dbbd3c5288 100644 --- a/src/cell.c +++ b/src/cell.c @@ -912,10 +912,7 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { struct engine *e = s->space->e; #endif - //message("unskip! c=%p c->kick1=%p c->drift=%p", c, c->kick1, c->drift); - //task_print(c->drift); - - int ret = 0; + int rebuild = 0; /* Un-skip the density tasks involved with this cell. */ for (struct link *l = c->density; l != NULL; l = l->next) { @@ -942,7 +939,7 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { (max(ci->h_max, cj->h_max) + ci->dx_max + cj->dx_max > cj->dmin || ci->dx_max > space_maxreldx * ci->h_max || cj->dx_max > space_maxreldx * cj->h_max)) - ret = 1; + rebuild = 1; #ifdef WITH_MPI /* Activate the send/recv flags. */ @@ -1039,9 +1036,7 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { if (c->cooling != NULL) scheduler_activate(s, c->cooling); if (c->sourceterms != NULL) scheduler_activate(s, c->sourceterms); - //task_print(c->drift); - - return ret; + return rebuild; } /** diff --git a/src/engine.c b/src/engine.c index da9ea5059dfb28dccd142f7812602e5a33a36018..9b7bc5d6d4e49e160fc4bd55b49f473fca61d0d3 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2612,8 +2612,6 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs) { engine_rebuild(e); - // engine_prepare(e); - engine_marktasks(e); /* No time integration. We just want the density and ghosts */ @@ -2726,8 +2724,6 @@ void engine_step(struct engine *e) { /* Prepare the tasks to be launched. */ engine_prepare(e); - if (e->step == 1) e->forcerebuild = 1; - /* Print the number of active tasks ? */ if (e->verbose) engine_print_task_counts(e); @@ -2742,6 +2738,17 @@ void engine_step(struct engine *e) { engine_launch(e, e->nr_threads); TIMER_TOC(timer_runners); + + /* Collect the values of rebuild from all nodes. */ +#ifdef WITH_MPI + int buff = 0; + if (MPI_Allreduce(&e->forcerebuild, &buff, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD) != + MPI_SUCCESS) + error("Failed to aggregate the rebuild flag across nodes."); + e->forcerebuild = buff; +#endif + + /* Do we want a snapshot? */ if (e->ti_end_min >= e->ti_nextSnapshot && e->ti_nextSnapshot > 0) e->dump_snapshot = 1; @@ -2762,7 +2769,6 @@ void engine_step(struct engine *e) { message("snap=%d, rebuild=%d repart=%d", e->dump_snapshot, e->forcerebuild, e->forcerepart); - /* Write a snapshot ? */ if (e->dump_snapshot) {