From ffb788974882c97084f41e4e3d266a595cd5aaeb Mon Sep 17 00:00:00 2001
From: "Peter W. Draper" <p.w.draper@durham.ac.uk>
Date: Fri, 24 Mar 2023 19:08:03 +0000
Subject: [PATCH] Make memory interleaving the default NUMA memory policy

---
 README                                      |  2 +-
 README.md                                   |  2 +-
 doc/RTD/source/CommandLineOptions/index.rst |  2 +-
 examples/EAGLE_low_z/EAGLE_6/run.sh         |  2 +-
 swift.c                                     | 17 ++++++++++++-----
 5 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/README b/README
index b3c32f001f..53b802dfab 100644
--- a/README
+++ b/README
@@ -70,7 +70,7 @@ Parameters:
   Control options:
 
     -a, --pin                         Pin runners using processor affinity.
-    --interleave                      Interleave memory allocations across
+    --nointerleave                    Do not interleave memory allocations across
                                       NUMA regions.
     -d, --dry-run                     Dry run. Read the parameter file, allocates
                                       memory but does not read the particles
diff --git a/README.md b/README.md
index bdc6467671..a7e163e05d 100644
--- a/README.md
+++ b/README.md
@@ -164,7 +164,7 @@ Parameters:
   Control options:
 
     -a, --pin                         Pin runners using processor affinity.
-    --interleave                      Interleave memory allocations across
+    --nointerleave                    Do not interleave memory allocations across
                                       NUMA regions.
     -d, --dry-run                     Dry run. Read the parameter file, allocates
                                       memory but does not read the particles
diff --git a/doc/RTD/source/CommandLineOptions/index.rst b/doc/RTD/source/CommandLineOptions/index.rst
index 7900a90967..eff27aeadb 100644
--- a/doc/RTD/source/CommandLineOptions/index.rst
+++ b/doc/RTD/source/CommandLineOptions/index.rst
@@ -67,7 +67,7 @@ can be found by typing ``./swift -h``:
   Control options:
 
     -a, --pin                         Pin runners using processor affinity.
-    --interleave                      Interleave memory allocations across
+    --nointerleave                    Do not interleave memory allocations across
                                       NUMA regions.
     -d, --dry-run                     Dry run. Read the parameter file, allocates
                                       memory but does not read the particles
diff --git a/examples/EAGLE_low_z/EAGLE_6/run.sh b/examples/EAGLE_low_z/EAGLE_6/run.sh
index f7db75e6e3..1f7be1e09f 100755
--- a/examples/EAGLE_low_z/EAGLE_6/run.sh
+++ b/examples/EAGLE_low_z/EAGLE_6/run.sh
@@ -7,5 +7,5 @@ then
     ./getIC.sh
 fi
 
-../../../swift -v 1 --interleave --hydro --threads=4 -n 16 -y 1 eagle_6.yml | tee output.log
+../../../swift -v 1 --hydro --threads=4 -n 16 -y 1 eagle_6.yml | tee output.log
 
diff --git a/swift.c b/swift.c
index 130cdc871d..252437a599 100644
--- a/swift.c
+++ b/swift.c
@@ -157,7 +157,8 @@ int main(int argc, char *argv[]) {
   if (myrank == 0) greetings(/*fof=*/0);
 
   int with_aff = 0;
-  int with_interleave = 0;
+  int with_nointerleave = 0;
+  int with_interleave = 0; /* Deprecated. */
   int dry_run = 0;
   int dump_tasks = 0;
   int dump_cells = 0;
@@ -286,9 +287,11 @@ int main(int argc, char *argv[]) {
       OPT_GROUP("  Control options:\n"),
       OPT_BOOLEAN('a', "pin", &with_aff,
                   "Pin runners using processor affinity.", NULL, 0, 0),
+      OPT_BOOLEAN(0, "nointerleave", &with_nointerleave,
+                  "Do not interleave memory allocations across NUMA regions.",
+                  NULL, 0, 0),
       OPT_BOOLEAN(0, "interleave", &with_interleave,
-                  "Interleave memory allocations across NUMA regions.", NULL, 0,
-                  0),
+                  "Deprecated option, now default", NULL, 0, 0),
       OPT_BOOLEAN('d', "dry-run", &dry_run,
                   "Dry run. Read the parameter file, allocates memory but does "
                   "not read the particles from ICs. Exits before the start of "
@@ -410,8 +413,12 @@ int main(int argc, char *argv[]) {
     return 1;
   }
 #endif
+
+  if (with_interleave)
+    message("WARNING: the --interleave option is deprecated and ignored.");
+
 #if !defined(HAVE_LIBNUMA)
-  if (with_interleave) {
+  if (!with_nointerleave || with_interleave) {
     printf("Error: no NUMA support for interleaving memory\n");
     return 1;
   }
@@ -657,7 +664,7 @@ int main(int argc, char *argv[]) {
 #if defined(HAVE_LIBNUMA) && defined(_GNU_SOURCE)
 
   /* Set the NUMA memory policy to interleave. */
-  if (with_interleave) engine_numa_policies(myrank, verbose);
+  if (!with_nointerleave) engine_numa_policies(myrank, verbose);
 #endif
 
   /* Genesis 1.1: And then, there was time ! */
-- 
GitLab