Skip to content

Commit a44914c

Browse files
authored
Merge pull request #7915 from bosilca/fix/intel_2330_warning_take2
Second take on fixing the Intel _Atomic atomic operation warning
2 parents f5cb1a4 + ddfb4de commit a44914c

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
OPAL_PROG_CC_C11
157157

@@ -224,6 +224,20 @@ AC_DEFUN([OPAL_SETUP_CC],[
224224
#endif])
225225
AC_DEFINE([_GNU_SOURCE])])
226226

227+
AS_IF([test "$opal_cv_c_compiler_vendor" = "intel"],
228+
[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],
229+
[],[[
230+
#ifdef __INTEL_COMPILER
231+
#if __INTEL_COMPILER_BUILD_DATE <= 20200310
232+
#error Lacks support for proper atomic operations on _Atomic variables.
233+
#endif /* __INTEL_COMPILER_BUILD_DATE <= 20200310 */
234+
#endif /* __INTEL_COMPILER */
235+
]])],
236+
[opal_prog_cc_c11_helper_proper__Atomic_support_in_atomics=1])
237+
238+
AC_DEFINE_UNQUOTED([OPAL_C_HAVE_ATOMIC_SUPPORT_FOR__ATOMIC], [$opal_prog_cc_c11_helper_proper__Atomic_support_in_atomics],
239+
[Whether C compiler supports atomic operations on _Atomic variables without warnings])
240+
227241
# Do we want code coverage
228242
if test "$WANT_COVERAGE" = "1"; then
229243
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)