Added a parameter to indicate whether the loop needs to be synced after parallelizati...
authorChao Mei <chaomei2@illinois.edu>
Fri, 24 Feb 2012 02:04:36 +0000 (20:04 -0600)
committerChao Mei <chaomei2@illinois.edu>
Fri, 24 Feb 2012 02:04:36 +0000 (20:04 -0600)
NodeHelper.C
NodeHelper.h
NodeHelperAPI.h
example/fft-trans/fft1d.C
example/simpleLoopBench/hello.C

index 2733633d974e5c6f18873b3c339e1379a2707b3a..041cf75ab1377d26cb9d10fc84084a2226369d56 100644 (file)
@@ -32,7 +32,8 @@ int FuncNodeHelper::MAX_CHUNKS = 64;
 #endif
 
 void FuncNodeHelper::parallelizeFunc(HelperFn func, int paramNum, void * param, 
-                                    int msgPriority, int numChunks, int lowerRange, int upperRange, 
+                                    int numChunks, int lowerRange, 
+                                   int upperRange, int sync,
                                     void *redResult, REDUCTION_TYPE type) {
                                         
     double _start; //may be used for tracing
@@ -72,6 +73,8 @@ void FuncNodeHelper::parallelizeFunc(HelperFn func, int paramNum, void * param,
        curLoop->stealWork();
        TRACE_BRACKET(20);
        
+       if(!sync) return;
+
        TRACE_START(21);                
        curLoop->waitLoopDone();
        TRACE_BRACKET(21);        
@@ -178,11 +181,12 @@ CProxy_FuncNodeHelper NodeHelper_Init(){
 }
 
 void NodeHelper_Parallelize(CProxy_FuncNodeHelper nodeHelper, HelperFn func, 
-                        int paramNum, void * param, int msgPriority,
-                        int numChunks, int lowerRange, int upperRange, 
+                        int paramNum, void * param, 
+                        int numChunks, int lowerRange, int upperRange,
+                       int sync,
                         void *redResult, REDUCTION_TYPE type)
 {
-    nodeHelper[CkMyNode()].ckLocalBranch()->parallelizeFunc(func, paramNum, param, msgPriority, numChunks, lowerRange, upperRange, redResult, type);
+    nodeHelper[CkMyNode()].ckLocalBranch()->parallelizeFunc(func, paramNum, param, numChunks, lowerRange, upperRange, sync, redResult, type);
 }
 
 #include "NodeHelper.def.h"
index 085dcba3de27dbd573adc40df4e2ea93bb974de2..de5c737889bcdfaa42c003e8f76257e3467cf7c5 100644 (file)
@@ -112,9 +112,9 @@ public:
     
     void parallelizeFunc(HelperFn func, /* the function that finishes a partial work on another thread */
                         int paramNum, void * param, /* the input parameters for the above func */
-                        int msgPriority, /* the priority of the intra-node msg, and node-level msg */
                         int numChunks, /* number of chunks to be partitioned */
                         int lowerRange, int upperRange, /* the loop-like parallelization happens in [lowerRange, upperRange] */                        
+                       int sync=1, /* whether the flow will continue until all chunks have finished */
                         void *redResult=NULL, REDUCTION_TYPE type=NODEHELPER_NONE /* the reduction result, ONLY SUPPORT SINGLE VAR of TYPE int/float/double */
                         );
     void reduce(void **redBufs, void *redBuf, REDUCTION_TYPE type, int numChunks);
index 915a675d7b9de7fb1f99af8d98a5c604cc6c04df..cf9bc795c964ea209e5d9811c2277fd0c17b9e5f 100644 (file)
@@ -20,9 +20,9 @@ extern void NodeHelper_Parallelize(
                                                CProxy_FuncNodeHelper nodeHelper, /* the proxy to the FuncNodeHelper instance */
                                                HelperFn func, /* the function that finishes a partial work on another thread */
                         int paramNum, void * param, /* the input parameters for the above func */
-                        int msgPriority, /* the priority of the intra-node msg, and node-level msg */
                         int numChunks, /* number of chunks to be partitioned */
                         int lowerRange, int upperRange, /* the loop-like parallelization happens in [lowerRange, upperRange] */                        
+                       int sync=1, /* whether the flow will continue unless all chunks have finished */ 
                         void *redResult=NULL, REDUCTION_TYPE type=NODEHELPER_NONE /* the reduction result, ONLY SUPPORT SINGLE VAR of TYPE int/float/double */
                         );
 #endif
index 8d64bffd8bd66919ed086afe91cc91dbbc829e49..82ebf49d03747758e81dfcfeea2859791a7edf33 100644 (file)
@@ -81,7 +81,8 @@ struct Main : public CBase_Main {
     fftProxy = CProxy_fft::ckNew(numChunks);
 
     // Construct a nodehelper to do the calculation
-    nodeHelperProxy = NodeHelper_Init(NODEHELPER_MODE, numTasks);
+    //nodeHelperProxy = NodeHelper_Init(NODEHELPER_MODE, numTasks);
+    nodeHelperProxy = NodeHelper_Init();
     
     CkStartQD(CkIndex_Main::initDone((CkQdMsg *)0), &thishandle);
   }
@@ -239,7 +240,7 @@ struct fft : public CBase_fft {
     //FuncNodeHelper *nth = nodeHelperProxy[CkMyNode()].ckLocalBranch();
     //nth->parallelizeFunc(doCalc, numTasks, numTasks, thisIndex, numTasks, 1, 1, plan, 0, NULL);
     double ffttime = CmiWallTimer();
-    NodeHelper_Parallelize(nodeHelperProxy, doCalc, 1, plan, 0, numTasks, 0, numTasks-1);    
+    NodeHelper_Parallelize(nodeHelperProxy, doCalc, 1, plan, numTasks, 0, numTasks-1);    
     CkPrintf("FFT time: %.3f (ms)\n", (CmiWallTimer()-ffttime)*1e3);
   }
 
index 18751e7004431f01dbd6a4772ad21720fb4e7458..16bcff934f65ace7d7c85647e30a31b0b071b154 100644 (file)
@@ -228,7 +228,7 @@ void TestInstance::doTest(int curstep, int curTestMode) {
     double timerec = CmiWallTimer();
     
     if(curTestMode == 0){
-           NodeHelper_Parallelize(nodeHelperProxy, doCalc, 0, NULL, 0, numChunks, 0, loopTimes-1, &result, NODEHELPER_INT_SUM);
+           NodeHelper_Parallelize(nodeHelperProxy, doCalc, 0, NULL, numChunks, 0, loopTimes-1, 1, &result, NODEHELPER_INT_SUM);
     }else if(curTestMode == 1){
         result = openMPWork(0, loopTimes-1);
     }