[Ace-users] [ace-bugs] ACE_OS::gethrtime produces inconsistent results on x86_64 architecture

J.T. Conklin jtc at acorntoolworks.com
Tue Nov 13 01:15:22 CST 2007


"Ernst, Nathan" <Nathan.Ernst at citadelgroup.com> writes:
> Using the ACE_High_Res_Timer, it was noticed that with a high frequency,
> the elapsed time reported was incorrect.  Namely, operations that
> completed in sub second timeframes were being reported to have taken 207
> years to complete.
>
> [...]
>
> Essentially what occurs is the current implementation only correctly
> retrieves the lower 32-bits from the rdstc invocation due to differences
> in register layout between x86 and x86_64.  The upper 32-bits returned
> is random garbage left in the upper 32-bits of %rax.

Hi Nathan, 

I've checked in a change that recognizes the rdtsc instructions stores
timestamps in the %eax/%edx registers on the amd64/x86_64 architecture
(just like the x86) which must be combined into the 64 bit timer value.

While this code also works on the x86, current (and past) versions of
gcc/g++ generate substationally worse code, I've left the x86 version
as is.

It appears that one reason you encountered this where I have not was
that your config had ACE_HAS_PENTIUM defined.  Although it's not
stated either way, I'm not sure that is needed or desirable for the
amd64/x86_64 architecture.  I believe most amd64/x86_86 specific
optimizations are enabled by ACE_HAS_INTEL_ASSEMBLY, __amd64__, and/or
__x86_64__.  I'll try to make this clear one way or another as soon as
I figure it out myself.

    --jtc

-- 
J.T. Conklin



More information about the Ace-users mailing list