From eeaa0e88ef89afdf3b011a1a570a3e2bde896b72 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Sat, 14 Jul 2018 22:21:27 +0200
Subject: [PATCH] Give a reasonable weight to the gravity-MM task.

---
 src/runner.c    | 8 ++++++--
 src/scheduler.c | 3 +++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/runner.c b/src/runner.c
index ffe1b13745..37c6030889 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -998,9 +998,13 @@ void runner_do_unskip_mapper(void *map_data, int num_elements,
   for (int ind = 0; ind < num_elements; ind++) {
     struct cell *c = &s->cells_top[local_cells[ind]];
     if (c != NULL) {
+
+      /* Hydro tasks */
       if (e->policy & engine_policy_hydro) runner_do_unskip_hydro(c, e);
-      if (e->policy &
-          (engine_policy_self_gravity | engine_policy_external_gravity))
+
+      /* All gravity tasks */
+      if ((e->policy & engine_policy_self_gravity) ||
+          (e->policy & engine_policy_external_gravity))
         runner_do_unskip_gravity(c, e);
     }
   }
diff --git a/src/scheduler.c b/src/scheduler.c
index c7376ab566..d81e5b6556 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -1325,6 +1325,9 @@ void scheduler_reweight(struct scheduler *s, int verbose) {
       case task_type_grav_long_range:
         cost = wscale * gcount_i;
         break;
+      case task_type_grav_mm:
+        cost = wscale * (gcount_i + gcount_j);
+        break;
       case task_type_end_force:
         cost = wscale * count_i + wscale * gcount_i;
         break;
-- 
GitLab