1. Bug fix in chunk mesh streamer - set chunk index correctly.
authorLukasz Wesolowski <wesolwsk@illinois.edu>
Wed, 24 Oct 2012 05:07:02 +0000 (00:07 -0500)
committerLukasz Wesolowski <wesolwsk@illinois.edu>
Wed, 24 Oct 2012 18:31:41 +0000 (13:31 -0500)
2. Make buffer capacity calculation consistent between the two
   mesh streamer constructors

src/libs/ck-libs/NDMeshStreamer/NDMeshStreamer.h

index 1736a179713a05d438f48a358e6a9bda4660491c..395a5f0c9551ed1a311d093a8c81ae3e05b8dc3b 100644 (file)
@@ -16,7 +16,7 @@
 // #define CACHE_LOCATIONS
 // #define SUPPORT_INCOMPLETE_MESH
 // #define CACHE_ARRAY_METADATA // only works for 1D array clients
 // #define CACHE_LOCATIONS
 // #define SUPPORT_INCOMPLETE_MESH
 // #define CACHE_ARRAY_METADATA // only works for 1D array clients
-#define STREAMER_VERBOSE_OUTPUT
+// #define STREAMER_VERBOSE_OUTPUT
 
 #define TRAM_BROADCAST (-100)
 
 
 #define TRAM_BROADCAST (-100)
 
@@ -313,14 +313,15 @@ MeshStreamer<dtype>::MeshStreamer(
   // a bufferSize input of 0 indicates it should be calculated by the library
   if (bufferSize_ == 0) {
     CkAssert(maxNumDataItemsBuffered_ > 0);
   // a bufferSize input of 0 indicates it should be calculated by the library
   if (bufferSize_ == 0) {
     CkAssert(maxNumDataItemsBuffered_ > 0);
-    // except for personalized messages, the buffers for dimensions with the 
-    //   same index as the sender's are not used
+    // buffers for dimensions with the 
+    //   same index as the sender's are not allocated/used
     bufferSize_ = OVERALLOCATION_FACTOR * maxNumDataItemsBuffered_ 
       / (sumAlongAllDimensions - numDimensions_ + 1); 
   }
   else {
     maxNumDataItemsBuffered_ = 
     bufferSize_ = OVERALLOCATION_FACTOR * maxNumDataItemsBuffered_ 
       / (sumAlongAllDimensions - numDimensions_ + 1); 
   }
   else {
     maxNumDataItemsBuffered_ = 
-      bufferSize_ * (sumAlongAllDimensions - numDimensions_ + 1);
+      bufferSize_ * (sumAlongAllDimensions - numDimensions_ + 1) 
+      / OVERALLOCATION_FACTOR;
   }
 
   if (bufferSize_ <= 0) {
   }
 
   if (bufferSize_ <= 0) {
@@ -1382,10 +1383,10 @@ public:
         memcpy(chunk.rawData, inputData + offset, CHUNK_SIZE);
       }
 
         memcpy(chunk.rawData, inputData + offset, CHUNK_SIZE);
       }
 
+      MeshStreamer<ChunkDataItem>::insertData(chunk, destinationPe); 
+      chunk.chunkNumber++; 
     }
 
     }
 
-    MeshStreamer<ChunkDataItem>::insertData(chunk, destinationPe); 
-
   }
 
   inline void processChunk(const ChunkDataItem& chunk) {
   }
 
   inline void processChunk(const ChunkDataItem& chunk) {
@@ -1394,9 +1395,9 @@ public:
       receiveBuffers[chunk.sourcePe] = new dtype[chunk.numItems]; 
     }      
 
       receiveBuffers[chunk.sourcePe] = new dtype[chunk.numItems]; 
     }      
 
-    char *receiveBuffer = (char *) &receiveBuffers[chunk.sourcePe];
+    char *receiveBuffer = (char *) receiveBuffers[chunk.sourcePe];
 
 
-    memcpy(receiveBuffer + chunk.chunkNumber * sizeof(dtype)
+    memcpy(receiveBuffer + chunk.chunkNumber * CHUNK_SIZE
            chunk.rawData, chunk.chunkSize);
     if (++receivedChunks[chunk.sourcePe] == chunk.numChunks) {
       clientObj_->receiveArray((dtype *) receiveBuffer, chunk.numItems, chunk.sourcePe);
            chunk.rawData, chunk.chunkSize);
     if (++receivedChunks[chunk.sourcePe] == chunk.numChunks) {
       clientObj_->receiveArray((dtype *) receiveBuffer, chunk.numItems, chunk.sourcePe);