From 85579ae95f527d32ccdc0aa87d8a3e54ef3ff32d Mon Sep 17 00:00:00 2001
From: Pedro Gonnet <gonnet@google.com>
Date: Mon, 26 Jun 2017 21:53:35 +0200
Subject: [PATCH] don't activate drift tasks, just mark the cells.

---
 src/cell.h   |  1 +
 src/engine.c | 26 ++++++++++----------------
 2 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/src/cell.h b/src/cell.h
index dc4d5df199..1c3508fef3 100644
--- a/src/cell.h
+++ b/src/cell.h
@@ -395,6 +395,7 @@ void cell_check_timesteps(struct cell *c);
 void cell_store_pre_drift_values(struct cell *c);
 void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj,
                                  struct scheduler *s);
+void cell_activate_drift_part(struct cell *c, struct scheduler *s);
 
 /* Inlined functions (for speed). */
 
diff --git a/src/engine.c b/src/engine.c
index cfa3410802..4ca441090b 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -2591,7 +2591,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
         if (!(ci->sorted & (1 << t->flags)) || ci->nodeID != engine_rank) {
           atomic_or(&ci->sorts->flags, (1 << t->flags));
           scheduler_activate(s, ci->sorts);
-          if (ci->nodeID == engine_rank) scheduler_activate(s, ci->drift_part);
+          if (ci->nodeID == engine_rank) cell_activate_drift_part(ci, s);
         }
         if (cj->dx_max_sort > space_maxreldx * cj->dmin) {
           for (struct cell *finger = cj; finger != NULL;
@@ -2606,7 +2606,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
         if (!(cj->sorted & (1 << t->flags)) || cj->nodeID != engine_rank) {
           atomic_or(&cj->sorts->flags, (1 << t->flags));
           scheduler_activate(s, cj->sorts);
-          if (cj->nodeID == engine_rank) scheduler_activate(s, cj->drift_part);
+          if (cj->nodeID == engine_rank) cell_activate_drift_part(cj, s);
         }
       }
       /* Store current values of dx_max and h_max. */
@@ -2637,11 +2637,8 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
         scheduler_activate(s, l->t);
 
         /* Drift both cells, the foreign one at the level which it is sent. */
-        if (l->t->ci->drift_part)
-          scheduler_activate(s, l->t->ci->drift_part);
-        else
-          error("Drift task missing !");
-        if (t->type == task_type_pair) scheduler_activate(s, cj->drift_part);
+        cell_activate_drift_part(l->t->ci, s);
+        if (t->type == task_type_pair) cell_activate_drift_part(cj, s);
 
         if (cell_is_active(cj, e)) {
           for (l = cj->send_rho; l != NULL && l->t->cj->nodeID != ci->nodeID;
@@ -2686,11 +2683,8 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
         scheduler_activate(s, l->t);
 
         /* Drift both cells, the foreign one at the level which it is sent. */
-        if (l->t->ci->drift_part)
-          scheduler_activate(s, l->t->ci->drift_part);
-        else
-          error("Drift task missing !");
-        if (t->type == task_type_pair) scheduler_activate(s, ci->drift_part);
+        cell_activate_drift_part(l->t->ci, s);
+        if (t->type == task_type_pair) cell_activate_drift_part(ci, s);
 
         if (cell_is_active(ci, e)) {
           for (l = ci->send_rho; l != NULL && l->t->cj->nodeID != cj->nodeID;
@@ -2715,13 +2709,13 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
         }
 
       } else if (t->type == task_type_pair) { /* ci and cj on same node */
-        scheduler_activate(s, ci->drift_part);
-        scheduler_activate(s, cj->drift_part);
+        cell_activate_drift_part(ci, s);
+        cell_activate_drift_part(cj, s);
       }
 #else
       if (t->type == task_type_pair) {
-        scheduler_activate(s, ci->drift_part);
-        scheduler_activate(s, cj->drift_part);
+        cell_activate_drift_part(ci, s);
+        cell_activate_drift_part(cj, s);
       }
 #endif
     }
-- 
GitLab