diff --git a/examples/parameter_example.yml b/examples/parameter_example.yml index 0898771a755b34af1a51a9772b35a7a44295f28c..6bcdbf23406682f25898f33e99e4fa6e5c51ea9d 100644 --- a/examples/parameter_example.yml +++ b/examples/parameter_example.yml @@ -78,8 +78,10 @@ FOF: Scheduler: nr_queues: 0 # (Optional) The number of task queues to use. Use 0 to let the system decide. cell_max_size: 8000000 # (Optional) Maximal number of interactions per task if we force the split (this is the default value). - cell_sub_size_pair_hydro: 256000000 # (Optional) Maximal number of interactions per sub-pair hydro task (this is the default value). - cell_sub_size_self_hydro: 32000 # (Optional) Maximal number of interactions per sub-self hydro task (this is the default value). + cell_sub_size_pair_hydro: 256000000 # (Optional) Maximal number of hydro-hydro interactions per sub-pair hydro/star task (this is the default value). + cell_sub_size_self_hydro: 32000 # (Optional) Maximal number of hydro-hydro interactions per sub-self hydro/star task (this is the default value). + cell_sub_size_pair_stars: 256000000 # (Optional) Maximal number of hydro-star interactions per sub-pair hydro/star task (this is the default value). + cell_sub_size_self_stars: 32000 # (Optional) Maximal number of hydro-star interactions per sub-self hydro/star task (this is the default value). cell_sub_size_pair_grav: 256000000 # (Optional) Maximal number of interactions per sub-pair gravity task (this is the default value). cell_sub_size_self_grav: 32000 # (Optional) Maximal number of interactions per sub-self gravity task (this is the default value). cell_split_size: 400 # (Optional) Maximal number of particles per cell (this is the default value). diff --git a/src/scheduler.c b/src/scheduler.c index 367fbe599a14e86fd592569c9e2b1de8a45154e0..392c868e7e269bee630860ba94d5e87e4f1ac0b8 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -587,7 +587,8 @@ 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_self_hydro_task(ci)) { /* Make a sub? */ - if (scheduler_dosub && ci->hydro.count < space_subsize_self_hydro) { + if (scheduler_dosub && (ci->hydro.count < space_subsize_self_hydro) && + (ci->stars.count < space_subsize_self_stars)) { /* convert to a self-subtask. */ t->type = task_type_sub_self; @@ -664,11 +665,40 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) { /* Should this task be split-up? */ if (cell_can_split_pair_hydro_task(ci) && cell_can_split_pair_hydro_task(cj)) { + + const int h_count_i = ci->hydro.count; + const int h_count_j = cj->hydro.count; + + const int s_count_i = ci->stars.count; + const int s_count_j = cj->stars.count; + + int do_sub_hydro = 1; + int do_sub_stars_i = 1; + int do_sub_stars_j = 1; + if (h_count_i > 0 && h_count_j > 0) { + + /* Note: Use division to avoid integer overflow. */ + do_sub_hydro = + h_count_i * sid_scale[sid] < space_subsize_pair_hydro / h_count_j; + } + if (s_count_i > 0 && h_count_j > 0) { + + /* Note: Use division to avoid integer overflow. */ + do_sub_stars_i = + s_count_i * sid_scale[sid] < space_subsize_pair_stars / h_count_j; + } + if (s_count_j > 0 && h_count_i > 0) { + + /* Note: Use division to avoid integer overflow. */ + do_sub_stars_j = + s_count_j * sid_scale[sid] < space_subsize_pair_stars / h_count_i; + } + /* Replace by a single sub-task? */ - if (scheduler_dosub && /* Use division to avoid integer overflow. */ - ci->hydro.count * sid_scale[sid] < - space_subsize_pair_hydro / cj->hydro.count && + if (scheduler_dosub && + (do_sub_hydro && do_sub_stars_i && do_sub_stars_j) && !sort_is_corner(sid)) { + /* Make this task a sub task. */ t->type = task_type_sub_pair; diff --git a/src/space.c b/src/space.c index 638a4c9d0e2cafc3f7b84554be1ede97b5893bb4..f7c3b7f77953a87985692f4c1a03cfaf97b93a5e 100644 --- a/src/space.c +++ b/src/space.c @@ -69,6 +69,8 @@ int space_splitsize = space_splitsize_default; int space_subsize_pair_hydro = space_subsize_pair_hydro_default; int space_subsize_self_hydro = space_subsize_self_hydro_default; +int space_subsize_pair_stars = space_subsize_pair_stars_default; +int space_subsize_self_stars = space_subsize_self_stars_default; int space_subsize_pair_grav = space_subsize_pair_grav_default; int space_subsize_self_grav = space_subsize_self_grav_default; int space_subdepth_diff_grav = space_subdepth_diff_grav_default; @@ -4635,6 +4637,12 @@ void space_init(struct space *s, struct swift_params *params, space_subsize_self_hydro = parser_get_opt_param_int(params, "Scheduler:cell_sub_size_self_hydro", space_subsize_self_hydro_default); + space_subsize_pair_stars = + parser_get_opt_param_int(params, "Scheduler:cell_sub_size_pair_stars", + space_subsize_pair_stars_default); + space_subsize_self_stars = + parser_get_opt_param_int(params, "Scheduler:cell_sub_size_self_stars", + space_subsize_self_stars_default); space_subsize_pair_grav = parser_get_opt_param_int(params, "Scheduler:cell_sub_size_pair_grav", space_subsize_pair_grav_default); @@ -5355,6 +5363,10 @@ void space_struct_dump(struct space *s, FILE *stream) { "space_subsize_pair_hydro", "space_subsize_pair_hydro"); restart_write_blocks(&space_subsize_self_hydro, sizeof(int), 1, stream, "space_subsize_self_hydro", "space_subsize_self_hydro"); + restart_write_blocks(&space_subsize_pair_stars, sizeof(int), 1, stream, + "space_subsize_pair_stars", "space_subsize_pair_stars"); + restart_write_blocks(&space_subsize_self_stars, sizeof(int), 1, stream, + "space_subsize_self_stars", "space_subsize_self_stars"); restart_write_blocks(&space_subsize_pair_grav, sizeof(int), 1, stream, "space_subsize_pair_grav", "space_subsize_pair_grav"); restart_write_blocks(&space_subsize_self_grav, sizeof(int), 1, stream, @@ -5409,6 +5421,10 @@ void space_struct_restore(struct space *s, FILE *stream) { "space_subsize_pair_hydro"); restart_read_blocks(&space_subsize_self_hydro, sizeof(int), 1, stream, NULL, "space_subsize_self_hydro"); + restart_read_blocks(&space_subsize_pair_stars, sizeof(int), 1, stream, NULL, + "space_subsize_pair_stars"); + restart_read_blocks(&space_subsize_self_stars, sizeof(int), 1, stream, NULL, + "space_subsize_self_stars"); restart_read_blocks(&space_subsize_pair_grav, sizeof(int), 1, stream, NULL, "space_subsize_pair_grav"); restart_read_blocks(&space_subsize_self_grav, sizeof(int), 1, stream, NULL, diff --git a/src/space.h b/src/space.h index 21d36b7e880c3b8943e03bfbbc16bfefe6fff0d1..c294bfae3612c699345bd4a267c40b67cffc2bf1 100644 --- a/src/space.h +++ b/src/space.h @@ -52,6 +52,8 @@ struct cosmology; #define space_expected_max_nr_strays_default 100 #define space_subsize_pair_hydro_default 256000000 #define space_subsize_self_hydro_default 32000 +#define space_subsize_pair_stars_default 256000000 +#define space_subsize_self_stars_default 32000 #define space_subsize_pair_grav_default 256000000 #define space_subsize_self_grav_default 32000 #define space_subdepth_diff_grav_default 4 @@ -68,6 +70,8 @@ extern int space_splitsize; extern int space_maxsize; extern int space_subsize_pair_hydro; extern int space_subsize_self_hydro; +extern int space_subsize_pair_stars; +extern int space_subsize_self_stars; extern int space_subsize_pair_grav; extern int space_subsize_self_grav; extern int space_subdepth_diff_grav;