Community
cancel
Showing results for 
Search instead for 
Did you mean: 
nyserveradmin
Beginner
45 Views

Sampling realtime clock speed on Ivy Bridge / Haswell Xeon CPUs

I am trying to sample the realtime clock speed on Windows, but it seems to only return the listed frequency for the CPU model regardless of C-state. Does anyone have a C++ routine that will return the realtime clock speed on an Ivy Bridge or Haswell Xeon CPU?

0 Kudos
1 Reply
McCalpinJohn
Black Belt
45 Views

Are you asking for the instantaneous CPU core frequency?  (I dunno if the phrase "realtime clock" means something different in Windows.)

The instantaneous CPU core frequency can only be read while in kernel mode, and the act of switching from user mode to kernel mode can be enough to trigger the core frequency to change.

A combination of the TSC and hardware performance counters can be used to measure the average core frequency over an interval.  In most configurations, the TSC can be read at low latency from user space, while reading the performance counters is typically done using a kernel call.   The hardware supports reading the performance counters from user space (at low latency), but the resulting values are only useful if you can guarantee that the "before" and "after" user-space performance counter readings were taken on the same core.