summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openmp/runtime/src/kmp.h12
-rw-r--r--openmp/runtime/src/z_Linux_util.cpp6
2 files changed, 11 insertions, 7 deletions
diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index 885495218ea..c89506e9254 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -894,10 +894,14 @@ extern int __kmp_place_num_threads_per_core;
#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.
diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp
index 34114bcbb02..2c034f9c560 100644
--- a/openmp/runtime/src/z_Linux_util.cpp
+++ b/openmp/runtime/src/z_Linux_util.cpp
@@ -90,7 +90,7 @@ static pthread_mutexattr_t __kmp_suspend_mutex_attr;
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,7 +2157,7 @@ __kmp_now_nsec()
}
#if KMP_ARCH_X86 || KMP_ARCH_X86_64
-/* Measure clock tick per nanosecond */
+/* Measure clock ticks per millisecond */
void
__kmp_initialize_system_tick()
{
@@ -2166,7 +2166,7 @@ __kmp_initialize_system_tick()
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
OpenPOWER on IntegriCloud