Skip to content

opal_atomic_rmb: GCC has fixed its acquire fence barrier in its 8 release #10118

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

Merged
merged 1 commit into from
Mar 21, 2022

Conversation

devreal
Copy link
Contributor

@devreal devreal commented Mar 14, 2022

Only force a full memory barrier for GCC releases prior to 8.1.0.

Signed-off-by: Joseph Schuchart schuchart@icl.utk.edu

@devreal devreal requested review from hjelmn and bwbarrett March 14, 2022 16:16
@devreal
Copy link
Contributor Author

devreal commented Mar 14, 2022

Forgot to add: I came across this issue in the test suite of another project with GCC 7.3.0. With GCC 8.1.0 the issue seems to be fixed and the test suite succeeds there. We should only exclude GCC prior to 8.1.0 and not all x86-64 compilers.

*/
# if defined(PLATFORM_ARCH_X86_64) && \
PLATFORM_COMPILER_GNU && __GNUC__ < 8
# define OPAL_ATOMIC_RMB_GCC_FENCE_ACQUIRE_BROKEN 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need the extra define? I'd rather not create another (in this case atomic_stdc-only) define we need to maintain going forward.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it'd be cleaner (I had a somewhat more complex condition earlier). I agree, put it back into the code directly.

* to be fixed from 8.1.0 onwards
*/
# if defined(PLATFORM_ARCH_X86_64) && \
PLATFORM_COMPILER_GNU && __GNUC__ < 8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the issue fixed in GCC 8.0 (the code) or GCC 8.1 (the comment)? We should be careful there. Do we need to check __GNUC_MINOR__ as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was no 8.0 release. The first release in the 8 series was 8.1: https://gcc.gnu.org/releases.html

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a good thing to put in a comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, took out the reference to 8.1.0 and mention 8 release series instead.

@devreal devreal force-pushed the atomic_acq_fence_fix branch 3 times, most recently from ca1f77f to b2f9f7e Compare March 14, 2022 16:44
Copy link
Member

@bwbarrett bwbarrett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with the change, other than the leftover #endif.

@@ -48,12 +48,17 @@ static inline void opal_atomic_wmb(void)
atomic_thread_fence(memory_order_release);
}

# endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you left this extra #endif from the previous version of the patch?

@devreal devreal force-pushed the atomic_acq_fence_fix branch from b2f9f7e to e5d2c2a Compare March 14, 2022 16:55
@devreal
Copy link
Contributor Author

devreal commented Mar 15, 2022

For the record, this issue was brought up and fixed in a 2017 GCC bug report. The issue had already been reported back in 2012 but little details were provided, so it went to /dev/null.

Lesson learned: proper issue reporting could have saved 5 years of broken acquire fence and workarounds in 3rd party codes that will stay around for at least a decade...

…ease

Only force a full memory barrier for GCC releases prior to 8.1.0.

Signed-off-by: Joseph Schuchart <schuchart@icl.utk.edu>
@devreal devreal force-pushed the atomic_acq_fence_fix branch from e5d2c2a to 935ee76 Compare March 17, 2022 13:42
@devreal
Copy link
Contributor Author

devreal commented Mar 17, 2022

I put the link to the GCC bug report into the comment. I think this is good to go.

@awlauria
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@gpaulsen
Copy link
Member

Did anyone test any non-gcc compilers on x86? This will change the code-path for icc and other compilers on x86 as well. The premise that this is only a gcc bug in versions <= 7, but the previous code would have hidden any bugs in other compilers on x86.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants