NDMeshStreamer: compute destination location once per sequence of items
authorLukasz Wesolowski <wesolwsk@illinois.edu>
Fri, 27 Apr 2012 20:30:28 +0000 (15:30 -0500)
committerLukasz Wesolowski <wesolwsk@illinois.edu>
Fri, 27 Apr 2012 20:30:28 +0000 (15:30 -0500)
for the same destination

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

index a3302fa3a45e470795610e0f5bd4485f7ecb4b32..6613e616ea867345ae5da88aaefafdafc9edd35f 100644 (file)
@@ -469,9 +469,10 @@ void MeshStreamer<dtype>::finish() {
 template <class dtype>
 void MeshStreamer<dtype>::receiveAlongRoute(MeshStreamerMessage<dtype> *msg) {
 
-  int destinationPe; 
+  int destinationPe, lastDestinationPe
   MeshLocation destinationLocation;
 
+  lastDestinationPe = -1;
   for (int i = 0; i < msg->numDataItems; i++) {
     destinationPe = msg->destinationPes[i];
     dtype &dataItem = msg->getDataItem(i);
@@ -479,9 +480,13 @@ void MeshStreamer<dtype>::receiveAlongRoute(MeshStreamerMessage<dtype> *msg) {
       localDeliver(dataItem);
     }
     else {
-      destinationLocation = determineLocation(destinationPe);
+      if (destinationPe != lastDestinationPe) {
+        // do this once per sequence of items with the same destination
+        destinationLocation = determineLocation(destinationPe);
+      }
       storeMessage(destinationPe, destinationLocation, &dataItem);   
     }
+    lastDestinationPe = destinationPe; 
   }
 
   delete msg;