Several new changes
authorSameer Kumar <skumar2@uiuc.edu>
Fri, 18 Mar 2005 03:21:55 +0000 (03:21 +0000)
committerSameer Kumar <skumar2@uiuc.edu>
Fri, 18 Mar 2005 03:21:55 +0000 (03:21 +0000)
     Learning framework will now be tested in autobuild
     Fixed cached index bug.

     EachToManyMulticast strategy now does not work with sections. This makes it a lot simpler.
     The strategy should now be explicitly be used for all-to-all operations

     Cleaned up direct and ring multicast strategies. Isolated and abstracted out a lot
     of common code.

15 files changed:
src/ck-com/AAMLearner.C
src/ck-com/ComlibLearner.h
src/ck-com/ComlibManager.C
src/ck-com/ComlibSectionInfo.C
src/ck-com/ComlibSectionInfo.h
src/ck-com/ComlibStrategy.C
src/ck-com/ComlibStrategy.h
src/ck-com/DirectMulticastStrategy.C
src/ck-com/DirectMulticastStrategy.h
src/ck-com/EachToManyMulticastStrategy.C
src/ck-com/EachToManyMulticastStrategy.h
src/ck-com/MPIStrategy.C
src/ck-com/MeshStreamingStrategy.C
src/ck-com/RingMulticastStrategy.C
src/ck-com/RingMulticastStrategy.h

index e771a3d22fa83a812fe06b94ee5dffbc77bd72bd..4b300ccc73f1d0f26a1dba7683054c61a9885c71 100644 (file)
@@ -2,7 +2,7 @@
 #include "ComlibManager.h"
 
 #include "EachToManyMulticastStrategy.h"
