Enable kmpc_atomic functions for arm64
authorBran Hagger <brhagger@microsoft.com>
Wed, 7 Dec 2022 10:00:15 +0000 (12:00 +0200)
committerMartin Storsjö <martin@martin.st>
Wed, 7 Dec 2022 21:38:12 +0000 (23:38 +0200)
Define the same kmpc_atomic functions for arm and arm64 that are defined for x86 and x64.

Reviewed By: mstorsjo

Differential Revision: https://reviews.llvm.org/D139139

openmp/runtime/src/dllexports
openmp/runtime/src/kmp_atomic.cpp
openmp/runtime/src/kmp_atomic.h
openmp/runtime/src/kmp_os.h

index a541f58..0699e75 100644 (file)
@@ -817,10 +817,7 @@ kmp_set_disp_num_buffers                    890
 
     %endif
 
-    # These are specific to x86 and x64
-    %ifdef IS_IA_ARCH
-
-        # ATOMIC extensions for OpenMP 3.1 spec (x86 and x64 only)
+        # ATOMIC extensions for OpenMP 3.1 spec
 
         __kmpc_atomic_fixed1_rd                2265
         __kmpc_atomic_fixed2_rd                2266
@@ -1047,6 +1044,9 @@ kmp_set_disp_num_buffers                    890
         __kmpc_atomic_float10_div_cpt_fp
         %endif
 
+            # These are specific to x86 and x64
+            %ifdef IS_IA_ARCH
+
             # ATOMIC extensions for OpenMP 4.0 spec (x86 and x64 only)
 
             __kmpc_atomic_fixed1_swp           2412
index a7d16a4..261e9f1 100644 (file)
@@ -1914,8 +1914,7 @@ ATOMIC_CMPXCHG_CMPLX(cmplx4, kmp_cmplx32, mul, 64, *, cmplx8, kmp_cmplx64, 8c,
 ATOMIC_CMPXCHG_CMPLX(cmplx4, kmp_cmplx32, div, 64, /, cmplx8, kmp_cmplx64, 8c,
                      7, KMP_ARCH_X86) // __kmpc_atomic_cmplx4_div_cmplx8
 
-// READ, WRITE, CAPTURE are supported only on IA-32 architecture and Intel(R) 64
-#if KMP_ARCH_X86 || KMP_ARCH_X86_64
+// READ, WRITE, CAPTURE
 
 // ------------------------------------------------------------------------
 // Atomic READ routines
@@ -2925,6 +2924,7 @@ ATOMIC_CRITICAL_CPT(cmplx16, div_a16_cpt, kmp_cmplx128_a16_t, /, 32c,
 // binop x; v = x; }  for non-commutative operations.
 // Supported only on IA-32 architecture and Intel(R) 64
 
+#if KMP_ARCH_X86 || KMP_ARCH_X86_64
 // -------------------------------------------------------------------------
 // Operation on *lhs, rhs bound by critical section
 //     OP     - operator (it's supposed to contain an assignment)
index 19c02e9..4fc51ee 100644 (file)
@@ -1005,8 +1005,7 @@ void __kmpc_atomic_20(ident_t *id_ref, int gtid, void *lhs, void *rhs,
 void __kmpc_atomic_32(ident_t *id_ref, int gtid, void *lhs, void *rhs,
                       void (*f)(void *, void *, void *));
 
-// READ, WRITE, CAPTURE are supported only on IA-32 architecture and Intel(R) 64
-#if KMP_ARCH_X86 || KMP_ARCH_X86_64
+// READ, WRITE, CAPTURE
 
 //  Below routines for atomic READ are listed
 char __kmpc_atomic_fixed1_rd(ident_t *id_ref, int gtid, char *loc);
@@ -1337,7 +1336,6 @@ void __kmpc_atomic_cmplx4_mul_cpt(ident_t *id_ref, int gtid, kmp_cmplx32 *lhs,
                                   kmp_cmplx32 rhs, kmp_cmplx32 *out, int flag);
 void __kmpc_atomic_cmplx4_div_cpt(ident_t *id_ref, int gtid, kmp_cmplx32 *lhs,
                                   kmp_cmplx32 rhs, kmp_cmplx32 *out, int flag);
-
 kmp_cmplx64 __kmpc_atomic_cmplx8_add_cpt(ident_t *id_ref, int gtid,
                                          kmp_cmplx64 *lhs, kmp_cmplx64 rhs,
                                          int flag);
@@ -1419,7 +1417,7 @@ void __kmpc_atomic_end(void);
 
 // OpenMP 4.0: v = x = expr binop x; { v = x; x = expr binop x; } { x = expr
 // binop x; v = x; }  for non-commutative operations.
-
+#if KMP_ARCH_X86 || KMP_ARCH_X86_64
 char __kmpc_atomic_fixed1_sub_cpt_rev(ident_t *id_ref, int gtid, char *lhs,
                                       char rhs, int flag);
 char __kmpc_atomic_fixed1_div_cpt_rev(ident_t *id_ref, int gtid, char *lhs,
index 76fcbb8..1b07dca 100644 (file)
@@ -596,27 +596,26 @@ inline kmp_int32 __kmp_compare_and_store_ptr(void *volatile *p, void *cv,
 }
 
 // The _RET versions return the value instead of a bool
-/*
+
 #define KMP_COMPARE_AND_STORE_RET8(p, cv, sv)                                  \
    _InterlockedCompareExchange8((p), (sv), (cv))
 #define KMP_COMPARE_AND_STORE_RET16(p, cv, sv)                                 \
   _InterlockedCompareExchange16((p), (sv), (cv))
-*/
+
 #define KMP_COMPARE_AND_STORE_RET64(p, cv, sv)                                 \
   _InterlockedCompareExchange64((volatile kmp_int64 *)(p), (kmp_int64)(sv),    \
                                 (kmp_int64)(cv))
 
-/*
+
 #define KMP_XCHG_FIXED8(p, v)                                                  \
   _InterlockedExchange8((volatile kmp_int8 *)(p), (kmp_int8)(v));
-*/
-// #define KMP_XCHG_FIXED16(p, v) _InterlockedExchange16((p), (v));
-// #define KMP_XCHG_REAL64(p, v) __kmp_xchg_real64((p), (v)));
+#define KMP_XCHG_FIXED16(p, v) _InterlockedExchange16((p), (v));
+#define KMP_XCHG_REAL64(p, v) __kmp_xchg_real64((p), (v)));
 
-// inline kmp_real64 __kmp_xchg_real64(volatile kmp_real64 *p, kmp_real64 v) {
-//   kmp_int64 tmp = _InterlockedExchange64((volatile kmp_int64 *)p, *(kmp_int64
-//   *)&v); return *(kmp_real64 *)&tmp;
-// }
+inline kmp_real64 __kmp_xchg_real64(volatile kmp_real64 *p, kmp_real64 v) {
+  kmp_int64 tmp = _InterlockedExchange64((volatile kmp_int64 *)p, *(kmp_int64
+  *)&v); return *(kmp_real64 *)&tmp;
+}
 
 #else // !KMP_ARCH_AARCH64