From 2de5c83fc9326e8ea7bdb69df4d20a2b75959937 Mon Sep 17 00:00:00 2001 From: Pedro Gonnet Date: Thu, 27 Jul 2017 12:08:06 +0200 Subject: [PATCH 1/2] avoid divide-by-zero if the cell has no hydro parts as it may have gravity parts. --- src/scheduler.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/scheduler.c b/src/scheduler.c index e14fc017d..b7a505c40 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -210,7 +210,8 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) { if (cell_can_split_pair_task(ci) && cell_can_split_pair_task(cj)) { /* Replace by a single sub-task? */ - if (scheduler_dosub && /* Use division to avoid integer overflow. */ + if (scheduler_dosub && ci->count && + cj->count && /* Use division to avoid integer overflow. */ ci->count * sid_scale[sid] < space_subsize_pair / cj->count && !sort_is_corner(sid)) { @@ -560,6 +561,7 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) { /* Otherwise, break it up if it is too large? */ } else if (scheduler_doforcesplit && ci->split && cj->split && + ci->count && cj->count && (ci->count > space_maxsize / cj->count)) { // message( "force splitting pair with %i and %i parts." , ci->count , -- GitLab From 1ebc98c705df31adbe158f048fd129bab056f929 Mon Sep 17 00:00:00 2001 From: Pedro Gonnet Date: Thu, 27 Jul 2017 12:32:19 +0200 Subject: [PATCH 2/2] actively remove hydro tasks that have zero hydro particles in either cell. --- src/scheduler.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/scheduler.c b/src/scheduler.c index b7a505c40..c1f58fa50 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -127,7 +127,8 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) { redo = 0; /* Non-splittable task? */ - if ((t->ci == NULL) || (t->type == task_type_pair && t->cj == NULL)) { + if ((t->ci == NULL) || (t->type == task_type_pair && t->cj == NULL) || + t->ci->count == 0 || (t->cj != NULL && t->cj->count == 0)) { t->type = task_type_none; t->subtype = task_subtype_none; t->cj = NULL; @@ -167,7 +168,7 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) { while (ci->progeny[first_child] == NULL) first_child++; t->ci = ci->progeny[first_child]; for (int k = first_child + 1; k < 8; k++) - if (ci->progeny[k] != NULL) + if (ci->progeny[k] != NULL && ci->progeny[k]->count) scheduler_splittask_hydro( scheduler_addtask(s, task_type_self, t->subtype, 0, 0, ci->progeny[k], NULL), @@ -175,9 +176,9 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) { /* Make a task for each pair of progeny */ for (int j = 0; j < 8; j++) - if (ci->progeny[j] != NULL) + if (ci->progeny[j] != NULL && ci->progeny[j]->count) for (int k = j + 1; k < 8; k++) - if (ci->progeny[k] != NULL) + if (ci->progeny[k] != NULL && ci->progeny[k]->count) scheduler_splittask_hydro( scheduler_addtask(s, task_type_pair, t->subtype, sub_sid_flag[j][k], 0, ci->progeny[j], @@ -210,8 +211,7 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) { if (cell_can_split_pair_task(ci) && cell_can_split_pair_task(cj)) { /* Replace by a single sub-task? */ - if (scheduler_dosub && ci->count && - cj->count && /* Use division to avoid integer overflow. */ + if (scheduler_dosub && /* Use division to avoid integer overflow. */ ci->count * sid_scale[sid] < space_subsize_pair / cj->count && !sort_is_corner(sid)) { @@ -561,7 +561,6 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) { /* Otherwise, break it up if it is too large? */ } else if (scheduler_doforcesplit && ci->split && cj->split && - ci->count && cj->count && (ci->count > space_maxsize / cj->count)) { // message( "force splitting pair with %i and %i parts." , ci->count , @@ -571,9 +570,9 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) { t->type = task_type_none; for (int j = 0; j < 8; j++) - if (ci->progeny[j] != NULL) + if (ci->progeny[j] != NULL && ci->progeny[j]->count) for (int k = 0; k < 8; k++) - if (cj->progeny[k] != NULL) { + if (cj->progeny[k] != NULL && cj->progeny[k]->count) { struct task *tl = scheduler_addtask(s, task_type_pair, t->subtype, 0, 0, ci->progeny[j], cj->progeny[k]); -- GitLab