diff --git a/config/opal_setup_cc.m4 b/config/opal_setup_cc.m4 index 73007fad7b..78e86b4866 100644 --- a/config/opal_setup_cc.m4 +++ b/config/opal_setup_cc.m4 @@ -151,7 +151,7 @@ AC_DEFUN([OPAL_SETUP_CC],[ AC_REQUIRE([_OPAL_PROG_CC]) AC_REQUIRE([AM_PROG_CC_C_O]) - OPAL_VAR_SCOPE_PUSH([opal_prog_cc_c11_helper__Thread_local_available opal_prog_cc_c11_helper_atomic_var_available opal_prog_cc_c11_helper__Atomic_available opal_prog_cc_c11_helper__static_assert_available opal_prog_cc_c11_helper__Generic_available opal_prog_cc__thread_available opal_prog_cc_c11_helper_atomic_fetch_xor_explicit_available]) + OPAL_VAR_SCOPE_PUSH([opal_prog_cc_c11_helper__Thread_local_available opal_prog_cc_c11_helper_atomic_var_available opal_prog_cc_c11_helper__Atomic_available opal_prog_cc_c11_helper__static_assert_available opal_prog_cc_c11_helper__Generic_available opal_prog_cc__thread_available opal_prog_cc_c11_helper_atomic_fetch_xor_explicit_available opal_prog_cc_c11_helper_proper__Atomic_support_in_atomics]) OPAL_PROG_CC_C11 @@ -224,6 +224,20 @@ AC_DEFUN([OPAL_SETUP_CC],[ #endif]) AC_DEFINE([_GNU_SOURCE])]) + AS_IF([test "$opal_cv_c_compiler_vendor" = "intel"], + [OPAL_CC_HELPER([if $CC is Intel < 20200310 (lacks proper support for atomic operations on _Atomic variables)], [opal_prog_cc_c11_helper_proper__Atomic_support_in_atomics], + [],[[ + #ifdef __INTEL_COMPILER + #if __INTEL_COMPILER_BUILD_DATE <= 20200310 + #error Lacks support for proper atomic operations on _Atomic variables. + #endif /* __INTEL_COMPILER_BUILD_DATE <= 20200310 */ + #endif /* __INTEL_COMPILER */ + ]])], + [opal_prog_cc_c11_helper_proper__Atomic_support_in_atomics=1]) + + AC_DEFINE_UNQUOTED([OPAL_C_HAVE_ATOMIC_SUPPORT_FOR__ATOMIC], [$opal_prog_cc_c11_helper_proper__Atomic_support_in_atomics], + [Whether C compiler supports atomic operations on _Atomic variables without warnings]) + # Do we want code coverage if test "$WANT_COVERAGE" = "1"; then if test "$opal_c_vendor" = "gnu" ; then diff --git a/opal/include/opal/sys/atomic.h b/opal/include/opal/sys/atomic.h index d015b4d171..8e396384e6 100644 --- a/opal/include/opal/sys/atomic.h +++ b/opal/include/opal/sys/atomic.h @@ -59,7 +59,7 @@ #include "opal/sys/architecture.h" #include "opal_stdatomic.h" -#if OPAL_ASSEMBLY_BUILTIN == OPAL_BUILTIN_C11 +#if OPAL_ASSEMBLY_BUILTIN == OPAL_BUILTIN_C11 && !defined(__INTEL_COMPILER) #include "atomic_stdc.h" diff --git a/opal/include/opal_stdatomic.h b/opal/include/opal_stdatomic.h index 854413c87f..4c76f59c26 100644 --- a/opal/include/opal_stdatomic.h +++ b/opal/include/opal_stdatomic.h @@ -14,7 +14,7 @@ #include "opal_stdint.h" -#if OPAL_ASSEMBLY_BUILTIN != OPAL_BUILTIN_C11 +#if (OPAL_ASSEMBLY_BUILTIN != OPAL_BUILTIN_C11) || defined(__INTEL_COMPILER) typedef volatile int opal_atomic_int_t; typedef volatile long opal_atomic_long_t; @@ -33,6 +33,12 @@ typedef volatile uintptr_t opal_atomic_uintptr_t; #include +#ifdef __INTEL_COMPILER +#if __INTEL_COMPILER_BUILD_DATE <= 20200310 +#warning C11 _Atomic type not fully supported. The C11 atomic support should have been disabled. +#endif +#endif + typedef atomic_int opal_atomic_int_t; typedef atomic_long opal_atomic_long_t; @@ -51,7 +57,7 @@ typedef _Atomic uintptr_t opal_atomic_uintptr_t; #if HAVE_OPAL_INT128_T /* do not use C11 atomics for __int128 if they are not lock free */ -#if OPAL_HAVE_C11_CSWAP_INT128 +#if OPAL_HAVE_C11_CSWAP_INT128 && ! defined(__INTEL_COMPILER) typedef _Atomic opal_int128_t opal_atomic_int128_t;