delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/13/15:59:54

Message-Id: <199705131955.VAA03718@zeus.hu.bonus.com>
From: "Abonyi Gyorgy" <loop AT hu DOT bonus DOT com>
To: "quark(particle)" <quark AT webspan DOT net>, <djgpp AT delorie DOT com>
Subject: Re: Any tips on optimizing C code?
Date: Tue, 13 May 1997 21:55:08 +0200
MIME-Version: 1.0

quark wrote:
> I've read the Michael Abrash text.. and.. well.. 
> I still think that integer math is faster... I had
> few floting point programs which doubled their
> speed once I converted them to integer math...
> 
> and I have a Pentium. and a 486.  pentium is better
> with floting point numbers than the 486, but nothing
> beats clean integer math.  
> 
> I mean... who would use floting numbers in a simple
> line algorithm... everybody wants the "all integer, no shifting" 
> aproach...... why?  wouldn't it be easier just to write 
> the thing with floting point number?
> 
> >Robert Blum wrote:
> >>
> >> Duh.. That must have been from a very old source of information. On
> >> the Pentium (I assume you use one), FP is even faster than integer
> >> performance.

FP arithmetic isn't faster than pure integer, allmost every fp operation
takes more clock cycles than the integer operations.
What makes the FP faster in some reasons, that in the pentium family, the
FP unit can execute instructions paralell with the integer unit, so you can
execute integer operations, while a fp operation runs "on the background".
So when you read an FDIV takes only one cycle, it means, it takes 27 or 37
cycles (sorry i don't know exactly), but your program can make some usefull
integer arithmetic meantime....
So if you need the evaluated value in the next line of code, than fp will
be really slow, but with carrefuly coding, and with mixing integer and fp
operations, you can get nice speedups.

Gyorgy Abonyi Jr.
loop AT hu DOT bonus DOT com
http://www.hu.bonus.com/~loop

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019