l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
November 4: Social gathering
Next Installfest:
TBD
Latest News:
Oct. 10: LUGOD Installfests coming again soon
Page last updated:
2005 Jan 17 12:31

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] gcc questions: inline and -ffast-math
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] gcc questions: inline and -ffast-math



Hi Josh,

Thanks for such an in-depth answer!


On Mon 17 Jan 05,  9:20 AM, Josh Parsons <jbparsons@ucdavis.edu> said:
> On Mon, 2005-01-17 at 10:45 -0500, Peter Jay Salzman wrote:
> 
> > Given that, I'm interested in the -ffast-math gcc option....
> > OTOH, I need the code to stop if anything becomes "NaN" or "inf".  One "NaN"
> > or "inf" makes the whole calculation garbage, and that could be a waste of 2
> > weeks of computer time.
> 
> -ffast-math turns on a bunch of other optimization and code-gen options,
> some of which you do *not* want.  From the manual:
> 
> "Sets `-fno-math-errno', `-funsafe-math-optimizations', `-fno-trapping-
> math', `-ffinite-math-only', `-fno-rounding-math' and `-fno-signaling-
> nans'."
> 
> Of these, -ffinite-math-only and -funsafe-math-optimizations allow the
> compiler to assume that results and arguments are never NaN or inf.
> 
> In some cases an ISO C compiler is required to generate code that
> prevents an FPE signal being raised.  This sometimes happens where a
> floating point op is represented in C by a library function such as sqrt
> ().  Here, to be conformant with the standard, gcc has to arrange to
> catch any floating point exception and set errno, at a cost in speed. 
> 
> -fno-math-errno prevents this. So you would probably want to use that.
 
Just to make sure I understand:

You're saying that I want to enable -fno-math-errno because I don't care
about or use errno; all the numerical problems that might crop up are being
caught via SIGFPE and reported via siginfo_t info->si_code, and thus, any
extra code that gcc inserts to handle errno is wasted code?

So it sounds like I'd like to replace

   -ffast-math

with:

   -fno-math-errno -fno-trapping-math -fno-rounding-math -fno-signaling-nans

Do you know what a "user visible trap" is?  Is that like an assertion?


> Some more ideas for wringing extra speed out of gcc:  a) I hope you're
> going to run this thing through a profiler.  b) If you're using a PC,
> then -fomit-frame-pointer and judicious use of gcc's regparm function
> attribute could help. c) You can arrange for functions that aren't being
> inlined to be subjected to CSE optimization by using the const and pure
> function attributes.

Holy cow.  You've just given me *hours* of Googling material!   :-P

Pete

-- 
The mathematics of physics has become ever more abstract, rather than more
complicated.  The mind of God appears to be abstract but not complicated.
He also appears to like group theory.  --  Tony Zee's "Fearful Symmetry"

GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E  70A9 A3B9 1945 67EA 951D
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
O'Reilly and Associates
For numerous book donations.