forked from OSchip/llvm-project
[STATS] Properly guard the tick_time() function and its uses
llvm-svn: 255910
This commit is contained in:
parent
e5a6191732
commit
8b524597ef
|
@ -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 */
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue