[sldev] QueryPerformanceCounter()

Dzonatas dzonatas at dzonux.net
Thu May 31 02:35:25 PDT 2007


Paul TBBle Hampson wrote:
> Now you're looking at using it for Linux,
The performance counter is a bonus to finish the port of the frequency 
detection.

Here is my suggestion to wrap up rdtsc for x86_64. (despite the format)

 __asm__ volatile ( "*
"    *rdtsc                               \n"
"    shlq $32, %%rdx              \n"
"    orq %%rax, %%rdx          \n"
: "=rdx" (start) :: "rax" );

This avoids an extra cache hit with two movl's (like in the example 
provided).

I do not have immediate access to test this on 64bit Linux at this time. 
If I can get a confirmation it works, that will be helpful, and I'll 
update the patch.

I could still use "=A" here, but after I read different articles on its 
usage I decided its best not to confuse it for readability. For example, 
this  could work for both 32 bit and 64 bit

 __asm__ volatile ( "*
"    *rdtsc                               \n"
#if defined(_x86_64_)
"    shlq $32, %%rdx              \n"
"    orq %%rdx, %%rax          \n"
#endif
: "=A" (start) :: "d" );


Back to QueryPerformanceCounter()...

It is helpful to have a consistent port of the frequency detection just 
in case we want to crunch the numbers.

-- 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.secondlife.com/pipermail/sldev/attachments/20070531/15350183/attachment.htm


More information about the SLDev mailing list