[Openmp-commits] [PATCH] D97079: [OpenMP] libomp: eliminate pause from atomic CAS loops
Andrey Churbanov via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Fri Feb 19 12:21:57 PST 2021
AndreyChurbanov created this revision.
AndreyChurbanov added reviewers: hbae, jlpeyton, tlwilmar, Nawrin.
AndreyChurbanov added a project: OpenMP.
Herald added subscribers: jfb, guansong, yaxunl.
AndreyChurbanov requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: openmp-commits, sstefan1.
Pause is good in spin-loops waiting for something.
Atomic CAS loops do not wait for anything,
each CAS failure means some other thread progressed.
So pause only causes unnecessary slowdown.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D97079
Files:
openmp/runtime/src/kmp_atomic.cpp
Index: openmp/runtime/src/kmp_atomic.cpp
===================================================================
--- openmp/runtime/src/kmp_atomic.cpp
+++ openmp/runtime/src/kmp_atomic.cpp
@@ -779,7 +779,7 @@
#if KMP_MIC
#define KMP_DO_PAUSE _mm_delay_32(1)
#else
-#define KMP_DO_PAUSE KMP_CPU_PAUSE()
+#define KMP_DO_PAUSE
#endif /* KMP_MIC */
// ------------------------------------------------------------------------
@@ -1132,7 +1132,6 @@
(kmp_int##BITS *)lhs, \
*VOLATILE_CAST(kmp_int##BITS *) & old_value, \
*VOLATILE_CAST(kmp_int##BITS *) & rhs)) { \
- KMP_CPU_PAUSE(); \
temp_val = *lhs; \
old_value = temp_val; \
} \
@@ -2087,8 +2086,6 @@
while (!KMP_COMPARE_AND_STORE_ACQ##BITS( \
(kmp_int##BITS *)lhs, *VOLATILE_CAST(kmp_int##BITS *) & old_value, \
*VOLATILE_CAST(kmp_int##BITS *) & new_value)) { \
- KMP_CPU_PAUSE(); \
- \
temp_val = *lhs; \
old_value = temp_val; \
new_value = rhs; \
@@ -2237,8 +2234,6 @@
while (!KMP_COMPARE_AND_STORE_ACQ##BITS( \
(kmp_int##BITS *)lhs, *VOLATILE_CAST(kmp_int##BITS *) & old_value, \
*VOLATILE_CAST(kmp_int##BITS *) & new_value)) { \
- KMP_CPU_PAUSE(); \
- \
temp_val = *lhs; \
old_value = temp_val; \
new_value = (TYPE)(old_value OP rhs); \
@@ -2633,7 +2628,6 @@
(kmp_int##BITS *)lhs, \
*VOLATILE_CAST(kmp_int##BITS *) & old_value, \
*VOLATILE_CAST(kmp_int##BITS *) & rhs)) { \
- KMP_CPU_PAUSE(); \
temp_val = *lhs; \
old_value = temp_val; \
} \
@@ -2930,8 +2924,6 @@
while (!KMP_COMPARE_AND_STORE_ACQ##BITS( \
(kmp_int##BITS *)lhs, *VOLATILE_CAST(kmp_int##BITS *) & old_value, \
*VOLATILE_CAST(kmp_int##BITS *) & new_value)) { \
- KMP_CPU_PAUSE(); \
- \
temp_val = *lhs; \
old_value = temp_val; \
new_value = (TYPE)(rhs OP old_value); \
@@ -3254,8 +3246,6 @@
while (!KMP_COMPARE_AND_STORE_ACQ##BITS( \
(kmp_int##BITS *)lhs, *VOLATILE_CAST(kmp_int##BITS *) & old_value, \
*VOLATILE_CAST(kmp_int##BITS *) & new_value)) { \
- KMP_CPU_PAUSE(); \
- \
temp_val = *lhs; \
old_value = temp_val; \
new_value = rhs; \
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97079.325058.patch
Type: text/x-patch
Size: 4328 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210219/32ae69f0/attachment.bin>
More information about the Openmp-commits
mailing list