public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jamie Lokier <jamie@shareable.org>
To: Daniel Forrest <forrest@lmcg.wisc.edu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Somewhat OT: gcc, x86, -ffast-math, and Linux
Date: Sat, 27 Mar 2004 14:24:59 +0000	[thread overview]
Message-ID: <20040327142459.GF21884@mail.shareable.org> (raw)
In-Reply-To: <200403262054.i2QKsV223748@rda07.lmcg.wisc.edu>

Daniel Forrest wrote:
> What is the -ffast-math option doing?

It enables some optimisations and mathematical transformations which
do not satisfy the properties of IEEE floating point arithmetic.

(Not that GCC's output satisfies those properties without -ffast-math
on x86, but this flag enables much looser semantics).

> How are the excess bits of precision dealt with during context
> switches?

They are preserved - they are part of the floating point context.
If there is any failure to preserve all of that context, it's a kernel bug.

> Shouldn't the same binary with the same inputs produce the same
> output on identical hardware?

Is the hardware *identical*, or are they different x86 CPUs?

Different CPUs give different results for the trigonometric functions.
GCC's manual claims that fsin, fcos and fsqrt instructions are only
used if the -funsafe-math-optimizations flag is also used, if the GCC
version is >= 2.6.1.  However you may find that Glibc's <math.h> ends
up using those instructions when -ffast-math is used alone.

-- Jamie

  parent reply	other threads:[~2004-03-27 14:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-26 20:54 Somewhat OT: gcc, x86, -ffast-math, and Linux Daniel Forrest
2004-03-26 21:26 ` Richard B. Johnson
2004-03-26 21:45 ` Andy Isaacson
2004-03-27 14:24 ` Jamie Lokier [this message]
2004-03-27 15:13   ` Jakub Jelinek
2004-03-29  8:47 ` Eric W. Biederman
2004-03-31  7:14 ` J.A. Magallon
  -- strict thread matches above, loose matches on Subject: below --
2004-03-27 14:48 Nick Warne

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=20040327142459.GF21884@mail.shareable.org \
    --to=jamie@shareable.org \
    --cc=forrest@lmcg.wisc.edu \
    --cc=linux-kernel@vger.kernel.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