Moved the registration of converse handlers to initproc function for consistency...
authorChao Mei <chaomei2@illinois.edu>
Mon, 27 Feb 2012 23:21:15 +0000 (17:21 -0600)
committerChao Mei <chaomei2@illinois.edu>
Mon, 27 Feb 2012 23:21:15 +0000 (17:21 -0600)
NodeHelper.C
NodeHelper.ci
NodeHelper.h

index 3f4fb9c894c45712800665f40a42f8b7006974d8..12cd51c2f72f2cb56eb931d4473af2b890a2d9bb 100644 (file)
@@ -122,6 +122,32 @@ void FuncNodeHelper::reduce(void **redBufs, void *redBuf, REDUCTION_TYPE type, i
     }
 }
 
+CpvStaticDeclare(int, NdhStealWorkHandler);
+static void RegisterNodeHelperHdlrs(){
+    CpvInitialize(int, NdhStealWorkHandler);
+    CpvAccess(NdhStealWorkHandler) = CmiRegisterHandler((CmiHandler)SingleHelperStealWork);
+}
+
+FuncSingleHelper::FuncSingleHelper(size_t ndhPtr) {
+    thisNodeHelper = (FuncNodeHelper *)ndhPtr;
+    CmiAssert(thisNodeHelper!=NULL);
+        
+       nextFreeNotifyMsg = 0;
+    notifyMsg = (ConverseNotifyMsg *)malloc(sizeof(ConverseNotifyMsg)*MSG_BUFFER_SIZE);
+    for(int i=0; i<MSG_BUFFER_SIZE; i++){
+        ConverseNotifyMsg *tmp = notifyMsg+i;
+        if(thisNodeHelper->useTreeBcast){
+            tmp->srcRank = CmiMyRank();
+        }else{
+            tmp->srcRank = -1;
+        }            
+        tmp->ptr = (void *)(new CurLoopInfo(FuncNodeHelper::MAX_CHUNKS));
+        CmiSetHandler(tmp, CpvAccess(NdhStealWorkHandler));
+    }
+    thisNodeHelper->helperPtr[CkMyRank()] = this;
+}
+
+
 void SingleHelperStealWork(ConverseNotifyMsg *msg){
        
        int srcRank = msg->srcRank;
index 1fd0e24f536baf1b3f01cb0fea4fefe51cbbbd0f..b8ce748d8c8fd97271a699bd6f42592abfc394c1 100644 (file)
@@ -1,4 +1,5 @@
 module NodeHelper{
+    initproc void RegisterNodeHelperHdlrs(void);
        nodegroup FuncNodeHelper{
                entry FuncNodeHelper();
        };
index 41f077d0a1381380b16dbe779c1d1abf9eafefc1..3ddbecc4386595eee6bc5abc096215c739125493 100644 (file)
@@ -136,25 +136,7 @@ private:
     //CurLoopInfo *curLoop; /* Points to the current loop that is being processed */
     
 public:
-    FuncSingleHelper(size_t ndhPtr) {
-        thisNodeHelper = (FuncNodeHelper *)ndhPtr;
-        CmiAssert(thisNodeHelper!=NULL);        
-        int stealWorkHandler = CmiRegisterHandler((CmiHandler)SingleHelperStealWork);
-        
-       nextFreeNotifyMsg = 0;
-        notifyMsg = (ConverseNotifyMsg *)malloc(sizeof(ConverseNotifyMsg)*MSG_BUFFER_SIZE);
-        for(int i=0; i<MSG_BUFFER_SIZE; i++){
-            ConverseNotifyMsg *tmp = notifyMsg+i;
-            if(thisNodeHelper->useTreeBcast){
-                tmp->srcRank = CmiMyRank();
-            }else{
-                tmp->srcRank = -1;
-            }            
-            tmp->ptr = (void *)(new CurLoopInfo(FuncNodeHelper::MAX_CHUNKS));
-            CmiSetHandler(tmp, stealWorkHandler);
-        }
-        thisNodeHelper->helperPtr[CkMyRank()] = this;
-    }
+    FuncSingleHelper(size_t ndhPtr);
 
     ~FuncSingleHelper() {
         for(int i=0; i<MSG_BUFFER_SIZE; i++){