Changing CharmStrategy and DirectMulticastStrategy to use the strategy_handler
authorSameer Kumar <skumar2@uiuc.edu>
Tue, 22 Mar 2005 15:14:03 +0000 (15:14 +0000)
committerSameer Kumar <skumar2@uiuc.edu>
Tue, 22 Mar 2005 15:14:03 +0000 (15:14 +0000)
code.

src/ck-com/BroadcastStrategy.C
src/ck-com/ComlibStrategy.h
src/ck-com/DirectMulticastStrategy.C
src/ck-com/DirectMulticastStrategy.h

index 9931d5b094cfbe95de1899ce04af3f98f86deb50..985ba6c8d3edc50234b3284a80d8803d79ed5b96 100644 (file)
@@ -75,7 +75,8 @@ void BroadcastStrategy::insertMessage(CharmMessageHolder *cmsg){
         //conv_header->root = CkMyPe();
         conv_header->xhdl = CkMyPe();
     
-    handleMessage((char *)UsrToEnv(msg));
+    CkPackMessage(&env);
+    handleMessage((char *) env);
     
     delete cmsg;
 }
index 53831745096de78b5e0e4def113b4c8d8e51ade3..1d1262139c9b5f8373aee64b1cffc7480a56035d 100644 (file)
@@ -187,6 +187,7 @@ class ComlibArrayInfo {
    node groups, groups and arrays */
 
 class CharmStrategy : public Strategy {
+    
  protected:
     int forwardOnMigration;
     ComlibLearner *learner;
@@ -242,9 +243,12 @@ class CharmStrategy : public Strategy {
     //a result of a learning decision
     virtual void finalizeProcessing(){}
 
-    virtual ComlibLearner *getLearner() {return learner;}
-    virtual void setLearner(ComlibLearner *l) {learner = l;}
-
+    //Called when a message is received in the strategy handler
+    virtual void handleMessage(void *msg) {}
+    
+    ComlibLearner *getLearner() {return learner;}
+    void setLearner(ComlibLearner *l) {learner = l;}
+    
     virtual void pup(PUP::er &p);
     PUPable_decl(CharmStrategy);
 
index efa8da97d85badae9d24f597f2811f07440343f2..3104945d4c97e49112bd4fa8e9c2436a44f52f99 100644 (file)
@@ -19,6 +19,7 @@
 
 CkpvExtern(CkGroupID, cmgrID);
 
+/*
 void *DMHandler(void *msg){
     ComlibPrintf("[%d]:In CallbackHandler\n", CkMyPe());
     DirectMulticastStrategy *nm_mgr;    
@@ -30,11 +31,10 @@ void *DMHandler(void *msg){
         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;
 }
+*/
 
 DirectMulticastStrategy::DirectMulticastStrategy(CkArrayID aid)
     :  CharmStrategy() {
@@ -188,7 +188,10 @@ void DirectMulticastStrategy::remoteMulticast(envelope *env,
         return;    
     }
     
-    CmiSetHandler(env, handlerId);
+    //CmiSetHandler(env, handlerId);
+    CmiSetHandler(env, CkpvAccess(strategy_handlerid));
+
+    ((CmiMsgHeaderBasic *) env)->stratid = getInstance();
 
     //Collect Multicast Statistics
     RECORD_SENDM_STATS(getInstance(), env->getTotalsize(), pelist, npes);
@@ -205,7 +208,7 @@ void DirectMulticastStrategy::pup(PUP::er &p){
 
 void DirectMulticastStrategy::beginProcessing(int numElements){
     
-    handlerId = CkRegisterHandler((CmiHandler)DMHandler);    
+    //handlerId = CkRegisterHandler((CmiHandler)DMHandler);    
     
     CkArrayID dest;
     int nidx;
@@ -218,8 +221,9 @@ void DirectMulticastStrategy::beginProcessing(int numElements){
     setLearner(learner);
 }
 
-void DirectMulticastStrategy::handleMulticastMessage(void *msg){
-    register envelope *env = (envelope *)msg;
+void DirectMulticastStrategy::handleMessage(void *msg){
+    envelope *env = (envelope *)msg;
+    RECORD_RECV_STATS(getInstance(), env->getTotalsize(), env->getSrcPe());
 
     //Section multicast base message
     CkMcastBaseMsg *cbmsg = (CkMcastBaseMsg *)EnvToUsr(env);
@@ -247,7 +251,7 @@ void DirectMulticastStrategy::handleMulticastMessage(void *msg){
 
 
 void DirectMulticastStrategy::handleNewMulticastMessage(envelope *env) {
-
+    
     ComlibPrintf("%d : In handleNewMulticastMessage\n", CkMyPe());
 
     CkUnpackMessage(&env);    
index 135788c68686697b287eb432e0ceaed7324f6aff..29ffc1f967df91863e8da4baad4fb0272c7d40bb 100644 (file)
@@ -8,7 +8,7 @@ void *DMHandler(void *msg);
 
 class DirectMulticastStrategy: public CharmStrategy {
  protected:
-    int handlerId;    
+    //   int handlerId;    
     ComlibSectionInfo sinfo;
     
     //Array section support
@@ -53,7 +53,7 @@ class DirectMulticastStrategy: public CharmStrategy {
     virtual void doneInserting();
 
     //Called by the converse handler function
-    void handleMulticastMessage(void *msg);    
+    virtual void handleMessage(void *msg);    
 
     virtual void pup(PUP::er &p);    
     virtual void beginProcessing(int nelements);