Refactoring code for message logging protocols.
authorEsteban Meneses <emenese2@illinois.edu>
Thu, 13 Sep 2012 15:49:42 +0000 (10:49 -0500)
committerEsteban Meneses <emenese2@illinois.edu>
Thu, 13 Sep 2012 15:49:42 +0000 (10:49 -0500)
src/ck-core/ckcausalmlog.C
src/ck-core/ckmessagelogging.C
src/ck-core/ckobjid.C [new file with mode: 0644]
src/ck-core/ckobjid.h
src/scripts/Make.depends
src/scripts/Makefile

index 32332075998015fcdfa67c90e9d8e5ed88159dd8..05c482017956ccae5f851c947195aa5668aed5e5 100644 (file)
@@ -1065,7 +1065,7 @@ int preProcessReceivedMessage(envelope *env, Chare **objPointer, MlogEntry **log
                int possiblePE = recver.guessPE();
                if(possiblePE != CkMyPe()){
                        int totalSize = env->getTotalsize();
-                       CmiSyncSend(possiblePE,totalSize,(char *)env);
+                       CmiSyncSendAndFree(possiblePE,totalSize,(char *)env);
                        
                        DEBUG_PE(0,printf("[%d] Forwarding message SN %d sender %s recver %s to %d\n",CkMyPe(),env->SN,env->sender.toString(senderString), recver.toString(recverString), possiblePE));
                }else{
@@ -3648,141 +3648,6 @@ void _messageLoggingExit(){
 
 }
 
-/**
-       The method for returning the actual object pointed to by an id
-       If the object doesnot exist on the processor it returns NULL
-**/
-
-void* CkObjID::getObject(){
-       
-               switch(type){
-                       case TypeChare: 
-                               return CkLocalChare(&data.chare.id);
-                       case TypeMainChare:
-                               return CkLocalChare(&data.chare.id);
-                       case TypeGroup:
-       
-                               CkAssert(data.group.onPE == CkMyPe());
-                               return CkLocalBranch(data.group.id);
-                       case TypeNodeGroup:
-                               CkAssert(data.group.onPE == CkMyNode());
-                               //CkLocalNodeBranch(data.group.id);
-                               {
-                                       CmiImmediateLock(CksvAccess(_nodeGroupTableImmLock));
-                                 void *retval = CksvAccess(_nodeGroupTable)->find(data.group.id).getObj();
-                                 CmiImmediateUnlock(CksvAccess(_nodeGroupTableImmLock));                                       
-       
-                                       return retval;
-                               }       
-                       case TypeArray:
-                               {
-       
-       
-                                       CkArrayID aid(data.array.id);
-       
-                                       if(aid.ckLocalBranch() == NULL){ return NULL;}
-       
-                                       CProxyElement_ArrayBase aProxy(aid,data.array.idx.asChild());
-       
-                                       return aProxy.ckLocal();
-                               }
-                       default:
-                               CkAssert(0);
-               }
-}
-
-
-int CkObjID::guessPE(){
-               switch(type){
-                       case TypeChare:
-                       case TypeMainChare:
-                               return data.chare.id.onPE;
-                       case TypeGroup:
-                       case TypeNodeGroup:
-                               return data.group.onPE;
-                       case TypeArray:
-                               {
-                                       CkArrayID aid(data.array.id);
-                                       if(aid.ckLocalBranch() == NULL){
-                                               return -1;
-                                       }
-                                       return aid.ckLocalBranch()->lastKnown(data.array.idx.asChild());
-                               }
-                       default:
-                               CkAssert(0);
-               }
-};
-
-char *CkObjID::toString(char *buf) const {
-       
-       switch(type){
-               case TypeChare:
-                       sprintf(buf,"Chare %p PE %d \0",data.chare.id.objPtr,data.chare.id.onPE);
-                       break;
-               case TypeMainChare:
-                       sprintf(buf,"Chare %p PE %d \0",data.chare.id.objPtr,data.chare.id.onPE);       
-                       break;
-               case TypeGroup:
-                       sprintf(buf,"Group %d   PE %d \0",data.group.id.idx,data.group.onPE);
-                       break;
-               case TypeNodeGroup:
-                       sprintf(buf,"NodeGroup %d       Node %d \0",data.group.id.idx,data.group.onPE);
-                       break;
-               case TypeArray:
-                       {
-                               const CkArrayIndexMax &idx = data.array.idx.asChild();
-                               const int *indexData = idx.data();
-                               sprintf(buf,"Array |%d %d %d| id %d \0",indexData[0],indexData[1],indexData[2],data.array.id.idx);
-                               break;
-                       }
-               default:
-                       CkAssert(0);
-       }
-       
-       return buf;
-};
-
-void CkObjID::updatePosition(int PE){
-       if(guessPE() == PE){
-               return;
-       }
-       switch(type){
-               case TypeArray:
-                       {
-                                       CkArrayID aid(data.array.id);
-                                       if(aid.ckLocalBranch() == NULL){
-                                               
-                                       }else{
-                                               char str[100];
-                                               CkLocMgr *mgr = aid.ckLocalBranch()->getLocMgr();
-//                                             CmiPrintf("[%d] location for object %s is %d\n",CmiMyPe(),toString(str),PE);
-                                               CkLocRec *rec = mgr->elementNrec(data.array.idx.asChild());
-                                               if(rec != NULL){
-                                                       if(rec->type() == CkLocRec::local){
-                                                               CmiPrintf("[%d] local object %s can not exist on another processor %d\n",CmiMyPe(),str,PE);
-                                                               return;
-                                                       }
-                                               }
-                                               mgr->inform(data.array.idx.asChild(),PE);
-                                       }       
-                               }
-
-                       break;
-               case TypeChare:
-               case TypeMainChare:
-                       CkAssert(data.chare.id.onPE == PE);
-                       break;
-               case TypeGroup:
-               case TypeNodeGroup:
-                       CkAssert(data.group.onPE == PE);
-                       break;
-               default:
-                       CkAssert(0);
-       }
-}
-
-
-
 void MlogEntry::pup(PUP::er &p){
        p | destPE;
        p | _infoIdx;
index efdf53c465b1a19557be486348155580936ba92a..7cca744001d72ff23375147fed1b1ef5185c7f53 100644 (file)
@@ -735,15 +735,15 @@ int preProcessReceivedMessage(envelope *env, Chare **objPointer, MlogEntry **log
                int possiblePE = recver.guessPE();
                if(possiblePE != CkMyPe()){
                        int totalSize = env->getTotalsize();
-                       CmiSyncSend(possiblePE,totalSize,(char *)env);
+                       CmiSyncSendAndFree(possiblePE,totalSize,(char *)env);
                        
-                       DEBUG_PE(0,printf("[%d] Forwarding message SN %d sender %s recver %s to %d\n",CkMyPe(),env->SN,env->sender.toString(senderString), recver.toString(recverString), possiblePE));
+                       DEBUG_NOW(printf("[%d] Forwarding message SN %d sender %s recver %s to %d\n",CkMyPe(),env->SN,env->sender.toString(senderString), recver.toString(recverString), possiblePE));
                }else{
                        // this is the case where a message is received and the object has not been initialized
                        // we delayed the delivery of the message
                        CqsEnqueue(CpvAccess(_outOfOrderMessageQueue),env);
                        
-                       DEBUG_PE(0,printf("[%d] Message SN %d TN %d sender %s recver %s, receiver NOT found\n",CkMyPe(),env->SN,env->TN,env->sender.toString(senderString), recver.toString(recverString)));
+                       DEBUG_NOW(printf("[%d] Message SN %d sender %s recver %s, receiver NOT found\n",CkMyPe(),env->SN,env->sender.toString(senderString), recver.toString(recverString)));
                }
                return 0;
        }
@@ -2112,141 +2112,6 @@ void _messageLoggingExit(){
        printf("\n");
 #endif
 #endif
-
-
-}
-
-/**
-       The method for returning the actual object pointed to by an id
-       If the object doesnot exist on the processor it returns NULL
-**/
-
-void* CkObjID::getObject(){
-       
-               switch(type){
-                       case TypeChare: 
-                               return CkLocalChare(&data.chare.id);
-                       case TypeMainChare:
-                               return CkLocalChare(&data.chare.id);
-                       case TypeGroup:
-       
-                               CkAssert(data.group.onPE == CkMyPe());
-                               return CkLocalBranch(data.group.id);
-                       case TypeNodeGroup:
-                               CkAssert(data.group.onPE == CkMyNode());
-                               //CkLocalNodeBranch(data.group.id);
-                               {
-                                       CmiImmediateLock(CksvAccess(_nodeGroupTableImmLock));
-                                 void *retval = CksvAccess(_nodeGroupTable)->find(data.group.id).getObj();
-                                 CmiImmediateUnlock(CksvAccess(_nodeGroupTableImmLock));                                       
-       
-                                       return retval;
-                               }       
-                       case TypeArray:
-                               {
-       
-       
-                                       CkArrayID aid(data.array.id);
-       
-                                       if(aid.ckLocalBranch() == NULL){ return NULL;}
-       
-                                       CProxyElement_ArrayBase aProxy(aid,data.array.idx.asChild());
-       
-                                       return aProxy.ckLocal();
-                               }
-                       default:
-                               CkAssert(0);
-               }
-}
-
-
-int CkObjID::guessPE(){
-               switch(type){
-                       case TypeChare:
-                       case TypeMainChare:
-                               return data.chare.id.onPE;
-                       case TypeGroup:
-                       case TypeNodeGroup:
-                               return data.group.onPE;
-                       case TypeArray:
-                               {
-                                       CkArrayID aid(data.array.id);
-                                       if(aid.ckLocalBranch() == NULL){
-                                               return -1;
-                                       }
-                                       return aid.ckLocalBranch()->lastKnown(data.array.idx.asChild());
-                               }
-                       default:
-                               CkAssert(0);
-               }
-};
-
-char *CkObjID::toString(char *buf) const {
-       
-       switch(type){
-               case TypeChare:
-                       sprintf(buf,"Chare %p PE %d \0",data.chare.id.objPtr,data.chare.id.onPE);
-                       break;
-               case TypeMainChare:
-                       sprintf(buf,"Chare %p PE %d \0",data.chare.id.objPtr,data.chare.id.onPE);       
-                       break;
-               case TypeGroup:
-                       sprintf(buf,"Group %d   PE %d \0",data.group.id.idx,data.group.onPE);
-                       break;
-               case TypeNodeGroup:
-                       sprintf(buf,"NodeGroup %d       Node %d \0",data.group.id.idx,data.group.onPE);
-                       break;
-               case TypeArray:
-                       {
-                               const CkArrayIndexMax &idx = data.array.idx.asChild();
-                               const int *indexData = idx.data();
-                               sprintf(buf,"Array |%d %d %d| id %d \0",indexData[0],indexData[1],indexData[2],data.array.id.idx);
-                               break;
-                       }
-               default:
-                       CkAssert(0);
-       }
-       
-       return buf;
-};
-
-void CkObjID::updatePosition(int PE){
-       if(guessPE() == PE){
-               return;
-       }
-       switch(type){
-               case TypeArray:
-                       {
-                                       CkArrayID aid(data.array.id);
-                                       if(aid.ckLocalBranch() == NULL){
-                                               
-                                       }else{
-                                               char str[100];
-                                               CkLocMgr *mgr = aid.ckLocalBranch()->getLocMgr();
-//                                             CmiPrintf("[%d] location for object %s is %d\n",CmiMyPe(),toString(str),PE);
-                                               CkLocRec *rec = mgr->elementNrec(data.array.idx.asChild());
-                                               if(rec != NULL){
-                                                       if(rec->type() == CkLocRec::local){
-                                                               CmiPrintf("[%d] local object %s can not exist on another processor %d\n",CmiMyPe(),str,PE);
-                                                               return;
-                                                       }
-                                               }
-                                               mgr->inform(data.array.idx.asChild(),PE);
-                                       }       
-                               }
-
-                       break;
-               case TypeChare:
-               case TypeMainChare:
-                       CkAssert(data.chare.id.onPE == PE);
-                       break;
-               case TypeGroup:
-               case TypeNodeGroup:
-                       CkAssert(data.group.onPE == PE);
-                       break;
-               default:
-                       CkAssert(0);
-       }
 }
 
 void MlogEntry::pup(PUP::er &p){
diff --git a/src/ck-core/ckobjid.C b/src/ck-core/ckobjid.C
new file mode 100644 (file)
index 0000000..03ac47d
--- /dev/null
@@ -0,0 +1,138 @@
+#include "charm.h"
+#include "ck.h"
+#include "ckobjid.h"
+
+/**
+       The method for returning the actual object pointed to by an id 
+       If the object doesnot exist on the processor it returns NULL
+**/
+
+void* CkObjID::getObject(){
+       
+               switch(type){
+                       case TypeChare: 
+                               return CkLocalChare(&data.chare.id);
+                       case TypeMainChare:
+                               return CkLocalChare(&data.chare.id);
+                       case TypeGroup:
+       
+                               CkAssert(data.group.onPE == CkMyPe());
+                               return CkLocalBranch(data.group.id);
+                       case TypeNodeGroup:
+                               CkAssert(data.group.onPE == CkMyNode());
+                               //CkLocalNodeBranch(data.group.id);
+                               {
+                                       CmiImmediateLock(CksvAccess(_nodeGroupTableImmLock));
+                                 void *retval = CksvAccess(_nodeGroupTable)->find(data.group.id).getObj();
+                                 CmiImmediateUnlock(CksvAccess(_nodeGroupTableImmLock));                                       
+       
+                                       return retval;
+                               }       
+                       case TypeArray:
+                               {
+       
+       
+                                       CkArrayID aid(data.array.id);
+       
+                                       if(aid.ckLocalBranch() == NULL){ return NULL;}
+       
+                                       CProxyElement_ArrayBase aProxy(aid,data.array.idx.asChild());
+       
+                                       return aProxy.ckLocal();
+                               }
+                       default:
+                               CkAssert(0);
+               }
+}
+
+
+int CkObjID::guessPE(){
+               switch(type){
+                       case TypeChare:
+                       case TypeMainChare:
+                               return data.chare.id.onPE;
+                       case TypeGroup:
+                       case TypeNodeGroup:
+                               return data.group.onPE;
+                       case TypeArray:
+                               {
+                                       CkArrayID aid(data.array.id);
+                                       if(aid.ckLocalBranch() == NULL){
+                                               return -1;
+                                       }
+                                       return aid.ckLocalBranch()->lastKnown(data.array.idx.asChild());
+                               }
+                       default:
+                               CkAssert(0);
+               }
+};
+
+char *CkObjID::toString(char *buf) const {
+       
+       switch(type){
+               case TypeChare:
+                       sprintf(buf,"Chare %p PE %d \0",data.chare.id.objPtr,data.chare.id.onPE);
+                       break;
+               case TypeMainChare:
+                       sprintf(buf,"Chare %p PE %d \0",data.chare.id.objPtr,data.chare.id.onPE);       
+                       break;
+               case TypeGroup:
+                       sprintf(buf,"Group %d   PE %d \0",data.group.id.idx,data.group.onPE);
+                       break;
+               case TypeNodeGroup:
+                       sprintf(buf,"NodeGroup %d       Node %d \0",data.group.id.idx,data.group.onPE);
+                       break;
+               case TypeArray:
+                       {
+                               const CkArrayIndexMax &idx = data.array.idx.asChild();
+                               const int *indexData = idx.data();
+                               sprintf(buf,"Array |%d %d %d| id %d \0",indexData[0],indexData[1],indexData[2],data.array.id.idx);
+                               break;
+                       }
+               default:
+                       CkAssert(0);
+       }
+       
+       return buf;
+};
+
+void CkObjID::updatePosition(int PE){
+       if(guessPE() == PE){
+               return;
+       }
+       switch(type){
+               case TypeArray:
+                       {
+                                       CkArrayID aid(data.array.id);
+                                       if(aid.ckLocalBranch() == NULL){
+                                               
+                                       }else{
+                                               char str[100];
+                                               CkLocMgr *mgr = aid.ckLocalBranch()->getLocMgr();
+//                                             CmiPrintf("[%d] location for object %s is %d\n",CmiMyPe(),toString(str),PE);
+                                               CkLocRec *rec = mgr->elementNrec(data.array.idx.asChild());
+                                               if(rec != NULL){
+                                                       if(rec->type() == CkLocRec::local){
+                                                               CmiPrintf("[%d] local object %s can not exist on another processor %d\n",CmiMyPe(),str,PE);
+                                                               return;
+                                                       }
+                                               }
+                                               mgr->inform(data.array.idx.asChild(),PE);
+                                       }       
+                               }
+
+                       break;
+               case TypeChare:
+               case TypeMainChare:
+                       CkAssert(data.chare.id.onPE == PE);
+                       break;
+               case TypeGroup:
+               case TypeNodeGroup:
+                       CkAssert(data.group.onPE == PE);
+                       break;
+               default:
+                       CkAssert(0);
+       }
+}
+
+// #endif    //CMK_MESSAGE_LOGGING
index 3e01ab33f274d834e9825e4d1873a06941a7bfe3..6d1337621da665d659677b150774dd2dcb47a88d 100644 (file)
@@ -84,7 +84,7 @@ public:
        
        void* getObject();
 
-       inline int guessPE();
+       int guessPE();
        
        char *toString(char *buf) const;
 
index 031fa625ae48f2209831ba186d4de68bb6f72190..bb1628a7a9a440a03b911814e5b00cfb5a17e6c9 100644 (file)
@@ -925,6 +925,25 @@ ckcausalmlog.o: ckcausalmlog.C charm.h converse.h conv-config.h \
  CentralLB.decl.h CentralLBMsg.h
        $(CHARMC) -c -I. ckcausalmlog.C
 
+ckobjid.o: ckobjid.C charm.h converse.h conv-config.h \
+ conv-autoconfig.h conv-common.h conv-mach.h conv-mach-opt.h pup_c.h \
+ queueing.h conv-cpm.h conv-cpath.h conv-qd.h conv-random.h conv-lists.h \
+ conv-trace.h persistent.h debug-conv.h pup.h ck.h charm++.h middle.h \
+ middle-conv.h cklists.h ckbitvector.h ckstream.h init.h ckhashtable.h \
+ debug-charm.h debug-conv++.h simd.h CkMarshall.decl.h ckarrayindex.h \
+ cksection.h ckcallback.h conv-ccs.h sockRoutines.h ccs-server.h ckobjQ.h \
+ ckreduction.h CkReduction.decl.h CkArrayReductionMgr.decl.h \
+ ckmemcheckpoint.h CkMemCheckpoint.decl.h readonly.h ckarray.h \
+ cklocation.h LBDatabase.h lbdb.h LBDBManager.h LBObj.h LBOM.h LBComm.h \
+ LBMachineUtil.h lbdb++.h LBDatabase.decl.h NullLB.decl.h BaseLB.decl.h \
+ CkLocation.decl.h CkArray.decl.h ckfutures.h CkFutures.decl.h charisma.h \
+ charisma.decl.h tempo.h tempo.decl.h waitqd.h waitqd.decl.h sdag.h \
+ ckcheckpoint.h CkCheckpoint.decl.h ckevacuation.h ckarrayreductionmgr.h \
+ trace.h trace-bluegene.h envelope.h qd.h register.h stats.h \
+ TopoManager.h ckobjid.h CentralLB.h BaseLB.h \
+ CentralLB.decl.h CentralLBMsg.h
+       $(CHARMC) -c -I. ckobjid.C
+
 LBDBManager.o: LBDBManager.C charm++.h charm.h converse.h conv-config.h \
  conv-autoconfig.h conv-common.h conv-mach.h conv-mach-opt.h pup_c.h \
  queueing.h conv-cpm.h conv-cpath.h conv-qd.h conv-random.h conv-lists.h \
index 8d08cbaae01894fb925e8129e9cf0b2038aee267..79f127cf2f9c25be9467be106463189d6342b5f9 100644 (file)
@@ -713,7 +713,7 @@ LIBCK_CORE=trace-common.o tracec.o tracef.o init.o register.o qd.o ck.o main.o \
           msgalloc.o ckfutures.o ckIgetControl.o debug-message.o debug-charm.o ckcallback.o \
           cklocation.o ckarray.o ckreduction.o ckarrayreductionmgr.o \
            tempo.o waitqd.o LBDatabase.o lbdb.o lbdbf.o charisma.o ckobjQ.o  \
-          LBAgent.o LBProfit.o ckcheckpoint.o ckmemcheckpoint.o ckevacuation.o ckmessagelogging.o ckcausalmlog.o\
+          LBAgent.o LBProfit.o ckcheckpoint.o ckmemcheckpoint.o ckevacuation.o ckmessagelogging.o ckcausalmlog.o ckobjid.o\
            LBDBManager.o LBComm.o LBObj.o LBMachineUtil.o CentralPredictor.o \
           BaseLB.o CentralLB.o HybridBaseLB.o NborBaseLB.o \
            ckgraph.o LButil.o Refiner.o RefinerApprox.o  \