Skip to content
Snippets Groups Projects
Commit a13630c6 authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

don't activate drift tasks, just mark the cells.

parent 846e08b4
No related branches found
No related tags found
1 merge request!343Subset sorting
...@@ -1316,6 +1316,29 @@ int cell_is_drift_needed(struct cell *c, const struct engine *e) { ...@@ -1316,6 +1316,29 @@ int cell_is_drift_needed(struct cell *c, const struct engine *e) {
return 0; return 0;
} }
/**
* @brief Activate the drifts on the given cell.
*/
void cell_activate_drift_part(struct cell *c, struct scheduler *s) {
/* If this cell is already marked for drift, quit early. */
if (c->do_drift) return;
/* Mark this cell for drifting. */
c->do_drift = 1;
/* Set the do_sub_drifts all the way up and activate the super drift
if this has not yet been done. */
for (struct cell *parent = c->parent; parent != NULL && !parent->do_sub_drift;
parent = parent->parent) {
parent->do_sub_drift = 1;
if (parent == c->super) {
scheduler_activate(s, parent->drift_part);
break;
}
}
}
/** /**
* @brief Traverse a sub-cell task and activate the sort tasks along the way. * @brief Traverse a sub-cell task and activate the sort tasks along the way.
*/ */
...@@ -1576,8 +1599,8 @@ void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj, ...@@ -1576,8 +1599,8 @@ void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj,
cj->dx_max_sort_old = cj->dx_max_sort; cj->dx_max_sort_old = cj->dx_max_sort;
/* Activate the drifts if the cells are local. */ /* Activate the drifts if the cells are local. */
if (ci->nodeID == engine_rank) scheduler_activate(s, ci->drift_part); if (ci->nodeID == engine_rank) cell_activate_drift_part(ci, s);
if (cj->nodeID == engine_rank) scheduler_activate(s, cj->drift_part); if (cj->nodeID == engine_rank) cell_activate_drift_part(cj, s);
/* Do we need to sort ci ? */ /* Do we need to sort ci ? */
if (ci->dx_max_sort > space_maxreldx * ci->dmin) { if (ci->dx_max_sort > space_maxreldx * ci->dmin) {
...@@ -1660,7 +1683,7 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { ...@@ -1660,7 +1683,7 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) {
if (!(ci->sorted & (1 << t->flags)) || ci->nodeID != engine_rank) { if (!(ci->sorted & (1 << t->flags)) || ci->nodeID != engine_rank) {
atomic_or(&ci->sorts->flags, (1 << t->flags)); atomic_or(&ci->sorts->flags, (1 << t->flags));
scheduler_activate(s, ci->sorts); scheduler_activate(s, ci->sorts);
if (ci->nodeID == engine_rank) scheduler_activate(s, ci->drift_part); if (ci->nodeID == engine_rank) cell_activate_drift_part(ci, s);
} }
if (cj->dx_max_sort > space_maxreldx * cj->dmin) { if (cj->dx_max_sort > space_maxreldx * cj->dmin) {
for (struct cell *finger = cj; finger != NULL; for (struct cell *finger = cj; finger != NULL;
...@@ -1675,7 +1698,7 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { ...@@ -1675,7 +1698,7 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) {
if (!(cj->sorted & (1 << t->flags)) || cj->nodeID != engine_rank) { if (!(cj->sorted & (1 << t->flags)) || cj->nodeID != engine_rank) {
atomic_or(&cj->sorts->flags, (1 << t->flags)); atomic_or(&cj->sorts->flags, (1 << t->flags));
scheduler_activate(s, cj->sorts); scheduler_activate(s, cj->sorts);
if (cj->nodeID == engine_rank) scheduler_activate(s, cj->drift_part); if (cj->nodeID == engine_rank) cell_activate_drift_part(cj, s);
} }
} }
/* Store current values of dx_max and h_max. */ /* Store current values of dx_max and h_max. */
...@@ -1713,11 +1736,8 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { ...@@ -1713,11 +1736,8 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) {
scheduler_activate(s, l->t); scheduler_activate(s, l->t);
/* Drift both cells, the foreign one at the level which it is sent. */ /* Drift both cells, the foreign one at the level which it is sent. */
if (l->t->ci->drift_part) cell_activate_drift_part(l->t->ci, s);
scheduler_activate(s, l->t->ci->drift_part); if (t->type == task_type_pair) cell_activate_drift_part(cj, s);
else
error("Drift task missing !");
if (t->type == task_type_pair) scheduler_activate(s, cj->drift_part);
if (cell_is_active(cj, e)) { if (cell_is_active(cj, e)) {
...@@ -1763,11 +1783,8 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { ...@@ -1763,11 +1783,8 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) {
scheduler_activate(s, l->t); scheduler_activate(s, l->t);
/* Drift both cells, the foreign one at the level which it is sent. */ /* Drift both cells, the foreign one at the level which it is sent. */
if (l->t->ci->drift_part) cell_activate_drift_part(l->t->ci, s);
scheduler_activate(s, l->t->ci->drift_part); if (t->type == task_type_pair) cell_activate_drift_part(ci, s);
else
error("Drift task missing !");
if (t->type == task_type_pair) scheduler_activate(s, ci->drift_part);
if (cell_is_active(ci, e)) { if (cell_is_active(ci, e)) {
...@@ -1794,13 +1811,13 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { ...@@ -1794,13 +1811,13 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) {
} }
else if (t->type == task_type_pair) { /* ci and cj on same node */ else if (t->type == task_type_pair) { /* ci and cj on same node */
scheduler_activate(s, ci->drift_part); cell_activate_drift_part(ci, s);
scheduler_activate(s, cj->drift_part); cell_activate_drift_part(cj, s);
} }
#else #else
if (t->type == task_type_pair) { if (t->type == task_type_pair) {
scheduler_activate(s, ci->drift_part); cell_activate_drift_part(ci, s);
scheduler_activate(s, cj->drift_part); cell_activate_drift_part(cj, s);
} }
#endif #endif
} }
...@@ -1909,11 +1926,11 @@ void cell_drift_part(struct cell *c, const struct engine *e, int force) { ...@@ -1909,11 +1926,11 @@ void cell_drift_part(struct cell *c, const struct engine *e, int force) {
/* Update the time of the last drift */ /* Update the time of the last drift */
c->ti_old_part = ti_current; c->ti_old_part = ti_current;
/* Clear the drift flags. */ /* Clear the drift flags. */
c->do_drift = 0; c->do_drift = 0;
c->do_sub_drift = 0; c->do_sub_drift = 0;
} else if (force && ti_current > ti_old_part) { } else if (force && ti_current > ti_old_part) {
/* Loop over all the gas particles in the cell */ /* Loop over all the gas particles in the cell */
...@@ -1960,10 +1977,9 @@ void cell_drift_part(struct cell *c, const struct engine *e, int force) { ...@@ -1960,10 +1977,9 @@ void cell_drift_part(struct cell *c, const struct engine *e, int force) {
/* Update the time of the last drift */ /* Update the time of the last drift */
c->ti_old_part = ti_current; c->ti_old_part = ti_current;
/* Clear the drift flags. */ /* Clear the drift flags. */
c->do_drift = 0; c->do_drift = 0;
c->do_sub_drift = 0;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment