reduced the frequency of calling atomic increment.
authorChao Mei <chaomei2@illinois.edu>
Thu, 23 Feb 2012 06:11:57 +0000 (00:11 -0600)
committerChao Mei <chaomei2@illinois.edu>
Thu, 23 Feb 2012 06:11:57 +0000 (00:11 -0600)
NodeHelper.C
NodeHelper.h

index 20fc4d6726fdc33e24a93dc9079b4b8e45ca8401..2733633d974e5c6f18873b3c339e1379a2707b3a 100644 (file)
@@ -151,6 +151,7 @@ void CurLoopInfo::stealWork(){
     int markIdx = remainder*(unit+1);
     
     int nextChunkId = getNextChunkIdx();
+    int execTimes = 0;
     while(nextChunkId < numChunks){
         if(nextChunkId < remainder){
             first = (unit+1)*nextChunkId;
@@ -161,10 +162,10 @@ void CurLoopInfo::stealWork(){
         }
                 
         fnPtr(first, last, redBufs[nextChunkId], paramNum, param);
-        reportFinished();
-        
+        execTimes++;
         nextChunkId = getNextChunkIdx();
     }
+    reportFinished(execTimes);
 }
 
 //======================================================================//
index 6a0c9bfdb718f98e2c0a443c3c325538cc369d95..2e0ec510bae4ed6f047f5fcb85212bcea4579a83 100644 (file)
@@ -66,8 +66,9 @@ public:
     int getNextChunkIdx(){
         return __sync_add_and_fetch(&curChunkIdx, 1);
     }
-    void reportFinished(){
-        __sync_add_and_fetch(&finishFlag, 1);
+    void reportFinished(int counter){
+       if(counter==0) return;
+        __sync_add_and_fetch(&finishFlag, counter);
     }
     
        void **getRedBufs() { return redBufs; }