Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Question - Who Is Using -ffast-math?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on AMD64
View previous topic :: View next topic  
Author Message
robnotts
Guru
Guru


Joined: 15 Mar 2004
Posts: 405
Location: Nottingham, UK

PostPosted: Sun Jul 03, 2005 4:02 pm    Post subject: Question - Who Is Using -ffast-math? Reply with quote

Having been slapped down by one of the developers for reporting a bug where -ffast-math breaks a program... specifically games-sports/foobillard-3.0a and requesting that a new ebuild is generated with the -ffast-math flag filtered, I am curious to know how many people on AMD64 are using -ffast-math, and are they experiencing any problems, and do they notice any speed ups?

The reason I ask... I do a lot of video/sound work on this machine, and as most (now thankfully not all) software does not have AMD64 sse/sse2 optimisations I was using -ffast-math to gain some speed up. Apart from foobillard as listed above, I have not noticed any problems, and indeed seem to have a very stable machine.

Rob.
_________________
---

Gentoo Phenom][ X4 955 on AMD790 + Geforce 220GT 8GB/1.75TB (Desktop)
+ MythTV (3xFreeview,1xFreesat HD) on 1080p
Gentoo Turion64 X2 Geforce 6150 2GB/120GB (Laptop)
Back to top
View user's profile Send private message
neuron
Advocate
Advocate


Joined: 28 May 2002
Posts: 2371

PostPosted: Sun Jul 03, 2005 5:14 pm    Post subject: Reply with quote

I seriously considered it, after reading an article (see http://forums.gentoo.org/viewtopic-t-332318.html ), but I dont have it on now.

I also made another thread a long time ago on the subject http://forums.gentoo.org/viewtopic-t-10535.html :)
Back to top
View user's profile Send private message
robnotts
Guru
Guru


Joined: 15 Mar 2004
Posts: 405
Location: Nottingham, UK

PostPosted: Sun Jul 03, 2005 5:44 pm    Post subject: Reply with quote

An interesting article certainly... I think I'll stick with the -ffast-math, and just put into my /usr/local/portage directory anything that I need to change to filter out flags.

Rob.
_________________
---

Gentoo Phenom][ X4 955 on AMD790 + Geforce 220GT 8GB/1.75TB (Desktop)
+ MythTV (3xFreeview,1xFreesat HD) on 1080p
Gentoo Turion64 X2 Geforce 6150 2GB/120GB (Laptop)
Back to top
View user's profile Send private message
crazycat
l33t
l33t


Joined: 26 Aug 2003
Posts: 838
Location: Hamburg, Germany

PostPosted: Sun Jul 03, 2005 6:16 pm    Post subject: Reply with quote

A very interesting article on the topic: gentoo ont opteron with gcc 3.4.3
http://www.coyotegulch.com/products/acovea/aco5k8gcc34.html
You can see that -O2 is generally better than -O3 probably because -O3 uncludes -funroll-all-loops.
-funroll-all-loops looks like the worst optimization ever while -frename-registers and -fweb are quite usefull.
I also found that on -ffast-math while googling
Quote:

The gcc `man` page says that -ffast-math allows for ANSI and
IEEE rules to be violated. There is also a statement about
not using it in conjunction with -O options as this will result
in incorrect output.

So you get what you asked for.

The FPU has 80-bits of precision internally. Its state is
always saved and restored across context-switches. There
are no "extra bits of precision" as you state.

The FPU's state is not saved during system-calls so the
kernel is not supposed to use the FPU internally.

Look at <math.h> and the files it includes. Note that the
math library takes and returns type double. If you have
declared your floating-point variables as type float, you
will have serious dynamic rounding errors unless you
closely adhere to the IEEE spec. Even then, it might
be serious. If the IEEE spec gets violated by the
--fast-math, you might have discovered the reason why
you get strange values.
Back to top
View user's profile Send private message
neuron
Advocate
Advocate


Joined: 28 May 2002
Posts: 2371

PostPosted: Sun Jul 03, 2005 6:45 pm    Post subject: Reply with quote

the threads that benchmark linked to was very interesting, I especially liked this post:
http://gcc.gnu.org/ml/gcc/2004-03/msg01459.html

If it's good enough for people who "make a very nice
living from selling software to solve finite-difference Poison-Boltzmann
electrostatic calculations on regular grids, and molecular minimizations
using quasi-newtonian numerical optimizers" then hell, it's gotta be good enough for me ;)

in fact I'm gonna recompile with
Code:

CFLAGS="-march=athlon64 -O2 -msse3 -pipe -frename-registers -fweb -ffast-math"
CXXFLAGS="${CFLAGS} -fvisibility-inlines-hidden"


added rename-registers web and fast-math now.
Back to top
View user's profile Send private message
Earthwings
Administrator
Administrator


Joined: 14 Apr 2003
Posts: 7751
Location: Karlsruhe, Germany

PostPosted: Sun Jul 03, 2005 7:17 pm    Post subject: Reply with quote

Please don't create any bug reports if you're using it.
_________________
KDE 4.13 - Get It While It's Hot!
Back to top
View user's profile Send private message
crazycat
l33t
l33t


Joined: 26 Aug 2003
Posts: 838
Location: Hamburg, Germany

PostPosted: Sun Jul 03, 2005 8:06 pm    Post subject: Reply with quote

I once posted a bug to gentoos bugzilla along with a link to the patch that fixes the problem http://bugs.gentoo.org/show_bug.cgi?id=87149 ,and it's still not fixed (3 months already). Since then I'd rather check/post on creators website than report a bug to gentoo's bugzilla.
Back to top
View user's profile Send private message
Birtz
Apprentice
Apprentice


Joined: 09 Feb 2005
Posts: 272
Location: Osijek / Croatia

PostPosted: Sun Jul 03, 2005 8:46 pm    Post subject: Reply with quote

Interesting read neuron, thank you. I myself don't use the -ffast-math flag because I never did much FP intensive stuff myself. If I did, I would consider testing the overall speed versus efficiency, and make the conclusion for myself. That said, I follow directions set by Gentoo developers (and "vast majority" of GCC team developers). This way I don't step on toes and "in most cases" my bug-reports or objections are rendered serious ;) On the other hand, if the bug-report policy says that you shoud drop "those flags" and "test again" it is only few minutes more effort, no?

Regards
_________________
It is not enough to have a good mind. The main thing is to use it well.
-- Rene Descartes

Don't have a childhood hero? How about Rob Hubbard http://www.freenetpages.co.uk/hp/tcworh/profile.htm
Back to top
View user's profile Send private message
thumper
Guru
Guru


Joined: 06 Dec 2002
Posts: 442
Location: Venice FL

PostPosted: Sun Jul 03, 2005 8:58 pm    Post subject: Reply with quote

With the exception of a few packages that this breaks, I have been using this system wide without any obvious ill effects. (knock wood)
Code:
CFLAGS="-march=athlon64 -O2 -pipe -frename-registers -fweb -ffast-math -mfpmath=sse -ftracer -funroll-loops -fstack-protector "


George
Back to top
View user's profile Send private message
robnotts
Guru
Guru


Joined: 15 Mar 2004
Posts: 405
Location: Nottingham, UK

PostPosted: Sun Jul 03, 2005 9:10 pm    Post subject: Reply with quote

Well I must admit, I have no problem with taking out the -ffast-math flag for those packages that need it removing, the one so far, foobillard, but surely it only takes a few minutes effort to add the command into the ebuild, unless I miss understood something?

Anyway, never mind, I'll just carry on regardless... I seem to have very conservative CFLAGS with the exception of the -ffast-math flag anyway...

I'll get around to doing an emerge -Dvep world with something a bit more serious, I live the look of -fweb and -frename-registers, once I get the X2 processor and don't have to kill a day and a bit recompiling!

Rob.
_________________
---

Gentoo Phenom][ X4 955 on AMD790 + Geforce 220GT 8GB/1.75TB (Desktop)
+ MythTV (3xFreeview,1xFreesat HD) on 1080p
Gentoo Turion64 X2 Geforce 6150 2GB/120GB (Laptop)
Back to top
View user's profile Send private message
Shapemaker
n00b
n00b


Joined: 22 Aug 2004
Posts: 64
Location: Finland

PostPosted: Mon Jul 04, 2005 4:41 am    Post subject: Reply with quote

crazycat wrote:
A very interesting article on the topic: gentoo ont opteron with gcc 3.4.3
http://www.coyotegulch.com/products/acovea/aco5k8gcc34.html
You can see that -O2 is generally better than -O3 probably because -O3 uncludes -funroll-all-loops.
-funroll-all-loops looks like the worst optimization ever while -frename-registers and -fweb are quite usefull.

No, it does not include -funroll-loops. From http://gcc.gnu.org/onlinedocs/gcc-3.4.4/gcc/Optimize-Options.html:
Quote:
-O3
Optimize yet more. -O3 turns on all optimizations specified by -O2 and also turns on the -finline-functions, -fweb and -frename-registers options.

You're likely thinking about -finline-functions, which can be very useful at times, specifically with all kinds of media encoders.
_________________
"Intellectual Property" should be an affront to anyone capable of independent thought.
Back to top
View user's profile Send private message
Imago
Apprentice
Apprentice


Joined: 25 Nov 2004
Posts: 157
Location: Germany

PostPosted: Mon Jul 04, 2005 9:48 am    Post subject: Reply with quote

thumper wrote:
With the exception of a few packages that this breaks, I have been using this system wide without any obvious ill effects. (knock wood)
Code:
CFLAGS="-march=athlon64 -O2 -pipe -frename-registers -fweb -ffast-math -mfpmath=sse -ftracer -funroll-loops -fstack-protector "


George


-mfpmath=sse is the default choice for the x86-64 compiler, so you can leave that out ;)

CU
Imago
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on AMD64 All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum