2 quick questions regarding RDTSC
a) Does RDTSC return the number of CPU clock-ticks since boot?
b) If so -
On my Core i5 (520M), I have tried to use RDTSC to calculate the CPU speed.
I read the TSC, wait for 100ms, read again and take the difference.
For some reason, it is telling me the difference is ~2.1 billion ticks.
I know the timing loop is correct as I also use it to calculate the FSB (which is coming back as 1066Mhz).
I was about to multiply the TSC diff by 10 (to get seconds) when I noticed it was already huge . I have checked the start and end TSC readings, and manually calculated the difference = 2 billion.
Am I getting 10 ticks per clock cycle or is something else weird going on?
RDTSC on Corei5
Re: RDTSC on Corei5
No, the number may not related to ticks upon boot, btw it may be paused for inactive processors, or accordingly the the manual:sentientnz wrote:Does RDTSC return the number of CPU clock-ticks since boot?
The processor monotonically increments the time-stamp counter MSR every clock cycle and resets it to 0 whenever the processor is reset.
There is always rounding errors and interrupts/SMM/hidden tasks. The only way to increase accuracy is enlarge sample.sentientnz wrote:Am I getting 10 ticks per clock cycle or is something else weird going on?
Re: RDTSC on Corei5
Hi,
Note that for Core i5, "nominal clock ticks" has nothing to do with the speed that the CPU is actually running at, and may not have anything to do with any speed the CPU could ever run at. I'm not too sure exactly what the TSC in Core i5 measures - I'd guess the maximum turbo-boost speed (e.g. 2.933 GHz for a Core i5 520M), but that's only a guess, and it could just multiply the bus speed by an arbitrary "large enough" number (like 18).
Cheers,
Brendan
For Core i5, TSC should measure "nominal clock ticks" since the CPU was started last (e.g. including reset, etc); as long as nobody messed with the MSR to change the TSC.sentientnz wrote:a) Does RDTSC return the number of CPU clock-ticks since boot?
Note that for Core i5, "nominal clock ticks" has nothing to do with the speed that the CPU is actually running at, and may not have anything to do with any speed the CPU could ever run at. I'm not too sure exactly what the TSC in Core i5 measures - I'd guess the maximum turbo-boost speed (e.g. 2.933 GHz for a Core i5 520M), but that's only a guess, and it could just multiply the bus speed by an arbitrary "large enough" number (like 18).
You can't estimate CPU speed using RDTSC on any recent CPU (you can only determine what speed the TSC runs at).sentientnz wrote:On my Core i5 (520M), I have tried to use RDTSC to calculate the CPU speed.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.