public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Vincent Lefevre <vincent+gcc@vinc17.org>
To: gcc-help@gcc.gnu.org
Subject: Re: Floating point performance issue
Date: Mon, 26 Dec 2011 01:15:00 -0000	[thread overview]
Message-ID: <20111226005853.GI5641@xvii.vinc17.org> (raw)
In-Reply-To: <4EF5B140.6030800@hesbynett.no>

On 2011-12-24 12:02:24 +0100, David Brown wrote:
> And (regarding other examples in your posts) if floating-point code
> depends on things like the order of calculations, it is also wrong -
> thus "-ffast-math" will not affect the correctness of the program,
> but will sometimes greatly improve the speed.

Whether you like it or not, a floating-point result does depend on the
order of calculations in general. How would you write code to compute
the mathematical expression a + b - c where you know that you have the
property 1/2 <= a/c <= 2 on the inputs? Or code to compute a*a - b*b
where a and b are close to each other? With the IEEE 754 rules, one
can use formulas that give very accurate results, but if the compiler
is allowed to rewrite the code (without control from the developer who
wrote the code), the results may no longer be accurate (and may even
be quite wrong).

> I don't think I'm alone in wishing that more programmers used stricter
> coding practices

On the contrary, we are very strict on coding practices in order to
get accurate results.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)

  reply	other threads:[~2011-12-26  0:59 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-20  9:52 Ico
2011-12-20 10:05 ` Marcin Mirosław
2011-12-20 10:20   ` Ico
2011-12-20 10:34     ` Jonathan Wakely
2011-12-20 10:43       ` Ico
2011-12-20 11:24       ` Vincent Lefevre
2011-12-20 11:51         ` Dario Saccavino
2011-12-20 12:02           ` Ico
2011-12-20 12:12           ` Vincent Lefevre
2011-12-20 12:28             ` Tim Prince
2011-12-20 12:43             ` Segher Boessenkool
2011-12-20 13:02               ` Vincent Lefevre
2011-12-20 19:51                 ` Segher Boessenkool
2011-12-20 21:02                   ` Vincent Lefevre
2011-12-21  4:36                     ` Segher Boessenkool
2011-12-21  6:15                       ` Segher Boessenkool
2011-12-23 20:25                         ` Vincent Lefevre
2011-12-20 13:43             ` David Brown
2011-12-20 13:58               ` Vincent Lefevre
2011-12-20 14:25                 ` David Brown
2011-12-20 15:05                   ` Vincent Lefevre
2011-12-20 15:44                     ` David Brown
2011-12-20 16:18                       ` Vincent Lefevre
2011-12-20 22:32                         ` David Brown
2011-12-23 20:11                           ` Vincent Lefevre
2011-12-24  7:38                             ` Vincent Lefevre
2011-12-24 11:11                             ` David Brown
2011-12-26  1:15                               ` Vincent Lefevre [this message]
2011-12-26 11:48                                 ` David Brown
2011-12-26 13:07                                   ` Vincent Lefevre
2011-12-26 13:37                                     ` Tim Prince
2011-12-26 14:01                                       ` Vincent Lefevre
2011-12-26 14:39                                         ` Tim Prince
2011-12-26 16:40                                           ` Vincent Lefevre
2011-12-21  1:19                       ` Miles Bader
2011-12-21  2:19                         ` David Brown
2011-12-21  4:03                           ` Miles Bader
2011-12-21  8:32                             ` David Brown
2011-12-21  9:02                               ` Miles Bader
2011-12-21  9:23                                 ` David Brown
2011-12-21 11:58                                   ` Miles Bader
2011-12-21 16:49                                     ` David Brown
2011-12-22  3:23                                       ` Miles Bader
2011-12-23 21:15                               ` Vincent Lefevre
2011-12-24 17:18                                 ` David Brown
2011-12-26  8:12                                   ` Vincent Lefevre
2011-12-26 13:00                                     ` David Brown
2011-12-26 13:22                                       ` Vincent Lefevre
2011-12-20 15:45                     ` Jeff Kenton
2011-12-20 11:44     ` David Brown
2011-12-20 11:49       ` David Brown
2011-12-20 10:46 ` Marc Glisse
2011-12-20 11:11   ` Ico
2011-12-20 11:16   ` Vincent Lefevre
2011-12-20 12:00     ` Vincent Lefevre
2011-12-20 12:21 ` Tim Prince

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111226005853.GI5641@xvii.vinc17.org \
    --to=vincent+gcc@vinc17.org \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).