From 7ee5f9066ff490e9d4e12ff8cccc9cd6deddc264 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Tue, 6 Nov 2018 16:05:32 +0000
Subject: [PATCH] No need for the 'end_force_in' task.

---
 examples/analyse_tasks.py |  2 +-
 examples/plot_tasks.py    |  2 +-
 src/cell.c                |  2 --
 src/cell.h                |  3 ---
 src/engine_maketasks.c    | 29 ++++++-----------------------
 src/engine_marktasks.c    |  3 +--
 src/task.c                |  1 -
 src/task.h                |  1 -
 8 files changed, 9 insertions(+), 34 deletions(-)

diff --git a/examples/analyse_tasks.py b/examples/analyse_tasks.py
index 343814d58a..5dc381411a 100755
--- a/examples/analyse_tasks.py
+++ b/examples/analyse_tasks.py
@@ -53,7 +53,7 @@ infile = args.input
 #  Tasks and subtypes. Indexed as in tasks.h.
 TASKTYPES = ["none", "sort", "self", "pair", "sub_self", "sub_pair",
              "init_grav", "init_grav_out", "ghost_in", "ghost", "ghost_out", "extra_ghost", "drift_part", "drift_gpart", "drift_gpart_out",
-             "end_force", "end_force_in", "kick1", "kick2", "timestep", "send", "recv", "grav_long_range", "grav_mm", "grav_down_in", 
+             "end_force", "kick1", "kick2", "timestep", "send", "recv", "grav_long_range", "grav_mm", "grav_down_in", 
              "grav_down", "grav_mesh", "cooling", "star_formation", "sourceterms",
              "stars_ghost_in", "stars_ghost",   "stars_ghost_out",
              "count"]
diff --git a/examples/plot_tasks.py b/examples/plot_tasks.py
index 588061cd49..46fe56813f 100755
--- a/examples/plot_tasks.py
+++ b/examples/plot_tasks.py
@@ -111,7 +111,7 @@ pl.rcParams.update(PLOT_PARAMS)
 #  Tasks and subtypes. Indexed as in tasks.h.
 TASKTYPES = ["none", "sort", "self", "pair", "sub_self", "sub_pair",
              "init_grav", "init_grav_out", "ghost_in", "ghost", "ghost_out", "extra_ghost", "drift_part", "drift_gpart", "drift_gpart_out",
-             "end_force", "end_force_in", "kick1", "kick2", "timestep", "send", "recv", "grav_long_range", "grav_mm", "grav_down_in", 
+             "end_force", "kick1", "kick2", "timestep", "send", "recv", "grav_long_range", "grav_mm", "grav_down_in", 
              "grav_down", "grav_mesh", "cooling", "star_formation", "sourceterms",
              "stars_ghost_in", "stars_ghost",   "stars_ghost_out",
              "count"]
diff --git a/src/cell.c b/src/cell.c
index 79ccf02118..645dfbd3ea 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -2770,7 +2770,6 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
     if (c->kick2 != NULL) scheduler_activate(s, c->kick2);
     if (c->timestep != NULL) scheduler_activate(s, c->timestep);
     if (c->end_force != NULL) scheduler_activate(s, c->end_force);
-    if (c->end_force_in != NULL) scheduler_activate(s, c->end_force_in);
     if (c->hydro.cooling != NULL) scheduler_activate(s, c->hydro.cooling);
     if (c->hydro.star_formation != NULL)
       scheduler_activate(s, c->hydro.star_formation);
