Mail Archives: djgpp/1997/05/19/08:47:41
For tips on optimizing C code in general you can visit my optimization
web page at:
http://www.geocities.com/SiliconValley/9498/optimize.html
On 13 May 1997 12:24:10 EDT, quark(particle) (quark AT webspan DOT net) said:
> 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...
Then please see my web page for more examples of how to optimize with the
floating point processor. (And read Agner Fog's article while you're at
it.)
http://www.geocities.com/SiliconValley/9498/p5opt.html
> and I have a Pentium. and a 486. pentium is better
> with floting point numbers than the 486, but nothing
> beats clean integer math.
You aint tried hard enough. I've done own comparisons, and the FPU is
clear hands down winner.
> 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?
Well of course there are always weird cases. For example, using the FPU
to calculate address offsets (or DDA line coordinates) is not likely to
yield any performance improvments over the regular integer instructions.
But this is primarily because the x86 can only use integer registers for
addresses, and hence always requires conversion from FPU to int which is
not terribly fast.
The bottleneck in line drawing should be the fact that you touching lots
of piddly little memory locations, rather than writing them in bursts in
a DWORD aligned fashion. If you wanted to go nuts you could optimize for
"mostly horizontal" cases, but I doubt that would be worth the effort.
Fixed point DDA will work out best for the amount of effort you put into
it.
--
Paul Hsieh
http://www.geocities.com/SiliconValley/9498/mailme.html
- Raw text -