From 79c022ee0cfdee91d1cb8b4b5ddbb75f73dd0269 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Wed, 12 Sep 2018 14:15:53 +0200
Subject: [PATCH] More detailed timers in the critical section of the
 repartitioning algorithm.

---
 src/engine.c    | 7 ++++---
 src/partition.c | 6 ++++++
 src/space.c     | 7 +++++++
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/engine.c b/src/engine.c
index 3508784350..0b15cc9765 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -5351,6 +5351,10 @@ void engine_reconstruct_multipoles(struct engine *e) {
 void engine_makeproxies(struct engine *e) {
 
 #ifdef WITH_MPI
+  /* Let's time this */
+  const ticks tic = getticks();
+
+  /* Useful local information */
   const int nodeID = e->nodeID;
   const struct space *s = e->s;
 
@@ -5378,9 +5382,6 @@ void engine_makeproxies(struct engine *e) {
                         cell_width[2] * cell_width[2];
   const double r_max = sqrt(r_max2);
 
-  /* Let's time this */
-  const ticks tic = getticks();
-
   /* Prepare the proxies and the proxy index. */
   if (e->proxy_ind == NULL)
     if ((e->proxy_ind = (int *)malloc(sizeof(int) * e->nr_nodes)) == NULL)
diff --git a/src/partition.c b/src/partition.c
index 98e3e7b670..361bf9500e 100644
--- a/src/partition.c
+++ b/src/partition.c
@@ -868,6 +868,8 @@ void partition_repartition(struct repartition *reparttype, int nodeID,
 
 #if defined(WITH_MPI) && defined(HAVE_METIS)
 
+  ticks tic = getticks();
+
   if (reparttype->type == REPART_METIS_VERTEX_COSTS_EDGE_COSTS) {
     repart_edge_metis(0, 1, 0, nodeID, nr_nodes, s, tasks, nr_tasks);
 
@@ -895,6 +897,10 @@ void partition_repartition(struct repartition *reparttype, int nodeID,
   } else {
     error("Impossible repartition type");
   }
+
+  if (s->e->verbose)
+    message("took %.3f %s.", clocks_from_ticks(getticks() - tic),
+            clocks_getunit());
 #else
   error("SWIFT was not compiled with METIS support.");
 #endif
diff --git a/src/space.c b/src/space.c
index 604fbdd86f..a754351b37 100644
--- a/src/space.c
+++ b/src/space.c
@@ -239,9 +239,16 @@ void space_rebuild_recycle_mapper(void *map_data, int num_elements,
  * @brief Free up any allocated cells.
  */
 void space_free_cells(struct space *s) {
+
+  ticks tic = getticks();
+
   threadpool_map(&s->e->threadpool, space_rebuild_recycle_mapper, s->cells_top,
                  s->nr_cells, sizeof(struct cell), 0, s);
   s->maxdepth = 0;
+
+  if (s->e->verbose)
+    message("took %.3f %s.", clocks_from_ticks(getticks() - tic),
+            clocks_getunit());
 }
 
 /**
-- 
GitLab