@@ -2920,7 +2919,6 @@ int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) {
     if (c->kick2 != NULL) scheduler_activate(s, c->kick2);
     if (c->timestep != NULL) scheduler_activate(s, c->timestep);
     if (c->end_force != NULL) scheduler_activate(s, c->end_force);
-    if (c->end_force_in != NULL) scheduler_activate(s, c->end_force_in);
     if (c->grav.down != NULL) scheduler_activate(s, c->grav.down);
     if (c->grav.down_in != NULL) scheduler_activate(s, c->grav.down_in);
     if (c->grav.mesh != NULL) scheduler_activate(s, c->grav.mesh);
diff --git a/src/cell.h b/src/cell.h
index a5d0f7c61d..bc3a21dbbd 100644
--- a/src/cell.h
+++ b/src/cell.h
@@ -544,9 +544,6 @@ struct cell {
   /*! The task to end the force calculation */
   struct task *end_force;
 
-  /*! Implicit task (going up- and down the tree) for the end force */
-  struct task *end_force_in;
-
   /*! The first kick task */
   struct task *kick1;
 
diff --git a/src/engine_maketasks.c b/src/engine_maketasks.c
index 21b4cec0ed..35f161f92c 100644
--- a/src/engine_maketasks.c
+++ b/src/engine_maketasks.c
@@ -462,10 +462,6 @@ void engine_make_hierarchical_tasks_common(struct engine *e, struct cell *c) {
       c->end_force = scheduler_addtask(s, task_type_end_force,
                                        task_subtype_none, 0, 0, c, NULL);
 
-      /* Implicit task for the up pass */
-      c->end_force_in = scheduler_addtask(s, task_type_end_force_in,
-                                          task_subtype_none, 0, 1, c, NULL);
-
       /* Subgrid tasks */
       if (is_with_cooling) {
 
@@ -491,33 +487,20 @@ void engine_make_hierarchical_tasks_common(struct engine *e, struct cell *c) {
         scheduler_addunlock(s, c->kick2, c->timestep);
       }
       
-      //scheduler_addunlock(s, c->end_force_in, c->end_force);
       scheduler_addunlock(s, c->timestep, c->kick1);
 
 #if defined(WITH_LOGGER)
       scheduler_addunlock(s, c->kick1, c->logger);
 #endif
     }
-  }
-
-  /* We are below the super-cell but not below the maximal splitting depth */
-  else if (c->super != NULL) {
-
-    /* Local tasks only... */
-    if (c->nodeID == e->nodeID) {
-
-      c->end_force_in = scheduler_addtask(s, task_type_end_force_in,
-                                          task_subtype_none, 0, 1, c, NULL);
+  } else { /* We are above the super-cell so need to go deeper */
 
-      scheduler_addunlock(s, c->end_force_in, c->parent->end_force_in);
-    }
+    /* Recurse. */
+    if (c->split)
+      for (int k = 0; k < 8; k++)
+	if (c->progeny[k] != NULL)
+	  engine_make_hierarchical_tasks_common(e, c->progeny[k]);
   }
-
-  /* Recurse. */
-  if (c->split)
-    for (int k = 0; k < 8; k++)
-      if (c->progeny[k] != NULL)
-        engine_make_hierarchical_tasks_common(e, c->progeny[k]);
 }
 
 /**
diff --git a/src/engine_marktasks.c b/src/engine_marktasks.c
index 2065f63644..3d607bcf85 100644
--- a/src/engine_marktasks.c
+++ b/src/engine_marktasks.c
@@ -444,8 +444,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
     }
 
     /* End force ? */
-    else if (t_type == task_type_end_force ||
-             t_type == task_type_end_force_in) {
+    else if (t_type == task_type_end_force) {
 
       if (cell_is_active_hydro(t->ci, e) || cell_is_active_gravity(t->ci, e))
         scheduler_activate(s, t);
diff --git a/src/task.c b/src/task.c
index 13ce88452c..1665672feb 100644
--- a/src/task.c
+++ b/src/task.c
@@ -63,7 +63,6 @@ const char *taskID_names[task_type_count] = {"none",
                                              "drift_gpart",
                                              "drift_gpart_out",
                                              "end_force",
-                                             "end_force_in",
                                              "kick1",
                                              "kick2",
                                              "timestep",
diff --git a/src/task.h b/src/task.h
index 90016472cf..64b611534e 100644
--- a/src/task.h
+++ b/src/task.h
@@ -55,7 +55,6 @@ enum task_types {
   task_type_drift_gpart,
   task_type_drift_gpart_out, /* Implicit */
   task_type_end_force,
-  task_type_end_force_in, /* Implicit */
   task_type_kick1,
   task_type_kick2,
   task_type_timestep,
-- 
GitLab