-
Notifications
You must be signed in to change notification settings - Fork 877
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
Update opal to use C11 atomics if available #5445
Conversation
@bosilca Can you take a look? @jsquyres @bwbarrett @hppritcha It is my opinion we should always use the language support if it is available. I am sure there will be disagreement so I would like to know how we should proceed. I cab make configure prefer C11 atomics and give a way to force either sync builtins or the hand-written atomics. |
Needs some more work. Will update later today. |
Would be great for v4.0, but don't hold v4.0 branch. |
6f4729c
to
65dbd7c
Compare
e6f0137
to
fa97c2b
Compare
Think I fixed everything. The opal_atomic_*_ptr functions were changed to work on |
No user-facing things changed. All this is completely internal. |
As for downsides, I don't think there are any vs what we already have with the gcc/icc builtins (__sync, __atomic). In fact, __atomic is likely the underlying implementation of the C11/C++11 atomics. I plan to run some performance tests today to make sure there is no slowdown with the C11 atomics. I do not expect one but need to be sure. |
Ok, that should make the pull request build checker happy. Forgot the int128_t C11 atomics on x86_64 with gcc are not lock-free. The workaround is to use __sync builtins for the 128-bit CAS. |
Performance of RMA-MT on Cray XC shows no performance difference between C11 and the hand-written assembly. That is a good sign :). |
c64c9b9
to
bc8617c
Compare
@hoopoepg The ARM64 tests failed for something unrelated to this PR. Looks like it is in oshmem. Can you take a look at the errors in https://jenkins.open-mpi.org/jenkins/job/open-mpi.build.platforms/3283/Platform=ARMv8/ |
Ok, looks good to go now. The only failure appears to be unrelated to this PR. |
Hmm, i see what is going wrong:
@hoopoepg atomic_init is a C-language macro. You need to change the name. In fact, you need to avoid using any of these identifiers: https://en.cppreference.com/w/c/atomic . They are not reserved but at some point we will require C11 and will always include stdatomic.h. |
@hoopoepg perfect. thanks! |
:bot:retest |
Ok, so far so good. I have to address one bug then this is good to go. Turns out the implicit memory order is |
@bosilca Any comments on this? |
I only have positive comments. Maybe the only concern I have with this patch is the overwhelming number of functions for atomic support with most of them never used and doubtfully needed in the future. I might have preferred a smaller patch, one that only provide the _strong version of the atomic functions (which is the only one we currently use if I'm not mistaken). |
This commit updates the entire codebase to use specific opal types for all atomic variables. This is a change from the prior atomic support which required the use of the volatile keyword. This is the first step towards implementing support for C11 atomics as that interface requires the use of types declared with the _Atomic keyword. Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
This commit disables the use of both the builtin and hand-written atomics if proper C11 atomic support is detected. This is the first step towards requiring the availability of C11 atomics for the C compiler used to build Open MPI. Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
This PR introduces a new set of types to be used for all opal atomics (opal_atomic_*) and adds support for C11 atomics. If C11 atomics are detected they are used exclusively.
This PR should be safe for v4.0.0 if we want to merge it today. I have no opinion either way.