Skip to content

Commit ddfb4de

Browse files
committed
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 <bosilca@icl.utk.edu>
1 parent dbc5675 commit ddfb4de

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

config/opal_setup_cc.m4

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ AC_DEFUN([OPAL_SETUP_CC],[
151151
AC_REQUIRE([_OPAL_PROG_CC])
152152
AC_REQUIRE([AM_PROG_CC_C_O])
153153

154-
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])
154+
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])
155155

156156
# AC_PROG_CC_C99 changes CC (instead of CFLAGS) so save CC (without c99
157157
# flags) for use in our wrappers.
@@ -229,6 +229,20 @@ AC_DEFUN([OPAL_SETUP_CC],[
229229
#endif])
230230
AC_DEFINE([_GNU_SOURCE])])
231231

232+
AS_IF([test "$opal_cv_c_compiler_vendor" = "intel"],
233+
[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],
234+
[],[[
235+
#ifdef __INTEL_COMPILER
236+
#if __INTEL_COMPILER_BUILD_DATE <= 20200310
237+
#error Lacks support for proper atomic operations on _Atomic variables.
238+
#endif /* __INTEL_COMPILER_BUILD_DATE <= 20200310 */
239+
#endif /* __INTEL_COMPILER */
240+
]])],
241+
[opal_prog_cc_c11_helper_proper__Atomic_support_in_atomics=1])
242+
243+
AC_DEFINE_UNQUOTED([OPAL_C_HAVE_ATOMIC_SUPPORT_FOR__ATOMIC], [$opal_prog_cc_c11_helper_proper__Atomic_support_in_atomics],
244+
[Whether C compiler supports atomic operations on _Atomic variables without warnings])
245+
232246
# Do we want code coverage
233247
if test "$WANT_COVERAGE" = "1"; then
234248
if test "$opal_c_vendor" = "gnu" ; then

opal/include/opal/sys/atomic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#include "opal/sys/architecture.h"
6060
#include "opal_stdatomic.h"
6161

62-
#if OPAL_ASSEMBLY_BUILTIN == OPAL_BUILTIN_C11
62+
#if OPAL_ASSEMBLY_BUILTIN == OPAL_BUILTIN_C11 && !defined(__INTEL_COMPILER)
6363

6464
#include "atomic_stdc.h"
6565

opal/include/opal_stdatomic.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include "opal_stdint.h"
1616

17-
#if OPAL_ASSEMBLY_BUILTIN != OPAL_BUILTIN_C11
17+
#if (OPAL_ASSEMBLY_BUILTIN != OPAL_BUILTIN_C11) || defined(__INTEL_COMPILER)
1818

1919
typedef volatile int opal_atomic_int_t;
2020
typedef volatile long opal_atomic_long_t;
@@ -33,6 +33,12 @@ typedef volatile uintptr_t opal_atomic_uintptr_t;
3333

3434
#include <stdatomic.h>
3535

36+
#ifdef __INTEL_COMPILER
37+
#if __INTEL_COMPILER_BUILD_DATE <= 20200310
38+
#warning C11 _Atomic type not fully supported. The C11 atomic support should have been disabled.
39+
#endif
40+
#endif
41+
3642
typedef atomic_int opal_atomic_int_t;
3743
typedef atomic_long opal_atomic_long_t;
3844

@@ -51,7 +57,7 @@ typedef _Atomic uintptr_t opal_atomic_uintptr_t;
5157
#if HAVE_OPAL_INT128_T
5258

5359
/* do not use C11 atomics for __int128 if they are not lock free */
54-
#if OPAL_HAVE_C11_CSWAP_INT128
60+
#if OPAL_HAVE_C11_CSWAP_INT128 && ! defined(__INTEL_COMPILER)
5561

5662
typedef _Atomic opal_int128_t opal_atomic_int128_t;
5763

0 commit comments

Comments
 (0)