Re: Measuring short times

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Daniel Lohmann wrote:
> Dennis Clarke schrieb:
>>> Dennis, those Solaris functions were not useful for me because I got
>>> no idea how to make it work on Windows.
>>>     
>>
>> How do you know that those functions are monotonic and consistent ?
>>   
> On IA-32 CPUs (Pentium or K5 and above) rdts returns the content of the
> 64 bit CPU-internal clock counter, which is set to 0 at system start and
> incremented by one at every clock tick. This is guaranteed to be not
> only monotonic, but even strongly monotonic. Moreover, even on a 4.2 GHz
> system it would take 2^32 seconds (>130 years) until the counter
> overflows. For all practical purposes, this should be fine :-)
> 
> Only caveat is that it depends on the CPU clock speed. Not only that the
> basic clock speed is different on every system, it may even change over
> time due to power saving strategies. Nevertheless, for short time
> periods this is on Intel the best method to go.
> 

I don't think it is safe to count on the rdtsc counter being zeroed at
boot.  On most current motherboards, the BIOS attempts to synchronize
the counters on various sockets at boot, but documentation indicates
that can't be counted upon, so it isn't necessarily safe to use rdtsc on
a multiple CPU machine unless timer calls are locked to the same CPU.
Intel CPUs for several years have based rdtsc counter on the front side
buss clock, so it doesn't vary with power saving.  It still is necessary
to disable power saving strategies in the BIOS in order to get full
repeatable performance, particularly for short intervals.  In case it's
of any interest, the 7 year design life of CPUs is contingent on leaving
power saving enabled.
In case it's more convenient, omp_get_wtime() should be capable of the
resolution mentioned by OP.  Windows Vista also should support HPET
timer on recent platforms.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux