From ddfb4def2df04238abefe8a4b3d726bbef725f63 Mon Sep 17 00:00:00 2001 From: George Bosilca Date: Wed, 8 Jul 2020 09:58:43 -0400 Subject: [PATCH] Second take on fixing the Inel _Atomic atomic operation warning. We completely disable C11 atomic op support for _Atomic for all Intel compiler prior to 20200310 (which is currently the latest released), by switching to our pre-C11 atomic operations. Signed-off-by: George Bosilca --- config/opal_setup_cc.m4 | 16 +++++++++++++++- opal/include/opal/sys/atomic.h | 2 +- opal/include/opal_stdatomic.h | 10 ++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/config/opal_setup_cc.m4 b/config/opal_setup_cc.m4 index 8737450a7e..7b32e95bd2 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]) # AC_PROG_CC_C99 changes CC (instead of CFLAGS) so save CC (without c99 # flags) for use in our wrappers. @@ -229,6 +229,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;