[Openmp-commits] [openmp] 7a795c4 - Enable kmpc_atomic functions for arm64
Martin Storsjö via Openmp-commits
openmp-commits at lists.llvm.org
Wed Dec 7 13:49:33 PST 2022
Author: Bran Hagger
Date: 2022-12-07T23:38:12+02:00
New Revision: 7a795c42ad7f003cd454bf8dbab714714425664c
URL: https://github.com/llvm/llvm-project/commit/7a795c42ad7f003cd454bf8dbab714714425664c
DIFF: https://github.com/llvm/llvm-project/commit/7a795c42ad7f003cd454bf8dbab714714425664c.diff
LOG: Enable kmpc_atomic functions for arm64
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
Added:
Modified:
openmp/runtime/src/dllexports
openmp/runtime/src/kmp_atomic.cpp
openmp/runtime/src/kmp_atomic.h
openmp/runtime/src/kmp_os.h
Removed:
################################################################################
diff --git a/openmp/runtime/src/dllexports b/openmp/runtime/src/dllexports
index a541f582a940..0699e7596841 100644
--- a/openmp/runtime/src/dllexports
+++ b/openmp/runtime/src/dllexports
@@ -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
diff --git a/openmp/runtime/src/kmp_atomic.cpp b/openmp/runtime/src/kmp_atomic.cpp
index a7d16a4f0ec8..261e9f1beee6 100644
--- a/openmp/runtime/src/kmp_atomic.cpp
+++ b/openmp/runtime/src/kmp_atomic.cpp
@@ -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)
diff --git a/openmp/runtime/src/kmp_atomic.h b/openmp/runtime/src/kmp_atomic.h
index 19c02e9d25c0..4fc51ee4289b 100644
--- a/openmp/runtime/src/kmp_atomic.h
+++ b/openmp/runtime/src/kmp_atomic.h
@@ -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,
diff --git a/openmp/runtime/src/kmp_os.h b/openmp/runtime/src/kmp_os.h
index 76fcbb841b94..1b07dca9031d 100644
--- a/openmp/runtime/src/kmp_os.h
+++ b/openmp/runtime/src/kmp_os.h
@@ -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
More information about the Openmp-commits
mailing list