delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/19/13:13:23

Message-Id: <m0yn4hr-000S4DC@inti.gov.ar>
Comments: Authenticated sender is <salvador AT natacha DOT inti DOT gov DOT ar>
From: "Salvador Eduardo Tropea (SET)" <salvador AT inti DOT gov DOT ar>
Organization: INTI
To: Rob Kramer <rkramer AT xs4all DOT nl>, djgpp AT delorie DOT com
Date: Fri, 19 Jun 1998 14:17:09 +0000
MIME-Version: 1.0
Subject: Re: Fixed vs floating point?
In-reply-to: <Pine.SUN.3.96.980619100615.14404A-100000@xs2.xs4all.nl>

Rob Kramer wrote:

> Can anyone make a guess if multiplications/devisions in fixed point math
> are still faster on a machine that has a FPU? I was wondering if it would
> do any good to #define my code to use conventional floats if the machine
> supports it. (I'm using Allegro's fixed math stuff b.t.w)

Depends on the CPU, in a 486 fixed will be normally faster if one of the 
values is know:

FMUL: 11 to 16 clocks (average values for different situations) 2 to 3 clocks 
if cache miss. 8 to 13 clocks in concurrent execution.
FDIV: 73, 2 to 3, 70  

A fixed MUL/DIV is reduced to shifts and adds when one of the values is know so 
is just a few clocks.

MUL: 13 to 42 for DWORDs (doesn't say what's the average) 
DIV: 40 for DWORDs
IDIV: 43 for DWORDs

As you can see the integer div is faster but the  MUL is slower.
I think that Pentiums have better floating point. So if your calculation is 
mostly MULs use the FPU.
Note that ADD and SUB are VERY slow in the 486 FPU so if you have an important 
number of sums (20%? or more) integers will be better.
And the best of all is to mix both like in the Quake engine, but I doubt you 
need such a huge optimization (They are concurrently executed).

SET

------------------------------------ 0 --------------------------------
Visit my home page: http://set-soft.home.ml.org/
or
http://www.geocities.com/SiliconValley/Vista/6552/
Salvador Eduardo Tropea (SET). (Electronics Engineer)
Alternative e-mail: set-soft AT usa DOT net set AT computer DOT org
ICQ: 2951574
Address: Curapaligue 2124, Caseros, 3 de Febrero
Buenos Aires, (1678), ARGENTINA
TE: +(541) 759 0013

- Raw text -


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