diff --git a/src/cell.c b/src/cell.c index c2e7ceada1ca86cbab1c80549b14482113c8477d..53e57164463634502bd9ad70fb0ecb5cf6b0ade8 100644 --- a/src/cell.c +++ b/src/cell.c @@ -344,6 +344,7 @@ int cell_unpack(struct pcell *restrict pc, struct cell *restrict c, c->split = 1; count += cell_unpack(&pc[pc->progeny[k]], temp, s, with_gravity); } + c->split = (count > 1); /* Return the total number of unpacked cells. */ c->mpi.pcell_size = count; @@ -3160,7 +3161,7 @@ void cell_set_super_mapper(void *map_data, int num_elements, void *extra_data) { /* All top-level cells get an MPI tag. */ #ifdef WITH_MPI - if (c->mpi.tag < 0 && c->mpi.sendto) cell_tag(c); + if (c->mpi.sendto) cell_ensure_tagged(c); #endif /* Super-pointer for hydro */ diff --git a/src/cell.h b/src/cell.h index 050295ce4387da141720344565c1844f272a19f4..59011e0df471dbbb240ba2f24be734a3cd49444e 100644 --- a/src/cell.h +++ b/src/cell.h @@ -850,13 +850,9 @@ __attribute__((always_inline)) INLINE static int cell_need_rebuild_for_pair( * * @param c The #cell to tag. */ -__attribute__((always_inline)) INLINE static void cell_tag(struct cell *c) { +__attribute__((always_inline)) INLINE static void cell_ensure_tagged(struct cell *c) { #ifdef WITH_MPI -#ifdef SWIFT_DEBUG_CHECKS - if (c->mpi.tag > 0) error("setting tag for already tagged cell"); -#endif - lock_lock(&c->hydro.lock); if (c->mpi.tag < 0 && (c->mpi.tag = atomic_inc(&cell_next_tag)) > cell_max_tag) diff --git a/src/engine.c b/src/engine.c index b1904ae2e6116ed22cb1d5e5e45f2545595df4f0..4f624495fa6cf99444af905e2de49e7088646234 100644 --- a/src/engine.c +++ b/src/engine.c @@ -1497,7 +1497,7 @@ void engine_addtasks_send_hydro(struct engine *e, struct cell *ci, if (t_xv == NULL) { /* Make sure this cell is tagged. */ - cell_tag(ci); + cell_ensure_tagged(ci); t_xv = scheduler_addtask(s, task_type_send, task_subtype_xv, ci->mpi.tag, 0, ci, cj); @@ -1589,7 +1589,7 @@ void engine_addtasks_send_gravity(struct engine *e, struct cell *ci, if (t_grav == NULL) { /* Make sure this cell is tagged. */ - cell_tag(ci); + cell_ensure_tagged(ci); t_grav = scheduler_addtask(s, task_type_send, task_subtype_gpart, ci->mpi.tag, 0, ci, cj); @@ -1652,7 +1652,7 @@ void engine_addtasks_send_timestep(struct engine *e, struct cell *ci, if (t_ti == NULL) { /* Make sure this cell is tagged. */ - cell_tag(ci); + cell_ensure_tagged(ci); t_ti = scheduler_addtask(s, task_type_send, task_subtype_tend, ci->mpi.tag, 0, ci, cj);