Add a feature to test whether a SMP node has idle PEs
authorChao Mei <chaomei2@hopper11.(none)>
Tue, 8 May 2012 04:10:40 +0000 (21:10 -0700)
committerChao Mei <chaomei2@hopper11.(none)>
Tue, 8 May 2012 04:10:40 +0000 (21:10 -0700)
src/conv-core/convcore.c
src/conv-core/converse.h

index 27886a21056aafc98fc4c040aaad09ec9600baec..1909bced9f43e995e00efc87433e929a61e7b32a 100644 (file)
@@ -223,6 +223,9 @@ void* LrtsAlloc(int, int);
 void  LrtsFree(void*);
 #endif
 
+CpvStaticDeclare(int, cmiMyPeIdle);
+int CmiIsMyNodeIdle();
+
 /*****************************************************************************
  *
  * Command-Line Argument (CLA) parsing routines.
@@ -1556,6 +1559,9 @@ void CsdBeginIdle(void)
 #if CMK_TRACE_ENABLED && CMK_PROJECTOR
   _LOG_E_PROC_IDLE();  /* projector */
 #endif
+
+  CpvAccess(cmiMyPeIdle) = 1;
+
   CcdRaiseCondition(CcdPROCESSOR_BEGIN_IDLE) ;
 }
 
@@ -1569,6 +1575,9 @@ void CsdEndIdle(void)
 #if CMK_TRACE_ENABLED && CMK_PROJECTOR
   _LOG_E_PROC_BUSY();  /* projector */
 #endif
+
+  CpvAccess(cmiMyPeIdle) = 0;
+
   CcdRaiseCondition(CcdPROCESSOR_BEGIN_BUSY) ;
 }
 
@@ -3520,6 +3529,10 @@ void ConverseCommonInit(char **argv)
 #endif
   if (CmiMyPe() == 0)
       CmiPrintf("Converse/Charm++ Commit ID: %s\n", CmiCommitID);
+
+  CpvInitialize(int, cmiMyPeIdle);
+  CpvAccess(cmiMyPeIdle) = 0;
+
 /* #if CONVERSE_POOL */
   CmiPoolAllocInit(30);  
 /* #endif */
@@ -3802,4 +3815,12 @@ double CmiReadSize(const char *str)
     return val;
 }
 
+int CmiIsMyNodeIdle(){
+    int i;
+    for(i=0; i<CmiMyNodeSize(); i++){
+        if(CpvAccessOther(cmiMyPeIdle, i)) return 1;
+    }
+    return 0;
+}
+
 /*@}*/
index 59d4e8c68810048528431dd248f086a6985ca583..b65b92e14d10b6c1b92aaadcf78debf95bcb039a 100644 (file)
@@ -1928,6 +1928,12 @@ CpvCExtern(int, _urgentSend);
 #define CmiEnableUrgentSend(yn)   
 #endif
 
+#if defined(__cplusplus)
+extern "C" int CmiIsMyNodeIdle();
+#else
+extern int CmiIsMyNodeIdle();
+#endif
+
 #endif /* CONVERSE_H */