From 800e62912a2c6bae9d517cce89c88495f5ef77d3 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Tue, 11 Jun 2019 12:22:30 +0100
Subject: [PATCH] Bh communication fixes

---
 src/cell.c             | 4 ----
 src/engine_maketasks.c | 6 ++++++
 src/engine_marktasks.c | 6 ------
 3 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/cell.c b/src/cell.c
index d2b102a974..fca6a04ea7 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -3800,7 +3800,6 @@ int cell_unskip_black_holes_tasks(struct cell *c, struct scheduler *s) {
       if (ci_nodeID != nodeID) {
         if (cj_active) {
           scheduler_activate_recv(s, ci->mpi.recv, task_subtype_xv);
-          scheduler_activate_recv(s, ci->mpi.recv, task_subtype_rho);
 
           /* If the local cell is active, more stuff will be needed. */
           scheduler_activate_send(s, cj->mpi.send, task_subtype_bpart,
@@ -3820,7 +3819,6 @@ int cell_unskip_black_holes_tasks(struct cell *c, struct scheduler *s) {
 
           /* Is the foreign cell active and will need stuff from us? */
           scheduler_activate_send(s, cj->mpi.send, task_subtype_xv, ci_nodeID);
-          scheduler_activate_send(s, cj->mpi.send, task_subtype_rho, ci_nodeID);
 
           /* Drift the cell which will be sent; note that not all sent
              particles will be drifted, only those that are needed. */
@@ -3831,7 +3829,6 @@ int cell_unskip_black_holes_tasks(struct cell *c, struct scheduler *s) {
         /* If the local cell is active, receive data from the foreign cell. */
         if (ci_active) {
           scheduler_activate_recv(s, cj->mpi.recv, task_subtype_xv);
-          scheduler_activate_recv(s, cj->mpi.recv, task_subtype_rho);
 
           /* If the local cell is active, more stuff will be needed. */
           scheduler_activate_send(s, ci->mpi.send, task_subtype_bpart,
@@ -3851,7 +3848,6 @@ int cell_unskip_black_holes_tasks(struct cell *c, struct scheduler *s) {
 
           /* Is the foreign cell active and will need stuff from us? */
           scheduler_activate_send(s, ci->mpi.send, task_subtype_xv, cj_nodeID);
-          scheduler_activate_send(s, ci->mpi.send, task_subtype_rho, cj_nodeID);
 
           /* Drift the cell which will be sent; note that not all sent
              particles will be drifted, only those that are needed. */
diff --git a/src/engine_maketasks.c b/src/engine_maketasks.c
index 56e5bfd564..150ec107f9 100644
--- a/src/engine_maketasks.c
+++ b/src/engine_maketasks.c
@@ -459,6 +459,12 @@ void engine_addtasks_recv_hydro(struct engine *e, struct cell *c,
     for (struct link *l = c->stars.density; l != NULL; l = l->next) {
       scheduler_addunlock(s, t_rho, l->t);
     }
+
+    /* Make sure the part have been sent before the BHs compute their densities.
+     */
+    for (struct link *l = c->black_holes.density; l != NULL; l = l->next) {
+      scheduler_addunlock(s, t_xv, l->t);
+    }
   }
 
   /* Recurse? */
diff --git a/src/engine_marktasks.c b/src/engine_marktasks.c
index 0971c95bab..b8d96edbbd 100644
--- a/src/engine_marktasks.c
+++ b/src/engine_marktasks.c
@@ -675,7 +675,6 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
 
           if (cj_active_black_holes) {
             scheduler_activate_recv(s, ci->mpi.recv, task_subtype_xv);
-            scheduler_activate_recv(s, ci->mpi.recv, task_subtype_rho);
 
             /* If the local cell is active, more stuff will be needed. */
             scheduler_activate_send(s, cj->mpi.send, task_subtype_bpart,
@@ -696,8 +695,6 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
             /* Is the foreign cell active and will need stuff from us? */
             scheduler_activate_send(s, cj->mpi.send, task_subtype_xv,
                                     ci_nodeID);
-            scheduler_activate_send(s, cj->mpi.send, task_subtype_rho,
-                                    ci_nodeID);
 
             /* Drift the cell which will be sent; note that not all sent
                particles will be drifted, only those that are needed. */
@@ -709,7 +706,6 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
           /* If the local cell is active, receive data from the foreign cell. */
           if (ci_active_black_holes) {
             scheduler_activate_recv(s, cj->mpi.recv, task_subtype_xv);
-            scheduler_activate_recv(s, cj->mpi.recv, task_subtype_rho);
 
             /* If the local cell is active, more stuff will be needed. */
             scheduler_activate_send(s, ci->mpi.send, task_subtype_bpart,
@@ -730,8 +726,6 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
             /* Is the foreign cell active and will need stuff from us? */
             scheduler_activate_send(s, ci->mpi.send, task_subtype_xv,
                                     cj_nodeID);
-            scheduler_activate_send(s, ci->mpi.send, task_subtype_rho,
-                                    cj_nodeID);
 
             /* Drift the cell which will be sent; note that not all sent
                particles will be drifted, only those that are needed. */
-- 
GitLab