Description
Most modern CPUs can change the CPU frequency for various reasons. To save power, Intel CPUs can reduce the CPU frequency. To improve performance, some Intel CPUs boost the frequency above the Time Stamp Counter (TSC) frequency. Along with knowing the %halted state (the percent of time the CPU is halted), it is useful to know the frequency at which the CPU is running. Particularly for benchmarking, when you might be trying to explain, say, a 10% variation in performance, it is essential to know the frequency of the CPU when you ran your benchmark.
Two of the fixed counters measure clockticks: CPU_CLK_UNHALTED.REF and CPU_CLK_UNHALTED.THREAD. CPU_CLK_UNHALTED.REF is incremented at the same frequency as the TSC. The TSC frequency is called the reference frequency and the TSC frequency doesn't vary. CPU_CLK_UNHALTED.THREAD is incremented at the frequency at which the CPU is running. Work gets done at the CPU frequency, not the TSC frequency. On Core2 CPUs, use CPU_CLK_UNHALTED.CORE instead of CPU_CLK_UNHALTED.THREAD.
The average unhalted frequency is computed as:
Average frequency =
TSC_frequency * (CPU_CLK_UNHALTED.THREAD / CPU_CLK_UNHALTED.REF)
Measuring the average unhalted frequency
To use the above method, you need to collect CPU_CLK_UNHALTED.REF and CPU_CLK_UNHALTED.THREAD. Intel® VTune™ and Intel® Performance Tuning Utility (Intel® PTU) usually collect these events since the events are two of the fixed counters.
If you are using Intel® VTune™ and Intel® Performance Tuning Utility (Intel® PTU) data, be clear whether you are looking at 'samples' or 'events'. You need use 'events'. You can compute the
Events of CPU_CLK_UNHALTED.THREAD = 'samples of CPU_CLK_UNHALTED.THREAD' * sample_after_value (SAV) or Events of CPU_CLK_UNHALTED.REF = 'samples of CPU_CLK_UNHALTED.REF' * sample_after_value (SAV)