Simplified initialization
authorChao Mei <chaomei2@illinois.edu>
Thu, 23 Feb 2012 04:12:37 +0000 (22:12 -0600)
committerChao Mei <chaomei2@illinois.edu>
Thu, 23 Feb 2012 04:12:37 +0000 (22:12 -0600)
NodeHelper.C
NodeHelper.ci
NodeHelper.h

index d2539af8fd87fba6768b2874f3a0db7e58730660..20fc4d6726fdc33e24a93dc9079b4b8e45ca8401 100644 (file)
@@ -13,17 +13,11 @@ FuncNodeHelper::FuncNodeHelper()
        useTreeBcast = (numHelpers >= USE_TREE_BROADCAST_THRESHOLD);
        
        int pestart = CkNodeFirst(CkMyNode());
-       
-       CkChareID *helperArr = new CkChareID[numHelpers];
-       for (int i=0; i<numHelpers; i++) {
-               CProxy_FuncSingleHelper::ckNew(thisgroup, &helperArr[i], pestart+i);
-               helperPtr[i] = NULL;
-       }
+               
        for (int i=0; i<numHelpers; i++) {
-               CProxy_FuncSingleHelper helpProxy(helperArr[i]);
-               helpProxy.reportCreated();
-       }
-       delete [] helperArr;
+        CkChareID helper;
+        CProxy_FuncSingleHelper::ckNew((size_t)this, &helper, pestart+i);
+       }       
 #endif
 }
 
index 1c3549a8fc2dd8227b86189d7ca708f3738166df..1fd0e24f536baf1b3f01cb0fea4fefe51cbbbd0f 100644 (file)
@@ -3,7 +3,6 @@ module NodeHelper{
                entry FuncNodeHelper();
        };
        chare FuncSingleHelper{
-               entry FuncSingleHelper(CkGroupID);
-               entry void reportCreated();
+               entry FuncSingleHelper(size_t);
        };
 };
index abe9fa6805a9592671f99780252b20d34b558b54..6a0c9bfdb718f98e2c0a443c3c325538cc369d95 100644 (file)
@@ -98,11 +98,6 @@ public:
     ~FuncNodeHelper() {
         delete [] helperPtr;
     }
-
-    /* handler is only useful when converse msg is used to initiate tasks on the pseudo-thread */
-    void oneHelperCreated(int hid, FuncSingleHelper* cptr) {
-        helperPtr[hid] = cptr;
-    }
     
     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 */
@@ -125,9 +120,8 @@ private:
     CurLoopInfo *curLoop; /* Points to the current loop that is being processed */
     
 public:
-    FuncSingleHelper(CkGroupID nid) {        
-        CProxy_FuncNodeHelper fh(nid);
-        thisNodeHelper = fh[CkMyNode()].ckLocalBranch();
+    FuncSingleHelper(size_t ndhPtr) {
+        thisNodeHelper = (FuncNodeHelper *)ndhPtr;
         CmiAssert(thisNodeHelper!=NULL);        
         int stealWorkHandler = CmiRegisterHandler((CmiHandler)SingleHelperStealWork);
         curLoop = new CurLoopInfo(FuncNodeHelper::MAX_CHUNKS);
@@ -140,6 +134,7 @@ public:
         }
         notifyMsg->ptr = (void *)curLoop;
         CmiSetHandler(notifyMsg, stealWorkHandler);
+        thisNodeHelper->helperPtr[CkMyRank()] = this;
     }
 
     ~FuncSingleHelper() {
@@ -147,12 +142,7 @@ public:
         delete notifyMsg;
     }
     
-    FuncSingleHelper(CkMigrateMessage *m) {}
-               
-    void reportCreated() {
-        //CkPrintf("Single helper %d is created on rank %d\n", CkMyPe(), CkMyRank());
-               thisNodeHelper->oneHelperCreated(CkMyRank(), this);
-    }    
+    FuncSingleHelper(CkMigrateMessage *m) {}           
 };
 
 #endif