David Brown said:
David Brown said:
On 25/04/13 07:58, Tim Rentsch wrote:
[substantial snipping]
Are you offering anything more than an opinion? [snip]
I offer only my opinion here - I have no direct evidence.
[snip elaboration]
I'm all for people offering their opinions (distinguished as
such). I do so myself. But people who offer only their opinion,
and nothing in the way of evidence or some sort of supporting
reasoning, just aren't very interesting, because they don't
really contribute anything to the discussion.
I agree on what you say about experts. /I/ can choose to use
"-ffast-math" with my code, and I can offer that as an
/opinion/ to other people. But you would not want me to decide
on the default policy on gcc compiler flags!
I'm pretty sure I agree with that last sentence.
Most developers are better served by compilers that are completely
conforming rather than partially conforming. For floating-point,
the benefits of more portable and more reliable behavior far
outweigh the difference in performance or accuracy (taking 64-bit
doubles and 80-bit internals as representative). Don't take my
word for it -- I encourage anyone who is interested to do some
experiments measuring how different compiler options affect
accuracy and/or performance. (It's much harder to measure the
costs of using using non-standard behavior. Often though the
effects in such cases are closer to "catastrophic" than "minor".)
This all depends on the type of program and the type of target in
question. For the sorts of systems I work with, /enforcing/
conforming behaviour in floating point work would be catastrophic.
I work on embedded systems, and don't often use floating point. But
when I do use it, speed and code size is vital - following IEEE
standards regarding rounding, [snip elaboration]
You are using 'conforming' here in a way that makes me think you
don't understand the different ways the Standard uses the term.
A conforming _implementation_ is one that follows all the rules
laid out by the ISO standard. These rules allow great latitude;
they don't require IEEE floating point, for example. There are
two uses of 'conforming' as applied to programs. There is a very
restricted class of programs called 'strictly conforming'. A C
program being strictly conforming basically means it will produce
identical output on ANY conforming implementation. This class is
very narrow. In fact it is so narrow that I'm not sure it is
even possible to write a strictly conforming program that uses
floating-point in any non-trivial way, and if it is possible it
certainly isn't easy. At the other end of the spectrum is a
'conforming' program (ie, without the 'strictly' adverb). A
conforming program is one that is accepted by SOME conforming
implemention (not all, but at least one). This class is very
wide, and admits things that look almost nothing like C programs,
to say nothing about what their outputs might be. For example,
the program source
#define __PASCAL__ 1
... here the source continues written in the Pascal
programming language ...
could be a conforming C program. (It isn't, because no conforming
implementation accepts it, but an implementation could be written
that accepts it, and still is a conforming implementation.)
My comment above is about conforming _implementations_. Your
comment is about _programs_. These two things (ignoring the
semantic glitch around "conforming") are not incompatible.
For example, your program source could have
#pragma floating point ala David Brown
and then do floating-point operations however you want, yet still
be within the bounds of what a conforming implementation is allowed
to do. Do you see how important this difference is? My comment is
about the behavior of implementations, not the programs they
translate; we can use only conforming implementations without
being forced to use one floating-point system or another, or even
_any_ pre-defined set of floating-point systems.
For more mainstream programming, I think it is common to treat
floating point as approximate numbers with a wide dynamic
range. For such applications, the differences in functionality
between strictly conforming floating point and "-ffast-math"
are going to be very minor - unless there are a lot of
calculations, in which case the speed difference might be
relevant. (But as noted above, this is just an opinion.)
Here again I think you are confusing the ideas of an implementation
being conforming and a program being "conforming". Depending on IEEE
floating-point (not counting depending on it in a way that makes no
difference) is guaranteed to make a program NOT be 'strictly
conforming", as the Standard defines the term. An implementation can
be conforming yet still offer a wide variety of floating-point
systems.
Obviously there are other types of application for which
non-conforming behaviour could be catastrophic. If there were
no need of the full set of IEEE floating point rules, then the
rules would not be there in the first place.
Now that I've written out this more careful differentiation of
how "conforming" is used, it might be helpful to go back and
re-read the earlier comments. Probably that will clear up
most of the confusion but if some further thoughts come up
I'd be interested to hear them.