Adding support for emigrant objects at reduction manager.
[charm.git] / src / ck-core / ckcausalmlog.C
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);