diff --git a/src/cell.c b/src/cell.c index eb702fbf7e9d93e80ff31df68cad7a07db6f8d29..19734e8cdb0b07b0f7c7ca6bc9cc6738aaf6cf5f 100644 --- a/src/cell.c +++ b/src/cell.c @@ -1674,13 +1674,14 @@ void cell_activate_drift_gpart(struct cell *c, struct scheduler *s) { * @brief Activate the #spart drifts on the given cell. */ void cell_activate_drift_spart(struct cell *c, struct scheduler *s) { + // MATTHIEU: This will need changing cell_activate_drift_gpart(c, s); } /** * @brief Activate the sorts up a cell hierarchy. */ -void cell_activate_sorts_up(struct cell *c, struct scheduler *s) { +void cell_activate_hydro_sorts_up(struct cell *c, struct scheduler *s) { if (c == c->hydro.super) { #ifdef SWIFT_DEBUG_CHECKS @@ -1711,7 +1712,7 @@ void cell_activate_sorts_up(struct cell *c, struct scheduler *s) { /** * @brief Activate the sorts on a given cell, if needed. */ -void cell_activate_sorts(struct cell *c, int sid, struct scheduler *s) { +void cell_activate_hydro_sorts(struct cell *c, int sid, struct scheduler *s) { /* Do we need to re-sort? */ if (c->hydro.dx_max_sort > space_maxreldx * c->dmin) { @@ -1720,7 +1721,7 @@ void cell_activate_sorts(struct cell *c, int sid, struct scheduler *s) { for (struct cell *finger = c; finger != NULL; finger = finger->parent) { if (finger->hydro.requires_sorts) { atomic_or(&finger->hydro.do_sort, finger->hydro.requires_sorts); - cell_activate_sorts_up(finger, s); + cell_activate_hydro_sorts_up(finger, s); } finger->hydro.sorted = 0; } @@ -1729,7 +1730,7 @@ void cell_activate_sorts(struct cell *c, int sid, struct scheduler *s) { /* Has this cell been sorted at all for the given sid? */ if (!(c->hydro.sorted & (1 << sid)) || c->nodeID != engine_rank) { atomic_or(&c->hydro.do_sort, (1 << sid)); - cell_activate_sorts_up(c, s); + cell_activate_hydro_sorts_up(c, s); } } @@ -1745,6 +1746,7 @@ void cell_activate_stars_sorts_up(struct cell *c, struct scheduler *s) { #endif scheduler_activate(s, c->stars.sorts); if (c->nodeID == engine_rank) { + // MATTHIEU: to do: do we actually need both drifts here? cell_activate_drift_part(c, s); cell_activate_drift_spart(c, s); } @@ -1757,7 +1759,7 @@ void cell_activate_stars_sorts_up(struct cell *c, struct scheduler *s) { if (parent == c->super) { #ifdef SWIFT_DEBUG_CHECKS if (parent->stars.sorts == NULL) - error("Trying to activate un-existing parents->hydro.sorts"); + error("Trying to activate un-existing parents->stars.sorts"); #endif scheduler_activate(s, parent->stars.sorts); if (parent->nodeID == engine_rank) { @@ -2145,8 +2147,8 @@ void cell_activate_subcell_hydro_tasks(struct cell *ci, struct cell *cj, if (cj->nodeID == engine_rank) cell_activate_drift_part(cj, s); /* Do we need to sort the cells? */ - cell_activate_sorts(ci, sid, s); - cell_activate_sorts(cj, sid, s); + cell_activate_hydro_sorts(ci, sid, s); + cell_activate_hydro_sorts(cj, sid, s); } } /* Otherwise, pair interation */ } @@ -2510,7 +2512,7 @@ void cell_activate_subcell_stars_tasks(struct cell *ci, struct cell *cj, if (cj->nodeID == engine_rank) cell_activate_drift_part(cj, s); /* Do we need to sort the cells? */ - cell_activate_sorts(cj, sid, s); + cell_activate_hydro_sorts(cj, sid, s); cell_activate_stars_sorts(ci, sid, s); } @@ -2528,7 +2530,7 @@ void cell_activate_subcell_stars_tasks(struct cell *ci, struct cell *cj, if (cj->nodeID == engine_rank) cell_activate_drift_spart(cj, s); /* Do we need to sort the cells? */ - cell_activate_sorts(ci, sid, s); + cell_activate_hydro_sorts(ci, sid, s); cell_activate_stars_sorts(cj, sid, s); } } @@ -2748,8 +2750,8 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { if (cj_nodeID == nodeID) cell_activate_drift_part(cj, s); /* Check the sorts and activate them if needed. */ - cell_activate_sorts(ci, t->flags, s); - cell_activate_sorts(cj, t->flags, s); + cell_activate_hydro_sorts(ci, t->flags, s); + cell_activate_hydro_sorts(cj, t->flags, s); } /* Store current values of dx_max and h_max. */ else if (t->type == task_type_sub_pair || t->type == task_type_sub_self) { @@ -3042,6 +3044,7 @@ int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) { * @return 1 If the space needs rebuilding. 0 otherwise. */ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) { + struct engine *e = s->space->e; const int nodeID = e->nodeID; int rebuild = 0; @@ -3084,7 +3087,7 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) { /* Check the sorts and activate them if needed. */ cell_activate_stars_sorts(ci, t->flags, s); - cell_activate_sorts(cj, t->flags, s); + cell_activate_hydro_sorts(cj, t->flags, s); /* Do cj */ /* hydro for ci */ @@ -3100,7 +3103,7 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) { if (ci->nodeID == nodeID) cell_activate_drift_part(ci, s); /* Check the sorts and activate them if needed. */ - cell_activate_sorts(ci, t->flags, s); + cell_activate_hydro_sorts(ci, t->flags, s); cell_activate_stars_sorts(cj, t->flags, s); } diff --git a/src/cell.h b/src/cell.h index c22c2ac1e20d5df474ae88ff9d8b8e89707c79e6..986bc99194702518c7b3a2f08fec95a45a7f4f3c 100644 --- a/src/cell.h +++ b/src/cell.h @@ -685,7 +685,7 @@ void cell_activate_subcell_external_grav_tasks(struct cell *ci, void cell_activate_drift_part(struct cell *c, struct scheduler *s); void cell_activate_drift_gpart(struct cell *c, struct scheduler *s); void cell_activate_drift_spart(struct cell *c, struct scheduler *s); -void cell_activate_sorts(struct cell *c, int sid, struct scheduler *s); +void cell_activate_hydro_sorts(struct cell *c, int sid, struct scheduler *s); void cell_activate_stars_sorts(struct cell *c, int sid, struct scheduler *s); void cell_clear_drift_flags(struct cell *c, void *data); void cell_set_super_mapper(void *map_data, int num_elements, void *extra_data); diff --git a/src/engine_marktasks.c b/src/engine_marktasks.c index 11ec4b4d86f6330c5367a7a5a409c640d868b0d8..2206a9b8ecdf8b4b24b8f0287b12a7222b72fb8e 100644 --- a/src/engine_marktasks.c +++ b/src/engine_marktasks.c @@ -208,8 +208,8 @@ void engine_marktasks_mapper(void *map_data, int num_elements, if (cj_nodeID == nodeID) cell_activate_drift_part(cj, s); /* Check the sorts and activate them if needed. */ - cell_activate_sorts(ci, t->flags, s); - cell_activate_sorts(cj, t->flags, s); + cell_activate_hydro_sorts(ci, t->flags, s); + cell_activate_hydro_sorts(cj, t->flags, s); } @@ -225,6 +225,11 @@ void engine_marktasks_mapper(void *map_data, int num_elements, ((ci_active_stars && ci->nodeID == engine_rank) || (cj_active_stars && cj->nodeID == engine_rank))) { + // MATTHIEU: The logic here can be improved. + // If ci is active for stars but not cj, then we can only drift the + // stars in ci and parts in cj. (and vice-versa). The same logic can be + // applied in cell_unskip_stars(). + scheduler_activate(s, t); /* Set the correct sorting flags */ @@ -244,7 +249,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, if (cj_nodeID == nodeID) cell_activate_drift_part(cj, s); /* Check the sorts and activate them if needed. */ - cell_activate_sorts(cj, t->flags, s); + cell_activate_hydro_sorts(cj, t->flags, s); cell_activate_stars_sorts(ci, t->flags, s); @@ -262,7 +267,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, if (cj_nodeID == nodeID) cell_activate_drift_spart(cj, s); /* Check the sorts and activate them if needed. */ - cell_activate_sorts(ci, t->flags, s); + cell_activate_hydro_sorts(ci, t->flags, s); cell_activate_stars_sorts(cj, t->flags, s); } diff --git a/src/runner.c b/src/runner.c index a08cfe7bc2619bbe7cb7dffce2a7384a70baa895..24a19f9f7eca2c522784f4d61e4b55793439832f 100644 --- a/src/runner.c +++ b/src/runner.c @@ -2822,7 +2822,7 @@ void *runner_main(void *data) { runner_do_stars_sort( r, ci, t->flags, ci->stars.dx_max_sort_old > space_maxreldx * ci->dmin, 1); - /* Reset the sort flags as our work here is done. */ + /* Reset the sort flags as our work here is done. */ t->flags = 0; break; case task_type_init_grav: diff --git a/src/task.c b/src/task.c index 0916cba850f7b558c9ae0ac1684a8a5e052f7719..3918dad3b713c6c226e5dacf3e38756910c1dd27 100644 --- a/src/task.c +++ b/src/task.c @@ -474,7 +474,6 @@ int task_lock(struct task *t) { cell_gunlocktree(ci); return 0; } - } else if (subtype == task_subtype_stars_density) { if (ci->stars.hold) return 0; if (cell_slocktree(ci) != 0) return 0;