Re: strange behavior w cpuid

From: John Doe (spamtrap_at_crayne.org)
Date: 11/03/04


Date: Wed, 3 Nov 2004 09:07:54 +0000 (UTC)

Can you post a link to the article?

"David J. Craig" <spamtrap@crayne.org> wrote in message
news:QuWhd.2564$As5.702@tornado.tampabay.rr.com...
> Do you ever read any professional publications about programming? This
> was mentioned in an article by Abrash this year.
>
> "Vasanth Venkatachalam" <spamtrap@crayne.org> wrote in message
> news:cm9200$bfq$1@news.service.uci.edu...
>> I'm encountering some strange behavior when timing some code. First I
>> timed
>> the number of cycles for the cpuid instruction. Then I timed the cycles
>> needed to execute both the cpuid instruction and an extra multiply. The
>> strange thing is that the code with the additional multiply finishes in
>> fewer cycles than the code that doesn't contain the multiply. This oddity
>> persists no matter how many times I repeat the measurements.
>>
>> When I leave out the multiply the code below takes on average 206 cycles.
>> When I add the extra multiply, the code only takes 197 cycles...
>>
>> Any ideas?
>>
>> int numsamples = 10000000;
>>
>> for(j = 0; j < numsamples; j++)
>> {
>>
>> readtsc(t0); //read timestamp counter
>>
>> x = x * x; //the multiply. I commented this out in the first run.
>>
>> __asm__ __volatile__("cpuid");
>>
>> readtsc(t1);
>>
>> total += t1 - t0;
>> }
>>
>> double result = (double)total/(double)numsamples;
>> printf("%f\n", result);
>>
>>
>



Relevant Pages

  • Re: strange behavior w cpuid
    ... >>I'm encountering some strange behavior when timing some code. ... >>the number of cycles for the cpuid instruction. ... >>needed to execute both the cpuid instruction and an extra multiply. ...
    (comp.lang.asm.x86)
  • Re: strange behavior w cpuid
    ... > I'm encountering some strange behavior when timing some code. ... > the number of cycles for the cpuid instruction. ... > needed to execute both the cpuid instruction and an extra multiply. ...
    (comp.lang.asm.x86)
  • Re: strange behavior w cpuid
    ... > I'm encountering some strange behavior when timing some code. ... > the number of cycles for the cpuid instruction. ... > needed to execute both the cpuid instruction and an extra multiply. ...
    (comp.lang.asm.x86)
  • strange behavior w cpuid
    ... I'm encountering some strange behavior when timing some code. ... the number of cycles for the cpuid instruction. ... needed to execute both the cpuid instruction and an extra multiply. ...
    (comp.lang.asm.x86)
  • Re: strange behavior w cpuid
    ... > I'm encountering some strange behavior when timing some code. ... > the number of cycles for the cpuid instruction. ... > needed to execute both the cpuid instruction and an extra multiply. ... What is the value of EAX when you execute the CPUID instruction? ...
    (comp.lang.asm.x86)