diff --git a/src/cell.c b/src/cell.c index de493159f98e57e856c2780b97985267e13bc475..900389f7f59e5de8ff7f842b2949c4b020c71e5d 100644 --- a/src/cell.c +++ b/src/cell.c @@ -2028,31 +2028,35 @@ void cell_activate_grav_mm_task(struct cell *ci, struct cell *cj, struct scheduler *s) { /* Some constants */ const struct engine *e = s->space->e; - const integertime_t ti_current = e->ti_current; + // const integertime_t ti_current = e->ti_current; /* Anything to do here? */ if (!cell_is_active_gravity_mm(ci, e) && !cell_is_active_gravity_mm(cj, e)) error("Inactive MM task being activated"); - /* Atomically drift the multipoles in the progenies of ci */ - for (int i = 0; i < 8; i++) { - struct cell *cpi = ci->progeny[i]; - if (cpi != NULL) { - lock_lock(&cpi->mlock); - if (cpi->ti_old_multipole < ti_current) cell_drift_multipole(cpi, e); - if (lock_unlock(&cpi->mlock) != 0) error("Impossible to unlock m-pole"); - } - } - - /* Atomically drift the multipoles in the progenies of cj */ - for (int j = 0; j < 8; j++) { - struct cell *cpj = cj->progeny[j]; - if (cpj != NULL) { - lock_lock(&cpj->mlock); - if (cpj->ti_old_multipole < ti_current) cell_drift_multipole(cpj, e); - if (lock_unlock(&cpj->mlock) != 0) error("Impossible to unlock m-pole"); - } - } + /* /\* Atomically drift the multipoles in the progenies of ci *\/ */ + /* for (int i = 0; i < 8; i++) { */ + /* struct cell *cpi = ci->progeny[i]; */ + /* if (cpi != NULL) { */ + /* lock_lock(&cpi->mlock); */ + /* if (cpi->ti_old_multipole < ti_current) cell_drift_multipole(cpi, e); + */ + /* if (lock_unlock(&cpi->mlock) != 0) error("Impossible to unlock + * m-pole"); */ + /* } */ + /* } */ + + /* /\* Atomically drift the multipoles in the progenies of cj *\/ */ + /* for (int j = 0; j < 8; j++) { */ + /* struct cell *cpj = cj->progeny[j]; */ + /* if (cpj != NULL) { */ + /* lock_lock(&cpj->mlock); */ + /* if (cpj->ti_old_multipole < ti_current) cell_drift_multipole(cpj, e); + */ + /* if (lock_unlock(&cpj->mlock) != 0) error("Impossible to unlock + * m-pole"); */ + /* } */ + /* } */ } /** diff --git a/src/engine.c b/src/engine.c index 148d915cad263fcee1fa5bb12386c61343d1f17d..7a589b650b1e576fa13e1ba6f622197024475325 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2681,22 +2681,6 @@ void engine_count_and_link_tasks_mapper(void *map_data, int num_elements, atomic_inc(&cj->nr_mm_tasks); engine_addlink(e, &ci->grav_mm, t); engine_addlink(e, &cj->grav_mm, t); - - /* for (int i = 0; i < 8; i++) { */ - /* struct cell *cpi = ci->progeny[i]; */ - /* if (cpi != NULL) { */ - /* atomic_inc(&cpi->nr_mm_tasks); */ - /* engine_addlink(e, &cpi->grav_mm, t); */ - /* } */ - /* } */ - - /* for (int j = 0; j < 8; j++) { */ - /* struct cell *cpj = cj->progeny[j]; */ - /* if (cpj != NULL) { */ - /* atomic_inc(&cpj->nr_mm_tasks); */ - /* engine_addlink(e, &cpj->grav_mm, t); */ - /* } */ - /* } */ } } } diff --git a/src/runner_doiact_grav.h b/src/runner_doiact_grav.h index 2a9e78a3ede3a16994eb79ddd6bec47ad032e866..ed8f935872496adc538a0bde9cca9c3db10070bf 100644 --- a/src/runner_doiact_grav.h +++ b/src/runner_doiact_grav.h @@ -1289,19 +1289,23 @@ static INLINE void runner_dopair_grav_mm(struct runner *r, const struct engine *e = r->e; + /* What do we need to do? */ const int do_i = cell_is_active_gravity_mm(ci, e) && (ci->nodeID == e->nodeID); const int do_j = cell_is_active_gravity_mm(cj, e) && (cj->nodeID == e->nodeID); + /* Do we need drifting first? */ + if (ci->ti_old_multipole < e->ti_current) cell_drift_multipole(ci, e); + if (cj->ti_old_multipole < e->ti_current) cell_drift_multipole(cj, e); + + /* Interact! */ if (do_i && do_j) runner_dopair_grav_mm_symmetric(r, ci, cj); else if (do_i) runner_dopair_grav_mm_nonsym(r, ci, cj); else if (do_j) runner_dopair_grav_mm_nonsym(r, cj, ci); - /* else */ - /* error("Running M-M task with two inactive cells."); */ } static INLINE void runner_dopair_grav_mm_progenies(struct runner *r, @@ -1655,8 +1659,7 @@ static INLINE void runner_do_grav_long_range(struct runner *r, struct cell *ci, error("Non-local cell in long-range gravity task!"); /* Check multipole has been drifted */ - if (ci->ti_old_multipole != e->ti_current) - error("Interacting un-drifted multipole"); + if (ci->ti_old_multipole < e->ti_current) cell_drift_multipole(ci, e); /* Get this cell's multipole information */ struct gravity_tensors *const multi_i = ci->multipole;