24 #include "kmp_stats_timing.h" 28 #if KMP_HAVE_TICK_TIME 30 double tsc_tick_count::tick_time()
33 return 1/((double)1000*1.e6);
35 # elif KMP_ARCH_X86 || KMP_ARCH_X86_64 38 double tsc_tick_count::tick_time()
40 static double result = 0.0;
47 __kmp_x86_cpuid(0x80000000, 0, &cpuinfo);
48 memset(brand, 0,
sizeof(brand));
49 int ids = cpuinfo.eax;
51 for (
unsigned int i=2; i<(ids^0x80000000)+2; i++)
52 __kmp_x86_cpuid(i | 0x80000000, 0, (kmp_cpuid_t*)(brand+(i-2)*
sizeof(kmp_cpuid_t)));
54 char * start = &brand[0];
55 for (;*start ==
' '; start++)
58 char * end = brand + KMP_STRLEN(brand) - 3;
61 if (*end ==
'M') multiplier = 1000LL*1000LL;
62 else if (*end ==
'G') multiplier = 1000LL*1000LL*1000LL;
63 else if (*end ==
'T') multiplier = 1000LL*1000LL*1000LL*1000LL;
66 cout <<
"Error determining multiplier '" << *end <<
"'\n";
70 while (*end !=
' ') end--;
73 double freq = strtod(end, &start);
76 cout <<
"Error calculating frequency " << end <<
"\n";
80 result = ((double)1.0)/(freq * multiplier);
87 static bool useSI =
true;
91 std::string formatSI(
double interval,
int width,
char unit)
99 static struct {
double scale;
char prefix; } ranges[] = {
118 os << std::setw(width-3) << std::right <<
"0.00" << std::setw(3) << unit;
122 bool negative =
false;
126 interval = -interval;
129 for (
int i=0; i<(int)(
sizeof(ranges)/
sizeof(ranges[0])); i++)
131 if (interval*ranges[i].scale < 1.e0)
133 interval = interval * 1000.e0 * ranges[i].scale;
134 os << std::fixed << std::setprecision(2) << std::setw(width-3) << std::right <<
135 (negative ? -interval : interval) << std::setw(2) << ranges[i].prefix << std::setw(1) << unit;
141 os << std::setprecision(2) << std::fixed << std::right << std::setw(width-3) << interval << std::setw(3) << unit;