diff --git a/src/cell.c b/src/cell.c index 8c4dafd960b95e17f0d2bc773bafa412502d3faf..e07d8612f206f652f83b11ea6a0c465407ce0add 100644 --- a/src/cell.c +++ b/src/cell.c @@ -1522,7 +1522,7 @@ void cell_activate_subcell_hydro_tasks(struct cell *ci, struct cell *cj, if (ci->count == 0 || !cell_is_active_hydro(ci, e)) return; /* Recurse? */ - if (cell_can_recurse_in_self_task(ci)) { + if (cell_can_recurse_in_self_hydro_task(ci)) { /* Loop over all progenies and pairs of progenies */ for (int j = 0; j < 8; j++) { @@ -1553,8 +1553,8 @@ void cell_activate_subcell_hydro_tasks(struct cell *ci, struct cell *cj, int sid = space_getsid(s->space, &ci, &cj, shift); /* recurse? */ - if (cell_can_recurse_in_pair_task(ci) && - cell_can_recurse_in_pair_task(cj)) { + if (cell_can_recurse_in_pair_hydro_task(ci) && + cell_can_recurse_in_pair_hydro_task(cj)) { /* Different types of flags. */ switch (sid) { diff --git a/src/cell.h b/src/cell.h index d7e1a35beb105d7a7945b18bc3e0b44ab6fed199..844b47b86f7f029b4e4f35ea166db663a758bd4b 100644 --- a/src/cell.h +++ b/src/cell.h @@ -538,7 +538,7 @@ int cell_can_use_pair_mm(const struct cell *ci, const struct cell *cj, * * @param c The #cell. */ -__attribute__((always_inline)) INLINE static int cell_can_recurse_in_pair_task( +__attribute__((always_inline)) INLINE static int cell_can_recurse_in_pair_hydro_task( const struct cell *c) { /* Is the cell split ? */ @@ -555,7 +555,7 @@ __attribute__((always_inline)) INLINE static int cell_can_recurse_in_pair_task( * * @param c The #cell. */ -__attribute__((always_inline)) INLINE static int cell_can_recurse_in_self_task( +__attribute__((always_inline)) INLINE static int cell_can_recurse_in_self_hydro_task( const struct cell *c) { /* Is the cell split and not smaller than the smoothing length? */ @@ -563,7 +563,7 @@ __attribute__((always_inline)) INLINE static int cell_can_recurse_in_self_task( } /** - * @brief Can a pair task associated with a cell be split into smaller + * @brief Can a pair hydro task associated with a cell be split into smaller * sub-tasks. * * @param c The #cell. @@ -580,7 +580,7 @@ __attribute__((always_inline)) INLINE static int cell_can_split_pair_hydro_task( } /** - * @brief Can a self task associated with a cell be split into smaller + * @brief Can a self hydro task associated with a cell be split into smaller * sub-tasks. * * @param c The #cell. @@ -589,11 +589,40 @@ __attribute__((always_inline)) INLINE static int cell_can_split_self_hydro_task( const struct cell *c) { /* Is the cell split ? */ + /* If so, is the cut-off radius with some leeway smaller than */ + /* the sub-cell sizes ? */ /* Note: No need for more checks here as all the sub-pairs and sub-self */ /* tasks will be created. So no need to check for h_max */ return c->split && (space_stretch * kernel_gamma * c->h_max < 0.5f * c->dmin); } + +/** + * @brief Can a pair gravity task associated with a cell be split into smaller + * sub-tasks. + * + * @param c The #cell. + */ +__attribute__((always_inline)) INLINE static int cell_can_split_pair_gravity_task( + const struct cell *c) { + + /* Is the cell split ? */ + return c->split; +} + +/** + * @brief Can a self gravity task associated with a cell be split into smaller + * sub-tasks. + * + * @param c The #cell. + */ +__attribute__((always_inline)) INLINE static int cell_can_split_self_gravity_task( + const struct cell *c) { + + /* Is the cell split ? */ + return c->split; +} + /** * @brief Have particles in a pair of cells moved too much and require a rebuild * ? diff --git a/src/runner_doiact.h b/src/runner_doiact.h index 2987d205e5005d4618c087bfe7f18a0b3c12fef5..80f661502d93a70c06e940b074ef56292b5e29fd 100644 --- a/src/runner_doiact.h +++ b/src/runner_doiact.h @@ -2086,7 +2086,7 @@ void DOSUB_PAIR1(struct runner *r, struct cell *ci, struct cell *cj, int sid, sid = space_getsid(s, &ci, &cj, shift); /* Recurse? */ - if (cell_can_recurse_in_pair_task(ci) && cell_can_recurse_in_pair_task(cj)) { + if (cell_can_recurse_in_pair_hydro_task(ci) && cell_can_recurse_in_pair_hydro_task(cj)) { /* Different types of flags. */ switch (sid) { @@ -2323,7 +2323,7 @@ void DOSUB_SELF1(struct runner *r, struct cell *ci, int gettimer) { if (ci->count == 0 || !cell_is_active_hydro(ci, r->e)) return; /* Recurse? */ - if (cell_can_recurse_in_self_task(ci)) { + if (cell_can_recurse_in_self_hydro_task(ci)) { /* Loop over all progeny. */ for (int k = 0; k < 8; k++) @@ -2376,7 +2376,7 @@ void DOSUB_PAIR2(struct runner *r, struct cell *ci, struct cell *cj, int sid, sid = space_getsid(s, &ci, &cj, shift); /* Recurse? */ - if (cell_can_recurse_in_pair_task(ci) && cell_can_recurse_in_pair_task(cj)) { + if (cell_can_recurse_in_pair_hydro_task(ci) && cell_can_recurse_in_pair_hydro_task(cj)) { /* Different types of flags. */ switch (sid) { @@ -2613,7 +2613,7 @@ void DOSUB_SELF2(struct runner *r, struct cell *ci, int gettimer) { if (ci->count == 0 || !cell_is_active_hydro(ci, r->e)) return; /* Recurse? */ - if (cell_can_recurse_in_self_task(ci)) { + if (cell_can_recurse_in_self_hydro_task(ci)) { /* Loop over all progeny. */ for (int k = 0; k < 8; k++) @@ -2665,7 +2665,7 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts, if (cj == NULL) { /* Recurse? */ - if (cell_can_recurse_in_self_task(ci)) { + if (cell_can_recurse_in_self_hydro_task(ci)) { /* Loop over all progeny. */ DOSUB_SUBSET(r, sub, parts, ind, count, NULL, -1, 0); @@ -2684,8 +2684,8 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts, else { /* Recurse? */ - if (cell_can_recurse_in_pair_task(ci) && - cell_can_recurse_in_pair_task(cj)) { + if (cell_can_recurse_in_pair_hydro_task(ci) && + cell_can_recurse_in_pair_hydro_task(cj)) { /* Get the type of pair if not specified explicitly. */ double shift[3] = {0.0, 0.0, 0.0}; diff --git a/src/scheduler.c b/src/scheduler.c index 8a21624aba2f92e6be7b3473c52a760f8b3df0bc..be3790beedbac59a8343cda32c4cbf1f1fd42686 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -841,7 +841,7 @@ static void scheduler_splittask_gravity(struct task *t, struct scheduler *s) { #ifndef WITH_MPI /* Should we split this task? */ - if (ci->split) { + if (cell_can_split_self_gravity_task(ci)) { if (scheduler_dosub && ci->gcount < space_subsize_self_grav) { @@ -906,7 +906,7 @@ static void scheduler_splittask_gravity(struct task *t, struct scheduler *s) { } /* Should this task be split-up? */ - if (ci->split && cj->split) { + if (cell_can_split_pair_gravity_task(ci) && cell_can_split_pair_gravity_task(cj)) { /* Replace by a single sub-task? */ if (scheduler_dosub && /* Use division to avoid integer overflow. */