-
Notifications
You must be signed in to change notification settings - Fork 897
bugfix: Setting OMPI_MPI_THREAD_LEVEL to a value different than requested crashes #13211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
* reserved. | ||
* Copyright (c) 2024 Triad National Security, LLC. All rights | ||
* reserved. | ||
* Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved. | ||
* $COPYRIGHT$ | ||
* | ||
* Additional copyrights may follow | ||
|
@@ -39,22 +40,32 @@ | |
PROTOTYPE ERROR_CLASS init_thread(INT_OUT argc, ARGV argv, INT required, | ||
INT_OUT provided) | ||
{ | ||
int err, safe_required = MPI_THREAD_SERIALIZED; | ||
int err, err_arg_required = false, safe_required = MPI_THREAD_SERIALIZED; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If |
||
char *env; | ||
|
||
ompi_hook_base_mpi_init_thread_top(argc, argv, required, provided); | ||
|
||
/* Detect an incorrect thread support level, but dont report until we have the minimum | ||
* infrastructure setup. | ||
*/ | ||
if( (MPI_THREAD_SINGLE == required) || (MPI_THREAD_SERIALIZED == required) || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is inconsistent with the way this is tested in MPI_INIT. To make it consistent, I picked the resolution with an explicit individual check per value (in MPI_INIT), this should be more in-tune with ABI values when that becomes relevant. |
||
(MPI_THREAD_FUNNELED == required) || (MPI_THREAD_MULTIPLE == required) ) { | ||
err_arg_required = (required != MPI_THREAD_SINGLE && required != MPI_THREAD_FUNNELED && | ||
required != MPI_THREAD_SERIALIZED && required != MPI_THREAD_MULTIPLE); | ||
if (!err_arg_required) { | ||
safe_required = required; | ||
} | ||
|
||
if (NULL != (env = getenv("OMPI_MPI_THREAD_LEVEL"))) { | ||
safe_required = atoi(env); | ||
} | ||
else { | ||
safe_required = required; | ||
/* check for environment overrides for required thread level. If | ||
* there is, check to see that it is a valid/supported thread level. | ||
* if it is lower than argument required, set it anyway, program can | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment says that you are checking for a lower value, but the code is not checking lower vs. higher. I personally think it's fine to have the env variable always override (regardless of lower vs. higher); please adjust the comment. |
||
* check provided == required to verify that required has been ignored | ||
*/ | ||
if (NULL != (env = getenv("OMPI_MPI_THREAD_LEVEL"))) { | ||
int env_required = atoi(env); | ||
err_arg_required = err_arg_required || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
(env_required != MPI_THREAD_SINGLE && env_required != MPI_THREAD_FUNNELED && | ||
env_required != MPI_THREAD_SERIALIZED && env_required != MPI_THREAD_MULTIPLE); | ||
if (!err_arg_required) { | ||
safe_required = env_required; | ||
} | ||
} | ||
|
||
|
@@ -70,7 +81,7 @@ PROTOTYPE ERROR_CLASS init_thread(INT_OUT argc, ARGV argv, INT required, | |
err = ompi_mpi_init(0, NULL, safe_required, provided, false); | ||
} | ||
|
||
if( safe_required != required ) { | ||
if (err_arg_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. */ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious: what's the need for this? Doesn't MPI specify the relationship between all the
MPI_THREAD_*
values such that < SINGLE and > MULTIPLE is guaranteed to be invalid?