On 9/3/06, Vladimir A. Pavlov <[EMAIL PROTECTED]> wrote:
AFAIK the main difference between enabling and disabling -ffast-math is
that if you, for example, call sin() function (or cos(), or tan(), ...)
in your program the compiler generates a corresponding libc function
call. In the opposite case (enabled -ffast-math) the compiler inserts
the assembler instruction (of course, if a given processor supports it)
rather then function call.

As you understand the result appears sooner in the latter case and
(theoretically) any 3d program would work faster if compiled with
-ffast-math.


Thanks for the information.

I have run across:
http://sources.redhat.com/ml/libc-hacker/2000-04/msg00056.html,
which does a damn good job of explaining -ffast-math, (and also
explains the errno problem that you mentioned).  From what it says, I
wonder if "-ffast-math -fmath-errno" Would allow your quick program to
work.  I'll be testing that.

I went through the Mesa source and looked for any check for:
__FAST_MATH__  and found none:

# cd Mesa-6.5
# for i in $(find $PWD -name '*.c') ; do grep __FAST_MATH__ $i ; echo $i ; done

I repeated for '*.h' as well, with no results.

Just in case, I also did:
# for i in $(find $PWD) ; do grep __FAST_MATH__ $i ; echo $i ; done

I also discovered a possible problem with either my system or the
uclibc on my system.
The code example you gave above did not have a non-zero errno value
returned (all returned a 0) with all of the following:

(gcc-4.1.1)
# gcc a.c -lm
# gcc a.c -lm -fmath-errno
# gcc a.c -ffast-math
# gcc a.c -ffast-math -fmath-errno

uname -p returns: athlon-4
( Do you have a nice patch for uname that better handles the uname -p
flags? I remember one of our patches already does that, but is not as
"informative" as yours is)
I am running on an AMD Athlon(tm) 64 Processor 3700+ as reported by
both hardinfo and "lshw | grep Athlon" (or gtk-lshw).

As a rather quick'n'dirty performance test, I tested the following:
#include <math.h>
#include <errno.h>

int main ()
{
      volatile double s = sqrt (-1);
       long i;

       for (i=0; i < 100000; i++){
               s = sqrt(-1);
       }
}

Against -lm, it took ~0.005s, whereas -ffast-math took ~0.001s.
--
Kevin Day
--
http://linuxfromscratch.org/mailman/listinfo/hlfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to