-
Notifications
You must be signed in to change notification settings - Fork 897
init/finalize: extensions #1007
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
Conversation
opal_mutex_unlock(&ompi_mpi_bootstrap_mutex); | ||
usleep(1); | ||
opal_mutex_lock(&ompi_mpi_bootstrap_mutex); | ||
} | ||
|
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.
The result of this loop is basically a continuous loop doing a "lock + unlock"every 1us, in all cases. As you are using a mutex, why don't you rely on the trigger of the mutex by the thread that succeeded to ensure the sequentiality of this code?
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.
I specifically didn't hold the lock for the duration of ompi_mpi_init() / ompi_mpi_finalize(). Hence, I can't have the thread here just block waiting for the lock (e.g., which would naturally wait until the thread in ompi_mpi_init() completed the function).
Instead, I'm only using the lock to access the variables. Hence, I have to loop around checking it, unlocking, delaying, and locking again.
Are you advocating that I should hold the lock through ompi_mpi_init() / ompi_mpi_finalize()? I could probably do that (and then get rid of this loop, and the similar one in INITIALIZED)
de8f493
to
58d6f86
Compare
@bosilca Code changed to hold the lock for the bulk of the duration of ompi_mpi_init() and ompi_mpi_finalize(), thereby removing the need to loop checking the values of variables. |
58d6f86
to
e0f49fa
Compare
Thanks Jeff. Also, adding the blurb of text to the man pages is a great idea. The code looks good 👍 |
@hppritcha Does this look good to you? |
e0f49fa
to
b2a5f31
Compare
The more I think about this, the less I think it makes sense to allow MPI_INIT[_THREAD] to be invoked multiple times safely, but only allow MPI_FINALIZE to be invoked once. Should we give up on the idea of invoking MPI_INIT[_THREAD] multiple times, and just have this PR essentially be the bootstrap_mutex stuff? |
bool ompi_mpi_finalized = false; | ||
bool ompi_rte_initialized = false; | ||
int32_t ompi_mpi_finalize_started = false; | ||
opal_mutex_t ompi_mpi_bootstrap_mutex; |
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.
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.
Looks like the Right way is #1026.
Looks excellent. |
0b6b809
to
d91b717
Compare
Test FAILed. |
d91b717
to
76ad8f2
Compare
Test FAILed. |
76ad8f2
to
b262382
Compare
Test FAILed. |
3 similar comments
Test FAILed. |
Test FAILed. |
Test FAILed. |
Proposed extensions for Open MPI: - If MPI_INITLIZED is invoked and MPI is only partially initialized, wait until MPI is fully initialized before returning. - If MPI_FINALIZED is invoked and MPI is only partially finalized, wait until MPI is fully finalized before returning. - If the ompi_mpix_allow_multi_init MCA param is true, allow MPI_INIT and MPI_INIT_THREAD to be invoked multiple times without error (MPI will be safely initialized only the first time it is invoked).
Update language surrounding initialization and finalization in MPI_Init[_thread], MPI_Initialized, MPI_Finalize, and MPI_Finalized.
b262382
to
40b4d5d
Compare
I removed the MPIX MCA param and the ability to call MPI_INIT[_THREAD] multiple times. It's a can of worms. If someone else wants to tackle that issue, feel free to do so. This PR is now just:
|
…ed-perl-construct v2.0.0: autogen: fix deprecated construct
Proposed extensions for Open MPI:
@hppritcha @bosilca This is a bit more than we talked about on the phone last week. I ended up using a mutex instead of atomics because I have to check multiple values, so it made more sense to put all the checks within a mutex lock.