Commit be1a76c7 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Delay the drifting of the multipoles for M-M tasks to the tasks themselves.

parent 6f800b1c
......@@ -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"); */
/* } */
/* } */
}
/**
......
......@@ -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); */
/* } */
/* } */
}
}
}
......
......@@ -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;
......
Supports Markdown
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