Skip to content

Commit 7c8a1fb

Browse files
committed
opal/asm: work around possible gcc compiler bug
It seems in some cases (gcc older than v6.0.0) the __atomic_thread_fence is a no-op with __ATOMIC_ACQUIRE. This appears to be the case with X86_64 so go ahead and use __ATOMIC_SEQ_CST for the x86_64 read memory barrier. This should not cause any performance issues as it is equivalent to the memory barrier in the hand-written atomics. References #6014 Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov> (cherry picked from commit 30119ee) Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
1 parent 1704063 commit 7c8a1fb

File tree

1 file changed

+9
-0
lines changed
  • opal/include/opal/sys/gcc_builtin

1 file changed

+9
-0
lines changed

opal/include/opal/sys/gcc_builtin/atomic.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* reserved.
1616
* Copyright (c) 2016 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
18+
* Copyright (c) 2018 Triad National Security, LLC. All rights
19+
* reserved.
1820
* $COPYRIGHT$
1921
*
2022
* Additional copyrights may follow
@@ -53,7 +55,14 @@ static inline void opal_atomic_mb(void)
5355

5456
static inline void opal_atomic_rmb(void)
5557
{
58+
#if OPAL_ASSEMBLY_ARCH == OPAL_X86_64
59+
/* work around a bug in older gcc versions where ACQUIRE seems to get
60+
* treated as a no-op instead of being equivalent to
61+
* __asm__ __volatile__("": : :"memory") */
62+
__atomic_thread_fence (__ATOMIC_SEQ_CST);
63+
#else
5664
__atomic_thread_fence (__ATOMIC_ACQUIRE);
65+
#endif
5766
}
5867

5968
static inline void opal_atomic_wmb(void)

0 commit comments

Comments
 (0)