[mpich-commits] [mpich] MPICH primary repository branch, master, updated. v3.1.3-114-g9ea630d

Service Account noreply at mpich.org
Tue Nov 4 08:54:24 CST 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "MPICH primary repository".

The branch, master has been updated
       via  9ea630d09e1f4e4b278579c76d878a48ea975dc5 (commit)
       via  435ce80008abb3c92e5710ccd1637ba518464e72 (commit)
       via  dfb872fe7dc6bc9d1a31546f76345ebf5b8caea5 (commit)
      from  ed20cd3738d66c7baa65ccb15534559bb0598220 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.mpich.org/mpich.git/commitdiff/9ea630d09e1f4e4b278579c76d878a48ea975dc5

commit 9ea630d09e1f4e4b278579c76d878a48ea975dc5
Author: Junchao Zhang <jczhang at mcs.anl.gov>
Date:   Mon Oct 27 08:49:19 2014 -0500

    Rename enum MPICH_WITHIN_MPI to MPICH_IN_INIT
    
    The new enum name is more descriptive to describle an MPIR_MPI_State_t
    that says MPICH is in initialization but not completely finished.
    
    Signed-off-by: Pavan Balaji <balaji at anl.gov>

diff --git a/src/include/mpiimpl.h b/src/include/mpiimpl.h
index cbeb22f..7402b0c 100644
--- a/src/include/mpiimpl.h
+++ b/src/include/mpiimpl.h
@@ -2167,7 +2167,7 @@ extern struct MPID_CommOps  *MPID_Comm_fns; /* Communicator creation functions *
 /* Per process data */
 typedef enum MPIR_MPI_State_t {
     MPICH_PRE_INIT=0,
-    MPICH_WITHIN_MPI,
+    MPICH_IN_INIT,
     MPICH_POST_INIT,
     MPICH_POST_FINALIZED
 } MPIR_MPI_State_t;
diff --git a/src/mpi/init/finalize.c b/src/mpi/init/finalize.c
index 9585778..f71668b 100644
--- a/src/mpi/init/finalize.c
+++ b/src/mpi/init/finalize.c
@@ -77,7 +77,7 @@ void MPIR_Add_finalize( int (*f)( void * ), void *extra_data, int priority )
 	/* This is a little tricky.  We may want to check the state of
 	   MPIR_Process.mpich_state to decide how to signal the error */
 	(void)MPIU_Internal_error_printf( "overflow in finalize stack!\n" );
