avoid msg copying when sending in node
authorGengbin Zheng <gzheng@upcrc1.cs.uiuc.edu>
Tue, 27 Apr 2010 15:21:14 +0000 (10:21 -0500)
committerGengbin Zheng <gzheng@upcrc1.cs.uiuc.edu>
Tue, 27 Apr 2010 15:21:14 +0000 (10:21 -0500)
src/conv-ldb/cldb.spray.c

index 39b9c66270bb1df2b186a9c7aed361685dcb246e..394a72cd33583d27c9bbccb3debde9691dc30260 100644 (file)
@@ -126,15 +126,15 @@ void CldHopHandler(char *msg)
   CldInfoFn ifn; CldPackFn pfn; int pe;
 
   if (pinf->rebalance) {
+    /* do pe = ((lrand48()&0x7FFFFFFF)%CmiNumPes()); */
+    do pe = ((CrnRand()&0x7FFFFFFF)%CmiNumPes());
+    while (pe == pinf->mype);
     ifn = (CldInfoFn)CmiHandlerToFunction(CmiGetInfo(msg));
     ifn(msg, &pfn, &len, &queueing, &priobits, &prioptr);
-    if (pfn) {
+    if (pfn && CmiNodeOf(pe) != CmiMyNode()) {
       pfn(&msg);
       ifn(msg, &pfn, &len, &queueing, &priobits, &prioptr);
     }
-    /* do pe = ((lrand48()&0x7FFFFFFF)%CmiNumPes()); */
-    do pe = ((CrnRand()&0x7FFFFFFF)%CmiNumPes());
-    while (pe == pinf->mype);
     CmiSyncSendAndFree(pe, len, msg);
     pinf->rebalance--;
   } else {
@@ -193,7 +193,7 @@ void CldEnqueue(int pe, void *msg, int infofn)
   ifn = (CldInfoFn)CmiHandlerToFunction(infofn);
   ifn(msg, &pfn, &len, &queueing, &priobits, &prioptr);
   if (pe != CLD_ANYWHERE) {
-    if (pfn && (pe != CmiMyPe())) {
+    if (pfn && (CmiNodeOf(pe) != CmiMyNode())) {
       pfn(&msg);
       ifn(msg, &pfn, &len, &queueing, &priobits, &prioptr);
     }