From a815a53f385d5fc8e1233b8e898ffc2731eac22e Mon Sep 17 00:00:00 2001
From: Pedro Gonnet <gonnet@google.com>
Date: Tue, 14 Apr 2015 21:38:35 +0200
Subject: [PATCH] derive cell tags from a global counter, no longer from the
 cell pointer as IntelMPI has a maximum value below 30 bits for its tags.

Former-commit-id: 18b6a9a9833a747d962bfb7657905811e3051620
---
 src/cell.c   | 6 +++++-
 src/cell.h   | 4 ++++
 src/engine.c | 1 +
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/cell.c b/src/cell.c
index cd2f2d6b86..a1360b9d5e 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -53,6 +53,9 @@
 #include "error.h"
 #include "inline.h"
 
+/* Global variables. */
+int cell_next_tag = 0;
+
 
 /**
  * @brief Get the size of the cell subtree.
@@ -178,7 +181,8 @@ 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 = ( ((long long int)c) / sizeof(struct cell) ) % (1 << 30);
+    // c->tag = pc->tag = ( ((long long int)c) / sizeof(struct cell) ) % (1 << 30);
+    c->tag = pc->tag = cell_next_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 0b4828efbe..43dedefbb6 100644
--- a/src/cell.h
+++ b/src/cell.h
@@ -21,6 +21,10 @@
 #define cell_sid_dt                 13
 
 
+/* Global variables. */
+extern int cell_next_tag;
+
+
 /* Packed cell. */
 struct pcell {
 
diff --git a/src/engine.c b/src/engine.c
index a6291a0c87..3128600552 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -702,6 +702,7 @@ void engine_exchange_cells ( struct engine *e ) {
         error( "Failed to allocate pcell buffer." );
         
     /* Pack the cells. */
+    cell_next_tag = 0;
     for ( k = 0 ; k < nr_cells ; k++ )
         if ( cells[k].sendto ) {
             cell_pack( &cells[k] , &pcells[ offset[k] ] );
-- 
GitLab