-#include "RingMulticastStrategy.h"
+//#include "RingMulticastStrategy.h"
 
 AAMLearner::AAMLearner() {
    init();
@@ -21,7 +21,8 @@ Strategy *AAMLearner::optimizePattern(Strategy *strat,
     CharmStrategy *ostrat = NULL;
 
     double degree = 0, msgsize = 0, nmsgs = 0;
-    stats.getAverageStats(strat->getInstance(), msgsize, nmsgs, degree, npes);
+    stats.getAverageStats(strat->getInstance(), msgsize, nmsgs, 
+                          degree, npes);
 
     double dcost = computeDirect(npes, msgsize, degree);
     double mcost = computeMesh(npes, msgsize, degree);
@@ -51,15 +52,21 @@ Strategy *AAMLearner::optimizePattern(Strategy *strat,
         CkPrintf("Choosing router %d, %g, %g, %g\n", minstrat, 
                  mcost, hcost, dcost);
         
-        if(minstrat != USE_DIRECT) {
-            ostrat = new EachToManyMulticastStrategy
-                (minstrat, said, daid,
-                 nsrc, sidxlist, ndest,
-                 didxlist);
-        }
-        else {
-            ostrat = new RingMulticastStrategy(said, daid);
-        }
+        //if(minstrat != USE_DIRECT) {
+        ostrat = new EachToManyMulticastStrategy
+            (minstrat, said, daid,
+             nsrc, sidxlist, ndest,
+             didxlist);
+        
+        ostrat->setMulticast();
+
+        /*
+          }        
+          else {
+          ostrat = new RingMulticastStrategy(said, daid);
+          
+          }
+        */
         
         ostrat->setInstance(in_strat->getInstance());
     }
@@ -107,6 +114,7 @@ double AAMLearner::computeHypercube(double P, double m, double d) {
 
 //P = number of processors, m = msgsize, d = degree
 double AAMLearner::computeGrid(double P, double m, double d) {
+
     double cost = 0.0;
     cost = 3 * cubeRoot((double) P) * alpha;
     cost += d * m * (beta + gamma);
index 5d60d29e0f52ff64d7347856d73864a847d154bf..aa1f1a066851148d7da01c0b2bf935e35562bb95 100644 (file)
@@ -19,12 +19,17 @@ class ComlibLearner {
     virtual void init() {}
     
     //Optimizes a specific strategy. Returns a new optimized strategy
-    virtual Strategy* optimizePattern(Strategy *strat,ComlibGlobalStats &sdata){return NULL;}
+    virtual Strategy* optimizePattern(Strategy *strat, 
+                                      ComlibGlobalStats &sdata){
+        return NULL;
+    }
     
     //Optimizes the communication pattern of a group of strategies
     //together
     virtual Strategy** optimizePattern(Strategy **strat, 
-                                           ComlibGlobalStats &sdata){return NULL;}
+                                       ComlibGlobalStats &sdata){
+        return NULL;
+    }
 };
 
 #endif
index 86d56b1dcf60ba7ceb13f26be83b503590752939..0d734c663b89878052f5503a8209863b388c33f0 100644 (file)
@@ -20,7 +20,7 @@ CkpvDeclare(int, RecvCombinedShortMsgHdlrIdx);
 CkpvDeclare(CkGroupID, cmgrID);
 CkpvExtern(ConvComlibManager *, conv_com_ptr);
 
-//handler to receive array messages
+//Handler to receive array messages
 void recv_array_msg(void *msg){
 
     ComlibPrintf("%d:In recv_msg\n", CkMyPe());
@@ -117,9 +117,7 @@ void ComlibManager::init(){
     
     receivedTable = 0;
     flushTable = 0;
-    //    totalMsgCount = 0;
-    //    totalBytes = 0;
-    //nIterations = 0;
+
     barrierReached = 0;
     barrier2Reached = 0;
 
@@ -258,15 +256,6 @@ void ComlibManager::endIteration(){
         
         ComlibPrintf("[%d]:In End Iteration %d\n", CkMyPe(), (* strategyTable)[curStratID].elementCount);
         
-        //nIterations ++;
-        /*
-        if(nIterations == LEARNING_PERIOD) {
-            //CkPrintf("Sending %d, %d\n", totalMsgCount, totalBytes);
-            CProxy_ComlibManager cgproxy(CkpvAccess(cmgrID));
-            cgproxy[0].learnPattern(totalMsgCount, totalBytes);
-        }
-        */
-        
         if(barrier2Reached) {      
            (* strategyTable)[curStratID].strategy->doneInserting();
         }
@@ -288,10 +277,6 @@ void ComlibManager::receiveTable(StrategyWrapper &sw,
     ComlibPrintf("[%d] In receiveTable %d, ite=%d\n", CkMyPe(), sw.nstrats, 
                  clibIteration);
 
-    //Reset cached array element index. Location table may have changed
-    CkpvAccess(cache_index).nInts = -1;
-    CkpvAccess(cache_aid).setZero();
-
     clibIteration ++;
     receivedTable = 1;
 
@@ -312,6 +297,10 @@ void ComlibManager::receiveTable(StrategyWrapper &sw,
 
         CkpvAccess(locationTable)->put(*idx) = *pe;       
     }
+    
+    //Reset cached array element index. Location table may have changed
+    CkpvAccess(cache_index).nInts = -1;
+    CkpvAccess(cache_aid).setZero();
 
     CkArrayID st_aid;
     int st_nelements;
@@ -412,6 +401,7 @@ void ComlibManager::receiveTable(StrategyWrapper &sw,
 }
 
 void ComlibManager::resumeFromBarrier2(){
+
     barrier2Reached = 1;
     barrierReached = 0;
 
@@ -432,10 +422,17 @@ void ComlibManager::resumeFromBarrier2(){
                         cmsg->dest_proc = getLastKnown(env->getsetArrayMgr(), 
                                                        env->getsetArrayIndex());
                     }
-                    //else
-                    //  CkAbort("NOT FIXED YET\n");                    
+                    //else multicast
                 }                                
-                (* strategyTable)[count].strategy->insertMessage(cmsg);
+
+                if(cmsg->dest_proc == CkMyPe()) {
+                    CmiSyncSendAndFree(CkMyPe(), cmsg->size,
+                                       (char *)
+                                       UsrToEnv(cmsg->getCharmMessage()));
+                    delete cmsg;
+                }
+                else
+                    (* strategyTable)[count].strategy->insertMessage(cmsg);
             }
         }
         
@@ -487,38 +484,33 @@ void ComlibManager::ArraySend(CkDelegateData *pd,int ep, void *msg,
         remoteQ.enq(cmsg);
         return;
     }
-
-    //Any bug here? FOO BAR??
-    //With migration some array messages may be directly sent
-    if(dest_proc == CkMyPe()){                
+    
+    //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){                
         CkArray *amgr = (CkArray *)_localBranch(a);
         amgr->deliver((CkArrayMessage *)msg, CkDeliver_queue);
         
-        //CProxyElement_ArrayBase ap(a, idx);
-        //ap.ckSend((CkArrayMessage *)msg, ep);
-
         return;
     }
-    
+
     CkPackMessage(&env);
     CmiSetHandler(env, CkpvAccess(RecvmsgHandle));        
     
-    //totalMsgCount ++;
-    //totalBytes += UsrToEnv(msg)->getTotalsize();
-
+    //get rid of the new.
     CharmMessageHolder *cmsg = new 
         CharmMessageHolder((char *)msg, dest_proc);
-    //get rid of the new.
     
     ComlibPrintf("[%d] Before Insert on strat %d received = %d\n", CkMyPe(), curStratID, receivedTable);
     
-    if (receivedTable)
+    if (receivedTable)        
         (* strategyTable)[curStratID].strategy->insertMessage(cmsg);
     else {
         flushTable = 1;
         (* strategyTable)[curStratID].tmplist.enq(cmsg);
     }
-
+    
     //CmiPrintf("After Insert\n");
 }
 
@@ -535,25 +527,12 @@ void ComlibManager::GroupSend(CkDelegateData *pd,int ep, void *msg, int onPE, Ck
     }
 
     int dest_proc = onPE;
-    /*
-    if(curStratID != prevStratID && prioEndIterationFlag) {        
-        CProxy_ComlibManager cgproxy(CkpvAccess(cmgrID));
-        ComlibPrintf("[%d] Array Send calling prio end iteration\n", 
-                     CkMyPe());
-        PrioMsg *pmsg = new(8 * sizeof(int)) PrioMsg;
-        *(int *)CkPriorityPtr(pmsg) = -0x7FFFFFFF;
-        CkSetQueueing(pmsg, CK_QUEUEING_IFIFO);
-        cgproxy[CkMyPe()].prioEndIteration(pmsg);
-        prioEndIterationFlag = 0;
-    }        
-    prevStratID = curStratID;            
-    */
 
     ComlibPrintf("Send Data %d %d %d\n", CkMyPe(), dest_proc, 
                  UsrToEnv(msg)->getTotalsize());
 
     register envelope * env = UsrToEnv(msg);
-    if(dest_proc == CkMyPe()){
+    if(dest_proc == CkMyPe() && receivedTable){
         _SET_USED(env, 0);
         CkSendMsgBranch(ep, msg, dest_proc, gid);
         return;
@@ -602,16 +581,6 @@ void ComlibManager::ArrayBroadcast(CkDelegateData *pd,int ep,void *m,CkArrayID a
 
     CmiSetHandler(env, CkpvAccess(RecvmsgHandle));
     
-    /*  //section multicast header not needed for broadcast
-      CkSectionInfo minfo;
-      minfo.type = COMLIB_MULTICAST_MESSAGE;
-      minfo.sInfo.cInfo.instId = curStratID;
-      minfo.sInfo.cInfo.status = COMLIB_MULTICAST_ALL;  
-      minfo.sInfo.cInfo.id = 0; 
-      minfo.pe = CkMyPe();
-      ((CkMcastBaseMsg *)m)->_cookie = minfo;       
-    */
-
     //RECORD_SENDM_STATS(curStratID, env->getTotalsize(), dest_proc);
 
     CharmMessageHolder *cmsg = new 
@@ -650,9 +619,6 @@ void ComlibManager::ArraySectionSend(CkDelegateData *pd,int ep, void *m,
     env->setUsed(0);    
     CkPackMessage(&env);
     
-    //totalMsgCount ++;
-    //totalBytes += env->getTotalsize();
-
     //Provide a dummy dest proc as it does not matter for mulitcast 
     CharmMessageHolder *cmsg = new CharmMessageHolder((char *)m,
                                                       IS_SECTION_MULTICAST);
@@ -711,8 +677,6 @@ void ComlibManager::multicast(CharmMessageHolder *cmsg) {
     CkPackMessage(&env);
 
     //Will be used to detect multicast message for learning
-    //totalMsgCount ++;
-    //totalBytes += env->getTotalsize();
     
     if (receivedTable)
        (* strategyTable)[curStratID].strategy->insertMessage(cmsg);
@@ -744,6 +708,10 @@ void ComlibManager::collectStats(ComlibLocalStats &stat, int pe,
         CkpvAccess(locationTable)->put(idx_vec[count]) = pe + CkNumPes();
     }        
 
+    //Reset cached array element index. Location table may have changed
+    CkpvAccess(cache_index).nInts = -1;
+    CkpvAccess(cache_aid).setZero();
+
     if(numStatsReceived == CkNumPes()) {
         numStatsReceived = 0;
 
@@ -757,9 +725,13 @@ void ComlibManager::collectStats(ComlibLocalStats &stat, int pe,
                                 
                 if(learner != NULL) {
                     ComlibPrintf("Calling Learner\n");
-                    newstrat = (CharmStrategy *)learner->optimizePattern(strat, clib_gstats);
+                    newstrat = (CharmStrategy *)learner->optimizePattern
+                        (strat, clib_gstats);
+                    
                     if(newstrat != NULL)
                         ListOfStrategies.enq(newstrat);
+                    else
+                        ListOfStrategies.enq(cstrat);
                 }
             }
         }
index 287a80a18237bd14bc6ed213c1ee3359d02bd8ec..0137c109c64c4112557b99de7cf83d10f88e8886 100644 (file)
@@ -10,17 +10,17 @@ ComlibMulticastMsg * ComlibSectionInfo::getNewMulticastMessage
 
     void *m = cmsg->getCharmMessage();
     envelope *env = UsrToEnv(m);
-    
+        
     if(cmsg->sec_id->_cookie.sInfo.cInfo.id != 0) 
         CmiAbort("In correct section\n");
 
+    initSectionID(cmsg->sec_id);   
+
     CkPackMessage(&env);
     int sizes[2];
     sizes[0] = cmsg->sec_id->_nElems;
     sizes[1] = env->getTotalsize();                
     
-    cmsg->sec_id->_cookie.sInfo.cInfo.id = MaxSectionID ++;
-    
     ComlibPrintf("Creating new comlib multicast message %d, %d\n", sizes[0], sizes[1]);
     
     ComlibMulticastMsg *msg = new(sizes, 0) ComlibMulticastMsg;
@@ -48,20 +48,14 @@ ComlibMulticastMsg * ComlibSectionInfo::getNewMulticastMessage
     
     CkPackMessage(&newenv);        
     return (ComlibMulticastMsg *)EnvToUsr(newenv);
-
-    return NULL;
 }
 
 void ComlibSectionInfo::unpack(envelope *cb_env, 
-                               CkVec<CkArrayIndexMax> *&dest_indices, 
+                               CkVec<CkArrayIndexMax> &dest_indices, 
                                envelope *&env) {
         
-    dest_indices = NULL;    
     ComlibMulticastMsg *ccmsg = (ComlibMulticastMsg *)EnvToUsr(cb_env);
     
-    if(ccmsg->nIndices > 0)
-        dest_indices = new CkVec<CkArrayIndexMax>;
-
     for(int count = 0; count < ccmsg->nIndices; count++){
         CkArrayIndexMax idx = ccmsg->indices[count];
         
@@ -70,8 +64,8 @@ void ComlibSectionInfo::unpack(envelope *cb_env,
         int dest_proc = ComlibGetLastKnown(destArrayID, idx);
         //CkArrayID::CkLocalBranch(destArrayID)->lastKnown(idx);
         
-        if(dest_proc == CkMyPe())
-            dest_indices->insertAtEnd(idx);                        
+        //        if(dest_proc == CkMyPe())
+        dest_indices.insertAtEnd(idx);                        
     }            
     
     envelope *usrenv = (envelope *) ccmsg->usrMsg;
@@ -92,34 +86,95 @@ void ComlibSectionInfo::processOldSectionMessage(CharmMessageHolder *cmsg) {
     cbmsg->_cookie.sInfo.cInfo.status = COMLIB_MULTICAST_OLD_SECTION;
 }
 
-void ComlibSectionInfo::initSectionID(CkSectionID *sid){
+void ComlibSectionInfo::getPeList(int _nElems, 
+                                  CkArrayIndexMax *_elems, 
+                                  int &npes, int *&pelist){
     
-    if(sid->npes > 0) 
-        return;
-
-    sid->pelist = new int[CkNumPes()];
-    sid->npes = 0;
+    int length = CkNumPes();
+    if(length > _nElems)    //There will not be more processors than
+                            //number of elements. This is wastage of
+                            //memory as there may be fewer
+                            //processors. Fix later.
+        length = _nElems;
+    
+    pelist = new int[length];
+    npes = 0;
     
     int count = 0, acount = 0;
+    
+    for(acount = 0; acount < _nElems; acount++){
+        
+        int p = ComlibGetLastKnown(destArrayID, _elems[acount]);
+        
+        if(p == -1) CkAbort("Invalid Section\n");        
+        for(count = 0; count < npes; count ++)
+            if(pelist[count] == p)
+                break;
+        
+        if(count == npes) {
+            pelist[npes ++] = p;
+        }
+    }   
+
+    if(npes == 0) {
+        delete pelist;
+        pelist = NULL;
+    }
+}
+
 
-    for(acount = 0; acount < sid->_nElems; acount++){
+void ComlibSectionInfo::getRemotePelist(int nindices, 
+                                        CkArrayIndexMax *idxlist, 
+                                        int &npes, int *&pelist) {
 
-        int p = ComlibGetLastKnown(destArrayID, sid->_elems[acount]);
-        //CkArrayID::CkLocalBranch(destArrayID)->
-        //lastKnown(sid->_elems[acount]);
+    int count = 0, acount = 0;
+    
+    int length = CkNumPes();
+    if(length > nindices)
+        length = nindices;
+    
+    pelist = new int[length];
+    npes = 0;
+
+    for(acount = 0; acount < nindices; acount++){
+        
+        int p = ComlibGetLastKnown(destArrayID, idxlist[acount]);
+        if(p == CkMyPe())
+            continue;
         
         if(p == -1) CkAbort("Invalid Section\n");        
-        for(count = 0; count < sid->npes; count ++)
-            if(sid->pelist[count] == p)
+        
+        //Collect remote processors
+        for(count = 0; count < npes; count ++)
+            if(pelist[count] == p)
                 break;
         
-        if(count == sid->npes) {
-            sid->pelist[sid->npes ++] = p;
+        if(count == npes) {
+            pelist[npes ++] = p;
         }
-    }   
+    }
+    
+    if(npes == 0) {
+        delete pelist;
+        pelist = NULL;
+    }
+}
+
+
+void ComlibSectionInfo::getLocalIndices(int nindices, 
+                                        CkArrayIndexMax *idxlist, 
+                                        CkVec<CkArrayIndexMax> &idx_vec){    
+    int count = 0, acount = 0;
+    idx_vec.resize(0);
+    
+    for(acount = 0; acount < nindices; acount++){
+        int p = ComlibGetLastKnown(destArrayID, idxlist[acount]);
+        if(p == CkMyPe()) 
+            idx_vec.insertAtEnd(idxlist[acount]);
+    }
 }
 
+
 void ComlibSectionInfo::localMulticast(envelope *env){
     ComlibArrayInfo::localMulticast(&localDestIndexVec, env);
 }
-
index 52d884355edca2d51724d0a82735f160129d5e98..1b28ecbbd7aeff3e787ed2de3361b7f15ae252ce 100644 (file)
@@ -71,6 +71,27 @@ inline CkHashCode ComlibSectionHashKey::staticHash(const void *v,size_t){
 /*************** End CkHashtable Functions *****************/
 
 
+
+class ComlibSectionHashObject {
+ public:
+    //My local indices
+    CkVec<CkArrayIndexMax> indices;
+    
+    //Other processors to send this message to
+    int npes;
+    int *pelist;
+    
+    ComlibSectionHashObject(): indices(0) {
+        npes = 0;
+        pelist = NULL;
+    }
+
+    ~ComlibSectionHashObject() {
+        delete pelist;
+    }
+};
+
+
 /*** Class that helps a communication library strategy manage array
      sections
 ***************/
@@ -101,23 +122,38 @@ class ComlibSectionInfo {
         MaxSectionID = 1;
     }
     
-    void initSectionID(CkSectionID *sid);
+    inline void initSectionID(CkSectionID *sid) {
+        sid->_cookie.sInfo.cInfo.id = MaxSectionID ++;            
+    }
     
     void processOldSectionMessage(CharmMessageHolder *cmsg);
 
     ComlibMulticastMsg *getNewMulticastMessage(CharmMessageHolder *cmsg);
 
-    void unpack(envelope *cb_env, CkVec<CkArrayIndexMax> *&destIndices, 
+    void unpack(envelope *cb_env, CkVec<CkArrayIndexMax> &destIndices, 
                 envelope *&env);
 
     void localMulticast(envelope *env);
 
+    void getRemotePelist(int nindices, CkArrayIndexMax *idxlist, 
+                         int &npes, int *&pelist);
+
+    void getPeList(int nindices, CkArrayIndexMax *idxlist, 
+                   int &npes, int *&pelist);
+
+    void getLocalIndices(int nindices, CkArrayIndexMax *idxlist, 
+                         CkVec<CkArrayIndexMax> &idx_vec);   
+        
     static inline int getSectionID(CkSectionID id) {
         return id._cookie.sInfo.cInfo.id;
     }
-    
-};
 
-PUPbytes(ComlibSectionInfo);
+    void pup(PUP::er &p) {
+        p | destArrayID;
+        p | MaxSectionID;
+        p | instanceID;
+        p | localDestIndexVec;
+    }
+};
 
 #endif
index a0b7de995cb41221aeceec6eb42060dc630c205d..b9eb697abeb0939e68af796912a324ed31d79943 100644 (file)
@@ -23,6 +23,7 @@ void CharmStrategy::pup(PUP::er &p) {
     p | ginfo;
     p | ainfo;
     p | forwardOnMigration;
+    p | mflag;
 }
 
 CharmMessageHolder::CharmMessageHolder(char * msg, int proc) 
@@ -457,9 +458,10 @@ void ComlibArrayInfo::localMulticast(CkVec<CkArrayIndexMax>*vec,
     env->getsetArrayHops()=1;
     env->setUsed(0);
 
-    for(int count = 0; count < nelements; count ++){
-        CkArrayIndexMax idx = (*vec)[count];
-        
+    CkArrayIndexMax idx;
+    
+    for(int count = 0; count < nelements-1; count ++){
+        idx = (*vec)[count];
         //if(comm_debug) idx.print();
 
         env->getsetArrayIndex() = idx;
@@ -474,7 +476,17 @@ void ComlibArrayInfo::localMulticast(CkVec<CkArrayIndexMax>*vec,
 
     }
 
-    CmiFree(env);
+    idx = (*vec)[nelements-1];
+    //if(comm_debug) idx.print();
+    env->getsetArrayIndex() = idx;
+    
+    CkArray *a=(CkArray *)_localBranch(dest_aid);
+    if(_entryTable[ep]->noKeep) {
+        a->deliver((CkArrayMessage *)msg, CkDeliver_inline, CK_MSG_KEEP);
+        CmiFree(env);
+    }
+    else
+        a->deliver((CkArrayMessage *)msg, CkDeliver_queue);
 }
 
 /* Delivers a message to an array element, making sure that
index b4f64c890beeeeb56959fd7ed0c349be8f208c9c..53831745096de78b5e0e4def113b4c8d8e51ade3 100644 (file)
@@ -63,7 +63,7 @@ inline int ClibGlobalArrayIndex::compare(const ClibGlobalArrayIndex &k2) const
 inline int ClibGlobalArrayIndex::staticCompare(const void *k1, const void *k2, 
                                                 size_t ){
     return ((const ClibGlobalArrayIndex *)k1)->
-                compare(*(const ClibGlobalArrayIndex *)k2);
+        compare(*(const ClibGlobalArrayIndex *)k2);
 }
 
 inline CkHashCode ClibGlobalArrayIndex::staticHash(const void *v,size_t){
@@ -190,6 +190,7 @@ class CharmStrategy : public Strategy {
  protected:
     int forwardOnMigration;
     ComlibLearner *learner;
+    CmiBool mflag;    //Does this strategy handle point-to-point or 
 
  public:
     ComlibGroupInfo ginfo;
@@ -203,26 +204,33 @@ class CharmStrategy : public Strategy {
         setType(GROUP_STRATEGY); 
         forwardOnMigration = 0;
         learner = NULL;
+        mflag = CmiFalse;
     }
 
     CharmStrategy(CkMigrateMessage *m) : Strategy(m){
         learner = NULL;
     }
 
+    //Set flag to optimize strategy for 
+    inline void setMulticast(){
+        mflag = CmiTrue;
+    }
+
+    //get the multicast flag
+    CmiBool getMulticast () {
+        return mflag;
+    }
+
     //Called for each message
     //Function inserts a Charm++ message
     virtual void insertMessage(CharmMessageHolder *msg) {
-      CkAbort("Bummer Should Not come here:CharmStrategy is abstract\n");
+        CkAbort("Bummer Should Not come here:CharmStrategy is abstract\n");
     }
 
     //Removed the virtual!
     //Charm strategies should not use Message Holder
     void insertMessage(MessageHolder *msg);
     
-    //Called after all chares and groups have finished depositing their 
-    //messages on that processor.
-    // DUPLICATED virtual void doneInserting() {}
-
     //Added a new call that is called after the strategy had be
     //created on every processor.
     //DOES NOT exist in Converse Strategies
index efae04e7113d316affdb989f6893de9645e7a5cd..9f985b24ef702262d2a8f02d6f41985b1352bfad 100644 (file)
@@ -1,5 +1,21 @@
+
+/********************************************************
+        Section multicast strategy suite. DirectMulticast and its
+        derivatives, multicast messages to a section of array elements
+        created on the fly. The section is invoked by calling a
+        section proxy. These strategies can also multicast to a subset
+        of processors for groups.
+
+        These strategies are non-bracketed. When the first request is
+        made a route is dynamically built on the section. The route
+        information is stored in
+
+ - Sameer Kumar
+
+**********************************************/
+
+
 #include "DirectMulticastStrategy.h"
-#include "AAMLearner.h"
 
 CkpvExtern(CkGroupID, cmgrID);
 
@@ -13,60 +29,24 @@ void *DMHandler(void *msg){
     nm_mgr = (DirectMulticastStrategy *) 
         CProxy_ComlibManager(CkpvAccess(cmgrID)).
         ckLocalBranch()->getStrategy(instid);
-
+    
     envelope *env = (envelope *) msg;
     RECORD_RECV_STATS(instid, env->getTotalsize(), env->getSrcPe());
     nm_mgr->handleMulticastMessage(msg);
     return NULL;
 }
 
-//Group Constructor
-DirectMulticastStrategy::DirectMulticastStrategy(int ndest, int *pelist)
-    : CharmStrategy() {
-    setType(GROUP_STRATEGY);
-    
-    ndestpes = ndest;
-    destpelist = pelist;
-
-    commonInit();
-}
-
 DirectMulticastStrategy::DirectMulticastStrategy(CkArrayID aid)
     :  CharmStrategy() {
 
-    //ainfo.setSourceArray(aid);
     ainfo.setDestinationArray(aid);
     setType(ARRAY_STRATEGY);
-    ndestpes = 0;
-    destpelist = 0;
-    commonInit();
-}
-
-DirectMulticastStrategy::DirectMulticastStrategy(CkArrayID said, CkArrayID daid)
-    :  CharmStrategy() {
-
-    ainfo.setSourceArray(said);
-    ainfo.setDestinationArray(daid);
-    setType(ARRAY_STRATEGY);
-    ndestpes = 0;
-    destpelist = 0;
-    commonInit();
-}
-
-void DirectMulticastStrategy::commonInit(){
-
-    if(ndestpes == 0) {
-        ndestpes = CkNumPes();
-        destpelist = new int[CkNumPes()];
-        for(int count = 0; count < CkNumPes(); count ++)
-            destpelist[count] = count;        
-    }
 }
 
+//Destroy all old built routes
 DirectMulticastStrategy::~DirectMulticastStrategy() {
-    if(ndestpes > 0)
-        delete [] destpelist;
+    
+    ComlibPrintf("Calling Distructor\n");
 
     if(getLearner() != NULL)
         delete getLearner();
@@ -76,140 +56,154 @@ DirectMulticastStrategy::~DirectMulticastStrategy() {
     while(ht_iterator->hasNext()){
         void **data;
         data = (void **)ht_iterator->next();        
-        CkVec<CkArrayIndexMax> *a_vec = (CkVec<CkArrayIndexMax> *) (* data);
-        if(a_vec != NULL)
-            delete a_vec;
+        ComlibSectionHashObject *obj = (ComlibSectionHashObject *) (* data);
+        if(obj != NULL)
+            delete obj;
     }
 }
 
 void DirectMulticastStrategy::insertMessage(CharmMessageHolder *cmsg){
-    if(messageBuf == NULL) {
-       CkPrintf("ERROR MESSAGE BUF IS NULL\n");
-       return;
-    }
-
-    ComlibPrintf("[%d] Comlib Direct Multicast: insertMessage \n", 
+    
+    ComlibPrintf("[%d] Comlib Direct Section Multicast: insertMessage \n", 
                  CkMyPe());   
-   
-    if(cmsg->dest_proc == IS_BROADCAST) {
-        void *m = cmsg->getCharmMessage();
-        CkSectionInfo minfo;
-        minfo.type = COMLIB_MULTICAST_MESSAGE;
-        minfo.sInfo.cInfo.instId = getInstance();
-        minfo.sInfo.cInfo.status = COMLIB_MULTICAST_ALL;  
-        minfo.sInfo.cInfo.id = 0; 
-        minfo.pe = CkMyPe();
-        ((CkMcastBaseMsg *)m)->_cookie = minfo;       
-    }
 
     if(cmsg->dest_proc == IS_SECTION_MULTICAST && cmsg->sec_id != NULL) { 
-        int cur_sec_id = ComlibSectionInfo::getSectionID(*cmsg->sec_id);
-
+        CkSectionID *sid = cmsg->sec_id;
+        int cur_sec_id = ComlibSectionInfo::getSectionID(*sid);
+        
         if(cur_sec_id > 0) {        
-            sinfo.processOldSectionMessage(cmsg);
-        }
-        else {
-            CkSectionID *sid = cmsg->sec_id;
+            sinfo.processOldSectionMessage(cmsg);            
+            
+            ComlibSectionHashKey 
+                key(CkMyPe(), sid->_cookie.sInfo.cInfo.id);        
+            ComlibSectionHashObject *obj = sec_ht.get(key);
 
+            if(obj == NULL)
+                CkAbort("Cannot Find Section\n");
+
+            envelope *env = UsrToEnv(cmsg->getCharmMessage());
+            localMulticast(env, obj);
+            remoteMulticast(env, obj);
+        }
+        else {            
             //New sec id, so send it along with the message
             void *newmsg = sinfo.getNewMulticastMessage(cmsg);
-            CkFreeMsg(cmsg->getCharmMessage());
-            delete cmsg;
+            insertSectionID(sid);
+
+            ComlibSectionHashKey 
+                key(CkMyPe(), sid->_cookie.sInfo.cInfo.id);        
             
-            sinfo.initSectionID(sid);
+            ComlibSectionHashObject *obj = sec_ht.get(key);
 
-            cmsg = new CharmMessageHolder((char *)newmsg, 
-                                          IS_SECTION_MULTICAST); 
-            cmsg->sec_id = sid;
+            if(obj == NULL)
+                CkAbort("Cannot Find Section\n");
+            
+            char *msg = cmsg->getCharmMessage();
+            localMulticast(UsrToEnv(msg), obj);
+            CkFreeMsg(msg);
+            
+            remoteMulticast(UsrToEnv(newmsg), obj);
         }        
     }
-   
-    messageBuf->enq(cmsg);
-    if(!isBracketed())
-        doneInserting();
+    else 
+        CkAbort("Section multicast cannot be used without a section proxy");
+
+    delete cmsg;       
 }
 
-void DirectMulticastStrategy::doneInserting(){
-    ComlibPrintf("%d: DoneInserting \n", CkMyPe());
+void DirectMulticastStrategy::insertSectionID(CkSectionID *sid) {
     
-    if(messageBuf->length() == 0) {
-        return;
-    }
+    ComlibSectionHashKey 
+        key(CkMyPe(), sid->_cookie.sInfo.cInfo.id);
 
-    while(!messageBuf->isEmpty()) {
-       CharmMessageHolder *cmsg = messageBuf->deq();
-        char *msg = cmsg->getCharmMessage();
-               
-        if(cmsg->dest_proc == IS_SECTION_MULTICAST || 
-           cmsg->dest_proc == IS_BROADCAST) {      
+    ComlibSectionHashObject *obj = NULL;    
+    obj = sec_ht.get(key);
+    
+    if(obj != NULL)
+        delete obj;
+    
+    obj = createObjectOnSrcPe(sid->_nElems, sid->_elems);
+    sec_ht.put(key) = obj;
+}
 
-            if(getType() == ARRAY_STRATEGY)
-                CmiSetHandler(UsrToEnv(msg), handlerId);
-            
-            int *cur_map = destpelist;
-            int cur_npes = ndestpes;
-            if(cmsg->sec_id != NULL && cmsg->sec_id->pelist != NULL) {
-                cur_map = cmsg->sec_id->pelist;
-                cur_npes = cmsg->sec_id->npes;
-            }
-            
-            //Collect Multicast Statistics
-            RECORD_SENDM_STATS(getInstance(), 
-                               ((envelope *)cmsg->getMessage())->getTotalsize(), 
-                               cur_map, cur_npes);
 
+ComlibSectionHashObject *DirectMulticastStrategy::createObjectOnSrcPe
+(int nindices, CkArrayIndexMax *idxlist) {
+
+    ComlibSectionHashObject *obj = new ComlibSectionHashObject();
+    
+    sinfo.getRemotePelist(nindices, idxlist, obj->npes, obj->pelist);
+    sinfo.getLocalIndices(nindices, idxlist, obj->indices);
+    
+    return obj;
+}
 
-            ComlibPrintf("[%d] Calling Direct Multicast %d %d %d\n", CkMyPe(),
-                         UsrToEnv(msg)->getTotalsize(), cur_npes, 
-                         cmsg->dest_proc);
 
-            /*
-              for(int i=0; i < cur_npes; i++)
-              CkPrintf("[%d] Sending to %d %d\n", CkMyPe(), 
-              cur_map[i], cur_npes);
-            */
+ComlibSectionHashObject *DirectMulticastStrategy::
+createObjectOnIntermediatePe(int nindices, CkArrayIndexMax *idxlist, 
+                             int srcpe){
 
-            CmiSyncListSendAndFree(cur_npes, cur_map, 
-                                   UsrToEnv(msg)->getTotalsize(), 
-                                   (char*)(UsrToEnv(msg)));            
-        }
-        else {
-            //CkPrintf("SHOULD NOT BE HERE\n");
-            CmiSyncSendAndFree(cmsg->dest_proc, 
-                               UsrToEnv(msg)->getTotalsize(), 
-                               (char *)UsrToEnv(msg));
-        }        
+    ComlibSectionHashObject *obj = new ComlibSectionHashObject();
         
-       delete cmsg; 
-    }
+    obj->pelist = 0;
+    obj->npes = 0;
+    
+    sinfo.getLocalIndices(nindices, idxlist, obj->indices);
+
+    return obj;
 }
 
-void DirectMulticastStrategy::pup(PUP::er &p){
 
-    CharmStrategy::pup(p);
+void DirectMulticastStrategy::doneInserting(){
+    //Do nothing! Its a bracketed strategy
+}
 
-    p | ndestpes;
-    if(p.isUnpacking() && ndestpes > 0)
-        destpelist = new int[ndestpes];
-    
-    p(destpelist, ndestpes);        
+//Send the multicast message the local array elements. The message is 
+//copied and sent if elements exist. 
+void DirectMulticastStrategy::localMulticast(envelope *env, 
+                                             ComlibSectionHashObject *obj) {
+    int nIndices = obj->indices.size();
     
-    if(p.isUnpacking()) {
-        CkArrayID src;
-        int nidx;
-        CkArrayIndexMax *idx_list;     
-        ainfo.getSourceArray(src, idx_list, nidx);
+    if(nIndices > 0) {
+        void *msg = EnvToUsr(env);
+        void *msg1 = msg;
         
-        if(!src.isZero()) {
-            AAMLearner *l = new AAMLearner();
-            setLearner(l);
-        }
+        msg1 = CkCopyMsg(&msg);
+        ComlibArrayInfo::localMulticast(&(obj->indices), UsrToEnv(msg1));
+    }    
+}
+
+
+//Calls default multicast scheme to send the messages. It could 
+//also call a converse lower level strategy to do the muiticast.
+//For example pipelined multicast
+void DirectMulticastStrategy::remoteMulticast(envelope *env, 
+                                              ComlibSectionHashObject *obj) {
+    
+    int npes = obj->npes;
+    int *pelist = obj->pelist;
+    
+    if(npes == 0) {
+        CmiFree(env);
+        return;    
     }
+    
+    CmiSetHandler(env, handlerId);
+
+    //Collect Multicast Statistics
+    RECORD_SENDM_STATS(getInstance(), env->getTotalsize(), pelist, npes);
+    
+    //Sending a remote multicast
+    CmiSyncListSendAndFree(npes, pelist, env->getTotalsize(), (char*)env);
+}
+
+void DirectMulticastStrategy::pup(PUP::er &p){
+
+    CharmStrategy::pup(p);
 }
 
 void DirectMulticastStrategy::beginProcessing(int numElements){
     
-    messageBuf = new CkQ<CharmMessageHolder *>;    
     handlerId = CkRegisterHandler((CmiHandler)DMHandler);    
     
     CkArrayID dest;
@@ -218,46 +212,82 @@ void DirectMulticastStrategy::beginProcessing(int numElements){
 
     ainfo.getDestinationArray(dest, idx_list, nidx);
     sinfo = ComlibSectionInfo(dest, myInstanceID);
+
+    ComlibLearner *learner = new ComlibLearner();
+    setLearner(learner);
 }
 
 void DirectMulticastStrategy::handleMulticastMessage(void *msg){
     register envelope *env = (envelope *)msg;
-    
-    CkMcastBaseMsg *cbmsg = (CkMcastBaseMsg *)EnvToUsr(env);
 
+    //Section multicast base message
+    CkMcastBaseMsg *cbmsg = (CkMcastBaseMsg *)EnvToUsr(env);
+    
     int status = cbmsg->_cookie.sInfo.cInfo.status;
-    ComlibPrintf("[%d] In local multicast %d\n", CkMyPe(), status);
+    ComlibPrintf("[%d] In handleMulticastMessage %d\n", CkMyPe(), status);
     
-    CkVec<CkArrayIndexMax> *dest_indices; 
-    if(status == COMLIB_MULTICAST_ALL) {        
-        ainfo.localBroadcast(env);
-    }   
-    else if(status == COMLIB_MULTICAST_NEW_SECTION){        
-        CkUnpackMessage(&env);
-        envelope *newenv;
-        sinfo.unpack(env, dest_indices, newenv);
-        ComlibArrayInfo::localMulticast(dest_indices, newenv);
-
-        CkVec<CkArrayIndexMax> *old_dest_indices;
-        ComlibSectionHashKey key(cbmsg->_cookie.pe, 
-                                 cbmsg->_cookie.sInfo.cInfo.id);
-
-        old_dest_indices = (CkVec<CkArrayIndexMax> *)sec_ht.get(key);
-        if(old_dest_indices != NULL)
-            delete old_dest_indices;
-        
-        sec_ht.put(key) = dest_indices;
-        CmiFree(env);                
-    }
+    if(status == COMLIB_MULTICAST_NEW_SECTION)
+        handleNewMulticastMessage(env);
     else {
         //status == COMLIB_MULTICAST_OLD_SECTION, use the cached section id
         ComlibSectionHashKey key(cbmsg->_cookie.pe, 
                                  cbmsg->_cookie.sInfo.cInfo.id);    
-        dest_indices = (CkVec<CkArrayIndexMax> *)sec_ht.get(key);
         
-        if(dest_indices == NULL)
+        ComlibSectionHashObject *obj;
+        obj = sec_ht.get(key);
+        
+        if(obj == NULL)
             CkAbort("Destination indices is NULL\n");
         
-        ComlibArrayInfo::localMulticast(dest_indices, env);
+        localMulticast(env, obj);
+        remoteMulticast(env, obj);
     }
 }
+
+
+void DirectMulticastStrategy::handleNewMulticastMessage(envelope *env) {
+
+    ComlibPrintf("%d : In handleNewMulticastMessage\n", CkMyPe());
+
+    CkUnpackMessage(&env);    
+    
+    envelope *newenv;
+    CkVec<CkArrayIndexMax> idx_list;    
+    
+    sinfo.unpack(env, idx_list, newenv);
+
+    ComlibMulticastMsg *cbmsg = (ComlibMulticastMsg *)EnvToUsr(env);
+    ComlibSectionHashKey key(cbmsg->_cookie.pe, 
+                             cbmsg->_cookie.sInfo.cInfo.id);
+    
+    ComlibSectionHashObject *old_obj = NULL;
+    
+    old_obj = sec_ht.get(key);
+    if(old_obj != NULL)
+        delete old_obj;
+
+    
+    CkArrayIndexMax *idx_list_array = new CkArrayIndexMax[idx_list.size()];
+    for(int count = 0; count < idx_list.size(); count++)
+        idx_list_array[count] = idx_list[count];
+
+    ComlibSectionHashObject *new_obj = createObjectOnIntermediatePe
+        (idx_list.size(), idx_list_array, cbmsg->_cookie.pe);
+
+    delete idx_list_array;
+    
+    sec_ht.put(key) = new_obj;
+
+    if(new_obj->npes > 0) {
+        CkPackMessage(&env);
+        CmiSyncListSendAndFree(new_obj->npes, new_obj->pelist, 
+                               env->getTotalsize(), (char*)env);  
+    }
+    else        
+        CmiFree(env);                
+    
+    if(new_obj->indices.size() > 0)
+        ComlibArrayInfo::localMulticast(&(new_obj->indices), newenv);    
+    else        
+        CmiFree(newenv);                
+}
index 941f41ca4e6dbc778b3ad363dfb1997ddce870f7..135788c68686697b287eb432e0ceaed7324f6aff 100644 (file)
@@ -8,31 +8,43 @@ void *DMHandler(void *msg);
 
 class DirectMulticastStrategy: public CharmStrategy {
  protected:
-    CkQ <CharmMessageHolder*> *messageBuf;
-    
-    int ndestpes, *destpelist; //Destination processors
-    int handlerId;
-    
+    int handlerId;    
     ComlibSectionInfo sinfo;
     
     //Array section support
-    CkHashtableT<ComlibSectionHashKey, void *> sec_ht; 
+    CkHashtableT<ComlibSectionHashKey, ComlibSectionHashObject *> sec_ht; 
     
-    //Common Initializer for group and array constructors
-    //Every substrategy should implement its own
-    void commonInit();
+    //Add this section to the hash table locally
+    void insertSectionID(CkSectionID *sid);
+
+    //Called when a new section multicast is called by the user locally.
+    //The strategy should then create a topology for it and 
+    //return a hash object to store that topology
+    virtual ComlibSectionHashObject *createObjectOnSrcPe
+        (int nindices, CkArrayIndexMax *idx_list);
+   
+    //Similar to createHashObjectOnSrcPe, but that this call 
+    //is made on the destination or intermediate processor
+    virtual ComlibSectionHashObject *createObjectOnIntermediatePe
+        (int nindices, CkArrayIndexMax *idx_list, int srcpe);
+        
+    //Called to multicast the message to local array elements
+    void localMulticast(envelope *env, ComlibSectionHashObject *obj);
     
+    //Called to send to message out to the remote destinations
+    //This method can be overridden to call converse level strategies 
+    virtual void remoteMulticast(envelope *env, ComlibSectionHashObject *obj);
+
+    //Process a new message by extracting the array elements 
+    //from it and creating a new hash object by calling createObjectOnIntermediatePe();
+    void handleNewMulticastMessage(envelope *env);
+
  public:
-    
-    //Group constructor
-    DirectMulticastStrategy(int ndestpes = 0, int *destpelist = 0);    
+
     DirectMulticastStrategy(CkMigrateMessage *m): CharmStrategy(m){}
                 
     //Array constructor
     DirectMulticastStrategy(CkArrayID aid);
-
-    //Array constructor
-    DirectMulticastStrategy(CkArrayID said, CkArrayID dest);
         
     //Destuctor
     ~DirectMulticastStrategy();
@@ -41,8 +53,8 @@ class DirectMulticastStrategy: public CharmStrategy {
     virtual void doneInserting();
 
     //Called by the converse handler function
-    virtual void handleMulticastMessage(void *msg);
-    
+    void handleMulticastMessage(void *msg);    
+
     virtual void pup(PUP::er &p);    
     virtual void beginProcessing(int nelements);
     
index a63b557fb8cb633d2bc189871d71c1f4b0c384e8..054ca56c7dd9be4d5adf514a48e87c9dea3b0272 100644 (file)
@@ -1,4 +1,19 @@
 
+/*********************************************************
+            The EachToManyMulticast Strategy optimizes all-to-all
+            communication. It combines messages and sends them along
+            virtual topologies 2d mesh, 3d mesh and hypercube.
+
+            For large messages send them directly.
+
+            This is the object level strategy. For processor level
+            optimizations routers are called.
+
+  - Sameer Kumar.
+
+**********************************************************/
+
+
 #include "EachToManyMulticastStrategy.h"
 #include "string.h"
 #include "routerstrategy.h"
@@ -17,7 +32,7 @@ void *itrDoneHandler(void *msg){
     DummyMsg *dmsg = (DummyMsg *)msg;
     comID id = dmsg->id;
     int instid = id.instanceID;
-
+    
     CmiFree(msg);
     ComlibPrintf("[%d] Iteration finished %d\n", CkMyPe(), instid);
 
@@ -38,10 +53,11 @@ void *itrDoneHandler(void *msg){
 void *E2MHandler(void *msg){
     //CkPrintf("[%d]:In EachtoMany CallbackHandler\n", CkMyPe());
     EachToManyMulticastStrategy *nm_mgr;    
+    
+    CmiMsgHeaderExt *conv_header = (CmiMsgHeaderExt *) msg;
+    int instid = conv_header->stratid;
 
     envelope *env = (envelope *)msg;
-    CkMcastBaseMsg *bmsg = (CkMcastBaseMsg *)EnvToUsr(env);
-    int instid = bmsg->_cookie.sInfo.cInfo.instId;
     
     nm_mgr = (EachToManyMulticastStrategy *) 
         CProxy_ComlibManager(CkpvAccess(cmgrID)).
@@ -68,7 +84,7 @@ EachToManyMulticastStrategy::EachToManyMulticastStrategy(int substrategy,
     ginfo.setSourceGroup(gid, src_pelist, n_srcpes);    
     ginfo.setDestinationGroup(gid, dest_pelist, n_destpes);
 
-    //Written in this funny way to be symettric with the array case.
+    //Written in this funny way to be symmetric with the array case.
     ginfo.getDestinationGroup(gid, destpelist, ndestpes);
     ginfo.getCombinedPeList(pelist, npes);
 
@@ -115,8 +131,6 @@ void EachToManyMulticastStrategy::commonInit() {
     setBracketed();
     setForwardOnMigration(1);
 
-    mflag = CmiFalse;
-
     if(CkMyPe() == 0 && router != NULL){
         if(strcmp(router, "USE_MESH") == 0)
             routerID = USE_MESH;
@@ -126,6 +140,10 @@ void EachToManyMulticastStrategy::commonInit() {
             routerID = USE_HYPERCUBE;
         else  if(strcmp(router, "USE_DIRECT") == 0)
             routerID = USE_DIRECT;        
+
+        //Just for the first step. After learning the learned
+        //strategies will be chosen
+        router = NULL;
     }
     
     ComlibPrintf("Creating Strategy %d\n", routerID);
@@ -134,15 +152,6 @@ void EachToManyMulticastStrategy::commonInit() {
 }
 
 EachToManyMulticastStrategy::~EachToManyMulticastStrategy() {
-    CkHashtableIterator *ht_iterator = sec_ht.iterator();
-    ht_iterator->seekStart();
-    while(ht_iterator->hasNext()){
-        void **data;
-        data = (void **)ht_iterator->next();        
-        CkVec<CkArrayIndexMax> *a_vec = (CkVec<CkArrayIndexMax> *) (* data);
-        if(a_vec != NULL)
-            delete a_vec;
-    }
 }
 
 
@@ -151,79 +160,31 @@ void EachToManyMulticastStrategy::insertMessage(CharmMessageHolder *cmsg){
     ComlibPrintf("[%d] EachToManyMulticast: insertMessage \n", 
                  CkMyPe());   
 
-    if(cmsg->dest_proc == IS_SECTION_MULTICAST && cmsg->sec_id != NULL) { 
-        int cur_sec_id = ComlibSectionInfo::getSectionID(*cmsg->sec_id);
-
-        if(cur_sec_id > 0) {        
-            sinfo.processOldSectionMessage(cmsg);
-        }
-        else {
-            //New sec id, so send it along with the message
-            void *newmsg = sinfo.getNewMulticastMessage(cmsg);
-            CkFreeMsg(cmsg->getCharmMessage());
-            CkSectionID *sid = cmsg->sec_id;
-            delete cmsg;
-            
-            cmsg = new CharmMessageHolder((char *)newmsg,
-                                          IS_SECTION_MULTICAST); 
-            cmsg->sec_id = sid;
-            initSectionID(cmsg->sec_id);
-        }        
-
-        if(cmsg->sec_id != NULL && cmsg->sec_id->pelist != NULL) {
-            cmsg->pelist = cmsg->sec_id->pelist;
-            cmsg->npes = cmsg->sec_id->npes;
-        }        
-    }
+    envelope *env = UsrToEnv(cmsg->getCharmMessage());
 
     if(cmsg->dest_proc == IS_BROADCAST) {
+        //All to all multicast
+        
         cmsg->npes = ndestpes;
         cmsg->pelist = destpelist;
-
-        //Added write now as a move from ComlibManager::ArrayBroadcast
-        void *m = cmsg->getCharmMessage();
-        CkSectionInfo minfo;
-        minfo.type = COMLIB_MULTICAST_MESSAGE;
-        minfo.sInfo.cInfo.instId = getInstance();
-        minfo.sInfo.cInfo.status = COMLIB_MULTICAST_ALL;  
-        minfo.sInfo.cInfo.id = 0; 
-        minfo.pe = CkMyPe();
-        ((CkMcastBaseMsg *)m)->_cookie = minfo;       
-    }
-
-    //For section multicasts and broadcasts
-    if(cmsg->dest_proc == IS_SECTION_MULTICAST 
-       || cmsg->dest_proc == IS_BROADCAST ) {
         
         //Use Multicast Learner (Foobar will not work for combinations
         //of personalized and multicast messages
         
-        if(!mflag) {
-            ComlibLearner *l = getLearner();
-            if(l != NULL) {
-                delete l;
-                l = NULL;
-            }
-            
-            AAMLearner *alearner = new AAMLearner();
-            setLearner(alearner);
-            mflag = CmiTrue;
-        }
-
-        CmiSetHandler(UsrToEnv(cmsg->getCharmMessage()), handlerId);
+        CmiSetHandler(env, handlerId);
 
         //Collect Multicast Statistics
-        RECORD_SENDM_STATS(getInstance(), 
-                           ((envelope *)cmsg->getMessage())->getTotalsize(), 
+        RECORD_SENDM_STATS(getInstance(), env->getTotalsize(), 
                            cmsg->pelist, cmsg->npes);
     }
     else {
+        //All to all personalized
+
         //Collect Statistics
-        RECORD_SEND_STATS(getInstance(), 
-                          ((envelope *)cmsg->getMessage())->getTotalsize(), 
+        RECORD_SEND_STATS(getInstance(), env->getTotalsize(), 
                           cmsg->dest_proc);
-    }
-    
+    }        
+
     rstrat->insertMessage(cmsg);
 }
 
@@ -233,10 +194,10 @@ void EachToManyMulticastStrategy::doneInserting(){
         CProxy_ComlibManager(CkpvAccess(cmgrID)).ckLocalBranch()
         ->getStrategyTableEntry(getInstance());
     int nexpected = sentry->numElements;
-
+    
     if(routerID == USE_DIRECT && nexpected == 0)
         return;
-
+    
     //ComlibPrintf("%d: DoneInserting \n", CkMyPe());    
     rstrat->doneInserting();
 }
@@ -251,7 +212,6 @@ void EachToManyMulticastStrategy::pup(PUP::er &p){
 
     p | routerID; 
     p | npes; p | ndestpes;     
-    p | mflag;
     
     if(p.isUnpacking() && npes > 0) {
         pelist = new int[npes];    
@@ -282,7 +242,7 @@ void EachToManyMulticastStrategy::pup(PUP::er &p){
 void EachToManyMulticastStrategy::beginProcessing(int numElements){
     
     ComlibPrintf("[%d] Begin processing %d\n", CkMyPe(), numElements);
-    
+    /*
     char dump[1000];
     char sdump[100];
     sprintf(dump, "%d: Each To MANY PELIST :\n", CkMyPe());
@@ -291,6 +251,7 @@ void EachToManyMulticastStrategy::beginProcessing(int numElements){
         strcat(dump, sdump);           
     }    
     ComlibPrintf("%s\n", dump);
+    */
 
     int expectedDeposits = 0;
 
@@ -298,7 +259,7 @@ void EachToManyMulticastStrategy::beginProcessing(int numElements){
 
     if(ainfo.isSourceArray()) 
         expectedDeposits = numElements;
-
+    
     if(getType() == GROUP_STRATEGY) {
         
         CkGroupID gid;
@@ -319,21 +280,15 @@ void EachToManyMulticastStrategy::beginProcessing(int numElements){
         sentry->numElements = expectedDeposits;
     }
     
-    CkArrayID dest;
-    int nidx;
-    CkArrayIndexMax *idx_list;
+    if(!mflag) 
+        setLearner(new AAPLearner());    
+    else 
+        setLearner(new AAMLearner());                
     
-    ainfo.getDestinationArray(dest, idx_list, nidx);
-    sinfo = ComlibSectionInfo(dest, myInstanceID);
-    
-    AAPLearner *alearner = new AAPLearner();
-    setLearner(alearner);
-
     if(expectedDeposits > 0)
         return;
     
     if(expectedDeposits == 0 && MyPe >= 0)
-        //doneInserting();
         ConvComlibScheduleDoneInserting(myInstanceID);
 }
 
@@ -351,59 +306,10 @@ void EachToManyMulticastStrategy::finalizeProcessing() {
         delete getLearner();
 }
 
-
 void EachToManyMulticastStrategy::localMulticast(void *msg){
     register envelope *env = (envelope *)msg;
     CkUnpackMessage(&env);
     
-    CkMcastBaseMsg *cbmsg = (CkMcastBaseMsg *)EnvToUsr(env);
-
-    int status = cbmsg->_cookie.sInfo.cInfo.status;
-    ComlibPrintf("[%d] In local multicast %d\n", CkMyPe(), status);
-        
-    if(status == COMLIB_MULTICAST_ALL) {        
-        ainfo.localBroadcast(env);
-        return;
-    }   
-
-    CkVec<CkArrayIndexMax> *dest_indices;    
-    if(status == COMLIB_MULTICAST_NEW_SECTION){        
-        envelope *newenv;
-        sinfo.unpack(env, dest_indices, newenv);        
-        ComlibArrayInfo::localMulticast(dest_indices, newenv);
-
-        CkVec<CkArrayIndexMax> *old_dest_indices;
-        ComlibSectionHashKey key(cbmsg->_cookie.pe, 
-                                 cbmsg->_cookie.sInfo.cInfo.id);
-
-        old_dest_indices = (CkVec<CkArrayIndexMax> *)sec_ht.get(key);
-        if(old_dest_indices != NULL)
-            delete old_dest_indices;
-        
-        sec_ht.put(key) = dest_indices;
-        CmiFree(env);
-        return;       
-    }
-
-    //status == COMLIB_MULTICAST_OLD_SECTION, use the cached section id
-    ComlibSectionHashKey key(cbmsg->_cookie.pe, 
-                             cbmsg->_cookie.sInfo.cInfo.id);    
-    dest_indices = (CkVec<CkArrayIndexMax> *)sec_ht.get(key);
-
-    if(dest_indices == NULL)
-        CkAbort("Destination indices is NULL\n");
-
-    ComlibArrayInfo::localMulticast(dest_indices, env);
+    ainfo.localBroadcast(env);
 }
 
-void EachToManyMulticastStrategy::initSectionID(CkSectionID *sid){
-
-    sinfo.initSectionID(sid);    
-
-    //Convert real processor numbers to virtual processors in the all
-    //to all multicast group
-    for(int count = 0; count < sid->npes; count ++) {
-        sid->pelist[count] = rstrat->getProcMap()[sid->pelist[count]]; 
-        if(sid->pelist[count] == -1) CkAbort("Invalid Section\n");
-    }
-}
index e31809bf627734cd35c4f9ba62283d75ec1b4b2b..13a63b3772382c0513e41b578ce3dfc2d6fbb716 100644 (file)
@@ -2,7 +2,6 @@
 #define EACH_TO_MANY_MULTICAST_STRATEGY
 
 #include "ComlibManager.h"
-#include "ComlibSectionInfo.h"
 #include "routerstrategy.h"
 
 class EachToManyMulticastStrategy: public CharmStrategy {
@@ -11,20 +10,13 @@ class EachToManyMulticastStrategy: public CharmStrategy {
     int npes, *pelist; //Domain of the topology
     int MyPe;          //My id in that domain
 
-    CmiBool mflag;
-
     int ndestpes, *destpelist; //Destination processors
     int handlerId;
     
-    //Dynamically set by the application
-    CkHashtableT<ComlibSectionHashKey, void *> sec_ht;
-
     //Executes common code just after array and group constructors
     virtual void commonInit();
-    virtual void initSectionID(CkSectionID *sid);
 
     RouterStrategy *rstrat;
-    ComlibSectionInfo sinfo;
 
  public:
     //Group constructor
index 2f1e266a623f5756f1bec0fcd386ff5dc6978031..82ccfe95e9f1a506fff6fea647ebb6b3a7584097 100644 (file)
@@ -89,6 +89,8 @@ void MPIStrategy::doneInserting(){
 }
 
 void MPIStrategy::pup(PUP::er &p) {
+    CharmStrategy::pup(p);
+
     p | messageCount;
     p | npes; 
        
index da223450797f5c40ed27a87d1577a4b9a34ea4b5..ba1b6b279bb6a9e1ee7767aed66856f7740f5866 100644 (file)
@@ -700,7 +700,7 @@ void MeshStreamingStrategy::pup (PUP::er &p)
   ComlibPrintf ("[%d] MeshStreamingStrategy::pup() invoked.\n", CkMyPe());
 
   // Call the superclass method -- easy.
-  Strategy::pup (p);
+  CharmStrategy::pup (p);
 
   // Pup the instance variables -- easy.
   p | num_pe;
index 44835bbcbc5bb9ed536c13c31fea61af70561b94..89e3187efa0fcdf04d6d364f7751afa45c859a5b 100644 (file)
-#include "RingMulticastStrategy.h"
 
-//Group Constructor
-RingMulticastStrategy::RingMulticastStrategy(int ndest, int *pelist) 
-    : DirectMulticastStrategy(ndest, pelist) {
-    commonRingInit();
-}
+#include "RingMulticastStrategy.h"
 
 //Array Constructor
 RingMulticastStrategy::RingMulticastStrategy(CkArrayID dest_aid)
     : DirectMulticastStrategy(dest_aid){
-    commonRingInit();    
-}
-
-//Array Constructor
-RingMulticastStrategy::RingMulticastStrategy(CkArrayID src, CkArrayID dest)
-    : DirectMulticastStrategy(src, dest){
-    commonRingInit();    
-}
-
-void RingMulticastStrategy::commonRingInit(){
-    //Sort destpelist
 }
 
 
-void RingMulticastStrategy::insertMessage(CharmMessageHolder *cmsg){
-    if(messageBuf == NULL) {
-       CkPrintf("ERROR MESSAGE BUF IS NULL\n");
-       return;
-    }
-    
-    ComlibPrintf("[%d] Comlib Direct Multicast: insertMessage \n", 
-                 CkMyPe());   
-    
-    if(cmsg->dest_proc == IS_BROADCAST) {
-        void *m = cmsg->getCharmMessage();
-        CkSectionInfo minfo;
-        minfo.type = COMLIB_MULTICAST_MESSAGE;
-        minfo.sInfo.cInfo.instId = getInstance();
-        minfo.sInfo.cInfo.status = COMLIB_MULTICAST_ALL;  
-        minfo.sInfo.cInfo.id = 0; 
-        minfo.pe = CkMyPe();
-        ((CkMcastBaseMsg *)m)->_cookie = minfo;       
-    }
-
-    if(cmsg->dest_proc == IS_SECTION_MULTICAST && cmsg->sec_id != NULL) { 
-        int cur_sec_id = ComlibSectionInfo::getSectionID(*cmsg->sec_id);
-
-        if(cur_sec_id > 0) {        
-            sinfo.processOldSectionMessage(cmsg);
-        }
-        else {
-            CkSectionID *sid = cmsg->sec_id;
-
-            //New sec id, so send it along with the message
-            void *newmsg = sinfo.getNewMulticastMessage(cmsg);
-            CkFreeMsg(cmsg->getCharmMessage());
-            delete cmsg;
-            
-            initSectionID(sid);
-            cmsg = new CharmMessageHolder((char *)newmsg, 
-                                          IS_SECTION_MULTICAST); 
-            cmsg->sec_id = sid;
-        }        
-    }
-    
-    messageBuf->enq(cmsg);
-    if(!isBracketed())
-        doneInserting();
-}
-
-extern int _charmHandlerIdx;
-void RingMulticastStrategy::doneInserting(){
-    ComlibPrintf("%d: DoneInserting \n", CkMyPe());
-    
-    if(messageBuf->length() == 0) {
-        return;
-    }
-
-    while(!messageBuf->isEmpty()) {
-       CharmMessageHolder *cmsg = messageBuf->deq();
-        char *msg = cmsg->getCharmMessage();
-        register envelope* env = UsrToEnv(msg);
-
-        ComlibPrintf("[%d] Calling Ring %d %d %d\n", CkMyPe(),
-                     env->getTotalsize(), ndestpes, cmsg->dest_proc);
-               
-        if(cmsg->dest_proc == IS_SECTION_MULTICAST ||
-           cmsg->dest_proc == IS_BROADCAST) {      
-            
-            CmiSetHandler(env, handlerId);
-            
-            int dest_pe = -1;
-            RingMulticastHashObject *robj;
-            
-            if(cmsg->sec_id == NULL)
-                dest_pe = nextPE;
-            else {
-                robj = getHashObject(CkMyPe(), 
-                                     cmsg->sec_id->_cookie.sInfo.cInfo.id);
-                
-                ComlibPrintf("Gotten has obect %d\n",  robj);                
-                CkAssert(robj != NULL);                
-                dest_pe = robj->nextPE;
-            }
-            
-            ComlibPrintf("[%d] Sending Message to %d\n", CkMyPe(), dest_pe);
-
-            if(dest_pe != -1)
-                CmiSyncSend(dest_pe, env->getTotalsize(), (char *)env); 
-            
-            if(getType() == ARRAY_STRATEGY) {
-                CmiSyncSendAndFree(CkMyPe(), env->getTotalsize(), (char *)env);
-            }
-            else {
-                CmiSetHandler(env, _charmHandlerIdx);
-                CmiSyncSendAndFree(CkMyPe(), env->getTotalsize(), (char *)env);
-            }
-        }
-        else {
-            CmiSyncSendAndFree(cmsg->dest_proc, UsrToEnv(msg)->getTotalsize(), 
-                               (char *)UsrToEnv(msg));
-        }        
-        
-       delete cmsg; 
-    }
-}
-
 void RingMulticastStrategy::pup(PUP::er &p){
 
     DirectMulticastStrategy::pup(p);
@@ -134,128 +15,21 @@ void RingMulticastStrategy::pup(PUP::er &p){
 void RingMulticastStrategy::beginProcessing(int  nelements){
 
     DirectMulticastStrategy::beginProcessing(nelements);
-
-    nextPE = -1;
-    if(ndestpes == 1)
-        return;
-
-    for(int count = 0; count < ndestpes; count++)
-        if(destpelist[count] > CkMyPe()) {
-            nextPE = destpelist[count];
-            break;
-        }
-    if(nextPE == -1)
-        nextPE = destpelist[0];
-}
-
-void RingMulticastStrategy::handleMulticastMessage(void *msg){
-    register envelope *env = (envelope *)msg;
-       
-    CkMcastBaseMsg *cbmsg = (CkMcastBaseMsg *)EnvToUsr(env);
-    int src_pe = cbmsg->_cookie.pe;
-    if(getType() == GROUP_STRATEGY){               
-
-        if(!isEndOfRing(nextPE, src_pe)) {
-            ComlibPrintf("[%d] Forwarding Message to %d\n", CkMyPe(), nextPE);
-            CmiSyncSend(nextPE, env->getTotalsize(), (char *)env);        
-        }
-        CmiSetHandler(env, _charmHandlerIdx);
-        CmiSyncSendAndFree(CkMyPe(), env->getTotalsize(), (char *)env);
-        
-        return;
-    }
-
-    int status = cbmsg->_cookie.sInfo.cInfo.status;
-    ComlibPrintf("[%d] In handle multicast message %d\n", CkMyPe(), status);
-
-    if(status == COMLIB_MULTICAST_ALL) {                        
-        if(src_pe != CkMyPe() && !isEndOfRing(nextPE, src_pe)) {
-            ComlibPrintf("[%d] Forwarding Message to %d\n", CkMyPe(), nextPE);
-            CmiSyncSend(nextPE, env->getTotalsize(), (char *)env); 
-        }
-
-        ainfo.localBroadcast(env);
-    }   
-    else if(status == COMLIB_MULTICAST_NEW_SECTION){        
-        CkUnpackMessage(&env);
-        ComlibPrintf("[%d] Received message for new section src=%d\n", 
-                     CkMyPe(), cbmsg->_cookie.pe);
-
-        ComlibMulticastMsg *ccmsg = (ComlibMulticastMsg *)cbmsg;
-        
-        RingMulticastHashObject *robj = 
-            createHashObject(ccmsg->nIndices, ccmsg->indices);
-        
-        envelope *usrenv = (envelope *) ccmsg->usrMsg;
-        
-        envelope *newenv = (envelope *)CmiAlloc(usrenv->getTotalsize());
-        memcpy(newenv, usrenv, usrenv->getTotalsize());
-
-        ComlibArrayInfo::localMulticast(&robj->indices, newenv);
-
-        ComlibSectionHashKey key(cbmsg->_cookie.pe, 
-                                 cbmsg->_cookie.sInfo.cInfo.id);
-
-        RingMulticastHashObject *old_robj = 
-            (RingMulticastHashObject*)sec_ht.get(key);
-        if(old_robj != NULL)
-            delete old_robj;
-        
-        sec_ht.put(key) = robj;
-
-        if(src_pe != CkMyPe() && !isEndOfRing(robj->nextPE, src_pe)) {
-            ComlibPrintf("[%d] Forwarding Message of %d to %d\n", CkMyPe(), 
-                         cbmsg->_cookie.pe, robj->nextPE);
-            CkPackMessage(&env);
-            CmiSyncSendAndFree(robj->nextPE, env->getTotalsize(), 
-                               (char *)env);
-        }
-        else
-            CmiFree(env);       
-    }
-    else {
-        //status == COMLIB_MULTICAST_OLD_SECTION, use the cached section id
-        ComlibSectionHashKey key(cbmsg->_cookie.pe, 
-                                 cbmsg->_cookie.sInfo.cInfo.id);    
-        RingMulticastHashObject *robj = (RingMulticastHashObject *)sec_ht.
-            get(key);
-        
-        if(robj == NULL)
-            CkAbort("Destination indices is NULL\n");
-        
-        if(src_pe != CkMyPe() && !isEndOfRing(robj->nextPE, src_pe)) {
-            CmiSyncSend(robj->nextPE, env->getTotalsize(), (char *)env);
-            ComlibPrintf("[%d] Forwarding Message to %d\n", CkMyPe(), 
-                         robj->nextPE);
-        }
-        
-        ComlibArrayInfo::localMulticast(&robj->indices, env);
-    }
-}
-
-void RingMulticastStrategy::initSectionID(CkSectionID *sid){
-
-    ComlibPrintf("Ring Init section ID\n");
-    sid->pelist = NULL;
-    sid->npes = 0;
-
-    RingMulticastHashObject *robj = 
-        createHashObject(sid->_nElems, sid->_elems);
-    
-    ComlibSectionHashKey key(CkMyPe(), sid->_cookie.sInfo.cInfo.id);
-    sec_ht.put(key) = robj;
 }
 
-RingMulticastHashObject *RingMulticastStrategy::createHashObject
+ComlibSectionHashObject *RingMulticastStrategy::createObjectOnSrcPe
 (int nelements, CkArrayIndexMax *elements){
 
-    RingMulticastHashObject *robj = new RingMulticastHashObject;
+    ComlibSectionHashObject *robj = new ComlibSectionHashObject;
 
     int next_pe = CkNumPes();
     int acount = 0;
     int min_dest = CkNumPes();
+    
+    //Equivalent to sorting the list of destination processors and
+    //sending the message to the next processor greater than MyPE.
+    //If MyPE is the largest processor send it to minpe
     for(acount = 0; acount < nelements; acount++){
-        //elements[acount].print();
         
         CkArrayID dest;
         int nidx;
@@ -263,11 +37,13 @@ RingMulticastHashObject *RingMulticastStrategy::createHashObject
         ainfo.getDestinationArray(dest, idx_list, nidx);
 
         int p = ComlibGetLastKnown(dest, elements[acount]);
-        //CkArrayID::CkLocalBranch(dest)->lastKnown(elements[acount]);
         
+        //Find the smallest destination
         if(p < min_dest)
             min_dest = p;
         
+        //If there is a processor greater than me and less than next_pe
+        //then he is my next_pe
         if(p > CkMyPe() && next_pe > p) 
             next_pe = p;       
 
@@ -282,35 +58,56 @@ RingMulticastHashObject *RingMulticastStrategy::createHashObject
     if(next_pe == CkNumPes())
         next_pe = -1;
 
-    robj->nextPE = next_pe;
-
+    if(next_pe != -1) {
+        robj->pelist = new int[1];
+        robj->npes = 1;
+        robj->pelist[0] = next_pe;
+    }
+    else {
+        robj->pelist = NULL;
+        robj->npes = 0;
+    }        
+    
     return robj;
 }
 
 
-RingMulticastHashObject *RingMulticastStrategy::getHashObject(int pe, int id){
+ComlibSectionHashObject *RingMulticastStrategy::createObjectOnIntermediatePe
+(int nelements, CkArrayIndexMax *elements, int src_pe){
+
+    ComlibSectionHashObject *obj;
+
+    obj = createObjectOnSrcPe(nelements, elements);
     
-    ComlibSectionHashKey key(pe, id);
-    RingMulticastHashObject *robj = (RingMulticastHashObject *)sec_ht.get(key);
-    return robj;
+    //here we check if have reached the end of the ring
+    if(obj->npes > 0 && isEndOfRing(*obj->pelist, src_pe)) {
+        delete obj->pelist;
+        obj->pelist = NULL;
+        obj->npes =0;
+    }
+
+    return obj;
 }
 
-int RingMulticastStrategy::isEndOfRing(int next_pe, int src_pe){
+//We need to end the ring, 
+//    if next_pe is the same as the source_pe, or
+//    if next_pe is the first processor in the ring, greater than srouce_pe.
+//Both these comparisons are done in a 'cyclic' way with wraparounds.
 
+int RingMulticastStrategy::isEndOfRing(int next_pe, int src_pe){
+    
     if(next_pe < 0)
         return 1;
-
+    
     ComlibPrintf("[%d] isEndofring %d, %d\n", CkMyPe(), next_pe, src_pe);
-
+    
     if(next_pe > CkMyPe()){
         if(src_pe <= next_pe && src_pe > CkMyPe())
             return 1;
-
+        
         return 0;
     }
     
-    //next_pe < CkMyPe()
-
     if(src_pe > CkMyPe() || src_pe <= next_pe)
         return 1;
     
index 03fd8a7bbfa73544bf369e93f512f6b56ae4e015..ab03e6dc511a66a9acd66fdf4c86e7a603090eef 100644 (file)
@@ -3,61 +3,34 @@
 
 #include "DirectMulticastStrategy.h"
 
-class RingMulticastHashObject{
- public:
-    CkVec<CkArrayIndexMax> indices;
-    int nextPE;
-};
-
 
 class RingMulticastStrategy: public DirectMulticastStrategy {
     
-    int nextPE;
+ protected:
     
-    void commonRingInit();
     int isEndOfRing(int next_pe, int src_pe);
-    RingMulticastHashObject *getHashObject(int pe, int id);
-    RingMulticastHashObject *createHashObject(int nelements, 
-                                              CkArrayIndexMax *elements);
-    void initSectionID(CkSectionID *sid);
+    
+    //Defining the two entries of the section multicast interface
+    virtual ComlibSectionHashObject *createObjectOnSrcPe(int nelements, 
+                                                         CkArrayIndexMax *elements);
 
- public:
+    virtual ComlibSectionHashObject *createObjectOnIntermediatePe
+        (int nelements, CkArrayIndexMax *elements, int src_pe);
     
-    //Group constructor
-    RingMulticastStrategy(int ndestpes, int *destpelist);
+ public:
     
     //Array constructor
     RingMulticastStrategy(CkArrayID dest_id);    
-    RingMulticastStrategy(CkArrayID src, CkArrayID dest);    
-    RingMulticastStrategy(CkMigrateMessage *m) {}
+    RingMulticastStrategy(CkMigrateMessage *m) : DirectMulticastStrategy(m){}
 
     //Destructor
-    ~RingMulticastStrategy() { 
-        
-        CkHashtableIterator *ht_iterator = sec_ht.iterator();
-        ht_iterator->seekStart();
-        while(ht_iterator->hasNext()){
-            void **data;
-            data = (void **)ht_iterator->next();        
-            RingMulticastHashObject *robj = 
-                (RingMulticastHashObject*)(* data);
-
-            *data = NULL;
-            if(robj)
-                delete robj;
-        }
-
-        sec_ht.empty();
-    }
-    
-    void insertMessage(CharmMessageHolder *msg);
-    void doneInserting();
-    void handleMulticastMessage(void *msg);
+    ~RingMulticastStrategy() {}
     
     void pup(PUP::er &p);    
     void beginProcessing(int nelements);
     
     PUPable_decl(RingMulticastStrategy);
 };
+
 #endif