-    if (OPA_load_int(&MPIR_Process.mpich_state) == MPICH_WITHIN_MPI ||
+    if (OPA_load_int(&MPIR_Process.mpich_state) == MPICH_IN_INIT ||
         OPA_load_int(&MPIR_Process.mpich_state) == MPICH_POST_INIT)
     {
 	    MPID_Abort( NULL, MPI_SUCCESS, 13, NULL );
diff --git a/src/mpi/init/finalized.c b/src/mpi/init/finalized.c
index 1acf83f..e4c2cd2 100644
--- a/src/mpi/init/finalized.c
+++ b/src/mpi/init/finalized.c
@@ -82,7 +82,7 @@ int MPI_Finalized( int *flag )
     /* --BEGIN ERROR HANDLING-- */
 #   ifdef HAVE_ERROR_CHECKING
   fn_fail:
-    if (OPA_load_int(&MPIR_Process.mpich_state) == MPICH_WITHIN_MPI ||
+    if (OPA_load_int(&MPIR_Process.mpich_state) == MPICH_IN_INIT ||
         OPA_load_int(&MPIR_Process.mpich_state) == MPICH_POST_INIT)
     {
 	{
diff --git a/src/mpi/init/initialized.c b/src/mpi/init/initialized.c
index 8b163c3..0108a9f 100644
--- a/src/mpi/init/initialized.c
+++ b/src/mpi/init/initialized.c
@@ -82,7 +82,7 @@ int MPI_Initialized( int *flag )
     /* --BEGIN ERROR HANDLING-- */
 #   ifdef HAVE_ERROR_CHECKING
   fn_fail:
-    if (OPA_load_int(&MPIR_Process.mpich_state) == MPICH_WITHIN_MPI ||
+    if (OPA_load_int(&MPIR_Process.mpich_state) == MPICH_IN_INIT ||
         OPA_load_int(&MPIR_Process.mpich_state) == MPICH_POST_INIT)
     {
 	{
diff --git a/src/mpi/init/initthread.c b/src/mpi/init/initthread.c
index a57eecc..a7d65ba 100644
--- a/src/mpi/init/initthread.c
+++ b/src/mpi/init/initthread.c
@@ -475,7 +475,7 @@ int MPIR_Init_thread(int * argc, char ***argv, int required, int * provided)
 
     /* define MPI as initialized so that we can use MPI functions within 
        MPID_Init if necessary */
-    OPA_store_int(&MPIR_Process.mpich_state, MPICH_WITHIN_MPI);
+    OPA_store_int(&MPIR_Process.mpich_state, MPICH_IN_INIT);
 
     /* We can't acquire any critical sections until this point.  Any
      * earlier the basic data structures haven't been initialized */

http://git.mpich.org/mpich.git/commitdiff/435ce80008abb3c92e5710ccd1637ba518464e72

commit 435ce80008abb3c92e5710ccd1637ba518464e72
Author: Junchao Zhang <jczhang at mcs.anl.gov>
Date:   Tue Oct 21 16:33:17 2014 -0500

    Make MPI_Initialized and friends thread-safe
    
    Implements MPI-Forum ticket 357 (https://svn.mpi-forum.org/trac/mpi-forum-web/ticket/357)
    
    The ticket will be included in MPI-3.1, which adds thread-safety to MPI_INITIALIZED,
    MPI_FINALIZED, MPI_QUERY_THREAD, MPI_IS_THREAD_MAIN, MPI_GET_VERSION and
    MPI_GET_LIBRARY_VERSION.
    
    In MPICH, we make MPIR_Process.mpich_state atomic. After MPI is fully initialized, i.e.,
    in POST_INIT state, MPI_QUERY_THREAD, MPI_IS_THREAD_MAIN are inherently thread-safe.
    
    Fixes #2137
    
    Signed-off-by: Pavan Balaji <balaji at anl.gov>

diff --git a/src/include/mpierrs.h b/src/include/mpierrs.h
index 3eeb243..5a5478f 100644
--- a/src/include/mpierrs.h
+++ b/src/include/mpierrs.h
@@ -832,7 +832,8 @@ cvars:
 #ifdef HAVE_ERROR_CHECKING
 #define MPIR_ERRTEST_INITIALIZED_ORDIE()			\
 do {								\
-    if (MPIR_Process.initialized != MPICH_WITHIN_MPI)		\
+    if (OPA_load_int(&MPIR_Process.mpich_state) == MPICH_PRE_INIT || \
+        OPA_load_int(&MPIR_Process.mpich_state) == MPICH_POST_FINALIZED) \
     {								\
 	MPIR_Err_preOrPostInit();				\
     }                                                           \
diff --git a/src/include/mpiimpl.h b/src/include/mpiimpl.h
index a063061..cbeb22f 100644
--- a/src/include/mpiimpl.h
+++ b/src/include/mpiimpl.h
@@ -2168,6 +2168,7 @@ extern struct MPID_CommOps  *MPID_Comm_fns; /* Communicator creation functions *
 typedef enum MPIR_MPI_State_t {
     MPICH_PRE_INIT=0,
     MPICH_WITHIN_MPI,
+    MPICH_POST_INIT,
     MPICH_POST_FINALIZED
 } MPIR_MPI_State_t;
 
@@ -2184,7 +2185,8 @@ typedef struct PreDefined_attrs {
 struct MPID_Datatype;
 
 typedef struct MPICH_PerProcess_t {
-    MPIR_MPI_State_t  initialized;      /* Is MPI initalized? */
+    OPA_int_t mpich_state; /* State of MPICH. Use OPA_int_t to make MPI_Initialized() etc.
+                              thread-safe per MPI-3.1.  See MPI-Forum ticket 357 */
     int               do_error_checks;  /* runtime error check control */
     struct MPID_Comm  *comm_world;      /* Easy access to comm_world for
                                            error handler */
diff --git a/src/mpi/errhan/errutil.c b/src/mpi/errhan/errutil.c
index 633697d..ff3dd13 100644
--- a/src/mpi/errhan/errutil.c
+++ b/src/mpi/errhan/errutil.c
@@ -211,10 +211,10 @@ void MPIR_Errhandler_set_fc( MPI_Errhandler errhand )
 /* --BEGIN ERROR HANDLING-- */
 void MPIR_Err_preOrPostInit( void )
 {
-    if (MPIR_Process.initialized == MPICH_PRE_INIT) {
+    if (OPA_load_int(&MPIR_Process.mpich_state) == MPICH_PRE_INIT) {
 	MPIU_Error_printf("Attempting to use an MPI routine before initializing MPICH\n");
     }
-    else if (MPIR_Process.initialized == MPICH_POST_FINALIZED) {
+    else if (OPA_load_int(&MPIR_Process.mpich_state) == MPICH_POST_FINALIZED) {
 	MPIU_Error_printf("Attempting to use an MPI routine after finalizing MPICH\n");
     }
     else {
@@ -244,8 +244,8 @@ int MPIR_Err_return_comm( MPID_Comm  *comm_ptr, const char fcname[],
     checkValidErrcode( error_class, fcname, &errcode );
 
     /* --BEGIN ERROR HANDLING-- */
-    if (MPIR_Process.initialized == MPICH_PRE_INIT ||
-        MPIR_Process.initialized == MPICH_POST_FINALIZED)
+    if (OPA_load_int(&MPIR_Process.mpich_state) == MPICH_PRE_INIT ||
+        OPA_load_int(&MPIR_Process.mpich_state) == MPICH_POST_FINALIZED)
     {
         /* for whatever reason, we aren't initialized (perhaps error 
 	   during MPI_Init) */
diff --git a/src/mpi/init/finalize.c b/src/mpi/init/finalize.c
index 97a4439..9585778 100644
--- a/src/mpi/init/finalize.c
+++ b/src/mpi/init/finalize.c
@@ -75,9 +75,11 @@ void MPIR_Add_finalize( int (*f)( void * ), void *extra_data, int priority )
     /* --BEGIN ERROR HANDLING-- */
     if (fstack_sp >= MAX_FINALIZE_FUNC) {
 	/* This is a little tricky.  We may want to check the state of
-	   MPIR_Process.initialized to decide how to signal the error */
+	   MPIR_Process.mpich_state to decide how to signal the error */
 	(void)MPIU_Internal_error_printf( "overflow in finalize stack!\n" );
-	if (MPIR_Process.initialized == MPICH_WITHIN_MPI) {
+    if (OPA_load_int(&MPIR_Process.mpich_state) == MPICH_WITHIN_MPI ||
+        OPA_load_int(&MPIR_Process.mpich_state) == MPICH_POST_INIT)
+    {
 	    MPID_Abort( NULL, MPI_SUCCESS, 13, NULL );
 	}
 	else {
@@ -256,7 +258,7 @@ int MPI_Finalize( void )
        finalize callbacks */
 
     MPIU_THREAD_CS_EXIT(ALLFUNC,);
-    MPIR_Process.initialized = MPICH_POST_FINALIZED;
+    OPA_store_int(&MPIR_Process.mpich_state, MPICH_POST_FINALIZED);
 
     MPIU_THREAD_CS_FINALIZE;
 
@@ -314,7 +316,7 @@ int MPI_Finalize( void )
     }
 #   endif
     mpi_errno = MPIR_Err_return_comm( 0, FCNAME, mpi_errno );
-    if (MPIR_Process.initialized < MPICH_POST_FINALIZED) {
+    if (OPA_load_int(&MPIR_Process.mpich_state) < MPICH_POST_FINALIZED) {
         MPIU_THREAD_CS_EXIT(ALLFUNC,);
     }
     goto fn_exit;
diff --git a/src/mpi/init/finalized.c b/src/mpi/init/finalized.c
index 12adc24..1acf83f 100644
--- a/src/mpi/init/finalized.c
+++ b/src/mpi/init/finalized.c
@@ -69,7 +69,7 @@ int MPI_Finalized( int *flag )
 
     /* ... body of routine ...  */
     
-    *flag = (MPIR_Process.initialized >= MPICH_POST_FINALIZED);
+    *flag = (OPA_load_int(&MPIR_Process.mpich_state) >= MPICH_POST_FINALIZED);
     
     /* ... end of body of routine ... */
 
@@ -82,8 +82,9 @@ int MPI_Finalized( int *flag )
     /* --BEGIN ERROR HANDLING-- */
 #   ifdef HAVE_ERROR_CHECKING
   fn_fail:
-    if (MPIR_Process.initialized == MPICH_WITHIN_MPI)
-    { 
+    if (OPA_load_int(&MPIR_Process.mpich_state) == MPICH_WITHIN_MPI ||
+        OPA_load_int(&MPIR_Process.mpich_state) == MPICH_POST_INIT)
+    {
 	{
 	    mpi_errno = MPIR_Err_create_code(
 		mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, 
diff --git a/src/mpi/init/init.c b/src/mpi/init/init.c
index 9bea820..e182ffc 100644
--- a/src/mpi/init/init.c
+++ b/src/mpi/init/init.c
@@ -132,7 +132,7 @@ int MPI_Init( int *argc, char ***argv )
     {
         MPID_BEGIN_ERROR_CHECKS;
         {
-            if (MPIR_Process.initialized != MPICH_PRE_INIT) {
+            if (OPA_load_int(&MPIR_Process.mpich_state) != MPICH_PRE_INIT) {
                 mpi_errno = MPIR_Err_create_code( MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER,
 						  "**inittwice", NULL );
 	    }
diff --git a/src/mpi/init/initialized.c b/src/mpi/init/initialized.c
index 07c3a4b..8b163c3 100644
--- a/src/mpi/init/initialized.c
+++ b/src/mpi/init/initialized.c
@@ -69,7 +69,7 @@ int MPI_Initialized( int *flag )
 
     /* ... body of routine ...  */
     
-    *flag = (MPIR_Process.initialized >= MPICH_WITHIN_MPI);
+    *flag = (OPA_load_int(&MPIR_Process.mpich_state) >= MPICH_POST_INIT);
     
     /* ... end of body of routine ... */
 
@@ -82,8 +82,9 @@ int MPI_Initialized( int *flag )
     /* --BEGIN ERROR HANDLING-- */
 #   ifdef HAVE_ERROR_CHECKING
   fn_fail:
-    if (MPIR_Process.initialized == MPICH_WITHIN_MPI)
-    { 
+    if (OPA_load_int(&MPIR_Process.mpich_state) == MPICH_WITHIN_MPI ||
+        OPA_load_int(&MPIR_Process.mpich_state) == MPICH_POST_INIT)
+    {
 	{
 	    mpi_errno = MPIR_Err_create_code(
 		mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, 
diff --git a/src/mpi/init/initthread.c b/src/mpi/init/initthread.c
index 7b3f32d..a57eecc 100644
--- a/src/mpi/init/initthread.c
+++ b/src/mpi/init/initthread.c
@@ -82,7 +82,7 @@ int MPI_Init_thread(int *argc, char ***argv, int required, int *provided) __attr
 /* Any internal routines can go here.  Make them static if possible */
 
 /* Global variables can be initialized here */
-MPICH_PerProcess_t MPIR_Process = { MPICH_PRE_INIT }; 
+MPICH_PerProcess_t MPIR_Process = { OPA_INT_T_INITIALIZER(MPICH_PRE_INIT) };
      /* all other fields in MPIR_Process are irrelevant */
 MPICH_ThreadInfo_t MPIR_ThreadInfo = { 0 };
 
@@ -475,7 +475,7 @@ int MPIR_Init_thread(int * argc, char ***argv, int required, int * provided)
 
     /* define MPI as initialized so that we can use MPI functions within 
        MPID_Init if necessary */
-    MPIR_Process.initialized = MPICH_WITHIN_MPI;
+    OPA_store_int(&MPIR_Process.mpich_state, MPICH_WITHIN_MPI);
 
     /* We can't acquire any critical sections until this point.  Any
      * earlier the basic data structures haven't been initialized */
@@ -560,12 +560,16 @@ int MPIR_Init_thread(int * argc, char ***argv, int required, int * provided)
 
 fn_exit:
     MPIU_THREAD_CS_EXIT(INIT,required);
+    /* Make fields of MPIR_Process global visible and set mpich_state
+       atomically so that MPI_Initialized() etc. are thread safe */
+    OPA_write_barrier();
+    OPA_store_int(&MPIR_Process.mpich_state, MPICH_POST_INIT);
     return mpi_errno;
 
 fn_fail:
     /* --BEGIN ERROR HANDLING-- */
     /* signal to error handling routines that core services are unavailable */
-    MPIR_Process.initialized = MPICH_PRE_INIT;
+    OPA_store_int(&MPIR_Process.mpich_state, MPICH_PRE_INIT);
 
     if (exit_init_cs_on_failure) {
         MPIU_THREAD_CS_EXIT(INIT,required);
@@ -635,7 +639,7 @@ int MPI_Init_thread( int *argc, char ***argv, int required, int *provided )
     {
         MPID_BEGIN_ERROR_CHECKS;
         {
-            if (MPIR_Process.initialized != MPICH_PRE_INIT) {
+            if (OPA_load_int(&MPIR_Process.mpich_state) != MPICH_PRE_INIT) {
                 mpi_errno = MPIR_Err_create_code( MPI_SUCCESS, MPIR_ERR_RECOVERABLE, "MPI_Init_thread", __LINE__, MPI_ERR_OTHER,
 						  "**inittwice", 0 );
 	    }

http://git.mpich.org/mpich.git/commitdiff/dfb872fe7dc6bc9d1a31546f76345ebf5b8caea5

commit dfb872fe7dc6bc9d1a31546f76345ebf5b8caea5
Author: Junchao Zhang <jczhang at mcs.anl.gov>
Date:   Sun Nov 2 22:09:42 2014 -0600

    Code clean up for enum MPIR_MPI_State_t
    
    Also remove numbering for each enum, which is not necessary and is
    hard to maintain.
    
    Signed-off-by: Pavan Balaji <balaji at anl.gov>

diff --git a/src/include/mpiimpl.h b/src/include/mpiimpl.h
index f3ede9e..a063061 100644
--- a/src/include/mpiimpl.h
+++ b/src/include/mpiimpl.h
@@ -2165,8 +2165,11 @@ extern struct MPID_CommOps  *MPID_Comm_fns; /* Communicator creation functions *
 
 
 /* Per process data */
-typedef enum MPIR_MPI_State_t { MPICH_PRE_INIT=0, MPICH_WITHIN_MPI=1,
-               MPICH_POST_FINALIZED=2 } MPIR_MPI_State_t;
+typedef enum MPIR_MPI_State_t {
+    MPICH_PRE_INIT=0,
+    MPICH_WITHIN_MPI,
+    MPICH_POST_FINALIZED
+} MPIR_MPI_State_t;
 
 typedef struct PreDefined_attrs {
     int appnum;          /* Application number provided by mpiexec (MPI-2) */

-----------------------------------------------------------------------

Summary of changes:
 src/include/mpierrs.h      |    3 ++-
 src/include/mpiimpl.h      |   11 ++++++++---
 src/mpi/errhan/errutil.c   |    8 ++++----
 src/mpi/init/finalize.c    |   10 ++++++----
 src/mpi/init/finalized.c   |    7 ++++---
 src/mpi/init/init.c        |    2 +-
 src/mpi/init/initialized.c |    7 ++++---
 src/mpi/init/initthread.c  |   12 ++++++++----
 8 files changed, 37 insertions(+), 23 deletions(-)


hooks/post-receive
-- 
MPICH primary repository


More information about the commits mailing list