1
1

Merge pull request #7323 from bosilca/fix/7320

Trap wrong parameters to MPI_Init_thread.
Этот коммит содержится в:
Jeff Squyres 2020-02-27 06:28:44 -05:00 коммит произвёл GitHub
родитель 19acb32a3f ecbd842ca8
Коммит af1ec9a594
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 19 добавлений и 9 удалений

Просмотреть файл

@ -61,7 +61,7 @@ void ompi_mpi_errors_are_fatal_comm_handler(struct ompi_communicator_t **comm,
va_start(arglist, error_code); va_start(arglist, error_code);
if (NULL != comm) { if ( (NULL != comm) && (NULL != *comm) ) {
name = (*comm)->c_name; name = (*comm)->c_name;
abort_comm = *comm; abort_comm = *comm;
} else { } else {

Просмотреть файл

@ -47,26 +47,36 @@ static const char FUNC_NAME[] = "MPI_Init_thread";
int MPI_Init_thread(int *argc, char ***argv, int required, int MPI_Init_thread(int *argc, char ***argv, int required,
int *provided) int *provided)
{ {
int err; int err, safe_required = MPI_THREAD_SERIALIZED;
ompi_hook_base_mpi_init_thread_top(argc, argv, required, provided); ompi_hook_base_mpi_init_thread_top(argc, argv, required, provided);
if ( MPI_PARAM_CHECK ) { /* Detect an incorrect thread support level, but dont report until we have the minimum
if (required < MPI_THREAD_SINGLE || required > MPI_THREAD_MULTIPLE) { * infrastructure setup.
ompi_mpi_errors_are_fatal_comm_handler(NULL, NULL, FUNC_NAME); */
} if( (MPI_THREAD_SINGLE == required) || (MPI_THREAD_SERIALIZED == required) ||
(MPI_THREAD_FUNNELED == required) || (MPI_THREAD_MULTIPLE == required) ) {
safe_required = required;
} }
*provided = required; *provided = safe_required;
/* Call the back-end initialization function (we need to put as /* Call the back-end initialization function (we need to put as
little in this function as possible so that if it's profiled, we little in this function as possible so that if it's profiled, we
don't lose anything) */ don't lose anything) */
if (NULL != argc && NULL != argv) { if (NULL != argc && NULL != argv) {
err = ompi_mpi_init(*argc, *argv, required, provided, false); err = ompi_mpi_init(*argc, *argv, safe_required, provided, false);
} else { } else {
err = ompi_mpi_init(0, NULL, required, provided, false); err = ompi_mpi_init(0, NULL, safe_required, provided, false);
}
if( safe_required != required ) {
/* Trigger the error handler for the incorrect argument. Keep it separate from the
* check on the ompi_mpi_init return and report a nice, meaningful error message to
* the user. */
return ompi_errhandler_invoke((ompi_errhandler_t*)&ompi_mpi_errors_are_fatal, NULL, OMPI_ERRHANDLER_TYPE_COMM,
MPI_ERR_ARG, FUNC_NAME);
} }
/* Since we don't have a communicator to invoke an errorhandler on /* Since we don't have a communicator to invoke an errorhandler on