Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Languages Misc > Re: Code perfor...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 1138 of 1217
Post > Topic >>

Re: Code performance, rdtsc and code alignment

by "Wolfgang Kern" <nowhere@[EMAIL PROTECTED] > Apr 26, 2008 at 02:17 PM

James Harris wrote:

> Oddly, no replies as yet. Will see if others are interested. The test
> below was on an Intel chip. Testing on an AMD CPU shows similar (but
> not as marked) effect.

:) I also waited for some answers ...

The align will affect the timing of all instructions after the
first RDTSC.  My time measurement work an a dedicated test area
filled with nops, aligned to cache-bounds and includes debugger
overhead, so I can step/trace my code under test and see the
re****ted TSC-difference.

But this is just useful for comparing algos or find obvious
dependencies early, it wont tell anything about code duration when
this test code become part of a greater scenario somewhere else ...

The different figures you get without align may come from cache-
bound-crossing of your test code and if I look in more detail:
+71,+91,+112,+126  could this be burst-read penalties caused by
the 2nd serialising ?

btw: I don't have a CPUID before the second RDTSC
so I get an almost contant 14 cycles count for an empty test.
__
wolfgang


> On 22 Apr, 02:30, James Harris <james.harri...@[EMAIL PROTECTED]
> wrote:
> > If I run the code below (which is based on an Intel performance
> > measuring note) the times for each of the three inter-rdtsc sequences
> > is almost always 122 cycles. However, if the align directive is
> > removed, sometimes the cycle counts vary markedly.
> >
> > Anyone else seen this effect?
> >
> > --
> > (Reposting here to avoid the moderator delay on another group.)
> > James
> >
> > An example of running the code without the align directive:
> >
> > Calibration times 122, 122, 122
> > Calibration times 122, 213, 122
> > Calibration times 122, 193, 122
> > Calibration times 122, 213, 122
> > Calibration times 122, 234, 122
> > Calibration times 122, 193, 122
> > Calibration times 122, 193, 122
> > Calibration times 122, 248, 122
> > Calibration times 122, 193, 122
> > Calibration times 122, 213, 122
> >
> > With the align directive:
> >
> > Calibration times 122, 122, 122
> > Calibration times 122, 122, 122
> > Calibration times 122, 122, 122
> > Calibration times 122, 122, 122
> > Calibration times 122, 122, 122
> > Calibration times 122, 122, 122
> > Calibration times 122, 122, 122
> > Calibration times 122, 122, 122
> > Calibration times 122, 122, 122
> > Calibration times 122, 122, 122
> >
> > ;;;;;;;;
> > ;Calibrate the time stamp counter measurement
> >
> >         align 32
> > tsc_calibrate:
> >         mov     eax, [subtime_1]        ;Preload cache
> >         xor     eax, eax
> >         cpuid
> >         rdtsc
> >         mov     [subtime_1], eax
> >         xor     eax, eax
> >         cpuid
> >         rdtsc
> >         sub     eax, [subtime_1]
> >         mov     [subtime_1], eax
> >
> >         mov     eax, [subtime_2]        ;Preload cache
> >         xor     eax, eax
> >         cpuid
> >         rdtsc
> >         mov     [subtime_2], eax
> >         xor     eax, eax
> >         cpuid
> >         rdtsc
> >         sub     eax, [subtime_2]
> >         mov     [subtime_2], eax
> >
> >         mov     eax, [subtime_3]        ;Preload cache
> >         xor     eax, eax
> >         cpuid
> >         rdtsc
> >         mov     [subtime_3], eax
> >         xor     eax, eax
> >         cpuid
> >         rdtsc
> >         sub     eax, [subtime_3]
> >         mov     [subtime_3], eax
> >
> >         ret
>
 




 2 Posts in Topic:
Re: Code performance, rdtsc and code alignment
James Harris <james.ha  2008-04-25 12:03:21 
Re: Code performance, rdtsc and code alignment
"Wolfgang Kern"  2008-04-26 14:17:35 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 5:23:05 CDT 2008.