Commit 64a5957d authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Use the same naming convention for the hydro sort activation function and the...

Use the same naming convention for the hydro sort activation function and the star sort activation function.
parent 6b607c98
......@@ -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);
}
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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:
......
......@@ -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;
......
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