From b5567d65b366028f9f0216e9445889477ecdb942 Mon Sep 17 00:00:00 2001
From: Pedro Gonnet <gonnet@google.com>
Date: Mon, 15 Apr 2019 23:21:12 +0200
Subject: [PATCH] replace the cell's mpi.hydro.recv_ti task pointer with the
 new linked recv pointers. goodbye, mpi.hydro!

---
 src/cell.c             | 6 +++---
 src/cell.h             | 5 -----
 src/engine.c           | 8 +++++---
 src/engine_maketasks.c | 2 +-
 src/engine_marktasks.c | 6 ++++--
 src/space.c            | 1 -
 6 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/src/cell.c b/src/cell.c
index e7003a6e7b..44383417cd 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -3275,7 +3275,7 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
 
         /* If the foreign cell is active, we want its ti_end values. */
         if (ci_active || with_limiter)
-          scheduler_activate(s, ci->mpi.hydro.recv_ti);
+          scheduler_activate_recv(s, ci->mpi.recv, task_subtype_tend_part);
 
         if (with_limiter) scheduler_activate(s, ci->mpi.limiter.recv);
         if (with_limiter)
@@ -3325,7 +3325,7 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
 
         /* If the foreign cell is active, we want its ti_end values. */
         if (cj_active || with_limiter)
-          scheduler_activate(s, cj->mpi.hydro.recv_ti);
+          scheduler_activate_recv(s, cj->mpi.recv, task_subtype_tend_part);
 
         if (with_limiter) scheduler_activate(s, cj->mpi.limiter.recv);
         if (with_limiter)
@@ -3902,7 +3902,7 @@ void cell_set_super_mapper(void *map_data, int num_elements, void *extra_data) {
 int cell_has_tasks(struct cell *c) {
 
 #ifdef WITH_MPI
-  if (c->timestep != NULL || c->mpi.hydro.recv_ti != NULL ||
+  if (c->timestep != NULL || c->mpi.recv != NULL ||
       c->mpi.grav.recv_ti != NULL || c->mpi.stars.recv_ti != NULL)
     return 1;
 #else
diff --git a/src/cell.h b/src/cell.h
index b275fa2635..10e807617e 100644
--- a/src/cell.h
+++ b/src/cell.h
@@ -580,11 +580,6 @@ struct cell {
       struct link *recv;
     };
 
-    struct {
-      /* Task receiving data (time-step). */
-      struct task *recv_ti;
-    } hydro;
-
     struct {
       /* Task receiving gpart data. */
       struct task *recv;
diff --git a/src/engine.c b/src/engine.c
index e0747dde19..1f01c3b7fd 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -2385,11 +2385,13 @@ void engine_barrier(struct engine *e) {
 void engine_collect_end_of_step_recurse_hydro(struct cell *c,
                                               const struct engine *e) {
 
-/* Skip super-cells (Their values are already set) */
+  /* Skip super-cells (Their values are already set) */
+  if (c->timestep != NULL) return;
 #ifdef WITH_MPI
-  if (c->timestep != NULL || c->mpi.hydro.recv_ti != NULL) return;
+  struct link *l = c->mpi.recv;
+  while (l != NULL && l->t->subtype != task_subtype_tend_part) l = l->next;
+  if (l != NULL) return;
 #else
-  if (c->timestep != NULL) return;
 #endif /* WITH_MPI */
 
 #ifdef SWIFT_DEBUG_CHECKS
diff --git a/src/engine_maketasks.c b/src/engine_maketasks.c
index 257fc70c5c..2442a10288 100644
--- a/src/engine_maketasks.c
+++ b/src/engine_maketasks.c
@@ -331,7 +331,7 @@ void engine_addtasks_recv_hydro(struct engine *e, struct cell *c,
   engine_addlink(e, &c->mpi.recv, t_xv);
   engine_addlink(e, &c->mpi.recv, t_rho);
   engine_addlink(e, &c->mpi.recv, t_gradient);
-  c->mpi.hydro.recv_ti = t_ti;
+  engine_addlink(e, &c->mpi.recv, t_ti);
 
   /* Add dependencies. */
   if (c->hydro.sorts != NULL) {
diff --git a/src/engine_marktasks.c b/src/engine_marktasks.c
index f4b84b303a..859531f480 100644
--- a/src/engine_marktasks.c
+++ b/src/engine_marktasks.c
@@ -372,7 +372,8 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
           }
 
           /* If the foreign cell is active, we want its ti_end values. */
-          if (ci_active_hydro) scheduler_activate(s, ci->mpi.hydro.recv_ti);
+          if (ci_active_hydro)
+            scheduler_activate_recv(s, ci->mpi.recv, task_subtype_tend_part);
 
           /* Is the foreign cell active and will need stuff from us? */
           if (ci_active_hydro) {
@@ -416,7 +417,8 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
           }
 
           /* If the foreign cell is active, we want its ti_end values. */
-          if (cj_active_hydro) scheduler_activate(s, cj->mpi.hydro.recv_ti);
+          if (cj_active_hydro)
+            scheduler_activate_recv(s, cj->mpi.recv, task_subtype_tend_part);
 
           /* Is the foreign cell active and will need stuff from us? */
           if (cj_active_hydro) {
diff --git a/src/space.c b/src/space.c
index f00d43d327..f6ca47ef44 100644
--- a/src/space.c
+++ b/src/space.c
@@ -269,7 +269,6 @@ void space_rebuild_recycle_mapper(void *map_data, int num_elements,
     c->mpi.tag = -1;
 
     c->mpi.recv = NULL;
-    c->mpi.hydro.recv_ti = NULL;
     c->mpi.grav.recv = NULL;
     c->mpi.grav.recv_ti = NULL;
     c->mpi.stars.recv = NULL;
-- 
GitLab