Code cleanup. Shorter header for streaming and enable array caching again.
authorSameer Kumar <skumar2@uiuc.edu>
Mon, 21 Mar 2005 05:21:51 +0000 (05:21 +0000)
committerSameer Kumar <skumar2@uiuc.edu>
Mon, 21 Mar 2005 05:21:51 +0000 (05:21 +0000)
src/ck-com/AAMLearner.C
src/ck-com/AAPLearner.C
src/ck-com/ComlibManager.C
src/ck-com/ComlibManager.h
src/ck-com/ComlibStrategy.C
src/ck-com/EachToManyMulticastStrategy.C
src/ck-com/MsgPacker.h

index 4b300ccc73f1d0f26a1dba7683054c61a9885c71..efca2ac96059d4a147aa414e82d4343ce536a991 100644 (file)
@@ -49,8 +49,8 @@ Strategy *AAMLearner::optimizePattern(Strategy *strat,
         else if(hcost == mincost) 
             minstrat = USE_HYPERCUBE;               
 
-        CkPrintf("Choosing router %d, %g, %g, %g\n", minstrat, 
-                 mcost, hcost, dcost);
+        //CkPrintf("Choosing router %d, %g, %g, %g\n", minstrat, 
+        //       mcost, hcost, dcost);
         
         //if(minstrat != USE_DIRECT) {
         ostrat = new EachToManyMulticastStrategy
index 68e8add4b7e6edef9e1fcf6f465fb53be7506e5c..9d498aedeeade79f5a13baf5b3e72d869f0d131d 100644 (file)
@@ -50,8 +50,8 @@ Strategy *AAPLearner::optimizePattern(Strategy *strat,
     else if(hcost == mincost) 
         minstrat = USE_HYPERCUBE;
 
-    CkPrintf("Choosing router %d, %g, %g, %g, %g; %g : %g,%g,%g\n", minstrat, 
-             mcost, hcost, gcost, dcost, mincost, npes, msgsize, degree);
+    //CkPrintf("Choosing router %d, %g, %g, %g, %g; %g : %g,%g,%g\n", minstrat, 
+    //       mcost, hcost, gcost, dcost, mincost, npes, msgsize, degree);
     
     if(in_strat->getType() == ARRAY_STRATEGY) {
         CkArrayID said, daid;
index 0d734c663b89878052f5503a8209863b388c33f0..801c17b7a07fa06e5ef9b7789b36524e7f9039bd 100644 (file)
@@ -116,7 +116,7 @@ void ComlibManager::init(){
     strategyTable = CkpvAccess(conv_com_ptr)->getStrategyTable();
     
     receivedTable = 0;
-    flushTable = 0;
+    setupComplete = 0;
 
     barrierReached = 0;
     barrier2Reached = 0;
@@ -250,7 +250,6 @@ void ComlibManager::endIteration(){
     
     (* strategyTable)[curStratID].elementCount++;
     int count = 0;
-    flushTable = 1;
     
     if((* strategyTable)[curStratID].elementCount == (* strategyTable)[curStratID].numElements) {
         
@@ -277,13 +276,13 @@ void ComlibManager::receiveTable(StrategyWrapper &sw,
     ComlibPrintf("[%d] In receiveTable %d, ite=%d\n", CkMyPe(), sw.nstrats, 
                  clibIteration);
 
-    clibIteration ++;
     receivedTable = 1;
 
     delete CkpvAccess(locationTable);
     CkpvAccess(locationTable) =  NULL;
 
-    CkpvAccess(locationTable) = new CkHashtableT<ClibGlobalArrayIndex, int>;
+    CkpvAccess(locationTable) = new 
+        CkHashtableT<ClibGlobalArrayIndex, int>;
 
     CkHashtableIterator *ht_iterator = htable.iterator();
     ht_iterator->seekStart();
@@ -333,7 +332,7 @@ void ComlibManager::receiveTable(StrategyWrapper &sw,
             (CharmStrategy *)CkpvAccess(conv_com_ptr)->getStrategy(loc)) 
            != NULL) {
             old_strategy->finalizeProcessing();
-
+            
             //Unregister from array listener if array strategy
             if(old_strategy->getType() == ARRAY_STRATEGY) {
                 ComlibArrayInfo &as = ((CharmStrategy *)cur_strategy)->ainfo;
@@ -359,7 +358,7 @@ void ComlibManager::receiveTable(StrategyWrapper &sw,
            cur_strategy->isBracketed()){ 
 
             ComlibPrintf("Inserting Array Listener\n");
-
+            
             ComlibArrayInfo &as = ((CharmStrategy *)cur_strategy)->ainfo;
             as.getSourceArray(st_aid, st_elem, st_nelements);
             
@@ -402,15 +401,19 @@ void ComlibManager::receiveTable(StrategyWrapper &sw,
 
 void ComlibManager::resumeFromBarrier2(){
 
+    setupComplete = 1;
+
     barrier2Reached = 1;
     barrierReached = 0;
 
+    clibIteration ++;
+
     ComlibPrintf("[%d] Barrier 2 reached nstrats = %d, ite = %d\n", CkMyPe(), CkpvAccess(conv_com_ptr)->nstrats, clibIteration);
 
-    //    if(flushTable) {
-    for (int count = 0; count < CkpvAccess(conv_com_ptr)->nstrats; count ++) {
+    for (int count = 0; count < CkpvAccess(conv_com_ptr)->nstrats; 
+         count ++) {
         if (!(* strategyTable)[count].tmplist.isEmpty()) {
-            CharmMessageHolder *cptr;
+            
             while (!(* strategyTable)[count].tmplist.isEmpty()) {
                 CharmMessageHolder *cmsg = (CharmMessageHolder *) 
                     (* strategyTable)[count].tmplist.deq();
@@ -418,13 +421,14 @@ void ComlibManager::resumeFromBarrier2(){
                 if((*strategyTable)[count].strategy->getType() == 
                    ARRAY_STRATEGY) {
                     if(cmsg->dest_proc >= 0) {
-                        envelope *env  = UsrToEnv(cmsg->getCharmMessage()); 
-                        cmsg->dest_proc = getLastKnown(env->getsetArrayMgr(), 
-                                                       env->getsetArrayIndex());
+                        envelope *env  = UsrToEnv(cmsg->getCharmMessage());
+                        cmsg->dest_proc = getLastKnown
+                            (env->getsetArrayMgr(),
+                             env->getsetArrayIndex());
                     }
                     //else multicast
                 }                                
-
+                
                 if(cmsg->dest_proc == CkMyPe()) {
                     CmiSyncSendAndFree(CkMyPe(), cmsg->size,
                                        (char *)
@@ -442,7 +446,7 @@ void ComlibManager::resumeFromBarrier2(){
             (* strategyTable)[count].strategy->doneInserting();
         }
     }
-    //}    
+    
     ComlibPrintf("[%d] After Barrier2\n", CkMyPe());
 }
 
@@ -488,7 +492,7 @@ void ComlibManager::ArraySend(CkDelegateData *pd,int ep, void *msg,
     //With migration some array messages may be directly sent Also no
     //message processing should happen before the comlib barriers have
     //gone through
-    if(dest_proc == CkMyPe() && receivedTable){                
+    if(dest_proc == CkMyPe() && setupComplete){                
         CkArray *amgr = (CkArray *)_localBranch(a);
         amgr->deliver((CkArrayMessage *)msg, CkDeliver_queue);
         
@@ -502,14 +506,12 @@ void ComlibManager::ArraySend(CkDelegateData *pd,int ep, void *msg,
     CharmMessageHolder *cmsg = new 
         CharmMessageHolder((char *)msg, dest_proc);
     
-    ComlibPrintf("[%d] Before Insert on strat %d received = %d\n", CkMyPe(), curStratID, receivedTable);
+    ComlibPrintf("[%d] Before Insert on strat %d received = %d\n", CkMyPe(), curStratID, setupComplete);
     
-    if (receivedTable)        
+    if (setupComplete)        
         (* strategyTable)[curStratID].strategy->insertMessage(cmsg);
-    else {
-        flushTable = 1;
+    else 
         (* strategyTable)[curStratID].tmplist.enq(cmsg);
-    }
     
     //CmiPrintf("After Insert\n");
 }
@@ -532,14 +534,14 @@ void ComlibManager::GroupSend(CkDelegateData *pd,int ep, void *msg, int onPE, Ck
                  UsrToEnv(msg)->getTotalsize());
 
     register envelope * env = UsrToEnv(msg);
-    if(dest_proc == CkMyPe() && receivedTable){
+    if(dest_proc == CkMyPe() && setupComplete){
         _SET_USED(env, 0);
         CkSendMsgBranch(ep, msg, dest_proc, gid);
         return;
     }
     
     ((CmiMsgHeaderExt *)env)->stratid = curStratID;
-    CpvAccess(_qd)->create(1);
+    CkpvAccess(_qd)->create(1);
 
     env->setMsgtype(ForBocMsg);
     env->setEpIdx(ep);
@@ -553,10 +555,9 @@ void ComlibManager::GroupSend(CkDelegateData *pd,int ep, void *msg, int onPE, Ck
     CharmMessageHolder *cmsg = new CharmMessageHolder((char *)msg, dest_proc); 
     //get rid of the new.
     
-    if(receivedTable)
+    if(setupComplete)
         (* strategyTable)[curStratID].strategy->insertMessage(cmsg);
     else {
-        flushTable = 1;
         (* strategyTable)[curStratID].tmplist.enq(cmsg);
     }
 }
@@ -647,7 +648,7 @@ void ComlibManager::GroupBroadcast(CkDelegateData *pd,int ep,void *m,CkGroupID g
     
     register envelope * env = UsrToEnv(m);
     
-    CpvAccess(_qd)->create(1);
+    CkpvAccess(_qd)->create(1);
 
     env->setMsgtype(ForBocMsg);
     env->setEpIdx(ep);
@@ -678,10 +679,9 @@ void ComlibManager::multicast(CharmMessageHolder *cmsg) {
 
     //Will be used to detect multicast message for learning
     
-    if (receivedTable)
+    if (setupComplete)
        (* strategyTable)[curStratID].strategy->insertMessage(cmsg);
     else {
-        flushTable = 1;
        ComlibPrintf("Enqueuing message in tmplist at %d\n", curStratID);
         (* strategyTable)[curStratID].tmplist.enq(cmsg);
     }
@@ -799,6 +799,7 @@ void ComlibManager::AtSync() {
 
     barrier2Reached = 0;
     receivedTable = 0;
+    setupComplete = 0;
     barrierReached = 0;
     CProxy_ComlibManager cgproxy(CkpvAccess(cmgrID));
 
@@ -807,8 +808,10 @@ void ComlibManager::AtSync() {
     CkVec<ClibGlobalArrayIndex> gidx_vec;
 
     CkVec<CkArrayID> tmp_vec;
-    for(int count = 0; count < CkpvAccess(conv_com_ptr)->nstrats; count ++) {
-        if((* strategyTable)[count].strategy->getType() == ARRAY_STRATEGY) {
+    for(int count = 0; count < CkpvAccess(conv_com_ptr)->nstrats; 
+        count ++) {
+        if((* strategyTable)[count].strategy->getType() 
+           == ARRAY_STRATEGY) {
             CharmStrategy *cstrat = (CharmStrategy*)
                 ((* strategyTable)[count].strategy);
             
index d4f92e20b920dc106aedec377eb8953a03b4f0b5..6fb37d57fd666cb4574e86eea9ee797801375eb7 100644 (file)
@@ -62,7 +62,7 @@ class ComlibInstanceHandle : public CkDelegateData {
     CkGroupID _dmid;
     int _srcPe;
     int toForward;
-    
+
  public:
     ComlibInstanceHandle();
     ComlibInstanceHandle(const ComlibInstanceHandle &h);
@@ -131,7 +131,7 @@ class ComlibManager: public CkDelegateMgr {
     //Number of strategies created by the user.
 
     //flags
-    int receivedTable, flushTable, barrierReached, barrier2Reached;
+    int receivedTable, setupComplete, barrierReached, barrier2Reached;
     CmiBool lbUpdateReceived;
 
     int bcount , b2count;
index a24b434c88fcfb750f8befa85462b57a252db175..0c5a6e169011b8c9f61edef556669413e221a851 100644 (file)
@@ -534,11 +534,9 @@ int ComlibGetLastKnown(CkArrayID aid, CkArrayIndexMax idx) {
         CkAbort("Uninitialized table\n");
     }
     CkAssert(CkpvAccess(locationTable) != NULL);
-
-    /*
+   
     if(CkpvAccess(cache_index) == idx && CkpvAccess(cache_aid) == aid)
         return CkpvAccess(cache_pe);
-    */
 
     ClibGlobalArrayIndex cidx;
     cidx.aid = aid;
index 054ca56c7dd9be4d5adf514a48e87c9dea3b0272..ddc4243abda38d86643c173c2f3e2f053eec5d83 100644 (file)
@@ -198,6 +198,9 @@ void EachToManyMulticastStrategy::doneInserting(){
     if(routerID == USE_DIRECT && nexpected == 0)
         return;
     
+    if(MyPe < 0)
+        return;
+
     //ComlibPrintf("%d: DoneInserting \n", CkMyPe());    
     rstrat->doneInserting();
 }
index c30744cfc8c60e9fee410474b377642174f5b34a..8779ed9fe86f3f294c88bb5f4f3c546b87018329 100644 (file)
@@ -41,7 +41,7 @@ inline void short_envelope::pup(PUP::er &p){
   char nints = 0;
 
   p | epIdx;
-  p | size;        
+  //  p | size;        
   //p | idx;
   
   //Complex pup of arrays, even want to save 3 bytes, GREEDY, GREEDY :)
@@ -52,15 +52,19 @@ inline void short_envelope::pup(PUP::er &p){
   idx.nInts = nints;
   p((int *)(idx.data()), idx.nInts);
   
-  p.pupCmiAllocBuf((void **)&data, size);
+  if(p.isUnpacking()) {
+      p.pupCmiAllocBuf((void **)&data);
+      size = SIZEFIELD(data);
+  }
+  else 
+      p.pupCmiAllocBuf((void **)&data, size);
 }
 
 struct CombinedMessage{
-
     char header[CmiReservedHeaderSize];
     CkArrayID aid;
-    int srcPE;
-    int nmsgs;
+    unsigned short srcPE;  //Will not work on a very large bluegene machine!
+    unsigned short nmsgs;
 };
 
 PUPbytes(CombinedMessage);