From ac74d8fd66c627c441de27e5ecfdbe5518f9a57c Mon Sep 17 00:00:00 2001
From: Pedro Gonnet <gonnet@google.com>
Date: Mon, 17 Aug 2015 21:30:54 +0200
Subject: [PATCH] wrap tag IDs to prevent going into bad territory, clean out
 runner_dosend.

Former-commit-id: 67253fd5d24b593bdd7822863d0b25781cb1e744
---
 src/cell.c   |  2 +-
 src/cell.h   |  1 +
 src/runner.c | 37 -------------------------------------
 3 files changed, 2 insertions(+), 38 deletions(-)

diff --git a/src/cell.c b/src/cell.c
index 13e1055649..30e089db08 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -181,7 +181,7 @@ int cell_pack ( struct cell *c , struct pcell *pc ) {
     pc->dt_min = c->dt_min;
     pc->dt_max = c->dt_max;
     pc->count = c->count;
-    c->tag = pc->tag = cell_next_tag++;
+    c->tag = pc->tag = atomic_inc(cell_next_tag) % cell_max_tag;
     
     /* Fill in the progeny, depth-first recursion. */
     for ( k = 0 ; k < 8 ; k++ )
diff --git a/src/cell.h b/src/cell.h
index 43dedefbb6..e4492c774f 100644
--- a/src/cell.h
+++ b/src/cell.h
@@ -19,6 +19,7 @@
 
 /* Some constants. */
 #define cell_sid_dt                 13
+#define cell_max_tag                (1 << 16)
 
 
 /* Global variables. */
diff --git a/src/runner.c b/src/runner.c
index 78171f4345..315f37767d 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -101,43 +101,6 @@ const char runner_flip[27] = { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1
 #include "runner_doiact_grav.h"
 
 
-/**
- * @brief Send a local cell's particle data to another node.
- *
- * @param r The #runner.
- * @param c The #cell.
- * @param nodeID The destination node's ID.
- * @param tag bit to distinguish between xv and rho sends.
- */
- 
-void runner_dosend ( struct runner *r , struct cell *c , int nodeID , int tag ) {
-
-#ifdef WITH_MPI
-
-    MPI_Request req;
-    
-    /* First check if all the density tasks have been run. */
-    if ( tag & 1 )
-        if ( c->parts[0].rho == 0.0 )
-            error( "Attempting to send rhos before ghost task completed." );
-    
-    /* Emit the isend. */
-    if ( MPI_Isend( c->parts , sizeof(struct part) * c->count , MPI_BYTE , nodeID , tag , MPI_COMM_WORLD , &req ) != MPI_SUCCESS )
-        error( "Failed to isend particle data." );
-        
-    message( "sending %i parts with tag=%i from %i to %i." ,
-        c->count , tag , r->e->nodeID , nodeID ); fflush(stdout);
-    
-    /* Free the request handler as we don't care what happens next. */
-    MPI_Request_free( &req );
-
-#else
-    error( "SWIFT was not compiled with MPI support." );
-#endif
-
-    }
-    
-
 /**
  * @brief Sort the entries in ascending order using QuickSort.
  *
-- 
GitLab