Adding a persistent option to the DirectMulticastStrategy which will make it keep...
authorSameer Kumar <skumar2@uiuc.edu>
Fri, 25 Mar 2005 04:29:34 +0000 (04:29 +0000)
committerSameer Kumar <skumar2@uiuc.edu>
Fri, 25 Mar 2005 04:29:34 +0000 (04:29 +0000)
src/ck-com/ComlibSectionInfo.h
src/ck-com/DirectMulticastStrategy.C
src/ck-com/DirectMulticastStrategy.h

index 1b28ecbbd7aeff3e787ed2de3361b7f15ae252ce..ec8e1bece0518b42de9b25cbb058fe7275777bfa 100644 (file)
@@ -80,14 +80,18 @@ class ComlibSectionHashObject {
     //Other processors to send this message to
     int npes;
     int *pelist;
+
+    void *msg;
     
     ComlibSectionHashObject(): indices(0) {
         npes = 0;
         pelist = NULL;
+       msg = NULL;
     }
 
     ~ComlibSectionHashObject() {
         delete pelist;
+       //delete msg;
     }
 };
 
index 3104945d4c97e49112bd4fa8e9c2436a44f52f99..bdc161f5867f9ba0565b4183e10158354f7d1641 100644 (file)
@@ -36,11 +36,14 @@ void *DMHandler(void *msg){
 }
 */
 
-DirectMulticastStrategy::DirectMulticastStrategy(CkArrayID aid)
+DirectMulticastStrategy::DirectMulticastStrategy(CkArrayID aid, 
+                                                int isPersistent)
     :  CharmStrategy() {
 
     ainfo.setDestinationArray(aid);
     setType(ARRAY_STRATEGY);
+
+    this->isPersistent = isPersistent;
 }
 
 //Destroy all old built routes
@@ -158,17 +161,35 @@ void DirectMulticastStrategy::doneInserting(){
     //Do nothing! Its a bracketed strategy
 }
 
+extern void CmiReference(void *);
+
 //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 the library is set to persistent. 
+    //The message is stored in the library. The applications should 
+    //use the message as a readonly and it exists till the next one 
+    //comes along
+    
+    if(obj->msg != NULL) {
+       delete obj->msg;
+       obj->msg = NULL;
+    } 
+    
     if(nIndices > 0) {
-        void *msg = EnvToUsr(env);
-        void *msg1 = msg;
+       void *msg = EnvToUsr(env);
+       void *msg1 = msg;
         
         msg1 = CkCopyMsg(&msg);
+       
+       if(isPersistent) {
+           CmiReference(UsrToEnv(msg1));
+           obj->msg = (void *)UsrToEnv(msg1);
+       }
+       
         ComlibArrayInfo::localMulticast(&(obj->indices), UsrToEnv(msg1));
     }    
 }
@@ -204,6 +225,7 @@ void DirectMulticastStrategy::remoteMulticast(envelope *env,
 void DirectMulticastStrategy::pup(PUP::er &p){
 
     CharmStrategy::pup(p);
+    p | isPersistent; 
 }
 
 void DirectMulticastStrategy::beginProcessing(int numElements){
@@ -284,9 +306,6 @@ void DirectMulticastStrategy::handleNewMulticastMessage(envelope *env) {
     sec_ht.put(key) = new_obj;
 
     remoteMulticast(env, new_obj);
-    
-    if(new_obj->indices.size() > 0)
-        ComlibArrayInfo::localMulticast(&(new_obj->indices), newenv);    
-    else        
-        CmiFree(newenv);                
+    localMulticast(newenv, new_obj); //local multicast always copies
+    CmiFree(newenv);                
 }
index 29ffc1f967df91863e8da4baad4fb0272c7d40bb..10634b1f2368d6b5f9cfe25369902b5cff8eb1d6 100644 (file)
@@ -10,6 +10,8 @@ class DirectMulticastStrategy: public CharmStrategy {
  protected:
     //   int handlerId;    
     ComlibSectionInfo sinfo;
+
+    int isPersistent; 
     
     //Array section support
     CkHashtableT<ComlibSectionHashKey, ComlibSectionHashObject *> sec_ht; 
@@ -44,7 +46,7 @@ class DirectMulticastStrategy: public CharmStrategy {
     DirectMulticastStrategy(CkMigrateMessage *m): CharmStrategy(m){}
                 
     //Array constructor
-    DirectMulticastStrategy(CkArrayID aid);
+    DirectMulticastStrategy(CkArrayID aid, int isPersistent = 0);
         
     //Destuctor
     ~DirectMulticastStrategy();