[Openmp-commits] [PATCH] D60938: Use correct way to test for MIPS arch after rOMP355687

Dimitry Andric via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Sat Apr 20 13:00:22 PDT 2019


dim created this revision.
dim added reviewers: petarj, jlpeyton, Hahnfeld.
Herald added subscribers: openmp-commits, jdoerfert, jfb, atanasyan, arichardson, sdardis.
Herald added a project: OpenMP.

I ran into some issues after rOMP355687 <https://reviews.llvm.org/rOMP355687>, where __atomic_fetch_add was
being used incorrectly on x86, and this turns out to be caused by the
following added conditionals:

  #if defined(KMP_ARCH_MIPS)

The problem is, these macros are always defined, and are either 0 or 1
depending on the architecture.  E.g. the correct way to test for MIPS
is:

  #if KMP_ARCH_MIPS


Repository:
  rOMP OpenMP

https://reviews.llvm.org/D60938

Files:
  runtime/src/kmp_os.h


Index: runtime/src/kmp_os.h
===================================================================
--- runtime/src/kmp_os.h
+++ runtime/src/kmp_os.h
@@ -533,7 +533,7 @@
   __sync_fetch_and_add((volatile kmp_int32 *)(p), 1)
 #define KMP_TEST_THEN_INC_ACQ32(p)                                             \
   __sync_fetch_and_add((volatile kmp_int32 *)(p), 1)
-#if defined(KMP_ARCH_MIPS)
+#if KMP_ARCH_MIPS
 #define KMP_TEST_THEN_INC64(p)                                                 \
   __atomic_fetch_add((volatile kmp_int64 *)(p), 1LL, __ATOMIC_SEQ_CST)
 #define KMP_TEST_THEN_INC_ACQ64(p)                                             \
@@ -548,7 +548,7 @@
   __sync_fetch_and_add((volatile kmp_int32 *)(p), 4)
 #define KMP_TEST_THEN_ADD4_ACQ32(p)                                            \
   __sync_fetch_and_add((volatile kmp_int32 *)(p), 4)
-#if defined(KMP_ARCH_MIPS)
+#if KMP_ARCH_MIPS
 #define KMP_TEST_THEN_ADD4_64(p)                                               \
   __atomic_fetch_add((volatile kmp_int64 *)(p), 4LL, __ATOMIC_SEQ_CST)
 #define KMP_TEST_THEN_ADD4_ACQ64(p)                                            \
@@ -575,7 +575,7 @@
   __sync_fetch_and_add((volatile kmp_int8 *)(p), (kmp_int8)(v))
 #define KMP_TEST_THEN_ADD32(p, v)                                              \
   __sync_fetch_and_add((volatile kmp_int32 *)(p), (kmp_int32)(v))
-#if defined(KMP_ARCH_MIPS)
+#if KMP_ARCH_MIPS
 #define KMP_TEST_THEN_ADD64(p, v)                                              \
   __atomic_fetch_add((volatile kmp_uint64 *)(p), (kmp_uint64)(v),              \
                      __ATOMIC_SEQ_CST)
@@ -592,7 +592,7 @@
   __sync_fetch_and_or((volatile kmp_uint32 *)(p), (kmp_uint32)(v))
 #define KMP_TEST_THEN_AND32(p, v)                                              \
   __sync_fetch_and_and((volatile kmp_uint32 *)(p), (kmp_uint32)(v))
-#if defined(KMP_ARCH_MIPS)
+#if KMP_ARCH_MIPS
 #define KMP_TEST_THEN_OR64(p, v)                                               \
   __atomic_fetch_or((volatile kmp_uint64 *)(p), (kmp_uint64)(v),               \
                     __ATOMIC_SEQ_CST)
@@ -637,7 +637,7 @@
 #define KMP_COMPARE_AND_STORE_RET32(p, cv, sv)                                 \
   __sync_val_compare_and_swap((volatile kmp_uint32 *)(p), (kmp_uint32)(cv),    \
                               (kmp_uint32)(sv))
-#if defined(KMP_ARCH_MIPS)
+#if KMP_ARCH_MIPS
 static inline bool mips_sync_bool_compare_and_swap(
   volatile kmp_uint64 *p, kmp_uint64 cv, kmp_uint64 sv) {
   return __atomic_compare_exchange(p, &cv, &sv, false, __ATOMIC_SEQ_CST,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60938.195979.patch
Type: text/x-patch
Size: 2572 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20190420/1b504d85/attachment.bin>


More information about the Openmp-commits mailing list