Reputation: 3571
As I read on Intel's website:
Intel compiler uses /fp-model fast=1 as defaults. This optimization favors speed over standards compliance. You may use compiler option -mieee-fp to get compliant code.
My understanding of the fp-model option in ICC is that (correct me if I'm wrong):
precise
corresponds to default settings in GCC and Clang,fast=2
is similar to -ffast-math
,fast=1
is somewhere between.What options in GCC or Clang would make floating point math most similar to Intel's default -fp-model fast=1
?
Upvotes: 5
Views: 3762
Reputation: 1374
Let's read what Intel says:
First, Intel disables exceptions by default, so -fno-trapping-math
there. But that applies even to "precise" mode, so not quite an answer.
There is a distinction between "precise" and "consistent", but it is not explained.
There is no explanation of re-association and other assumptions like GCC has. A Intel manual (1) says limited reassoc happens at fast=1, partly to enable SIMD reduction. An Intel presentation (2) mentions GCC's funsafe-math-optimizations
and lists some assocs, but it is not clarified if those reassocs are the "less risky" ones enabled by fast=1
. I would speculate that they are somewhat similar, considering "fun & safe" does have the reputation of being the safer of the bunch.
1 also mentions that:
-ffp-contract=fast
in GCC.We do have this behavior on choosing what libm implementation to use, which has no equivalent in GCC as far as I know:
The -fp-model and /fp options determine the setting for the maximum allowable relative error for math library function results (max-error) if none of the following options are specified (the following options are only available for
ifort
):
- -fimf-accuracy-bits (Linux* and macOS) or /Qimf-accuracy-bits (Windows*)
- -fimf-max-error (Linux and macOS) or /Qimf-max-error (Windows)
- -fimf-precision (Linux and macOS) or /Qimf-precision (Windows)
- [Q]fast-transcendentals
Option -fp-model=fast (and /fp:fast) sets option -fimf-precision=medium (/Qimf-precision:medium) and option -fp-model=precise (and /fp:precise) implies -fimf-precision=high (and /Qimf-precision:high). Option -fp-model=fast=2 (and /fp:fast2) sets option -fimf-precision=medium (and /Qimf-precision:medium) and option -fimf-domain-exclusion=15 (and /Qimf-domain-exclusion=15).
Here -fimf-precision
is described as equivalent to -fimf-max-error=4
, though the documentation does not tell us what 1 and 4 means (what's a relative error? ULP?).
-fimf-domain-exclusion=15
is a little easier to decipher: it means that math functions assumes that no "extreme normal number inputs", nans, infinites, nor denormals will be passed. That roughly corresponds to, for libm calls only, -fcx-limited-range -ffinite-math-only
, plus the denormal handling (x86-specific) -mdaz-ftz
.
Upvotes: 2
Reputation: 6999
As it follows from GCC's set_fast_math_flags function, ffast-math
option (at least in GCC 5.2) is equivalent to
(1) unsafe opts group:
-fno-trapping-math
-fassociative_math
-fno-signed-zeros
-freciprocal-math
(2) other guys:
-ffinite-math-only
-fno-errno-math
-fno-signaling-nans
-fno-rounding-math
-fcx-limited-range
First group is abbreviated with the option -funsafe-math-optimizations
.
You should figure out what comes in ICC and try to combine those flags to make desired effect.
Upvotes: 3