@@ -47,26 +47,36 @@ static const char FUNC_NAME[] = "MPI_Init_thread";
47
47
int MPI_Init_thread (int * argc , char * * * argv , int required ,
48
48
int * provided )
49
49
{
50
- int err ;
50
+ int err , safe_required = MPI_THREAD_SERIALIZED ;
51
51
52
52
ompi_hook_base_mpi_init_thread_top (argc , argv , required , provided );
53
53
54
- if ( MPI_PARAM_CHECK ) {
55
- if (required < MPI_THREAD_SINGLE || required > MPI_THREAD_MULTIPLE ) {
56
- ompi_mpi_errors_are_fatal_comm_handler (NULL , NULL , FUNC_NAME );
57
- }
54
+ /* Detect an incorrect thread support level, but dont report until we have the minimum
55
+ * infrastructure setup.
56
+ */
57
+ if ( (MPI_THREAD_SINGLE == required ) || (MPI_THREAD_SERIALIZED == required ) ||
58
+ (MPI_THREAD_FUNNELED == required ) || (MPI_THREAD_MULTIPLE == required ) ) {
59
+ safe_required = required ;
58
60
}
59
61
60
- * provided = required ;
62
+ * provided = safe_required ;
61
63
62
64
/* Call the back-end initialization function (we need to put as
63
65
little in this function as possible so that if it's profiled, we
64
66
don't lose anything) */
65
67
66
68
if (NULL != argc && NULL != argv ) {
67
- err = ompi_mpi_init (* argc , * argv , required , provided , false);
69
+ err = ompi_mpi_init (* argc , * argv , safe_required , provided , false);
68
70
} else {
69
- err = ompi_mpi_init (0 , NULL , required , provided , false);
71
+ err = ompi_mpi_init (0 , NULL , safe_required , provided , false);
72
+ }
73
+
74
+ if ( safe_required != required ) {
75
+ /* Trigger the error handler for the incorrect argument. Keep it separate from the
76
+ * check on the ompi_mpi_init return and report a nice, meaningful error message to
77
+ * the user. */
78
+ return ompi_errhandler_invoke ((ompi_errhandler_t * )& ompi_mpi_errors_are_fatal , NULL , OMPI_ERRHANDLER_TYPE_COMM ,
79
+ MPI_ERR_ARG , FUNC_NAME );
70
80
}
71
81
72
82
/* Since we don't have a communicator to invoke an errorhandler on
0 commit comments