From 0aadda706d9a0ec327e134fa0d396a638f1b5be9 Mon Sep 17 00:00:00 2001
From: "Peter W. Draper" <p.w.draper@durham.ac.uk>
Date: Mon, 2 Nov 2020 17:46:18 +0000
Subject: [PATCH] Restore --enable-dumper after code re-organization

---
 src/engine.c        | 66 ---------------------------------------------
 src/engine_config.c | 66 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+), 66 deletions(-)

diff --git a/src/engine.c b/src/engine.c
index f2037714a8..e9662b2267 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -2616,72 +2616,6 @@ void engine_unpin(void) {
 #endif
 }
 
-#ifdef SWIFT_DUMPER_THREAD
-/**
- * @brief dumper thread action, checks got the existence of the .dump file
- * every 5 seconds and does the dump if found.
- *
- * @param p the #engine
- */
-static void *engine_dumper_poll(void *p) {
-  struct engine *e = (struct engine *)p;
-  while (1) {
-    if (access(".dump", F_OK) == 0) {
-
-      /* OK, do our work. */
-      message("Dumping engine tasks in step: %d", e->step);
-      task_dump_active(e);
-
-#ifdef SWIFT_MEMUSE_REPORTS
-      /* Dump the currently logged memory. */
-      message("Dumping memory use report");
-      memuse_log_dump_error(e->nodeID);
-#endif
-
-#if defined(SWIFT_MPIUSE_REPORTS) && defined(WITH_MPI)
-      /* Dump the MPI interactions in the step. */
-      mpiuse_log_dump_error(e->nodeID);
-#endif
-
-      /* Add more interesting diagnostics. */
-      scheduler_dump_queues(e);
-
-      /* Delete the file. */
-      unlink(".dump");
-      message("Dumping completed");
-      fflush(stdout);
-    }
-
-    /* Take a breath. */
-    sleep(5);
-  }
-  return NULL;
-}
-#endif /* SWIFT_DUMPER_THREAD */
-
-#ifdef SWIFT_DUMPER_THREAD
-/**
- * @brief creates the dumper thread.
- *
- * This watches for the creation of a ".dump" file in the current directory
- * and if found dumps the current state of the tasks and memory use (if also
- * configured).
- *
- * @param e the #engine
- *
- */
-static void engine_dumper_init(struct engine *e) {
-  pthread_t dumper;
-
-  /* Make sure the .dump file is not present, that is bad when starting up. */
-  struct stat buf;
-  if (stat(".dump", &buf) == 0) unlink(".dump");
-
-  /* Thread does not exit, so nothing to do but create it. */
-  pthread_create(&dumper, NULL, &engine_dumper_poll, e);
-}
-#endif /* SWIFT_DUMPER_THREAD */
-
 /**
  * @brief init an engine struct with the necessary properties for the
  *        simulation.
diff --git a/src/engine_config.c b/src/engine_config.c
index f94900c46e..006f4deb5c 100644
--- a/src/engine_config.c
+++ b/src/engine_config.c
@@ -49,6 +49,72 @@ extern int engine_max_parts_per_cooling;
 /* Particle cache size. */
 #define CACHE_SIZE 512
 
+#ifdef SWIFT_DUMPER_THREAD
+/**
+ * @brief dumper thread action, checks got the existence of the .dump file
+ * every 5 seconds and does the dump if found.
+ *
+ * @param p the #engine
+ */
+static void *engine_dumper_poll(void *p) {
+  struct engine *e = (struct engine *)p;
+  while (1) {
+    if (access(".dump", F_OK) == 0) {
+
+      /* OK, do our work. */
+      message("Dumping engine tasks in step: %d", e->step);
+      task_dump_active(e);
+
+#ifdef SWIFT_MEMUSE_REPORTS
+      /* Dump the currently logged memory. */
+      message("Dumping memory use report");
+      memuse_log_dump_error(e->nodeID);
+#endif
+
+#if defined(SWIFT_MPIUSE_REPORTS) && defined(WITH_MPI)
+      /* Dump the MPI interactions in the step. */
+      mpiuse_log_dump_error(e->nodeID);
+#endif
+
+      /* Add more interesting diagnostics. */
+      scheduler_dump_queues(e);
+
+      /* Delete the file. */
+      unlink(".dump");
+      message("Dumping completed");
+      fflush(stdout);
+    }
+
+    /* Take a breath. */
+    sleep(5);
+  }
+  return NULL;
+}
+#endif /* SWIFT_DUMPER_THREAD */
+
+#ifdef SWIFT_DUMPER_THREAD
+/**
+ * @brief creates the dumper thread.
+ *
+ * This watches for the creation of a ".dump" file in the current directory
+ * and if found dumps the current state of the tasks and memory use (if also
+ * configured).
+ *
+ * @param e the #engine
+ *
+ */
+static void engine_dumper_init(struct engine *e) {
+  pthread_t dumper;
+
+  /* Make sure the .dump file is not present, that is bad when starting up. */
+  struct stat buf;
+  if (stat(".dump", &buf) == 0) unlink(".dump");
+
+  /* Thread does not exit, so nothing to do but create it. */
+  pthread_create(&dumper, NULL, &engine_dumper_poll, e);
+}
+#endif /* SWIFT_DUMPER_THREAD */
+
 /**
  * @brief configure an engine with the given number of threads, queues
  *        and core affinity. Also initialises the scheduler and opens various
-- 
GitLab