[Openmp-commits] [PATCH] D31008: Minor improvement of KMP_YIELD_NOW() macro.

Jonathan Peyton via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Mar 20 15:23:47 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL298314: Minor improvement of KMP_YIELD_NOW() macro. (authored by jlpeyton).

Changed prior to commit:
  https://reviews.llvm.org/D31008?vs=91948&id=92387#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31008

Files:
  openmp/trunk/runtime/src/kmp.h
  openmp/trunk/runtime/src/z_Linux_util.cpp


Index: openmp/trunk/runtime/src/kmp.h
===================================================================
--- openmp/trunk/runtime/src/kmp.h
+++ openmp/trunk/runtime/src/kmp.h
@@ -894,10 +894,14 @@
 #else
 # if KMP_OS_UNIX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
    // HW TSC is used to reduce overhead (clock tick instead of nanosecond).
-   extern double __kmp_ticks_per_nsec;
-#  define KMP_NOW() __kmp_hardware_timestamp()
-#  define KMP_NOW_MSEC() ((kmp_uint64)(KMP_NOW()/__kmp_ticks_per_nsec)/KMP_USEC_PER_SEC)
-#  define KMP_BLOCKTIME_INTERVAL() (__kmp_dflt_blocktime * KMP_USEC_PER_SEC * __kmp_ticks_per_nsec)
+   extern kmp_uint64 __kmp_ticks_per_msec;
+#  if KMP_COMPILER_ICC
+#   define KMP_NOW() _rdtsc()
+#  else
+#   define KMP_NOW() __kmp_hardware_timestamp()
+#  endif
+#  define KMP_NOW_MSEC() (KMP_NOW()/__kmp_ticks_per_msec)
+#  define KMP_BLOCKTIME_INTERVAL() (__kmp_dflt_blocktime * __kmp_ticks_per_msec)
 #  define KMP_BLOCKING(goal, count) ((goal) > KMP_NOW())
 # else
    // System time is retrieved sporadically while blocking.
Index: openmp/trunk/runtime/src/z_Linux_util.cpp
===================================================================
--- openmp/trunk/runtime/src/z_Linux_util.cpp
+++ openmp/trunk/runtime/src/z_Linux_util.cpp
@@ -90,7 +90,7 @@
 static kmp_cond_align_t    __kmp_wait_cv;
 static kmp_mutex_align_t   __kmp_wait_mx;
 
-double __kmp_ticks_per_nsec;
+kmp_uint64 __kmp_ticks_per_msec = 1000000;
 
 /* ------------------------------------------------------------------------ */
 /* ------------------------------------------------------------------------ */
@@ -2157,16 +2157,16 @@
 }
 
 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
-/* Measure clock tick per nanosecond */
+/* Measure clock ticks per millisecond */
 void
 __kmp_initialize_system_tick()
 {
     kmp_uint64 delay = 100000; // 50~100 usec on most machines.
     kmp_uint64 nsec = __kmp_now_nsec();
     kmp_uint64 goal = __kmp_hardware_timestamp() + delay;
     kmp_uint64 now;
     while ((now = __kmp_hardware_timestamp()) < goal);
-    __kmp_ticks_per_nsec = 1.0 * (delay + (now - goal)) / (__kmp_now_nsec() - nsec);
+    __kmp_ticks_per_msec = (kmp_uint64)(1e6 * (delay + (now - goal)) / (__kmp_now_nsec() - nsec));
 }
 #endif
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31008.92387.patch
Type: text/x-patch
Size: 2234 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20170320/e6c74d4a/attachment-0001.bin>


More information about the Openmp-commits mailing list