Making the learner a dynamic switch rather than a compile time switch.
authorSameer Kumar <skumar2@uiuc.edu>
Fri, 9 Dec 2005 16:53:39 +0000 (16:53 +0000)
committerSameer Kumar <skumar2@uiuc.edu>
Fri, 9 Dec 2005 16:53:39 +0000 (16:53 +0000)
src/ck-com/AAMLearner.C
src/ck-com/AAPLearner.C
src/ck-com/EachToManyMulticastStrategy.C
src/ck-com/EachToManyMulticastStrategy.h

index efca2ac96059d4a147aa414e82d4343ce536a991..72a13dd2722283a2d8f42d5e8c00ac24d4d63f5b 100644 (file)
@@ -69,6 +69,7 @@ Strategy *AAMLearner::optimizePattern(Strategy *strat,
         */
         
         ostrat->setInstance(in_strat->getInstance());
+        ((EachToManyMulticastStrategy *)ostrat)->enableLearning();
     }
     else
         CkAbort("Groups Not Implemented Yet\n");
index 9d498aedeeade79f5a13baf5b3e72d869f0d131d..ea516fbb9e464826c87cd31b56935dadbf9a82a4 100644 (file)
@@ -62,11 +62,12 @@ Strategy *AAPLearner::optimizePattern(Strategy *strat,
         in_strat->ainfo.getDestinationArray(daid, didxlist, ndest);
                 
         ostrat = new EachToManyMulticastStrategy
-            (minstrat, said, daid,
+            (minstrat, said, daid,
              nsrc, sidxlist, ndest,
              didxlist);
 
         ostrat->setInstance(in_strat->getInstance());
+        ((EachToManyMulticastStrategy *) ostrat)->enableLearning();
     }
     
     //Group strategy implement later, foo bar !!
@@ -79,6 +80,8 @@ Strategy *AAPLearner::optimizePattern(Strategy *strat,
 
         ostrat = new EachToManyMulticastStrategy
             (minstrat, src_npes, src_pelist, dest_npes, dest_pelist);
+        ((EachToManyMulticastStrategy *) ostrat)->enableLearning();
+        ostrat->setInstance(in_strat->getInstance());
     }
 
     return ostrat;
index 0ef13c75a9129df31c9f45c8daaddad16a7d3b52..7f9c1f7ef5326a99cfade452eda866155a37306c 100644 (file)
@@ -42,7 +42,8 @@ void *itrDoneHandler(void *msg){
     int nexpected = sentry->numElements;
     
     if(nexpected == 0) {             
-        ComlibPrintf("[%d] Calling Dummy Done Inserting, %d, %d\n", CkMyPe(), instid, nexpected);
+        ComlibPrintf("[%d] Calling Dummy Done Inserting, %d, %d\n", 
+                     CkMyPe(), instid, nexpected);
         nm_mgr = (EachToManyMulticastStrategy *)sentry->strategy;    
         nm_mgr->doneInserting();
        
@@ -153,6 +154,7 @@ void EachToManyMulticastStrategy::commonInit() {
     
     ComlibPrintf("Creating Strategy %d\n", routerID);
 
+    useLearner = 0;
     rstrat = NULL;
 }
 
@@ -220,7 +222,8 @@ void EachToManyMulticastStrategy::pup(PUP::er &p){
 
     p | routerID; 
     p | npes; p | ndestpes;     
-    
+    p | useLearner;
+
     if(p.isUnpacking() && npes > 0) {
         pelist = new int[npes];    
     }
@@ -290,13 +293,14 @@ void EachToManyMulticastStrategy::beginProcessing(int numElements){
             ->getStrategyTableEntry(myInstanceID);
         sentry->numElements = expectedDeposits;
     }
-    /*
-    if(!mflag) 
-        setLearner(new AAPLearner());    
-    else 
-        setLearner(new AAMLearner());                
-    */
-
+    
+    if(useLearner) {
+        if(!mflag) 
+            setLearner(new AAPLearner());    
+        else 
+            setLearner(new AAMLearner());                
+    }
+    
     if(expectedDeposits > 0)
         return;
     
@@ -314,7 +318,7 @@ void EachToManyMulticastStrategy::finalizeProcessing() {
     if(rstrat)
         delete rstrat;
 
-    if(getLearner() != NULL)
+    if(useLearner && getLearner() != NULL)
         delete getLearner();
 }
 
index 13a63b3772382c0513e41b578ce3dfc2d6fbb716..924a828712efa5e647f482bf312de0958d5789c2 100644 (file)
@@ -17,6 +17,7 @@ class EachToManyMulticastStrategy: public CharmStrategy {
     virtual void commonInit();
 
     RouterStrategy *rstrat;
+    int useLearner;
 
  public:
     //Group constructor
@@ -45,7 +46,8 @@ class EachToManyMulticastStrategy: public CharmStrategy {
     virtual void localMulticast(void *msg);
     
     PUPable_decl(EachToManyMulticastStrategy);
-
+    
+    inline void enableLearning() {useLearner = 1;}
 };
 #endif