1010 * Copyright (c) 2004-2005 The Regents of the University of California.
1111 * All rights reserved.
1212 * Copyright (c) 2006 University of Houston. All rights reserved.
13- * Copyright (c) 2008-2013 Cisco Systems, Inc. All rights reserved.
13+ * Copyright (c) 2008-2018 Cisco Systems, Inc. All rights reserved
1414 * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
1515 * Copyright (c) 2010-2011 Oak Ridge National Labs. All rights reserved.
1616 * Copyright (c) 2012 Los Alamos National Security, LLC.
@@ -149,7 +149,7 @@ void ompi_mpi_errors_return_win_handler(struct ompi_win_t **win,
149149
150150static void out (char * str , char * arg )
151151{
152- if (ompi_mpi_initialized && ! ompi_mpi_finalized ) {
152+ if (ompi_mpi_state < OMPI_MPI_STATE_FINALIZE_PAST_COMM_SELF_DESTRUCT ) {
153153 if (NULL != arg ) {
154154 opal_output (0 , str , arg );
155155 } else {
@@ -190,7 +190,9 @@ static void backend_fatal_aggregate(char *type,
190190 const char * usable_prefix = unknown_prefix ;
191191 const char * usable_err_msg = unknown_error ;
192192
193- assert (ompi_mpi_initialized && !ompi_mpi_finalized );
193+ int32_t state = ompi_mpi_state ;
194+ assert (state < OMPI_MPI_STATE_INIT_COMPLETED ||
195+ state >= OMPI_MPI_STATE_FINALIZE_PAST_COMM_SELF_DESTRUCT );
194196
195197 arg = va_arg (arglist , char * );
196198 va_end (arglist );
@@ -282,7 +284,9 @@ static void backend_fatal_no_aggregate(char *type,
282284{
283285 char * arg ;
284286
285- assert (!ompi_mpi_initialized || ompi_mpi_finalized );
287+ int32_t state = ompi_mpi_state ;
288+ assert (state < OMPI_MPI_STATE_INIT_COMPLETED ||
289+ state >= OMPI_MPI_STATE_FINALIZE_PAST_COMM_SELF_DESTRUCT );
286290
287291 fflush (stdout );
288292 fflush (stderr );
@@ -291,7 +295,7 @@ static void backend_fatal_no_aggregate(char *type,
291295
292296 /* Per #2152, print out in plain english if something was invoked
293297 before MPI_INIT* or after MPI_FINALIZE */
294- if (! ompi_mpi_init_started && ! ompi_mpi_initialized ) {
298+ if (state < OMPI_MPI_STATE_INIT_STARTED ) {
295299 if (NULL != arg ) {
296300 out ("*** The %s() function was called before MPI_INIT was invoked.\n"
297301 "*** This is disallowed by the MPI standard.\n" , arg );
@@ -302,7 +306,7 @@ static void backend_fatal_no_aggregate(char *type,
302306 "*** function was invoked, sorry. :-(\n" , NULL );
303307 }
304308 out ("*** Your MPI job will now abort.\n" , NULL );
305- } else if (ompi_mpi_finalized ) {
309+ } else if (state >= OMPI_MPI_STATE_FINALIZE_PAST_COMM_SELF_DESTRUCT ) {
306310 if (NULL != arg ) {
307311 out ("*** The %s() function was called after MPI_FINALIZE was invoked.\n"
308312 "*** This is disallowed by the MPI standard.\n" , arg );
@@ -377,7 +381,9 @@ static void backend_fatal(char *type, struct ompi_communicator_t *comm,
377381{
378382 /* We only want aggregation after MPI_INIT and before
379383 MPI_FINALIZE. */
380- if (ompi_mpi_initialized && !ompi_mpi_finalized ) {
384+ int32_t state = ompi_mpi_state ;
385+ if (state >= OMPI_MPI_STATE_INIT_COMPLETED &&
386+ state < OMPI_MPI_STATE_FINALIZE_PAST_COMM_SELF_DESTRUCT ) {
381387 backend_fatal_aggregate (type , comm , name , error_code , arglist );
382388 } else {
383389 backend_fatal_no_aggregate (type , comm , name , error_code , arglist );
0 commit comments