[Openmp-commits] [openmp] r255910 - [STATS] Properly guard the tick_time() function and its uses

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Thu Dec 17 09:27:51 PST 2015


Author: jlpeyton
Date: Thu Dec 17 11:27:51 2015
New Revision: 255910

URL: http://llvm.org/viewvc/llvm-project?rev=255910&view=rev
Log:
[STATS] Properly guard the tick_time() function and its uses

Modified:
    openmp/trunk/runtime/src/kmp_os.h
    openmp/trunk/runtime/src/kmp_stats_timing.cpp
    openmp/trunk/runtime/src/kmp_stats_timing.h

Modified: openmp/trunk/runtime/src/kmp_os.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_os.h?rev=255910&r1=255909&r2=255910&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_os.h (original)
+++ openmp/trunk/runtime/src/kmp_os.h Thu Dec 17 11:27:51 2015
@@ -703,6 +703,11 @@ typedef void    (*microtask_t)( int *gti
 # 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 */

Modified: openmp/trunk/runtime/src/kmp_stats_timing.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_stats_timing.cpp?rev=255910&r1=255909&r2=255910&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_stats_timing.cpp (original)
+++ openmp/trunk/runtime/src/kmp_stats_timing.cpp Thu Dec 17 11:27:51 2015
@@ -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()

Modified: openmp/trunk/runtime/src/kmp_stats_timing.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_stats_timing.h?rev=255910&r1=255909&r2=255910&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_stats_timing.h (original)
+++ openmp/trunk/runtime/src/kmp_stats_timing.h Thu Dec 17 11:27:51 2015
@@ -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 op
     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);
 




More information about the Openmp-commits mailing list