[Openmp-commits] [openmp] 9f1f1b9 - [OpenMP] Add upper limit to TPAUSE exponential backoff time

Nawrin Sultana via Openmp-commits openmp-commits at lists.llvm.org
Mon Oct 17 08:24:27 PDT 2022


Author: Nawrin Sultana
Date: 2022-10-17T10:22:11-05:00
New Revision: 9f1f1b924f420f0bbbe605b27346d89177c8129a

URL: https://github.com/llvm/llvm-project/commit/9f1f1b924f420f0bbbe605b27346d89177c8129a
DIFF: https://github.com/llvm/llvm-project/commit/9f1f1b924f420f0bbbe605b27346d89177c8129a.diff

LOG: [OpenMP] Add upper limit to TPAUSE exponential backoff time

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

Added: 
    

Modified: 
    openmp/runtime/src/kmp.h

Removed: 
    


################################################################################
diff  --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index 6aeb495d44f24..df02f40c8df04 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -1472,6 +1472,7 @@ static inline void __kmp_x86_pause(void) { _mm_pause(); }
 // requested. Uses a timed TPAUSE, and exponential backoff. If TPAUSE isn't
 // available, fall back to the regular CPU pause and yield combination.
 #if KMP_HAVE_UMWAIT
+#define KMP_TPAUSE_MAX_MASK ((kmp_uint64)0xFFFF)
 #define KMP_YIELD_OVERSUB_ELSE_SPIN(count, time)                               \
   {                                                                            \
     if (__kmp_tpause_enabled) {                                                \
@@ -1480,7 +1481,7 @@ static inline void __kmp_x86_pause(void) { _mm_pause(); }
       } else {                                                                 \
         __kmp_tpause(__kmp_tpause_hint, (time));                               \
       }                                                                        \
-      (time) *= 2;                                                             \
+      (time) = (time << 1 | 1) & KMP_TPAUSE_MAX_MASK;                          \
     } else {                                                                   \
       KMP_CPU_PAUSE();                                                         \
       if ((KMP_TRY_YIELD_OVERSUB)) {                                           \


        


More information about the Openmp-commits mailing list