diff options
author | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2015-12-17 17:27:51 +0000 |
---|---|---|
committer | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2015-12-17 17:27:51 +0000 |
commit | ef79bf6744d0bdebcf69715dbafde4b4380ae79b (patch) | |
tree | 8ea639a74e6f8d78e4b2d8b8eb8b76066af0d9fe /runtime | |
parent | 3c0db8d0f0ff45d7768a7ed71c3a204a26f1da62 (diff) |
[STATS] Properly guard the tick_time() function and its uses
git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@255910 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/src/kmp_os.h | 5 | ||||
-rw-r--r-- | runtime/src/kmp_stats_timing.cpp | 4 | ||||
-rw-r--r-- | runtime/src/kmp_stats_timing.h | 6 |
3 files changed, 13 insertions, 2 deletions
diff --git a/runtime/src/kmp_os.h b/runtime/src/kmp_os.h index 2c330fc..4f89c73 100644 --- a/runtime/src/kmp_os.h +++ b/runtime/src/kmp_os.h @@ -703,6 +703,11 @@ typedef void (*microtask_t)( int *gtid, int *npr, ... ); # define KMP_USE_ADAPTIVE_LOCKS KMP_USE_TSX #endif +// Enable tick time conversion of ticks to seconds +#if KMP_STATS_ENABLED +# define KMP_HAVE_TICK_TIME (KMP_OS_LINUX && (KMP_MIC || KMP_ARCH_X86 || KMP_ARCH_X86_64)) +#endif + // Warning levels enum kmp_warnings_level { kmp_warnings_off = 0, /* No warnings */ diff --git a/runtime/src/kmp_stats_timing.cpp b/runtime/src/kmp_stats_timing.cpp index 2b5049a..40e29eb 100644 --- a/runtime/src/kmp_stats_timing.cpp +++ b/runtime/src/kmp_stats_timing.cpp @@ -25,14 +25,14 @@ using namespace std; -#if KMP_OS_LINUX +#if KMP_HAVE_TICK_TIME # if KMP_MIC double tsc_tick_count::tick_time() { // pretty bad assumption of 1GHz clock for MIC return 1/((double)1000*1.e6); } -# else +# elif KMP_ARCH_X86 || KMP_ARCH_X86_64 # include <string.h> // Extract the value from the CPUID information double tsc_tick_count::tick_time() diff --git a/runtime/src/kmp_stats_timing.h b/runtime/src/kmp_stats_timing.h index 2bdfdea..83fb85b 100644 --- a/runtime/src/kmp_stats_timing.h +++ b/runtime/src/kmp_stats_timing.h @@ -32,7 +32,9 @@ class tsc_tick_count { explicit tsc_interval_t(int64_t _value) : value(_value) {} public: tsc_interval_t() : value(0) {}; // Construct 0 time duration +#if KMP_HAVE_TICK_TIME double seconds() const; // Return the length of a time interval in seconds +#endif double ticks() const { return double(value); } int64_t getValue() const { return value; } @@ -51,7 +53,9 @@ class tsc_tick_count { tsc_tick_count earlier(tsc_tick_count const other) const { return my_count < other.my_count ? (*this) : other; } +#if KMP_HAVE_TICK_TIME static double tick_time(); // returns seconds per cycle (period) of clock +#endif static tsc_tick_count now() { return tsc_tick_count(); } // returns the rdtsc register value friend tsc_tick_count::tsc_interval_t operator-(const tsc_tick_count t1, const tsc_tick_count t0); }; @@ -61,10 +65,12 @@ inline tsc_tick_count::tsc_interval_t operator-(const tsc_tick_count t1, const t return tsc_tick_count::tsc_interval_t( t1.my_count-t0.my_count ); } +#if KMP_HAVE_TICK_TIME inline double tsc_tick_count::tsc_interval_t::seconds() const { return value*tick_time(); } +#endif extern std::string formatSI(double interval, int width, char unit); |