Complete.Org: Mailing Lists: Archives: freeciv-dev: April 1999:
Re: [Freeciv-Dev] Some performance issues
Home

Re: [Freeciv-Dev] Some performance issues

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Stephen Hodge <stephenh@xxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: Re: [Freeciv-Dev] Some performance issues
From: Fabrice Noilhan <Fabrice.Noilhan@xxxxxx>
Date: Wed, 21 Apr 1999 10:08:41 +0200

On Tue, Apr 20, 1999 at 08:57:20PM +1000, Stephen Hodge wrote:

> Just a comment here - I think this sort of thing could hurt readability if
> it is not done carefully. That would hurt portability to some degree.

That's why using a macro can ease that kind of things. But in this
case, I'm not sure that's really needed.

> I think the major point was that mulitplication is NOT generally expensive.
> A lookup is only really fast if the array is in the cache and the array
> address is in a register. This sort of optimization might only make a
> significant difference on a very small set of targets (UltraSPARCs using
> Sun's compiler). In that case I would say it's not worth doing, just use a
> better compiler.

No, my point was that for instance 13*x is implemented using the mulx
opcode on UltraSparc. This costs 20 cycles. That could be implemented
with (x+(x<<2)+(x<<3)), which takes 5 cycles.

BUT:

- Sun's CC 5.0 is the only compiler which generates 64 bit code, and that
was what I needed. So that you can't use another compiler if you want
to generate 64 bit binaries.

- A lookup table is generally faster than a multiplication. The only
exception to the best of my knowledge are Pentium Pro/II/III processors.
In this case, you lose only a few cycles.

- There is no case for cache misses on modern processors for a 80 int
array...

        Fabrice
-- 
Fabrice.Noilhan@xxxxxx
http://www.eleves.ens.fr/~noilhan

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