Re: strange behavior w cpuid
From: John Doe (spamtrap_at_crayne.org)
Date: 11/03/04
- Next message: wolfgang kern: "Re: help convert 32-bit to 16-bit"
- Previous message: John Doe: "Re: strange behavior w cpuid"
- In reply to: David J. Craig: "Re: strange behavior w cpuid"
- Next in thread: David J. Craig: "Re: strange behavior w cpuid"
- Reply: David J. Craig: "Re: strange behavior w cpuid"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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);
>>
>>
>
- Next message: wolfgang kern: "Re: help convert 32-bit to 16-bit"
- Previous message: John Doe: "Re: strange behavior w cpuid"
- In reply to: David J. Craig: "Re: strange behavior w cpuid"
- Next in thread: David J. Craig: "Re: strange behavior w cpuid"
- Reply: David J. Craig: "Re: strange behavior w cpuid"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|