Changes to enable multi library calls, in a time shared manner
authorNikhil Jain <nikhil@illinois.edu>
Wed, 11 Jan 2012 02:20:33 +0000 (20:20 -0600)
committerNikhil Jain <nikhil@illinois.edu>
Wed, 11 Jan 2012 02:20:33 +0000 (20:20 -0600)
src/ck-core/init.C
src/conv-core/convcore.c
src/conv-core/converse.h

index c88b913479cef63e0ec45ad1d96805ec32744d2d..8d76bc554bcef6b468d8f3feda915c9161283a70 100644 (file)
@@ -476,8 +476,10 @@ static void _exitHandler(envelope *env)
         return;
       }
       _exitStarted = 1;
+#if !CMK_INTER_OPERATE
       CkNumberHandler(_charmHandlerIdx,(CmiHandler)_discardHandler);
       CkNumberHandler(_bocHandlerIdx, (CmiHandler)_discardHandler);
+#endif
       env->setMsgtype(ReqStatMsg);
       env->setSrcPe(CkMyPe());
       // if exit in ring, instead of broadcasting, send in ring
@@ -499,14 +501,17 @@ static void _exitHandler(envelope *env)
         _messageLoggingExit();
 #endif
       DEBUGF(("ReqStatMsg on %d\n", CkMyPe()));
+#if !CMK_INTER_OPERATE
       CkNumberHandler(_charmHandlerIdx,(CmiHandler)_discardHandler);
       CkNumberHandler(_bocHandlerIdx, (CmiHandler)_discardHandler);
+#endif
        /*FAULT_EVAC*/
       if(CmiNodeAlive(CkMyPe())){
          _sendStats();
-      }        
+      }
+#if !CMK_INTER_OPERATE
       _mainDone = 1; // This is needed because the destructors for
-                     // readonly variables will be called when the program
+#endif   // readonly variables will be called when the program
                     // exits. If the destructor is called while _mainDone
                     // is 0, it will assume that the readonly variable was
                     // declared locally. On all processors other than 0, 
@@ -526,7 +531,11 @@ static void _exitHandler(envelope *env)
         CmiFree(env);
       if(CkMyPe()){
        DEBUGF(("[%d] Calling converse exit \n",CkMyPe()));
+#if CMK_INTER_OPERATE
+        CpvAccess(charmLibExitFlag) = 1;
+#else
         ConverseExit();
+#endif
       }        
       break;
     case StatMsg:
@@ -538,9 +547,17 @@ static void _exitHandler(envelope *env)
       DEBUGF(("StatMsg on %d with %d\n", CkMyPe(), _numStatsRecd));
                        /*FAULT_EVAC*/
       if(_numStatsRecd==CkNumValidPes()) {
+#if CMK_INTER_OPERATE
+        _numStatsRecd = 0;
+#endif
         _printStats();
        DEBUGF(("[%d] Calling converse exit \n",CkMyPe()));
+#if CMK_INTER_OPERATE
+        _exitStarted = 0;
+        CpvAccess(charmLibExitFlag) = 1;
+#else
         ConverseExit();
+#endif
       }
       break;
     default:
@@ -824,11 +841,13 @@ void CkExit(void)
   CmiSetHandler(env, _exitHandlerIdx);
   CmiSyncSendAndFree(0, env->getTotalsize(), (char *)env);
 
+#if !CMK_INTER_OPERATE
 #if ! CMK_BIGSIM_THREAD
   _TRACE_END_EXECUTE();
   //Wait for stats, which will call ConverseExit when finished:
   CsdScheduler(-1);
 #endif
+#endif
 }
 
 /* This is a routine called in case the application is closing due to a signal.
index d2651271c79d11cf492db9d698588adb419a883a..373947d59b816d703ae17a4b16fb567c322af974 100644 (file)
@@ -135,6 +135,10 @@ extern void CldModuleInit(char **);
 CpvDeclare(int,_curRestartPhase);
 static int CsdLocalMax = CSD_LOCAL_MAX_DEFAULT;
 
+#if CMK_INTER_OPERATE
+CpvDeclare(int,charmLibExitFlag);
+#endif
+
 CpvStaticDeclare(int, CmiMainHandlerIDP); /* Main handler for _CmiMultipleSend that is run on every node */
 
 #if CMK_MEM_CHECKPOINT
@@ -1791,6 +1795,12 @@ void CsdScheduleForever(void)
   int isIdle=0;
   SCHEDULE_TOP
   while (1) {
+#if CMK_INTER_OPERATE
+    if(CpvAccess(charmLibExitFlag)) {
+      CpvAccess(charmLibExitFlag) = 0;
+      break;
+    }
+#endif
     msg = CsdNextMessage(&state);
     if (msg!=NULL) { /*A message is available-- process it*/
       if (isIdle) {isIdle=0;CsdEndIdle();}
@@ -3436,6 +3446,11 @@ void ConverseCommonInit(char **argv)
   CpvInitialize(int, cmiArgDebugFlag);
   CpvAccess(cmiArgDebugFlag) = 0;
 #endif
+#if CMK_INTER_OPERATE
+  CpvInitialize(int,charmLibExitFlag);
+  CpvAccess(charmLibExitFlag) = 0;
+#endif
+
   CpvInitialize(int,_curRestartPhase);
   CpvAccess(_curRestartPhase)=1;
   CmiArgInit(argv);
index 6efcd3a064a47b3af64d7cdcceb59f8543215d53..c08d5303ec00c5a6a1616b77a94fbddee787577d 100644 (file)
@@ -1899,4 +1899,8 @@ extern unsigned int CmiILog2(unsigned int);
 extern double CmiLog2(double);
 #endif
 
+#if CMK_INTER_OPERATE
+CpvExtern(int,charmLibExitFlag);
+#endif
+
 #endif /* CONVERSE_H */