added basic support for load balancing in pose (using the general LB framework).
authorGengbin Zheng <gzheng@illinois.edu>
Wed, 31 Mar 2010 02:41:26 +0000 (21:41 -0500)
committerGengbin Zheng <gzheng@illinois.edu>
Wed, 31 Mar 2010 02:41:26 +0000 (21:41 -0500)
src/libs/ck-libs/pose/gvt.C
src/libs/ck-libs/pose/gvt.ci
src/libs/ck-libs/pose/gvt.h
src/libs/ck-libs/pose/pvtobj.C
src/libs/ck-libs/pose/pvtobj.h
src/libs/ck-libs/pose/sim.C
src/libs/ck-libs/pose/sim.h

index 08ab8e292efdd25c17edbcc3b87a9b40f691ee33..d69279d06aa5157f4dfe817839b06241348fcd01 100644 (file)
@@ -19,7 +19,7 @@ PVT::PVT()
   CpvInitialize(eventID, theEventID);
   CpvAccess(theEventID)=eventID();
   //  CpvAccess(theEventID).dump();
-  LBTurnInstrumentOff();
+  //LBTurnInstrumentOff();
   optGVT = POSE_UnsetTS; conGVT = POSE_UnsetTS;
   rdone=0;
   SRs=NULL;
@@ -283,6 +283,32 @@ void PVT::beginCheckpoint(eventMsg *m) {
   }
 }
 
+void PVT::beginLoadbalancing(eventMsg *m) {
+  CkFreeMsg(m);
+  if (parCheckpointInProgress) {  // ensure this only happens once
+    CProxy_PVT p(ThePVT);
+    p.callAtSync();
+  }
+}
+
+void PVT::callAtSync()
+{
+  objs.callAtSync();
+}
+
+void PVT::doneLB() {
+  static int count = 0;
+  count ++;
+  if (count == objs.getNumObjs()) {
+    count =0;
+    if (CkMyPe()==0) { 
+      eventMsg *dummyMsg = new eventMsg();
+      CProxy_PVT p(ThePVT);
+      p[0].resumeAfterCheckpoint(dummyMsg);
+    }
+  }
+}
+
 /// ENTRY: resume after checkpointing, restarting, or if checkpointing doesn't occur
 void PVT::resumeAfterCheckpoint(eventMsg *m) {
   if (parCheckpointInProgress) {
index 6734bb511cc4ea5212083a24f1f83e5c6d33f7e9..c35fb4751bebdfd60a0c1488c051f6c0ecb2468f 100644 (file)
@@ -18,6 +18,8 @@ module gvt {
     entry void startPhaseExp(prioBcMsg *);     // not SMP safe to make this expedited
     entry void beginCheckpoint(eventMsg *);
     entry void resumeAfterCheckpoint(eventMsg *);
+    entry void beginLoadbalancing(eventMsg *);
+    entry void callAtSync();
     entry [expedited] void setGVT(GVTMsg *);
     entry [expedited] void reportReduce(UpdateMsg *);
   };
index e9b749a2ca350735bc104a6a924d4f03129d2eda..54b26fe2f5fd28c7b4d8799ac7b9ea80c60141e2 100644 (file)
@@ -134,6 +134,10 @@ class PVT : public Group {
   void beginCheckpoint(eventMsg *m);
   /// ENTRY: resume after checkpointing, restarting, or if checkpointing doesn't occur
   void resumeAfterCheckpoint(eventMsg *m);
+  void beginLoadbalancing(eventMsg *m);
+  void callAtSync();
+  void doneLB();
+
   /// Returns GVT estimate
   POSE_TimeType getGVT() { return estGVT; }    
 
index a519d9dc405a5c3a8137ea8357dde8762b035ffe..930771c45b3dd5992f36e11d6fb4030892df0c82 100644 (file)
@@ -61,6 +61,13 @@ int pvtObjects::Insert(int index, POSE_TimeType ovt, int sync, sim *myPtr)
   return idx;
 }
 
+void pvtObjects::callAtSync() {
+  register int i;
+  for (i=0; i<numSpaces; i++)
+    if (objs[i].isPresent()) {
+      (objs[i].localObjPtr)->AtSync();
+    }
+}
 /// Wake up all posers in list
 void pvtObjects::Wake() {
   register int i;
index 975ce7192bf65c5db54ef0fe63647ecdaec83cf5..998eb2c4c1aa1e49bf886aae283abddfde5560fd 100644 (file)
@@ -92,6 +92,7 @@ class pvtObjects {
   }                           
   /// Wake up all posers in list
   void Wake();
+  void callAtSync();
   /// Call Commit on all posers
   void Commit();
   /// Insert poser in list
index 7f52559ba8f16f427b0b105ede5e945537061b51..cbb514ea89be44aab61a30ca048caef8b04d67de 100644 (file)
@@ -333,6 +333,12 @@ void sim::SeqResumeAfterCheckpoint() {
   CkStartQD(CkIndex_pose::stop(), &POSE_Coordinator_ID);
 }
 
+void sim::ResumeFromSync()
+{
+  PVT *localPVT = (PVT *)CkLocalBranch(ThePVT);
+  localPVT->doneLB();
+}
+
 /// Dump all data fields
 void sim::dump()
 {
index 1bc82e9954166f52ac74663e337ccdc9dfc088ae..f3a7cef4ae009a709ad3ff0bd3096310c271c608 100644 (file)
@@ -297,6 +297,7 @@ class sim : public CBase_sim {
     va_end(ap);
     myStrat->currentEvent->commitErr = 1;
   }
+  void ResumeFromSync(void);
   /// Dump all data fields
   void dump();
  private: