Skip to content

Commit 8961daa

Browse files
committed
opal/atomic: work around memory barrier bug in older gcc
This commit fixes an issue seem with some older versions of gcc (verified to occur in gcc 6.x) where on x86_64 systems the acquire memory barrier in C11 atomics acts as a no-op. On these systems the three memory barriers should all be equivalent. This is related to the error fixed in 30119ee. References #6655. Signed-off-by: Nathan Hjelm <hjelmn@google.com>
1 parent 5f37fe6 commit 8961daa

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

opal/include/opal/sys/atomic_stdc.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* reserved.
55
* Copyright (c) 2018 Research Organization for Information Science
66
* and Technology (RIST). All rights reserved.
7+
* Copyright (c) 2019 Google, LLC. All rights reserved.
78
* $COPYRIGHT$
89
*
910
* Additional copyrights may follow
@@ -73,7 +74,14 @@ static inline void opal_atomic_wmb (void)
7374

7475
static inline void opal_atomic_rmb (void)
7576
{
77+
#if OPAL_ASSEMBLY_ARCH == OPAL_X86_64
78+
/* work around a bug in older gcc versions (observed in gcc 6.x)
79+
* where acquire seems to get treated as a no-op instead of being
80+
* equivalent to __asm__ __volatile__("": : :"memory") on x86_64 */
81+
opal_atomic_mb ();
82+
#else
7683
atomic_thread_fence (memory_order_acquire);
84+
#endif
7785
}
7886

7987
#define opal_atomic_compare_exchange_strong_32(addr, compare, value) atomic_compare_exchange_strong_explicit (addr, compare, value, memory_order_relaxed, memory_order_relaxed)

0 commit comments

Comments
 (0)