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. 24: LUGOD election season has begun!
Page last updated:
2005 Jan 17 10:47

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



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.

> Second question: Is there any point in declaring functions as inline:
> if I use the -O3 or -finline-functions gcc options?

Yes, because you might have a better idea than gcc's built-in heuristics
which of your functions is called frequently enough to justify inlining.

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.

-- 
Josh Parsons
Philosophy Department
1238 Social Sciences and Humanities Bldg.
University of California
Davis, CA 95616-8673
USA

Please avoid sending me Word or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html


_______________________________________________
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:
EDGE Tech Corp.
For donating some give-aways for our meetings.