Hopefully everything useful has been hunked
authorNikhil Jain <nikhil@illinois.edu>
Mon, 19 Mar 2012 01:24:51 +0000 (20:24 -0500)
committerPhil Miller <mille121@illinois.edu>
Mon, 19 Mar 2012 04:19:44 +0000 (23:19 -0500)
src/arch/mpi/machine.c
src/ck-core/init.C

index 038a3d8dc9c1ff8e01b1aee066ef4cb7e9af66b3..7c7866193f35fb686640228b57a91fe9ed02b401 100644 (file)
@@ -1204,11 +1204,13 @@ void MachineExitForMPI() {
 #endif
 #endif
 
+   if(!CharmLibInterOperate) {
 #if ! CMK_AUTOBUILD
-    signal(SIGINT, signal_int);
-    MPI_Finalize();
+      signal(SIGINT, signal_int);
+      MPI_Finalize();
 #endif
-    exit(0);
+      exit(0);
+    }
 }
 
 static int machine_exit_idx;
index ae88aad061af07477a4375946c224a8066b5a20f..9873e3f794f74b1102d99983e3551a4eb77ee3c2 100644 (file)
@@ -67,6 +67,7 @@ never be excluded...
 #include "trace.h"
 
 void CkRestartMain(const char* dirname);
+int storeInterOperateStatus = 0;
 
 #define  DEBUGF(x)     //CmiPrintf x;
 
@@ -463,10 +464,12 @@ static void _exitHandler(envelope *env)
   switch(env->getMsgtype()) {
     case StartExitMsg:
       CkAssert(CkMyPe()==0);
-      if (!_CkExitFnVec.isEmpty()) {
-        CkExitFn fn = _CkExitFnVec.deq();
-        fn();
-        break;
+      if(!CharmLibInterOperate) {
+        if (!_CkExitFnVec.isEmpty()) {
+          CkExitFn fn = _CkExitFnVec.deq();
+          fn();
+          break;
+        }
       }
       // else goto next
     case ExitMsg:
@@ -528,17 +531,19 @@ static void _exitHandler(envelope *env)
       }
       else
         CmiFree(env);
-//everyone exits here - there may be issues with leftover messages in the queue
-    if(CharmLibInterOperate) {
-           DEBUGF(("[%d] Calling converse exit \n",CkMyPe()));
-      _exitStarted = 0;
-      CpvAccess(charmLibExitFlag) = 1;
-    } else {
-      if(CkMyPe()){
-             DEBUGF(("[%d] Calling converse exit \n",CkMyPe()));
-        ConverseExit();
-      }        
-    }
+      //everyone exits here - there may be issues with leftover messages in the queue
+      if(CharmLibInterOperate) {
+        DEBUGF(("[%d] Calling converse exit \n",CkMyPe()));
+        _exitStarted = 0;
+        CpvAccess(charmLibExitFlag) = 1;
+      } else {
+        if(CkMyPe()){
+          DEBUGF(("[%d] Calling converse exit \n",CkMyPe()));
+          CharmLibInterOperate = storeInterOperateStatus;
+          CpvAccess(charmLibExitFlag) = 1;
+          ConverseExit();
+        }      
+      }
       break;
     case StatMsg:
 // shouldn't reach here in interoperate mode
@@ -551,7 +556,9 @@ static void _exitHandler(envelope *env)
                        /*FAULT_EVAC*/
       if(_numStatsRecd==CkNumValidPes()) {
         _printStats();
-       DEBUGF(("[%d] Calling converse exit \n",CkMyPe()));
+        DEBUGF(("[%d] Calling converse exit \n",CkMyPe()));
+        CharmLibInterOperate = storeInterOperateStatus;
+        CpvAccess(charmLibExitFlag) = 1;
         ConverseExit();
       }
       break;
@@ -840,7 +847,8 @@ void CkExit(void)
 #if ! CMK_BIGSIM_THREAD
     _TRACE_END_EXECUTE();
     //Wait for stats, which will call ConverseExit when finished:
-    CsdScheduler(-1);
+    if(!storeInterOperateStatus)
+      CsdScheduler(-1);
 #endif
   }
 }
@@ -1400,8 +1408,17 @@ void CharmLibInit(int peid, int numpes, int argc, char **argv){
     _Cmi_numnodes = numpes; 
     _Cmi_mynode = peid;
 
-    CharmLibInterOperate = 1;
-    ConverseInit(argc, argv, (CmiStartFn)_initCharm, 1, 0);
-    printf("node[%d]: called CharmLibInit with %d nodes\n", CmiMyPe(), CmiNumNodes()); 
+  CharmLibInterOperate = 1;
+  ConverseInit(argc, argv, (CmiStartFn)_initCharm, 1, 0);
+  printf("node[%d]: called CharmLibInit with %d nodes\n", CmiMyPe(), CmiNumNodes()); 
+}
+
+void CharmLibExit() {
+  storeInterOperateStatus = 1;
+  CharmLibInterOperate = 0;
+  if(CkMyPe() == 0) {
+    CkExit();
+  } 
+  CsdScheduler(-1);
 }
 /*@}*/