diff --git a/ompi/mpi/c/init_thread.c b/ompi/mpi/c/init_thread.c index 25adfe999e..b046ed0912 100644 --- a/ompi/mpi/c/init_thread.c +++ b/ompi/mpi/c/init_thread.c @@ -33,27 +33,39 @@ static const char FUNC_NAME[] = "MPI_Init_thread"; int MPI_Init_thread(int *argc, char ***argv, int required, int *provided) { - int err; - MPI_Comm null = NULL; + int err; + MPI_Comm null = NULL; - /* Ensure that we were not already initialized or finalized */ + /* + * A thread compliant MPI implementation will be able to return provided + * = MPI_THREAD_MULTIPLE. Such an implementation may always return provided + * = MPI_THREAD_MULTIPLE, irrespective of the value of required. + */ +#if OMPI_ENABLE_MPI_THREADS + *provided = MPI_THREAD_MULTIPLE; +#else + *provided = MPI_THREAD_SINGLE; +#endif - if (ompi_mpi_finalized) { - /* JMS show_help */ - return OMPI_ERRHANDLER_INVOKE(null, MPI_ERR_OTHER, FUNC_NAME); - } else if (ompi_mpi_initialized) { - /* JMS show_help */ - return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_OTHER, FUNC_NAME); - } + /* Ensure that we were not already initialized or finalized */ - /* Call the back-end initialization function (we need to put as - little in this function as possible so that if it's profiled, we - don't lose anything) */ + if (ompi_mpi_finalized) { + /* JMS show_help */ + return OMPI_ERRHANDLER_INVOKE(null, MPI_ERR_OTHER, FUNC_NAME); + } else if (ompi_mpi_initialized) { + /* JMS show_help */ + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_OTHER, FUNC_NAME); + } - if (NULL != argc && NULL != argv) { - err = ompi_mpi_init(*argc, *argv, required, provided); - } else { - err = ompi_mpi_init(0, NULL, required, provided); - } - OMPI_ERRHANDLER_RETURN(err, null, err, FUNC_NAME); + /* Call the back-end initialization function (we need to put as + little in this function as possible so that if it's profiled, we + don't lose anything) */ + + if (NULL != argc && NULL != argv) { + err = ompi_mpi_init(*argc, *argv, required, provided); + } else { + err = ompi_mpi_init(0, NULL, required, provided); + } + + OMPI_ERRHANDLER_RETURN(err, null, err, FUNC_NAME); }