optimize for checksum
[charm.git] / src / ck-core / ckmemcheckpoint.C
index 9ff229155e9b7b5d374e63a4d81c20e330c878b0..fa77b32188be7b642f1ee52f0bc04ade9638c6fd 100644 (file)
@@ -68,7 +68,7 @@ void noopck(const char*, ...)
 
 #define CMK_CHKP_ALL           1
 #define CMK_USE_BARRIER                0
-#define CMK_USE_CHECKSUM               0
+#define CMK_USE_CHECKSUM               1
 
 //stream remote records happned only if CK_NO_PROC_POOL =1 which means the chares to pe map will change
 #define STREAMING_INFORMHOME                    1
@@ -622,9 +622,6 @@ class MemElementPacker : public CkLocIterator{
     void writeCheckpoint(){
       std::map<CkHashCode, CkLocation>::iterator it;
       for(it = arrayMap.begin();it!=arrayMap.end();it++){
-        if(CkMyPe()==0){
-          //                           CkPrintf("[%d][%d] pack %d\n",CmiMyPartition(),CkMyPe(),it->first);
-        }
         CkLocation loc = it->second;
         CkLocMgr *locMgr = loc.getManager();
         CkArrayIndexMax idx = loc.getIndex();
@@ -708,9 +705,17 @@ void CkMemCheckPT::startCheckpoint(){
   CkCheckPTMessage * msg = new (size,0) CkCheckPTMessage;
   msg->len = size;
   msg->cp_flag = 1;
+  int checksum;
   {
+#if CMK_USE_CHECKSUM
+    PUP::checker p(msg->packData);
+    pupAllElements(p);
+    checksum = p.getChecksum();
+//    CmiPrintf("[%d][%d] checksum %d\n",CmiMyPartition(),CkMyPe(),checksum);
+#else 
     PUP::toMem p(msg->packData);
     pupAllElements(p);
+#endif
   }
   pointer = CpvAccess(curPointer);
   if(CpvAccess(chkpBuf)[pointer]) delete CpvAccess(chkpBuf)[pointer];
@@ -720,11 +725,10 @@ void CkMemCheckPT::startCheckpoint(){
   if(CkReplicaAlive()==1){
     CpvAccess(recvdLocal) = 1;
 #if CMK_USE_CHECKSUM
-    CkCheckPTMessage * tmpMsg = (CkCheckPTMessage *)CkCopyMsg((void **)&msg);
-    CpvAccess(localChecksum) = getChecksum((char *)(tmpMsg->packData));
-//    CmiPrintf("[%d][%d] checksum %d\n",CmiMyPartition(),CkMyPe(),CpvAccess(localChecksum));
-    delete tmpMsg;
-    //send checksum
+//    CkCheckPTMessage * tmpMsg = (CkCheckPTMessage *)CkCopyMsg((void **)&msg);
+//    CpvAccess(localChecksum) = getChecksum((char *)(tmpMsg->packData));
+//    delete tmpMsg;
+    CpvAccess(localChecksum) = checksum;
     char *chkpMsg = (char*)CmiAlloc(CmiMsgHeaderSizeBytes+sizeof(int));
     *(int *)(chkpMsg+CmiMsgHeaderSizeBytes) = CpvAccess(localChecksum);
     CmiSetHandler(chkpMsg,recvRemoteChkpHandlerIdx);