NDMeshStreamer: committing the version of the code which performs best
authorLukasz Wesolowski <wesolwsk@illinois.edu>
Thu, 16 Feb 2012 22:54:36 +0000 (22:54 +0000)
committerLukasz Wesolowski <wesolwsk@illinois.edu>
Thu, 16 Feb 2012 22:54:36 +0000 (22:54 +0000)
for 16k nodes of RandomAccess on BG/P; caching locations is disabled
by default and flushing sends largest buffer in each dimension

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

index c403723b637d56e31bc3fd67865a764e8c564ded..9dee88842c2841703a1a445afa7891efd83fb611 100644 (file)
@@ -248,7 +248,7 @@ MeshStreamer<dtype>::~MeshStreamer() {
 
 
 template <class dtype>
-inline 
+inline
 MeshLocation MeshStreamer<dtype>::determineLocation(int destinationPe) { 
 
 #ifdef CACHE_LOCATIONS
@@ -420,49 +420,48 @@ void MeshStreamer<dtype>::flushLargestBuffer() {
   MeshStreamerMessage<dtype> ** messageBuffers; 
   MeshStreamerMessage<dtype> *destinationBuffer; 
 
-  maxSize = 0;    
   for (int i = 0; i < numDimensions_; i++) {
 
     messageBuffers = dataBuffers_[i]; 
     numBuffers = individualDimensionSizes_[i]; 
-    
+
+    flushDimension = i; 
+    maxSize = 0;    
     for (int j = 0; j < numBuffers; j++) {
       if (messageBuffers[j] != NULL && 
          messageBuffers[j]->numDataItems > maxSize) {
        maxSize = messageBuffers[j]->numDataItems;
        flushIndex = j; 
-       flushDimension = i; 
       }
     }
-    
-  }
 
-  if (maxSize > 0) {
+    if (maxSize > 0) {
 
-    messageBuffers = dataBuffers_[flushDimension]; 
-    destinationBuffer = messageBuffers[flushIndex];
-    destinationIndex = myNodeIndex_ + 
-      (flushIndex - myLocationIndex_[flushDimension]) * 
-      combinedDimensionSizes_[flushDimension] ;
-
-    if (destinationBuffer->numDataItems < bufferSize_) {
-      // not sending the full buffer, shrink the message size
-      envelope *env = UsrToEnv(destinationBuffer);
-      env->setTotalsize(env->getTotalsize() - sizeof(dtype) *
-                       (bufferSize_ - destinationBuffer->numDataItems));
-    }
-    numDataItemsBuffered_ -= destinationBuffer->numDataItems;
+      messageBuffers = dataBuffers_[flushDimension]; 
+      destinationBuffer = messageBuffers[flushIndex];
+      destinationIndex = myNodeIndex_ + 
+       (flushIndex - myLocationIndex_[flushDimension]) * 
+       combinedDimensionSizes_[flushDimension] ;
+
+      if (destinationBuffer->numDataItems < bufferSize_) {
+       // not sending the full buffer, shrink the message size
+       envelope *env = UsrToEnv(destinationBuffer);
+       env->setTotalsize(env->getTotalsize() - sizeof(dtype) *
+                         (bufferSize_ - destinationBuffer->numDataItems));
+      }
+      numDataItemsBuffered_ -= destinationBuffer->numDataItems;
+
+      if (flushDimension == 0) {
+       clientProxy_[destinationIndex].receiveCombinedData(destinationBuffer);
+      }
+      else {
+       this->thisProxy[destinationIndex].receiveAlongRoute(destinationBuffer);
+      }
+      messageBuffers[flushIndex] = NULL;
 
-    if (flushDimension == 0) {
-      clientProxy_[destinationIndex].receiveCombinedData(destinationBuffer);
-    }
-    else {
-      this->thisProxy[destinationIndex].receiveAlongRoute(destinationBuffer);
     }
-    messageBuffers[flushIndex] = NULL;
 
   }
-
 }
 
 template <class dtype>