Skip to content

Commit 866b9d7

Browse files
authored
Merge pull request #10724 from devreal/gcc_atomic_as_default
Make GCC atomics the default atomic implementation
2 parents 50dbcb6 + c924ac7 commit 866b9d7

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

config/opal_config_asm.m4

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -609,11 +609,11 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
609609
610610
AC_ARG_ENABLE([c11-atomics],
611611
[AS_HELP_STRING([--enable-c11-atomics],
612-
[Enable use of C11 atomics if available (default: use if available, disabled by default on 64-bit PowerPC)])])
612+
[Enable use of C11 atomics if available. Note: GCC builtin atomics are currently preferred over C11 atomics. (default: use if available, disabled by default on 64-bit PowerPC)])])
613613
614614
AC_ARG_ENABLE([builtin-atomics],
615615
[AS_HELP_STRING([--enable-builtin-atomics],
616-
[Enable use of GCC built-in atomics. Note that C11 atomics are preferred over built-in atomics. (default: use if available, disabled by default on 64-bit PowerPC)])])
616+
[Enable use of GCC built-in atomics. Currently preferred over C11 atomics. (default: use if available, disabled by default on 64-bit PowerPC)])])
617617
618618
AC_ARG_ENABLE([builtin-atomics-for-ppc],
619619
[AS_HELP_STRING([--enable-builtin-atomics-for-ppc],
@@ -636,14 +636,29 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
636636
;;
637637
esac
638638
639-
# Option 1 for atomics: C11
639+
# Option 1 for atomics: GCC-style Builtin
640+
#
641+
# We prefer builtin atomics over C11 atomics because our use of C11 atomics
642+
# at this point is broken as it either incurs undue overheads or
643+
# requires casts to _Atomic where there should be no casts.
644+
AS_IF([test "$atomics_found" = "no" -a "$enable_builtin_atomics" != "no"],
645+
[OPAL_CHECK_GCC_ATOMIC_BUILTINS
646+
AS_IF([test $opal_cv_have___atomic = "yes"],
647+
[AC_MSG_NOTICE([Using GCC built-in style atomics])
648+
atomics_found="GCC built-in style atomics"
649+
want_gcc_builtin_atomics=1],
650+
[test "$enable_builtin_atomics" = "yes"],
651+
[AC_MSG_WARN([GCC built-in atomics requested but not found.])
652+
AC_MSG_ERROR([Cannot continue])])])
653+
654+
# Option 2 for atomics: C11
640655
#
641656
# We currently always disable C11 atomics with the Intel compilers.
642657
# We know builds older than 20200310 are broken with respect to
643658
# C11 atomics, but have not apparently found a build we are happy
644659
# with. In the future, this should be changed to a check for a
645660
# particular Intel version.
646-
AS_IF([test "$enable_c11_atomics" != "no" -a "$opal_cv_c11_supported" = "yes" -a "$opal_cv_c_compiler_vendor" != "intel"],
661+
AS_IF([test "$atomics_found" = "no" -a "$enable_c11_atomics" == "yes" -a "$opal_cv_c11_supported" = "yes" -a "$opal_cv_c_compiler_vendor" != "intel"],
647662
[AC_MSG_NOTICE([Using C11 atomics])
648663
OPAL_CHECK_C11_CSWAP_INT128
649664
want_c11_atomics=1
@@ -652,17 +667,6 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
652667
[AC_MSG_WARN([C11 atomics were requested but are not supported])
653668
AC_MSG_ERROR([Cannot continue])])
654669
655-
# Option 2 for atomics: GCC-style Builtin
656-
AS_IF([test "$atomics_found" = "no" -a "$enable_builtin_atomics" != "no"],
657-
[OPAL_CHECK_GCC_ATOMIC_BUILTINS
658-
AS_IF([test $opal_cv_have___atomic = "yes"],
659-
[AC_MSG_NOTICE([Using GCC built-in style atomics])
660-
atomics_found="GCC built-in style atomics"
661-
want_gcc_builtin_atomics=1],
662-
[test "$enable_builtin_atomics" = "yes"],
663-
[AC_MSG_WARN([GCC built-in atomics requested but not found.])
664-
AC_MSG_ERROR([Cannot continue])])])
665-
666670
# Option 3 for atomics: inline assembly
667671
AS_IF([test "$atomics_found" = "no" -a "$gcc_inline" = "1"],
668672
[case "${host}" in
@@ -687,7 +691,7 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
687691
AC_MSG_CHECKING([for inline assembly atomics])
688692
AC_MSG_RESULT([$atomics_found])])
689693
690-
AS_IF([test "$aomics_found" = "no"],
694+
AS_IF([test "$atomics_found" = "no"],
691695
[AC_MSG_ERROR([No usable atomics implementation found. Cannot continue.])])
692696
693697
AC_DEFINE_UNQUOTED([OPAL_USE_C11_ATOMICS],

0 commit comments

Comments
 (0)