[sldev] QueryPerformanceCounter() (was: Re: [PATCH] Re: CPUSlow)

Dzonatas dzonatas at dzonux.net
Wed May 30 17:16:58 PDT 2007


Paul TBBle Hampson wrote:
> This patch only implements CPUID under GCC, which of course only works
> on i386 or AMD64 platforms.
>   
Right.
> rdtsc usage is incorrect for AMD64 platforms (See comments in the patch
> attached to VWR-940 for details of that issue) The MSVC-based asm code
> for it gets it right, it's only your GCC variant that's wrong.
>   
It is? Here is the code:

#if LL_GNUC
    __asm__("rdtsc"    : "=A" (start) ) ;
#else
    __asm
    {
        rdtsc
        mov dword ptr [start+4], edx
        mov dword ptr [start], eax
    }
#endif

"=A" is documented as a 64bit word and "start"  is __int64. The compiler 
should be able to create one 64bit mov instruction or two 32 bit mov 
instruction as needed.


> And of course, PROCESSOR_FREQUENCY_MEASURE_AVAILABLE is only defined for
> LL_WINDOWS (Which is bizarre, they should have just used LL_WINDOWS
> there to make other platform implementations easier, since the code will
> differ)
>
> I can see how this patch would allow building under gcc on win32,
That's exactly how it was tested.
> but I
> really can't see how you could have shown this working under unix,
> unless you changed the definition of
> PROCESSOR_FREQUENCY_MEASURE_AVAILABLE, and supplied Sleep() and
> QueryPerformanceCounter() methods, and just left them out of the patch?
>   
That's a different issue from just getting cpuid to work.

I added this to jira: VWR-975 
<https://jira.secondlife.com/browse/VWR-975>: QueryPerformanceCounter() 
implementation for CProcessor::GetCPUFrequency() to return correct value 
under x86 Linux

Thank you*
*

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


More information about the SLDev mailing list