[Openmcl-devel] CCL 1.9 release candidate available

Gary Byers gb at clozure.com
Wed Feb 6 17:43:40 PST 2013


? (apropos "RDTSC")

It'd also be interesting to Google for something like "rdtsc problems" ...

To do something like Googling it for you: rdtsc - "read time stamp
counter" - is an x86 instruction that returns a 64-bit on-chip
counter; that counter counts clock cycles.  Two problems with using
rdtsc for timing:

1) the time stamp counters of different CPU cores in a multiprocessor
system aren't necessarily in sync with each other.
2) on many modern systems, the clock rate can fluctuate over time (mostly
to save power); unless you know a lot about if and how this has happened,
it's difficult to translate from a cycle count to wall-clock time.

Googling for "rdtsc site:clozure.com" may help some people reading this
overcome the mysterious sense of deja vu they may be experiencing ...


On Wed, 6 Feb 2013, Wade Humeniuk wrote:

> From a postat?http://stackoverflow.com/questions/275004/c-timer-function-to-provide-ti
> me-in-nano-seconds (see the full post for how to get nanoseconds)
> 
> I assume ccl can generate machine instructions directly...
> 
> Wade
> 
> <quote>
> 
> Here's the actual code to retrieve number of 80x86 CPU clock ticks passed
> since the CPU was last started. It will work on Pentium and above (386/486
> not supported). This code is actually MS Visual C++ specific, but can be
> probably very easy ported to whatever else, as long as it supports inline
> assembly.
> 
> inline __int64 GetCpuClocks()
> {
>
>     // Counter
>     struct { int32 low, high; } counter;
>
>     // Use RDTSC instruction to get clocks count
>     __asm push EAX
>     __asm push EDX
>     __asm __emit 0fh __asm __emit 031h // RDTSC
>     __asm mov counter.low, EAX
>     __asm mov counter.high, EDX
>     __asm pop EDX
>     __asm pop EAX
>
>     // Return result
>     return *(__int64 *)(&counter);
> 
> }
> 
> This function has also the advantage of being extremely fast - it usually
> takes no more than 50 cpu cycles to execute.
> 
> </quote>
> 
> On 2013-02-06, at 3:08 PM, "R. Matthew Emerson" <rme at clozure.com> wrote:
> 
>
>       On Feb 6, 2013, at 4:24 PM, Alexander Repenning
>       <Alexander.Repenning at colorado.edu> wrote:
> 
>
>             On Feb 6, 2013, at 1:48 PM, R. Matthew Emerson
>             wrote:
> 
>
>                   On Feb 6, 2013, at 3:36 PM, Alexander
>                   Repenning
>                   <alexander.repenning at Colorado.EDU>
>                   wrote:
>
>                         from the release notes:
>
>                               access to
>                               high-resolution
>                               clock
>
>                               CCL:CURRENT-TIME-IN-NANOSECONDS
>                               returns the
>                               number of
>                               elapsed
>                               nanoseconds
>                               since some
>                               arbitrary point
>                               in time (likely
>                               system boot.)
> 
>
>                         This sounds very useful.
>                         What is the approximate
>                         resolution of this function
>                         on Windows, i.e., what kind
>                         of Windows timer function is
>                         this based on?
> 
>
>                   Pressing M-. on
>                   current-time-in-nanoseconds leads me to
>                   its definition in ccl:lib;time.lisp. ?On
>                   Windows, that function uses
>                   #_GetSystemTimeAsFileTime.
> 
> 
>
>             I was afraid of that because on most Windows
>             systems, certainly XP, that would suggest a 15ms
>             resolution which is rather disappointing.
> 
>
>       If you know of a Windows function that that would provide
>       superior results, I'd love to hear about it.
>
>       QueryPerformanceCounter() is not a good solution. ?It requires a
>       lot of effort to compensate for its limitations. ??See, for
>       example, https://bugzilla.mozilla.org/show_bug.cgi?id=676349
>
>       _______________________________________________
>       Openmcl-devel mailing list
>       Openmcl-devel at clozure.com
>       http://clozure.com/mailman/listinfo/openmcl-devel
> 
> 
> 
>



More information about the Openmcl-devel mailing list