Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: One (silly) question about "C"

Author: Dieter Buerssner

Date: 17:37:45 02/05/02

Go up one level in this thread


On February 05, 2002 at 20:06:39, Dann Corbit wrote:

>C:\tmp>foo
>Expecting a sum of 30830878000000
>sum normal:   sum=30830878000000, used 8.422 seconds
>sum unrolled: sum=30830878000000, used 8.563 seconds

Ok, you win :-)

But to show, that one can get different results:

D:\TEST>gcc -O3 -osum sum.c

D:\TEST>sum
Expecting a sum of 30830878000000
sum normal:   sum=30830878000000, used 39.560 seconds
sum unrolled: sum=30830878000000, used 20.330 seconds

D:\TEST>gcc -O3 -funroll-loops -osum sum.c

D:\TEST>sum
Expecting a sum of 30830878000000
sum normal:   sum=30830878000000, used 30.769 seconds
sum unrolled: sum=30830878000000, used 19.011 seconds

Also, as I said before, typically in more complex applications, the compiler
unrolling is applied too often. And I also did not take the time, to use try
other unrolling factors than 8, something which I might have done for an inner
loop in an application that runs for a very long time. This also can naturally
be very CPU/cache size dependant.

Anyway, I agree with you, that normally it is not worthwhile to try such tricks.

Regards,
Dieter

PS. Perhaps my test is also flawed. I just wrote it up in few minutes, and did
not check if (for example) the usage of the double sum in the main() make a
difference, nor did I care to design this carefully.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.