*** empty log message ***
authorSameer Kumar <skumar2@uiuc.edu>
Thu, 20 May 2004 17:48:58 +0000 (17:48 +0000)
committerSameer Kumar <skumar2@uiuc.edu>
Thu, 20 May 2004 17:48:58 +0000 (17:48 +0000)
src/ck-com/ComlibManager.C
src/ck-com/ComlibManager.h
src/ck-core/ComlibStrategy.h

index 81d7f1bf3566220cc1f297c012c74bb0c980b3a4..e79b8c2f5f562f8ca056497551e32897ea9b65b7 100644 (file)
@@ -734,12 +734,14 @@ ComlibInstanceHandle::ComlibInstanceHandle(){
     _instid = -1;
     _dmid.setZero();
     _srcPe = -1;
+    toForward = 0;
 }
 
 //Called by user code
 ComlibInstanceHandle::ComlibInstanceHandle(const ComlibInstanceHandle &h){
     _instid = h._instid;
     _dmid = h._dmid;
+    toForward = h.toForward;
 
     ComlibPrintf("In Copy Constructor\n");
 
@@ -758,6 +760,7 @@ ComlibInstanceHandle::ComlibInstanceHandle(int instid, CkGroupID dmid){
     _instid = instid;
     _dmid   = dmid;
     _srcPe  = -1;
+    toForward = 0;
 }
 
 void ComlibInstanceHandle::beginIteration() { 
@@ -765,7 +768,15 @@ void ComlibInstanceHandle::beginIteration() {
 
     ComlibPrintf("Instance Handle beginIteration %d, %d\n", CkMyPe(), _srcPe);
 
-    if(_srcPe != CkMyPe()) {
+    //User forgot to make the instance handle a readonly or pass it
+    //into the constructor of an array and is using it directly from
+    //Main :: main
+    if(_srcPe == -1) {
+        ComlibPrintf("Warning:Instance Handle needs to be a readonly or a private variable of an array element\n");
+        _srcPe = CkMyPe();
+    }
+
+    if(_srcPe != CkMyPe() && toForward) {
         (cgproxy.ckLocalBranch())->setRemote(_srcPe);
     }
 
@@ -779,6 +790,7 @@ void ComlibInstanceHandle::endIteration() {
 }
 
 void ComlibInstanceHandle::setStrategy(CharmStrategy *s) {
+    toForward = s->getForwardOnMigration();
     CProxy_ComlibManager cgproxy(_dmid);
     (cgproxy.ckLocalBranch())->registerStrategy(_instid, s);
 }
index a6607e35959fe3152650beb302d42d2f4919ede8..4b275eae9f8d05827e72475e098d1b29acbfc5a2 100644 (file)
@@ -67,6 +67,7 @@ class ComlibInstanceHandle {
     int _instid;
     CkGroupID _dmid;
     int _srcPe;
+    int toForward;
     
  public:
     ComlibInstanceHandle();
@@ -83,10 +84,19 @@ class ComlibInstanceHandle {
     int getSourcePe() {return _srcPe;}
 
     friend class ComlibManager;
+    void pup(PUP::er &p) {
+        p | _instid;
+        p | _dmid;
+        p | _srcPe;
+        p | toForward;
+
+        //Fresh instance handle, so set My processor
+        if(p.isUnpacking())
+            if(_srcPe == -1)
+                _srcPe = CkMyPe();
+    }
 };
 
-PUPbytes(ComlibInstanceHandle);
-
 class ComlibManager: public CkDelegateMgr {
     friend class ComlibInstanceHandle;
 
index b812d5d30010f41124d7c2eef8e1abea760e8034..25a9097233d6a194341bf7d8bf518bad0689de84 100644 (file)
@@ -116,13 +116,14 @@ class ComlibArrayInfo {
    node groups, groups and arrays */
 
 class CharmStrategy : public Strategy {
+    int forwardOnMigration;
 
  public:
     ComlibGroupInfo ginfo;
     ComlibNodeGroupInfo nginfo;
     ComlibArrayInfo ainfo;    
 
-    CharmStrategy() : Strategy() {setType(GROUP_STRATEGY);}
+    CharmStrategy() : Strategy() {setType(GROUP_STRATEGY); forwardOnMigration = 0;}
     CharmStrategy(CkMigrateMessage *m) : Strategy(m){}
 
     //Called for each message
@@ -146,6 +147,14 @@ class CharmStrategy : public Strategy {
 
     virtual void pup(PUP::er &p);
     PUPable_decl(CharmStrategy);
+
+    void setForwardOnMigration(int f) {
+        forwardOnMigration = f;
+    }
+    
+    int getForwardOnMigration() {
+        return forwardOnMigration;
+    }
 };
 
 #endif