diff --git a/src/cell.c b/src/cell.c index 398eab4f63512e7f5da047c80553718c4637409d..13c4084084af3cf1ffb18722f815b0afa0749f7e 100644 --- a/src/cell.c +++ b/src/cell.c @@ -1541,6 +1541,16 @@ void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj, double shift[3]; int sid = space_getsid(s->space, &ci, &cj, shift); + /* We are going to interact this pair, so store some values. */ + ci->requires_sorts = ti_current; + cj->requires_sorts = ti_current; + ci->dx_max_sort_old = ci->dx_max_sort; + cj->dx_max_sort_old = cj->dx_max_sort; + + /* Activate the drifts if the cells are local. */ + if (ci->nodeID == engine_rank) scheduler_activate(s, ci->drift); + if (cj->nodeID == engine_rank) scheduler_activate(s, cj->drift); + if (ci->dx_max_sort > space_maxreldx * ci->dmin) { for (struct cell *finger = ci; finger != NULL; finger = finger->parent) { finger->sorted = 0; @@ -1551,7 +1561,6 @@ void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj, if (!(ci->sorted & (1 << sid))) { atomic_or(&ci->sorts->flags, (1 << sid)); scheduler_activate(s, ci->sorts); - if (ci->nodeID == engine_rank) scheduler_activate(s, ci->drift); } if (cj->dx_max_sort > space_maxreldx * cj->dmin) { for (struct cell *finger = cj; finger != NULL; finger = finger->parent) { @@ -1563,12 +1572,7 @@ void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj, if (!(cj->sorted & (1 << sid))) { atomic_or(&cj->sorts->flags, (1 << sid)); scheduler_activate(s, cj->sorts); - if (cj->nodeID == engine_rank) scheduler_activate(s, cj->drift); } - ci->requires_sorts = ti_current; - cj->requires_sorts = ti_current; - ci->dx_max_sort_old = ci->dx_max_sort; - cj->dx_max_sort_old = cj->dx_max_sort; } } @@ -1597,6 +1601,13 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { /* Set the correct sorting flags */ if (t->type == task_type_pair) { + /* Store some values. */ + ci->requires_sorts = ti_current; + cj->requires_sorts = ti_current; + ci->dx_max_sort_old = ci->dx_max_sort; + cj->dx_max_sort_old = cj->dx_max_sort; + + /* Check the sorts and activate them if needed. */ if (ci->dx_max_sort > space_maxreldx * ci->dmin) { for (struct cell *finger = ci; finger != NULL; finger = finger->parent) { @@ -1629,10 +1640,6 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { scheduler_activate(s, cj->sorts); if (cj->nodeID == engine_rank) scheduler_activate(s, cj->drift); } - ci->requires_sorts = ti_current; - cj->requires_sorts = ti_current; - ci->dx_max_sort_old = ci->dx_max_sort; - cj->dx_max_sort_old = cj->dx_max_sort; } /* Store current values of dx_max and h_max. */ else if (t->type == task_type_sub_pair || t->type == task_type_sub_self) { diff --git a/src/engine.c b/src/engine.c index d6ca0cd7dd0b8e281776a78ef19847aab073f8a5..5ba0549ed2647b71013c292ce64436c921ad2297 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2485,6 +2485,13 @@ void engine_marktasks_mapper(void *map_data, int num_elements, /* Set the correct sorting flags */ if (t->type == task_type_pair) { + /* Store some values. */ + ci->requires_sorts = ti_current; + cj->requires_sorts = ti_current; + ci->dx_max_sort_old = ci->dx_max_sort; + cj->dx_max_sort_old = cj->dx_max_sort; + + /* Activate the sorts where needed. */ if (ci->dx_max_sort > space_maxreldx * ci->dmin) { for (struct cell *finger = ci; finger != NULL; finger = finger->parent) { @@ -2517,10 +2524,6 @@ void engine_marktasks_mapper(void *map_data, int num_elements, scheduler_activate(s, cj->sorts); if (cj->nodeID == engine_rank) scheduler_activate(s, cj->drift); } - ci->requires_sorts = ti_current; - cj->requires_sorts = ti_current; - ci->dx_max_sort_old = ci->dx_max_sort; - cj->dx_max_sort_old = cj->dx_max_sort; } /* Store current values of dx_max and h_max. */ else if (t->type == task_type_sub_pair) {