Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2001:
[Freeciv-Dev] Re: Server Error (PR#666)
Home

[Freeciv-Dev] Re: Server Error (PR#666)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Vasco Alexandre Da Silva Costa <vasc@xxxxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Server Error (PR#666)
From: Gaute B Strokkenes <gs234@xxxxxxxxx>
Date: 01 Feb 2001 17:10:42 +0000

On Wed, 31 Jan 2001, vasc@xxxxxxxxxxxxxx wrote:

> On Tue, 30 Jan 2001, [BIG5] ½²«íµØ wrote:
> 
>> The CPU time saving is avoiding calls to normalize_map_pos()
>> (s-n)*(e-w) times, only calling is_coastline() islemass times.
>> > The compiler is perfectly capable of performing that sort of
>> > trivial optimisation itself.  Or at least it should.  8-)
>> Unfortunately, it doesn't. At least not with gcc on x86 platforms.
>> Diffing with "gcc -O3 -S" gives: (only essential parts are shown)
> 
> Yes that's typical.  I made a raytracer with a matrix multiply
> function sort of like this:
> 
> for (i=0; i<4; i++)
> {
>   for (j=0; j<4; j++)
>   {
>     ...
>   }
> }
> 
> And the stupid thing (gcc -O3 -mcpu=i686) didn't unroll the inner
> loop!  If it can't unroll something like this i wonder what kind of
> loops it does unroll...

None, unless you enable loop unrolling.  It's not on by default, not
even with -O3 :

-O2

    Optimize even more. GCC performs nearly all supported
    optimizations that do not involve a space-speed tradeoff. The
    compiler does not perform loop unrolling or function inlining when
    you specify `-O2'. As compared to `-O', this option increases both
    compilation time and the performance of the generated code. `-O2'
    turns on all optional optimizations except for loop unrolling,
    function inlining, and register renaming. It also turns on the
    `-fforce-mem' option on all machines and frame pointer elimination
    on machines where doing so does not interfere with debugging

> BTW: i unrolled the inner loop by hand and the damned thing
> raytraced that scene 35% faster.  Silly...

> And today's motto is: you can't trust a compiler to optimize your
> code properly.

This is true, but reading the manual helps too.  ;-)

-- 
Big Gaute                               http://www.srcf.ucam.org/~gs234/
Here I am in the POSTERIOR OLFACTORY LOBULE but I don't see CARL SAGAN
 anywhere!!



[Prev in Thread] Current Thread [Next in Thread]