Re: Is timeGetTime monotonic and uniform?



On 3 Dec 2006 12:16:49 -0800, "alanglloyd@xxxxxxx"
<alanglloyd@xxxxxxx> wrote:


Bob Masta wrote:

The instruction I would use is RDTSC, which is an
assembler opcode (ReaD Time Stamp Counter)
that returns the CPU ticks since boot time in EDX:EAX.
<snip>

Some time ago I read that when you get the RDTSC overhead (ie the time
to actuaaly call RDTSC which should be taken account of in timing) that
one should call RDTSC three times, checking the overhead between the
second and third time. This was because of caching of the call. I don't
know if this is still the case with present-day CPUs.

I have always done this when using RDTSC, but of course I have no means
of checking whether the above recommendation is really necessary, or is
effective.


I haven't run into the 3-times approach, but I have heard
recommendations to call CPUID just before RDTSC to
"serialize" the instructions. I believe this refers to
forcing all other instructions out of the internal CPU
pipeline, but don't know if this covers caches.

Best regards,



Bob Masta
dqatechATdaqartaDOTcom

D A Q A R T A
Data AcQuisition And Real-Time Analysis
www.daqarta.com
Home of DaqGen, the FREEWARE signal generator
.



Relevant Pages

  • Re: what exactly does CPU_TIME measure?
    ... clock cycles then rdtsc makes more sense. ... speed CPU) but clock cycles are. ... so you can get accurate timing even for small ...
    (comp.lang.fortran)
  • Re: Whats the purpose of get_cycles_sync()
    ... Vojtech had one test that tested time monotonicity over CPUs ... I suspect the reason was because the CPU reordered the RDTSCs so that ... fit more than one iteration into the CPU's reordering window. ... What could have been happening then was that the RDTSC instruction might ...
    (Linux-Kernel)
  • Re: assembly in future C standard
    ... should the compiler author implement method 1 ... Some compilers will give an option to which set of cpu instruction ... complience with standard XX run on a cpu predated XX. ... Again ill use an example of RDTSC: ...
    (comp.lang.c)
  • Re: rdtsc and the sleep fcn (Was problem with rdtsc instruction on Pentium M)
    ... > function goes into the idle loop, causing the tsc to stop counting. ... the CPU is slowed down which stuffs ... The solution is not to use RDTSC. ...
    (comp.lang.asm.x86)
  • Re: Thinking assembly?
    ... I simply needs to understand the CPU and how it works, ... > understand the instructions, be a good and experienced programmer, ... assembly language is the machine's language (or, at least, ...
    (alt.lang.asm)