From 51f60b4b1d66a57f6298b0153f6aeb42d8fa150e Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Fri, 22 Sep 2017 17:44:17 +0200 Subject: [PATCH] Added a configuration option to activate the naive interactions instead of the sorted ones. --- configure.ac | 13 +++++++++++++ examples/main.c | 7 +++++++ src/runner_doiact.h | 47 ++++++++++++++++++++++----------------------- 3 files changed, 43 insertions(+), 24 deletions(-) diff --git a/configure.ac b/configure.ac index 9ec78c8b8b..5851324ec7 100644 --- a/configure.ac +++ b/configure.ac @@ -226,6 +226,18 @@ if test "$enable_debugging_checks" = "yes"; then AC_DEFINE([SWIFT_DEBUG_CHECKS],1,[Enable expensive debugging]) fi +# Check whether we want to default to naive cell interactions +AC_ARG_ENABLE([naive-interactions], + [AS_HELP_STRING([--enable-naive-interactions], + [Activate use of naive cell interaction functions @<:@yes/no@:>@] + )], + [enable_naive_interactions="$enableval"], + [enable_naive_interactions="no"] +) +if test "$enable_naive_interactions" = "yes"; then + AC_DEFINE([SWIFT_USE_NAIVE_INTERACTIONS],1,[Enable use of naive cell interaction functions]) +fi + # Check if gravity force checks are on for some particles. AC_ARG_ENABLE([gravity-force-checks], [AS_HELP_STRING([--enable-gravity-force-checks], @@ -919,6 +931,7 @@ AC_MSG_RESULT([ Task debugging : $enable_task_debugging Threadpool debugging : $enable_threadpool_debugging Debugging checks : $enable_debugging_checks + Naive interactions : $enable_naive_interactions Gravity checks : $gravity_force_checks ------------------------]) diff --git a/examples/main.c b/examples/main.c index 56f463940d..0d87ea3507 100644 --- a/examples/main.c +++ b/examples/main.c @@ -361,6 +361,13 @@ int main(int argc, char *argv[]) { message("WARNING: Debugging checks activated. Code will be slower !"); #endif +/* Do we have debugging checks ? */ +#ifdef SWIFT_USE_NAIVE_INTERACTIONS + if (myrank == 0) + message( + "WARNING: Naive cell interactions activated. Code will be slower !"); +#endif + /* Do we have gravity accuracy checks ? */ #ifdef SWIFT_GRAVITY_FORCE_CHECKS if (myrank == 0) diff --git a/src/runner_doiact.h b/src/runner_doiact.h index cd52702b61..bcbd0b7425 100644 --- a/src/runner_doiact.h +++ b/src/runner_doiact.h @@ -124,10 +124,6 @@ void DOPAIR1_NAIVE(struct runner *r, struct cell *restrict ci, const struct engine *e = r->e; -#ifndef SWIFT_DEBUG_CHECKS - error("Don't use in actual runs ! Slow code !"); -#endif - TIMER_TIC; /* Anything to do here? */ @@ -216,10 +212,6 @@ void DOPAIR2_NAIVE(struct runner *r, struct cell *restrict ci, const struct engine *e = r->e; -#ifndef SWIFT_DEBUG_CHECKS - error("Don't use in actual runs ! Slow code !"); -#endif - TIMER_TIC; /* Anything to do here? */ @@ -310,10 +302,6 @@ void DOSELF1_NAIVE(struct runner *r, struct cell *restrict c) { const struct engine *e = r->e; -#ifndef SWIFT_DEBUG_CHECKS - error("Don't use in actual runs ! Slow code !"); -#endif - TIMER_TIC; /* Anything to do here? */ @@ -392,10 +380,6 @@ void DOSELF2_NAIVE(struct runner *r, struct cell *restrict c) { const struct engine *e = r->e; -#ifndef SWIFT_DEBUG_CHECKS - error("Don't use in actual runs ! Slow code !"); -#endif - TIMER_TIC; /* Anything to do here? */ @@ -481,10 +465,6 @@ void DOPAIR_SUBSET_NAIVE(struct runner *r, struct cell *restrict ci, const struct engine *e = r->e; -#ifndef SWIFT_DEBUG_CHECKS - error("Don't use in actual runs ! Slow code !"); -#endif - TIMER_TIC; const int count_j = cj->count; @@ -565,6 +545,11 @@ void DOPAIR_SUBSET(struct runner *r, struct cell *restrict ci, const struct engine *e = r->e; +#ifdef SWIFT_USE_NAIVE_INTERACTIONS + DOPAIR_SUBSET_NAIVE(r, ci, parts_i, ind, count, cj); + return; +#endif + TIMER_TIC; const int count_j = cj->count; @@ -777,8 +762,10 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj, const int sid, const struct engine *restrict e = r->e; - // DOPAIR1_NAIVE(r, ci, cj); - // return; +#ifdef SWIFT_USE_NAIVE_INTERACTIONS + DOPAIR1_NAIVE(r, ci, cj); + return; +#endif TIMER_TIC; @@ -999,8 +986,10 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj) { struct engine *restrict e = r->e; - // DOPAIR2_NAIVE(r, ci, cj); - // return; +#ifdef SWIFT_USE_NAIVE_INTERACTIONS + DOPAIR2_NAIVE(r, ci, cj); + return; +#endif TIMER_TIC; @@ -1337,6 +1326,11 @@ void DOSELF1(struct runner *r, struct cell *restrict c) { const struct engine *e = r->e; +#ifdef SWIFT_USE_NAIVE_INTERACTIONS + DOSELF1_NAIVE(r, c); + return; +#endif + TIMER_TIC; if (!cell_is_active(c, e)) return; @@ -1469,6 +1463,11 @@ void DOSELF2(struct runner *r, struct cell *restrict c) { const struct engine *e = r->e; +#ifdef SWIFT_USE_NAIVE_INTERACTIONS + DOSELF2_NAIVE(r, c); + return; +#endif + TIMER_TIC; if (!cell_is_active(c, e)) return; -- GitLab