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

Josh Parsons jbparsons at ucdavis.edu
Mon Jan 17 12:21:47 PST 2005


On Mon, 2005-01-17 at 13:47 -0500, Peter Jay Salzman wrote:

> 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;

That's right.  

> So it sounds like I'd like...

>    -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?

OK, here comes more detail, but before you rely on my expertise... a
disclaimer: I've looked closely at some of the gcc sources, but I don't
know much about floating point math.

That said, I believe that a "user visible trap" in this context refers
to a SIGFPE (or other similar mechanism on non-unix systems).  The
effects of -fno-trapping-math and -fno-signaling-nans are to generate
faster code that produces different numbers of these traps than would be
mandated by ISO standards. I don't know whether these can have the
effect of completely inhibiting traps for a program that would otherwise
produce one. If they can, then you don't want to use them.

Unfortunately, -fno-signaling-nans is on by default in gcc 3.4.2, and
the option to prevent its effects, -fsignaling-nans, is described by the
manual as "EXPERIMENTAL".  So I would strongly suggest that if you want
to rely on any of this that you experiment with gcc and make sure that
the code it generates raises SIGFPE where you want it to.

-fno-rounding-math is also on by default; so I would use just -fno-math-
errno, and experiment to see whether that setting will catch the errors
you want caught.

Alternatively you could explicitly check for NaN and inf where their
presence would indicate an error.  Then you could just enable -ffast-
math.

> > Some more ideas for wringing extra speed out of gcc:...

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

Well, you should be able to find out more about these with "man gprof"
and "info gcc".  If you haven't thought of using profiling, I'd start
there; that will help you write better, faster, code, and gain you much
more speed than tweaking code generation options would.

-- 
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




More information about the vox-tech mailing list