[sldev] QueryPerformanceCounter()
Paul TBBle Hampson
Paul.Hampson at Pobox.com
Thu May 31 00:03:20 PDT 2007
On Wed, May 30, 2007 at 05:16:58PM -0700, Dzonatas wrote:
> 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:
> __asm__("rdtsc" : "=A" (start) ) ;
> "=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.
(From the patch attached to VWR-940:)
http://www.gelato.unsw.edu.au/IA64wiki/rdtscOnAmd64
Precis: gcc docs say =A only works in 32-bit mode, not 64-bit mode
However, you don't want to use the suggested code on that page, as it's
GPL'd code from the Linux kernel. There's an ASM rdtsc reader in the
patch attached to VWR-940 which is safe to use, license wise.
> >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.
True, but the patch description and environment indicate it's for Linux,
when it neither effects Linux nor has reportedly been tested thereof.
> 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
For this, I don't think adding "QueryPerformanceCounter" is the right
solution here, myself. Although I don't have the code here to give that
suggestion any basis, and I only skimmed the code when trying to work
out why it always scored CPUSlow despite having a MHz measurement
available in gCPUInfo, and noticed that the code to measure the CPU
frequency was win32-only.
Now you're looking at using it for Linux, I'll give it a harder go
though, and see if I can get a version that works with PowerPC too.
--
-----------------------------------------------------------
Paul "TBBle" Hampson, B.Sc, LPI, MCSE
On-hiatus Asian Studies student, ANU
The Boss, Bubblesworth Pty Ltd (ABN: 51 095 284 361)
Paul.Hampson at Pobox.com
Of course Pacman didn't influence us as kids. If it did,
we'd be running around in darkened rooms, popping pills and
listening to repetitive music.
-- Kristian Wilson, Nintendo, Inc, 1989
License: http://creativecommons.org/licenses/by/2.1/au/
-----------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.secondlife.com/pipermail/sldev/attachments/20070531/60b44b7a/attachment-0001.pgp
More information about the SLDev
mailing list