diff --git a/src/cell.c b/src/cell.c index 11ac0e75039a4ca3869445d2af2c99a13d8585bd..5650a309f1c6bd55cf4048e92be665546a80979b 100644 --- a/src/cell.c +++ b/src/cell.c @@ -2692,11 +2692,9 @@ void cell_activate_subcell_hydro_tasks(struct cell *ci, struct cell *cj, * @param ci The first #cell we recurse in. * @param cj The second #cell we recurse in. * @param s The task #scheduler. - * @param with_star_formation Are we running with star formation switched on? */ void cell_activate_subcell_stars_tasks(struct cell *ci, struct cell *cj, - struct scheduler *s, - const int with_star_formation) { + struct scheduler *s) { const struct engine *e = s->space->e; /* Store the current dx_max and h_max values. */ @@ -2714,24 +2712,21 @@ void cell_activate_subcell_stars_tasks(struct cell *ci, struct cell *cj, /* Self interaction? */ if (cj == NULL) { - - const int ci_active = cell_is_active_stars(ci, e) || - (with_star_formation && cell_is_active_hydro(ci, e)); - /* Do anything? */ - if (!ci_active || ci->hydro.count == 0 || ci->stars.count == 0) return; + if (!cell_is_active_stars(ci, e) || ci->hydro.count == 0 || + ci->stars.count == 0) + return; /* Recurse? */ if (cell_can_recurse_in_self_stars_task(ci)) { /* Loop over all progenies and pairs of progenies */ for (int j = 0; j < 8; j++) { if (ci->progeny[j] != NULL) { - cell_activate_subcell_stars_tasks(ci->progeny[j], NULL, s, - with_star_formation); + cell_activate_subcell_stars_tasks(ci->progeny[j], NULL, s); for (int k = j + 1; k < 8; k++) if (ci->progeny[k] != NULL) cell_activate_subcell_stars_tasks(ci->progeny[j], ci->progeny[k], - s, with_star_formation); + s); } } } else { @@ -2743,15 +2738,8 @@ void cell_activate_subcell_stars_tasks(struct cell *ci, struct cell *cj, /* Otherwise, pair interation */ else { - - const int ci_active = cell_is_active_stars(ci, e) || - (with_star_formation && cell_is_active_hydro(ci, e)); - - const int cj_active = cell_is_active_stars(cj, e) || - (with_star_formation && cell_is_active_hydro(cj, e)); - /* Should we even bother? */ - if (!ci_active && !cj_active) return; + if (!cell_is_active_stars(ci, e) && !cell_is_active_stars(cj, e)) return; /* Get the orientation of the pair. */ double shift[3]; @@ -2766,14 +2754,13 @@ void cell_activate_subcell_stars_tasks(struct cell *ci, struct cell *cj, const int pjd = csp->pairs[k].pjd; if (ci->progeny[pid] != NULL && cj->progeny[pjd] != NULL) cell_activate_subcell_stars_tasks(ci->progeny[pid], cj->progeny[pjd], - s, with_star_formation); + s); } } /* Otherwise, activate the sorts and drifts. */ else { - - if (ci_active) { + if (cell_is_active_stars(ci, e)) { /* We are going to interact this pair, so store some values. */ atomic_or(&cj->hydro.requires_sorts, 1 << sid); atomic_or(&ci->stars.requires_sorts, 1 << sid); @@ -2790,7 +2777,7 @@ void cell_activate_subcell_stars_tasks(struct cell *ci, struct cell *cj, cell_activate_stars_sorts(ci, sid, s); } - if (cj_active) { + if (cell_is_active_stars(cj, e)) { /* We are going to interact this pair, so store some values. */ atomic_or(&cj->stars.requires_sorts, 1 << sid); atomic_or(&ci->hydro.requires_sorts, 1 << sid); @@ -3463,13 +3450,10 @@ int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) { * * @param c the #cell. * @param s the #scheduler. - * @param with_star_formation Are we running with star formation switched on? * * @return 1 If the space needs rebuilding. 0 otherwise. */ -int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s, - const int with_star_formation) { - +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; @@ -3483,14 +3467,8 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s, struct task *t = l->t; struct cell *ci = t->ci; struct cell *cj = t->cj; - - const int ci_active = cell_is_active_stars(ci, e) || - (with_star_formation && cell_is_active_hydro(ci, e)); - - const int cj_active = - (cj != NULL) && (cell_is_active_stars(cj, e) || - (with_star_formation && cell_is_active_hydro(cj, e))); - + const int ci_active = cell_is_active_stars(ci, e); + const int cj_active = (cj != NULL) ? cell_is_active_stars(cj, e) : 0; #ifdef WITH_MPI const int ci_nodeID = ci->nodeID; const int cj_nodeID = (cj != NULL) ? cj->nodeID : -1; @@ -3550,12 +3528,8 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s, } } - else if (t->type == task_type_sub_self) { - cell_activate_subcell_stars_tasks(ci, NULL, s, with_star_formation); - } - - else if (t->type == task_type_sub_pair) { - cell_activate_subcell_stars_tasks(ci, cj, s, with_star_formation); + else if (t->type == task_type_sub_pair || t->type == task_type_sub_self) { + cell_activate_subcell_stars_tasks(ci, cj, s); } } @@ -3638,14 +3612,8 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s, struct task *t = l->t; struct cell *ci = t->ci; struct cell *cj = t->cj; - - const int ci_active = cell_is_active_stars(ci, e) || - (with_star_formation && cell_is_active_hydro(ci, e)); - - const int cj_active = - (cj != NULL) && (cell_is_active_stars(cj, e) || - (with_star_formation && cell_is_active_hydro(cj, e))); - + const int ci_active = cell_is_active_stars(ci, e); + const int cj_active = (cj != NULL) ? cell_is_active_stars(cj, e) : 0; #ifdef WITH_MPI const int ci_nodeID = ci->nodeID; const int cj_nodeID = (cj != NULL) ? cj->nodeID : -1; @@ -3681,18 +3649,14 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s, } /* Unskip all the other task types. */ - if (c->nodeID == nodeID) { - if (cell_is_active_stars(c, e) || - (with_star_formation && cell_is_active_hydro(c, e))) { - - if (c->stars.ghost != NULL) scheduler_activate(s, c->stars.ghost); - if (c->stars.stars_in != NULL) scheduler_activate(s, c->stars.stars_in); - if (c->stars.stars_out != NULL) scheduler_activate(s, c->stars.stars_out); - if (c->kick1 != NULL) scheduler_activate(s, c->kick1); - if (c->kick2 != NULL) scheduler_activate(s, c->kick2); - if (c->timestep != NULL) scheduler_activate(s, c->timestep); - if (c->logger != NULL) scheduler_activate(s, c->logger); - } + if (c->nodeID == nodeID && cell_is_active_stars(c, e)) { + if (c->stars.ghost != NULL) scheduler_activate(s, c->stars.ghost); + if (c->stars.stars_in != NULL) scheduler_activate(s, c->stars.stars_in); + if (c->stars.stars_out != NULL) scheduler_activate(s, c->stars.stars_out); + if (c->kick1 != NULL) scheduler_activate(s, c->kick1); + if (c->kick2 != NULL) scheduler_activate(s, c->kick2); + if (c->timestep != NULL) scheduler_activate(s, c->timestep); + if (c->logger != NULL) scheduler_activate(s, c->logger); } return rebuild; diff --git a/src/cell.h b/src/cell.h index 461ed45028e2363ec5c6143e913de78611cda8e5..1cc6b81e35759136c8de3041674e8ae92715950b 100644 --- a/src/cell.h +++ b/src/cell.h @@ -844,8 +844,7 @@ void cell_check_spart_drift_point(struct cell *c, void *data); void cell_check_multipole_drift_point(struct cell *c, void *data); void cell_reset_task_counters(struct cell *c); int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s); -int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s, - const int with_star_formation); +int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s); int cell_unskip_black_holes_tasks(struct cell *c, struct scheduler *s); int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s); void cell_drift_part(struct cell *c, const struct engine *e, int force); @@ -861,8 +860,7 @@ void cell_activate_subcell_hydro_tasks(struct cell *ci, struct cell *cj, void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj, struct scheduler *s); void cell_activate_subcell_stars_tasks(struct cell *ci, struct cell *cj, - struct scheduler *s, - const int with_star_formation); + struct scheduler *s); void cell_activate_subcell_black_holes_tasks(struct cell *ci, struct cell *cj, struct scheduler *s); void cell_activate_subcell_external_grav_tasks(struct cell *ci, diff --git a/src/engine_marktasks.c b/src/engine_marktasks.c index 5560714dbea7505047c403d359d5049ea8bc7111..e38e2efc4175c4ea281634b238f39010a7d3153b 100644 --- a/src/engine_marktasks.c +++ b/src/engine_marktasks.c @@ -70,9 +70,8 @@ void engine_marktasks_mapper(void *map_data, int num_elements, struct engine *e = (struct engine *)((size_t *)extra_data)[0]; const int nodeID = e->nodeID; const int with_limiter = e->policy & engine_policy_limiter; - const int with_star_formation = e->policy & engine_policy_star_formation; - #ifdef WITH_MPI + const int with_star_formation = e->policy & engine_policy_star_formation; const int with_feedback = e->policy & engine_policy_feedback; #endif @@ -89,19 +88,11 @@ void engine_marktasks_mapper(void *map_data, int num_elements, /* Local pointer. */ struct cell *ci = t->ci; - /* How active is this cell? */ - const int ci_active_hydro = cell_is_active_hydro(ci, e); - const int ci_active_gravity = cell_is_active_gravity(ci, e); - const int ci_active_black_holes = cell_is_active_black_holes(ci, e); - const int ci_active_stars = - cell_is_active_stars(ci, e) || - (with_star_formation && cell_is_active_hydro(ci, e)); - if (ci->nodeID != nodeID) error("Non-local self task found"); /* Activate the hydro drift */ if (t_type == task_type_self && t_subtype == task_subtype_density) { - if (ci_active_hydro) { + if (cell_is_active_hydro(ci, e)) { scheduler_activate(s, t); cell_activate_drift_part(ci, s); if (with_limiter) cell_activate_limiter(ci, s); @@ -111,7 +102,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, /* Store current values of dx_max and h_max. */ else if (t_type == task_type_sub_self && t_subtype == task_subtype_density) { - if (ci_active_hydro) { + if (cell_is_active_hydro(ci, e)) { scheduler_activate(s, t); cell_activate_subcell_hydro_tasks(ci, NULL, s); if (with_limiter) cell_activate_limiter(ci, s); @@ -119,37 +110,37 @@ void engine_marktasks_mapper(void *map_data, int num_elements, } else if (t_type == task_type_self && t_subtype == task_subtype_force) { - if (ci_active_hydro) scheduler_activate(s, t); + if (cell_is_active_hydro(ci, e)) scheduler_activate(s, t); } else if (t_type == task_type_sub_self && t_subtype == task_subtype_force) { - if (ci_active_hydro) scheduler_activate(s, t); + if (cell_is_active_hydro(ci, e)) scheduler_activate(s, t); } else if (t->type == task_type_self && t->subtype == task_subtype_limiter) { - if (ci_active_hydro) scheduler_activate(s, t); + if (cell_is_active_hydro(ci, e)) scheduler_activate(s, t); } else if (t->type == task_type_sub_self && t->subtype == task_subtype_limiter) { - if (ci_active_hydro) scheduler_activate(s, t); + if (cell_is_active_hydro(ci, e)) scheduler_activate(s, t); } else if (t_type == task_type_self && t_subtype == task_subtype_gradient) { - if (ci_active_hydro) scheduler_activate(s, t); + if (cell_is_active_hydro(ci, e)) scheduler_activate(s, t); } else if (t_type == task_type_sub_self && t_subtype == task_subtype_gradient) { - if (ci_active_hydro) scheduler_activate(s, t); + if (cell_is_active_hydro(ci, e)) scheduler_activate(s, t); } /* Activate the star density */ else if (t_type == task_type_self && t_subtype == task_subtype_stars_density) { - if (ci_active_stars) { + if (cell_is_active_stars(ci, e)) { scheduler_activate(s, t); cell_activate_drift_part(ci, s); cell_activate_drift_spart(ci, s); @@ -159,28 +150,28 @@ void engine_marktasks_mapper(void *map_data, int num_elements, /* Store current values of dx_max and h_max. */ else if (t_type == task_type_sub_self && t_subtype == task_subtype_stars_density) { - if (ci_active_stars) { + if (cell_is_active_stars(ci, e)) { scheduler_activate(s, t); - cell_activate_subcell_stars_tasks(ci, NULL, s, with_star_formation); + cell_activate_subcell_stars_tasks(ci, NULL, s); } } else if (t_type == task_type_self && t_subtype == task_subtype_stars_feedback) { - if (ci_active_stars) { + if (cell_is_active_stars(ci, e)) { scheduler_activate(s, t); } } else if (t_type == task_type_sub_self && t_subtype == task_subtype_stars_feedback) { - if (ci_active_stars) scheduler_activate(s, t); + if (cell_is_active_stars(ci, e)) scheduler_activate(s, t); } /* Activate the black hole density */ else if (t_type == task_type_self && t_subtype == task_subtype_bh_density) { - if (ci_active_black_holes) { + if (cell_is_active_black_holes(ci, e)) { scheduler_activate(s, t); cell_activate_drift_part(ci, s); cell_activate_drift_bpart(ci, s); @@ -190,7 +181,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, /* Store current values of dx_max and h_max. */ else if (t_type == task_type_sub_self && t_subtype == task_subtype_bh_density) { - if (ci_active_black_holes) { + if (cell_is_active_black_holes(ci, e)) { scheduler_activate(s, t); cell_activate_subcell_black_holes_tasks(ci, NULL, s); } @@ -198,19 +189,19 @@ void engine_marktasks_mapper(void *map_data, int num_elements, else if (t_type == task_type_self && t_subtype == task_subtype_bh_feedback) { - if (ci_active_black_holes) { + if (cell_is_active_black_holes(ci, e)) { scheduler_activate(s, t); } } else if (t_type == task_type_sub_self && t_subtype == task_subtype_bh_feedback) { - if (ci_active_black_holes) scheduler_activate(s, t); + if (cell_is_active_black_holes(ci, e)) scheduler_activate(s, t); } /* Activate the gravity drift */ else if (t_type == task_type_self && t_subtype == task_subtype_grav) { - if (ci_active_gravity) { + if (cell_is_active_gravity(ci, e)) { scheduler_activate(s, t); cell_activate_subcell_grav_tasks(t->ci, NULL, s); } @@ -219,7 +210,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, /* Activate the gravity drift */ else if (t_type == task_type_self && t_subtype == task_subtype_external_grav) { - if (ci_active_gravity) { + if (cell_is_active_gravity(ci, e)) { scheduler_activate(s, t); cell_activate_drift_gpart(t->ci, s); } @@ -251,16 +242,12 @@ void engine_marktasks_mapper(void *map_data, int num_elements, const int ci_active_gravity = cell_is_active_gravity(ci, e); const int cj_active_gravity = cell_is_active_gravity(cj, e); + const int ci_active_stars = cell_is_active_stars(ci, e); + const int cj_active_stars = cell_is_active_stars(cj, e); + const int ci_active_black_holes = cell_is_active_black_holes(ci, e); const int cj_active_black_holes = cell_is_active_black_holes(cj, e); - const int ci_active_stars = - cell_is_active_stars(ci, e) || - (with_star_formation && cell_is_active_hydro(ci, e)); - const int cj_active_stars = - cell_is_active_stars(cj, e) || - (with_star_formation && cell_is_active_hydro(cj, e)); - /* Only activate tasks that involve a local active cell. */ if ((t_subtype == task_subtype_density || t_subtype == task_subtype_gradient || @@ -355,7 +342,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, /* Store current values of dx_max and h_max. */ else if (t_type == task_type_sub_pair && t_subtype == task_subtype_stars_density) { - cell_activate_subcell_stars_tasks(ci, cj, s, with_star_formation); + cell_activate_subcell_stars_tasks(ci, cj, s); } } @@ -838,8 +825,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, /* logger tasks ? */ else if (t->type == task_type_logger) { if (cell_is_active_hydro(t->ci, e) || cell_is_active_gravity(t->ci, e) || - cell_is_active_stars(t->ci, e) || - cell_is_active_black_holes(t->ci, e)) + cell_is_active_stars(t->ci, e)) scheduler_activate(s, t); } @@ -876,16 +862,12 @@ void engine_marktasks_mapper(void *map_data, int num_elements, /* Star ghost tasks ? */ else if (t_type == task_type_stars_ghost) { - if (cell_is_active_stars(t->ci, e) || - (with_star_formation && cell_is_active_hydro(t->ci, e))) - scheduler_activate(s, t); + if (cell_is_active_stars(t->ci, e)) scheduler_activate(s, t); } /* Feedback implicit tasks? */ else if (t_type == task_type_stars_in || t_type == task_type_stars_out) { - if (cell_is_active_stars(t->ci, e) || - (with_star_formation && cell_is_active_hydro(t->ci, e))) - scheduler_activate(s, t); + if (cell_is_active_stars(t->ci, e)) scheduler_activate(s, t); } /* Black hole ghost tasks ? */ diff --git a/src/runner.c b/src/runner.c index 95e70aed72b80248762cab730db53deafc5169b9..84201536891c40b3fba91742035865e4dc18b142 100644 --- a/src/runner.c +++ b/src/runner.c @@ -2344,32 +2344,27 @@ static void runner_do_unskip_hydro(struct cell *c, struct engine *e) { * * @param c The cell. * @param e The engine. - * @param with_star_formation Are we running with star formation on? */ -static void runner_do_unskip_stars(struct cell *c, struct engine *e, - const int with_star_formation) { +static void runner_do_unskip_stars(struct cell *c, struct engine *e) { /* Ignore empty cells. */ if (c->stars.count == 0) return; /* Skip inactive cells. */ - if (!cell_is_active_stars(c, e) && - (!with_star_formation || !cell_is_active_hydro(c, e))) - return; + if (!cell_is_active_stars(c, e)) return; /* Recurse */ if (c->split) { for (int k = 0; k < 8; k++) { if (c->progeny[k] != NULL) { struct cell *cp = c->progeny[k]; - runner_do_unskip_stars(cp, e, with_star_formation); + runner_do_unskip_stars(cp, e); } } } /* Unskip any active tasks. */ - const int forcerebuild = - cell_unskip_stars_tasks(c, &e->sched, with_star_formation); + const int forcerebuild = cell_unskip_stars_tasks(c, &e->sched); if (forcerebuild) atomic_inc(&e->forcerebuild); } @@ -2441,7 +2436,6 @@ void runner_do_unskip_mapper(void *map_data, int num_elements, void *extra_data) { struct engine *e = (struct engine *)extra_data; - const int with_star_formation = e->policy & engine_policy_star_formation; const int nodeID = e->nodeID; struct space *s = e->s; int *local_cells = (int *)map_data; @@ -2459,8 +2453,7 @@ void runner_do_unskip_mapper(void *map_data, int num_elements, runner_do_unskip_gravity(c, e); /* Stars tasks */ - if (e->policy & engine_policy_stars) - runner_do_unskip_stars(c, e, with_star_formation); + if (e->policy & engine_policy_stars) runner_do_unskip_stars(c, e); /* Black hole tasks */ if (e->policy & engine_policy_black_holes)