Skip to content

Commit 711c8c2

Browse files
committed
atomic/gcc_builtin: only apply the workaround when required.
A performance regression was reported when using the workaround `__asm__ __volatile__("" : : : "memory");` instead of `__atomic_thread_fence(__ATOMIC_ACQUIRE);` on a large SMP with recent GCC compiler. So only use the workaround on x86_64 when a busted GCC compiler is used. Thanks S. Biplab Raut for reporting this issue. Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
1 parent e82406f commit 711c8c2

File tree

1 file changed

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

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,22 @@
5050
#define OPAL_HAVE_ATOMIC_SUB_64 1
5151
#define OPAL_HAVE_ATOMIC_SWAP_64 1
5252

53+
#if (OPAL_ASSEMBLY_ARCH == OPAL_X86_64) && defined (__GNUC__) && !defined(__llvm) && (__GNUC__ < 6)
54+
/* work around a bug in older gcc versions where ACQUIRE seems to get
55+
* treated as a no-op instead */
56+
#define OPAL_BUSTED_ATOMIC_MB 1
57+
#else
58+
#define OPAL_BUSTED_ATOMIC_MB 0
59+
#endif
60+
5361
static inline void opal_atomic_mb(void)
5462
{
5563
__atomic_thread_fence(__ATOMIC_SEQ_CST);
5664
}
5765

5866
static inline void opal_atomic_rmb(void)
5967
{
60-
#if OPAL_ASSEMBLY_ARCH == OPAL_X86_64
61-
/* work around a bug in older gcc versions where ACQUIRE seems to get
62-
* treated as a no-op instead */
68+
#if OPAL_BUSTED_ATOMIC_MB
6369
__asm__ __volatile__("" : : : "memory");
6470
#else
6571
__atomic_thread_fence(__ATOMIC_ACQUIRE);

0 commit comments

Comments
 (0)