diff --git a/src/active.h b/src/active.h index 4ba442c2c28006c7d4eaa72bc7f3e7debb075608..ed882229f28b5bc5289a951ab4e60e7098ce2457 100644 --- a/src/active.h +++ b/src/active.h @@ -177,6 +177,8 @@ __attribute__((always_inline)) INLINE static int cell_is_all_active_gravity( /** * @brief Does a cell contain any s-particle finishing their time-step now ? * + * WARNING: TODO: need to be implemented + * * @param c The #cell. * @param e The #engine containing information about the current time. * @return 1 if the #cell contains at least an active particle, 0 otherwise. @@ -184,7 +186,7 @@ __attribute__((always_inline)) INLINE static int cell_is_all_active_gravity( __attribute__((always_inline)) INLINE static int cell_is_active_stars( const struct cell *c, const struct engine *e) { - return 1; + return cell_is_active_gravity(c, e); } /** diff --git a/src/cell.c b/src/cell.c index c4af3916443a42c82d8dc5c8e8671d1e49a5c0a9..8aa029d9f73d02561e44ea1137f496c632b1c0c0 100644 --- a/src/cell.c +++ b/src/cell.c @@ -1980,6 +1980,21 @@ void cell_activate_subcell_hydro_tasks(struct cell *ci, struct cell *cj, } /* Otherwise, pair interation */ } +/** + * @brief Traverse a sub-cell task and activate the stars drift tasks that are + * required + * by a stars task + * + * WARNING: TODO: Need to be implemented + * + * @param ci The first #cell we recurse in. + * @param cj The second #cell we recurse in. + * @param s The task #scheduler. + */ +void cell_activate_subcell_stars_tasks(struct cell *ci, struct cell *cj, + struct scheduler *s) {} + + void cell_activate_grav_mm_task(struct cell *ci, struct cell *cj, struct scheduler *s) { /* Some constants */ @@ -2326,9 +2341,6 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { if (c->ghost_in != NULL) scheduler_activate(s, c->ghost_in); if (c->ghost_out != NULL) scheduler_activate(s, c->ghost_out); if (c->ghost != NULL) scheduler_activate(s, c->ghost); - if (c->stars_ghost_in != NULL) scheduler_activate(s, c->stars_ghost_in); - if (c->stars_ghost_out != NULL) scheduler_activate(s, c->stars_ghost_out); - if (c->stars_ghost != NULL) scheduler_activate(s, c->stars_ghost); 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); @@ -2488,6 +2500,21 @@ int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) { return rebuild; } +/** + * @brief Un-skips all the stars tasks associated with a given cell and checks + * if the space needs to be rebuilt. + * + * WARNING: TODO: Need to be implemented + * + * @param c the #cell. + * @param s the #scheduler. + * + * @return 1 If the space needs rebuilding. 0 otherwise. + */ +int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) { + return 0; +} + /** * @brief Set the super-cell pointers for all cells in a hierarchy. * diff --git a/src/cell.h b/src/cell.h index f84b5ad312fe94919f0f37150bda8800c00c5b30..ad011ec1e4cc3147c434455b9365948946807da7 100644 --- a/src/cell.h +++ b/src/cell.h @@ -595,6 +595,8 @@ cell_can_recurse_in_self_hydro_task(const struct cell *c) { * @brief Can a sub-pair star task recurse to a lower level based * on the status of the particles in the cell. * + * WARNING: TODO: need to be implemented + * * @param c The #cell. */ __attribute__((always_inline)) INLINE static int @@ -607,6 +609,8 @@ cell_can_recurse_in_pair_stars_task(const struct cell *c) { * @brief Can a sub-self stars task recurse to a lower level based * on the status of the particles in the cell. * + * WARNING: TODO: need to be implemented + * * @param c The #cell. */ __attribute__((always_inline)) INLINE static int diff --git a/src/engine.c b/src/engine.c index 413f29f834b729bcac3e051e56927b65f5119c70..a10b5e1abf108d971341ca75f389b1fc61a2f44a 100644 --- a/src/engine.c +++ b/src/engine.c @@ -3329,9 +3329,11 @@ void engine_link_stars_tasks_mapper(void *map_data, int num_elements, /* Self-interaction? */ if (t->type == task_type_self && t->subtype == task_subtype_stars_density) { - /* Make the self-density tasks depend on the drift only. */ + /* Make the self-density tasks depend on the drifts. */ scheduler_addunlock(sched, t->ci->super->drift_part, t); + scheduler_addunlock(sched, t->ci->super->drift_gpart, t); + /* Now, build all the dependencies for the stars */ engine_make_stars_loops_dependencies(sched, t, t->ci); scheduler_addunlock(sched, t->ci->stars_ghost_out, t->ci->super->end_force); @@ -3470,7 +3472,7 @@ void engine_maketasks(struct engine *e) { #endif const size_t self_grav_tasks_per_cell = 125; const size_t ext_grav_tasks_per_cell = 1; - const size_t stars_tasks_per_cell = 1; + const size_t stars_tasks_per_cell = 15; if (e->policy & engine_policy_hydro) e->size_links += s->tot_cells * hydro_tasks_per_cell; @@ -3737,6 +3739,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, if (cell_is_active_stars(ci, e)) { scheduler_activate(s, t); cell_activate_drift_part(ci, s); + cell_activate_drift_gpart(ci, s); } } @@ -3745,7 +3748,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, t->subtype == task_subtype_stars_density) { if (cell_is_active_stars(ci, e)) { scheduler_activate(s, t); - cell_activate_subcell_hydro_tasks(ci, NULL, s); + cell_activate_subcell_stars_tasks(ci, NULL, s); } } diff --git a/src/runner.c b/src/runner.c index cf70cef08ee6ab597f20efab91cc21d0d343f8db..bbc658eb22be0f110f12b8ee799252301dfb9d60 100644 --- a/src/runner.c +++ b/src/runner.c @@ -1202,6 +1202,35 @@ static void runner_do_unskip_hydro(struct cell *c, struct engine *e) { if (forcerebuild) atomic_inc(&e->forcerebuild); } +/** + * @brief Unskip any stars tasks associated with active cells. + * + * @param c The cell. + * @param e The engine. + */ +static void runner_do_unskip_stars(struct cell *c, struct engine *e) { + + /* Ignore empty cells. */ + if (c->scount == 0) return; + + /* Skip inactive cells. */ + 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); + } + } + } + + /* Unskip any active tasks. */ + const int forcerebuild = cell_unskip_stars_tasks(c, &e->sched); + if (forcerebuild) atomic_inc(&e->forcerebuild); +} + /** * @brief Unskip any gravity tasks associated with active cells. * @@ -1255,6 +1284,10 @@ void runner_do_unskip_mapper(void *map_data, int num_elements, if ((e->policy & engine_policy_self_gravity) || (e->policy & engine_policy_external_gravity)) runner_do_unskip_gravity(c, e); + + /* Stars tasks */ + if (e->policy & engine_policy_stars) + runner_do_unskip_stars(c, e); } } } diff --git a/src/stars/Default/stars_io.h b/src/stars/Default/stars_io.h index 4fd28a813d735e7af570171fd0be098a84b85517..542fef4a778c0c8d9a13d5a11bfc82e1a9d3a018 100644 --- a/src/stars/Default/stars_io.h +++ b/src/stars/Default/stars_io.h @@ -78,6 +78,8 @@ INLINE static void stars_write_particles(const struct spart* sparts, /** * @brief Initialize the global properties of the stars scheme. * + * By default, takes the values provided by the hydro. + * * @param p The #stars_props. * @param phys_const The physical constants in the internal unit system. * @param us The internal unit system.