Commit e9e69cd2 authored by Loic Hausammann's avatar Loic Hausammann
Browse files

Add the gpart->stars dependency

parent ec125561
......@@ -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);
}
/**
......
......@@ -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.
*
......
......@@ -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
......
......@@ -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);
}
}
......
......@@ -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);
}
}
}
......
......@@ -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.
......
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