Adding support for emigrant objects at reduction manager.
authorEsteban Meneses <emenese2@illinois.edu>
Sat, 7 Jul 2012 22:06:01 +0000 (17:06 -0500)
committerEsteban Meneses <emenese2@illinois.edu>
Sat, 7 Jul 2012 22:06:01 +0000 (17:06 -0500)
src/ck-core/ckcausalmlog.C
src/ck-core/cklocation.h
src/ck-core/ckreduction.C
src/ck-core/ckreduction.h

index 561758c0fae43e25e70c4c36fda6d48fe7d7f30a..800a9843fb9f2d54d6ae96a6fb115d7470d3aede 100644 (file)
@@ -2923,13 +2923,21 @@ public:
                        
                CkArrayIndexMax idx = loc.getIndex();
                CkLocRec_local *rec = loc.getLocalRecord();
+               CkLocMgr *locMgr = loc.getManager();
+               CkVec<CkMigratable *> eltList;
                        
                CkPrintf("[%d] Distributing objects to Processor %d: ",CkMyPe(),*targetPE);
                idx.print();
 
                // incrementing number of emigrant objects
                CpvAccess(_numEmigrantRecObjs)++;
-                       
+       locMgr->migratableList((CkLocRec_local *)rec,eltList);
+               CkReductionMgr *reductionMgr = (CkReductionMgr*)CkpvAccess(_groupTable)->find(eltList[0]->mlogData->objID.data.array.id).getObj();
+               
+               // let everybody else know the object is leaving
+               locMgr->callMethod(rec,&CkMigratable::ckAboutToMigrate);
+               reductionMgr->incNumEmigrantRecObjs();
+       
                //pack up this location and send it across
                PUP::sizer psizer;
                pupLocation(loc,psizer);
@@ -2992,6 +3000,13 @@ void _sendBackLocationHandler(char *receivedMsg){
        printf("Array element inserted at processor %d after distribution at restart ",CkMyPe());
        idx.print();
 
+       // decrementing number of emigrant objects at reduction manager
+       CkVec<CkMigratable *> eltList;
+       CkLocRec *rec = mgr->elementRec(idx);
+       mgr->migratableList((CkLocRec_local *)rec,eltList);
+       CkReductionMgr *reductionMgr = (CkReductionMgr*)CkpvAccess(_groupTable)->find(eltList[0]->mlogData->objID.data.array.id).getObj();
+       reductionMgr->decNumEmigrantRecObjs();
+
        // checking if it has received all emigrant recovering objects
        CpvAccess(_numEmigrantRecObjs)--;
        if(CpvAccess(_numEmigrantRecObjs) == 0){
@@ -3214,6 +3229,9 @@ void sendBackImmigrantRecObjs(){
 
                CkPrintf("[%d] Sending back object to %d: ",CkMyPe(),targetPE);
                idx.print();
+
+               // let everybody else know the object is leaving
+               locMgr->callMethod(rec,&CkMigratable::ckAboutToMigrate);
                        
                //pack up this location and send it across
                pupLocation(loc,locMgr,psizer);
index fd67729b1060018dcfc05726e9618fc0ee7cf476..00076bfde4cbf66b0844f27429a803ae6a4b62be 100644 (file)
@@ -645,6 +645,7 @@ public:
        //Look up array element in hash table.  Return NULL if not there.
        CkLocRec *elementNrec(const CkArrayIndex &idx);
 
+
 private:
 //Internal interface:
        //Add given element array record at idx, replacing the existing record
@@ -669,7 +670,6 @@ private:
 
        /// Call this member function on each element of this location:
        typedef void (CkMigratable::* CkMigratable_voidfn_t)(void);
-       void callMethod(CkLocRec_local *rec,CkMigratable_voidfn_t fn);
 
        CmiBool deliverUnknown(CkArrayMessage *msg,CkDeliver_t type,int opts);
 
@@ -684,6 +684,9 @@ CkLocRec_local *createLocal(const CkArrayIndex &idx,
                CmiBool notifyHome);
 #endif
 
+public:
+       void callMethod(CkLocRec_local *rec,CkMigratable_voidfn_t fn);
+
 //Data Members:
        //Map array ID to manager and elements
        class ManagerRec {
index c1e2ae7b0ae4d6262b877e079cd31b3102f337d6..d9d928b797b5d37f0babaa9187b278fdd0d786c4 100644 (file)
@@ -667,7 +667,7 @@ void CkReductionMgr::finishReduction(void)
   }
   //CkPrintf("[%d]finishReduction called for redNo %d with nContrib %d at %.6f\n",CkMyPe(),redNo, nContrib,CmiWallTimer());
 #if (defined(_FAULT_CAUSAL_))
-       if (nContrib<(lcount+adj(redNo).lcount)-numImmigrantRecObjs){
+       if (nContrib<(lcount+adj(redNo).lcount) - numImmigrantRecObjs + numEmigrantRecObjs){
         DEBR((AA"Need more local messages %d %d\n"AB,nContrib,(lcount+adj(redNo).lcount)));
                return;//Need more local messages
        }
index 53c1d122e8cb02cf2336efa022e5109985289cff..f8c91416bb2a9d07741bc38c6dfab62154b30144 100644 (file)
@@ -551,12 +551,20 @@ public:
        void decNumImmigrantRecObjs(){
                numImmigrantRecObjs--;
        }
+       void incNumEmigrantRecObjs(){
+               numEmigrantRecObjs++;
+       }
+       void decNumEmigrantRecObjs(){
+               numEmigrantRecObjs--;
+       }
+
 #endif
 
 private:
 
 #if defined(_FAULT_CAUSAL_)
        int numImmigrantRecObjs;
+       int numEmigrantRecObjs;
 #endif
 
 //Data members