Commit 4d200d36 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Modified the splitting rule for self tasks to be less conservative. Added...

Modified the splitting rule for self tasks to be less conservative. Added proper documentation of the splitting conditions.
parent 668f58a9
......@@ -1317,9 +1317,8 @@ int cell_is_drift_needed(struct cell *c, const struct engine *e) {
}
/**
* @brief Can a task recurse to a lower level based on the staus of the
* particles
* in the cell.
* @brief Can a sub-pair hydro task recurse to a lower level based
* on the status of the particles in the cell.
*
* @param c The #cell.
*/
......@@ -1328,25 +1327,64 @@ int cell_can_recurse_in_pair_task(const struct cell *c) {
/* Is the cell split ? */
/* If so, is the cut-off radius plus the max distance the parts have moved */
/* smaller than the sub-cell sizes ? */
/* Note: We use the _old values as these might have been updated by a drift */
return c->split &&
((kernel_gamma * c->h_max_old + c->dx_max_old) < 0.5f * c->dmin);
}
/**
* @brief Can a task associated with a cell be split into smaller sub-tasks.
* @brief Can a sub-self hydro task recurse to a lower level based
* on the status of the particles in the cell.
*
* @param c The #cell.
*/
int cell_can_split_task(const struct cell *c) {
int cell_can_recurse_in_self_task(const struct cell *c) {
/* Is the cell split ? */
/* Note: No need for more checks here as all the sub-pairs and sub-self */
/* operations will be executed. So no need for the particle to be at exactly
*/
/* the right place. */
return c->split;
}
/**
* @brief Can a pair task associated with a cell be split into smaller
* sub-tasks.
*
* @param c The #cell.
*/
int cell_can_split_pair_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 that since tasks are build after a rebuild no need to take */
/* Note that since tasks are create after a rebuild no need to take */
/* into account any part motion (i.e. dx_max == 0 here) */
return c->split && (space_stretch * kernel_gamma * c->h_max < 0.5f * c->dmin);
}
/**
* @brief Can a self task associated with a cell be split into smaller
* sub-tasks.
*
* @param c The #cell.
*/
int cell_can_split_self_task(const struct cell *c) {
/* Is the cell split ? */
/* 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;
}
/**
* @brief Have particles in a pair of cells moved too much and require a rebuild
* ?
*
* @param ci The first #cell.
* @param cj The second #cell.
*/
int cell_need_rebuild_for_pair(const struct cell *ci, const struct cell *cj) {
/* Is the cut-off radius plus the max distance the parts in both cells have */
......
......@@ -389,7 +389,9 @@ void cell_store_pre_drift_values(struct cell *c);
void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj,
struct scheduler *s);
int cell_can_recurse_in_pair_task(const struct cell *c);
int cell_can_split_task(const struct cell *c);
int cell_can_recurse_in_self_task(const struct cell *c);
int cell_can_split_pair_task(const struct cell *c);
int cell_can_split_self_task(const struct cell *c);
int cell_need_rebuild_for_pair(const struct cell *ci, const struct cell *cj);
#endif /* SWIFT_CELL_H */
......@@ -2333,7 +2333,7 @@ void DOSUB_SELF1(struct runner *r, struct cell *ci, int gettimer) {
if (ci->count == 0 || !cell_is_active(ci, r->e)) return;
/* Recurse? */
if (cell_can_recurse_in_pair_task(ci)) {
if (cell_can_recurse_in_self_task(ci)) {
/* Loop over all progeny. */
for (int k = 0; k < 8; k++)
......@@ -2628,7 +2628,7 @@ void DOSUB_SELF2(struct runner *r, struct cell *ci, int gettimer) {
if (ci->count == 0 || !cell_is_active(ci, r->e)) return;
/* Recurse? */
if (cell_can_recurse_in_pair_task(ci)) {
if (cell_can_recurse_in_self_task(ci)) {
/* Loop over all progeny. */
for (int k = 0; k < 8; k++)
......@@ -2678,7 +2678,7 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts,
if (cj == NULL) {
/* Recurse? */
if (cell_can_recurse_in_pair_task(ci)) {
if (cell_can_recurse_in_self_task(ci)) {
/* Loop over all progeny. */
DOSUB_SUBSET(r, sub, parts, ind, count, NULL, -1, 0);
......
......@@ -188,7 +188,7 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) {
}
/* Is this cell even split and the task does not violate h ? */
if (cell_can_split_task(ci)) {
if (cell_can_split_self_task(ci)) {
/* Make a sub? */
if (scheduler_dosub && /* Note division here to avoid overflow */
......@@ -260,7 +260,7 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) {
const int sid = space_getsid(s->space, &ci, &cj, shift);
/* Should this task be split-up? */
if (cell_can_split_task(ci) && cell_can_split_task(cj)) {
if (cell_can_split_pair_task(ci) && cell_can_split_pair_task(cj)) {
/* Replace by a single sub-task? */
if (scheduler_dosub &&
......
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