diff --git a/src/engine.c b/src/engine.c index d87d7bafda1ab5b7fb95fa769cf5991a7404ad6b..afaa5ab297fdd5f4d4a4a1cebaa87cb1318236cd 100644 --- a/src/engine.c +++ b/src/engine.c @@ -66,6 +66,7 @@ #include "runner.h" #include "serial_io.h" #include "single_io.h" +#include "sort_part.h" #include "statistics.h" #include "timers.h" #include "tools.h" diff --git a/src/runner.h b/src/runner.h index ec63eb3ec98547859f7da75809555f231f277f62..51de9827406b014debeefba03ad09f636e3fa45f 100644 --- a/src/runner.h +++ b/src/runner.h @@ -23,10 +23,11 @@ #ifndef SWIFT_RUNNER_H #define SWIFT_RUNNER_H -#include "cache.h" +/* Config parameters. */ +#include "../config.h" -extern const double runner_shift[13][3]; -extern const char runner_flip[27]; +/* Includes. */ +#include "cache.h" struct cell; struct engine; diff --git a/src/scheduler.c b/src/scheduler.c index 9f0f0fd944ebeb1399591214489272d38e150a72..97300ff7b37d46638a83e143a702d1a33d494956 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -46,6 +46,7 @@ #include "intrinsics.h" #include "kernel_hydro.h" #include "queue.h" +#include "sort_part.h" #include "space.h" #include "task.h" #include "timers.h" @@ -229,7 +230,7 @@ static void scheduler_splittask(struct task *t, struct scheduler *s) { /* Replace by a single sub-task? */ if (scheduler_dosub && ci->count * sid_scale[sid] < space_subsize / cj->count && - sid != 0 && sid != 2 && sid != 6 && sid != 8) { + !sort_is_corner(sid)) { /* Make this task a sub task. */ t->type = task_type_sub_pair; diff --git a/src/sort_part.h b/src/sort_part.h index 5f680705564c78fee2f747105eac8c1c7d69a0be..a243fcdfae8ec0aba606000e26bc18d35601215c 100644 --- a/src/sort_part.h +++ b/src/sort_part.h @@ -33,7 +33,7 @@ struct entry { }; /* Orientation of the cell pairs */ -const double runner_shift[13][3] = { +static const double runner_shift[13][3] = { {5.773502691896258e-01, 5.773502691896258e-01, 5.773502691896258e-01}, {7.071067811865475e-01, 7.071067811865475e-01, 0.0}, {5.773502691896258e-01, 5.773502691896258e-01, -5.773502691896258e-01}, @@ -50,8 +50,38 @@ const double runner_shift[13][3] = { }; /* Does the axis need flipping ? */ -const char runner_flip[27] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +static const char runner_flip[27] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +/* Map shift vector to sortlist. */ +static const int sortlistID[27] = { + /* ( -1 , -1 , -1 ) */ 0, + /* ( -1 , -1 , 0 ) */ 1, + /* ( -1 , -1 , 1 ) */ 2, + /* ( -1 , 0 , -1 ) */ 3, + /* ( -1 , 0 , 0 ) */ 4, + /* ( -1 , 0 , 1 ) */ 5, + /* ( -1 , 1 , -1 ) */ 6, + /* ( -1 , 1 , 0 ) */ 7, + /* ( -1 , 1 , 1 ) */ 8, + /* ( 0 , -1 , -1 ) */ 9, + /* ( 0 , -1 , 0 ) */ 10, + /* ( 0 , -1 , 1 ) */ 11, + /* ( 0 , 0 , -1 ) */ 12, + /* ( 0 , 0 , 0 ) */ 0, + /* ( 0 , 0 , 1 ) */ 12, + /* ( 0 , 1 , -1 ) */ 11, + /* ( 0 , 1 , 0 ) */ 10, + /* ( 0 , 1 , 1 ) */ 9, + /* ( 1 , -1 , -1 ) */ 8, + /* ( 1 , -1 , 0 ) */ 7, + /* ( 1 , -1 , 1 ) */ 6, + /* ( 1 , 0 , -1 ) */ 5, + /* ( 1 , 0 , 0 ) */ 4, + /* ( 1 , 0 , 1 ) */ 3, + /* ( 1 , 1 , -1 ) */ 2, + /* ( 1 , 1 , 0 ) */ 1, + /* ( 1 , 1 , 1 ) */ 0}; /** * @brief Determines whether a pair of cells are corner to corner. @@ -72,7 +102,8 @@ __attribute__((always_inline)) INLINE static int sort_is_corner(int sid) { * @return 1 if edge to edge, 0 otherwise. */ __attribute__((always_inline)) INLINE static int sort_is_edge(int sid) { - return (sid == 1 || sid == 3 || sid == 5 || sid == 7 || sid == 9 || sid == 11); + return (sid == 1 || sid == 3 || sid == 5 || sid == 7 || sid == 9 || + sid == 11); } /** @@ -86,5 +117,4 @@ __attribute__((always_inline)) INLINE static int sort_is_face(int sid) { return (sid == 4 || sid == 10 || sid == 12); } - #endif /* SWIFT_SORT_PART_H */ diff --git a/src/space.c b/src/space.c index 64a9ab15c960e7664afdf6be4293bbad3176fc76..432873215c258b987b3c83f87486ade061ea66f0 100644 --- a/src/space.c +++ b/src/space.c @@ -53,6 +53,7 @@ #include "minmax.h" #include "multipole.h" #include "runner.h" +#include "sort_part.h" #include "stars.h" #include "threadpool.h" #include "tools.h" @@ -63,36 +64,6 @@ int space_subsize = space_subsize_default; int space_maxsize = space_maxsize_default; int space_maxcount = space_maxcount_default; -/* Map shift vector to sortlist. */ -const int sortlistID[27] = { - /* ( -1 , -1 , -1 ) */ 0, - /* ( -1 , -1 , 0 ) */ 1, - /* ( -1 , -1 , 1 ) */ 2, - /* ( -1 , 0 , -1 ) */ 3, - /* ( -1 , 0 , 0 ) */ 4, - /* ( -1 , 0 , 1 ) */ 5, - /* ( -1 , 1 , -1 ) */ 6, - /* ( -1 , 1 , 0 ) */ 7, - /* ( -1 , 1 , 1 ) */ 8, - /* ( 0 , -1 , -1 ) */ 9, - /* ( 0 , -1 , 0 ) */ 10, - /* ( 0 , -1 , 1 ) */ 11, - /* ( 0 , 0 , -1 ) */ 12, - /* ( 0 , 0 , 0 ) */ 0, - /* ( 0 , 0 , 1 ) */ 12, - /* ( 0 , 1 , -1 ) */ 11, - /* ( 0 , 1 , 0 ) */ 10, - /* ( 0 , 1 , 1 ) */ 9, - /* ( 1 , -1 , -1 ) */ 8, - /* ( 1 , -1 , 0 ) */ 7, - /* ( 1 , -1 , 1 ) */ 6, - /* ( 1 , 0 , -1 ) */ 5, - /* ( 1 , 0 , 0 ) */ 4, - /* ( 1 , 0 , 1 ) */ 3, - /* ( 1 , 1 , -1 ) */ 2, - /* ( 1 , 1 , 0 ) */ 1, - /* ( 1 , 1 , 1 ) */ 0}; - /** * @brief Interval stack necessary for parallel particle sorting. */ diff --git a/src/space.h b/src/space.h index 73bd50da928c55890a91415f6e07c5100a7b71e7..d2879d96b9a4ede4e96236ddd5ac19897fbd10cd 100644 --- a/src/space.h +++ b/src/space.h @@ -56,9 +56,6 @@ extern int space_maxsize; extern int space_subsize; extern int space_maxcount; -/* Map shift vector to sortlist. */ -extern const int sortlistID[27]; - /** * @brief The space in which the cells and particles reside. */