Floating Point Problem ffast-math Complex divide
Tobias Schlüter
tobias.schlueter@physik.uni-muenchen.de
Thu Oct 20 23:01:00 GMT 2005
FX Coudert wrote:
>> The following floating point complex divide doesn't work with -ffast-math.
>>[...]
>> This works correctly with Intel and Pathscale compilers.
>
>
> Some optimization options can cause incorrect behaviour ("incorrect" in
> the sense of "not respecting the IEEE rules"). This is known and
> documented, as for example (in the gcc manual):
>
> `-ffast-math'
> Sets `-fno-math-errno', `-funsafe-math-optimizations',
> `-fno-trapping-math', `-ffinite-math-only', `-fno-rounding-math',
> `-fno-signaling-nans' and `fcx-limited-range'.
>
> This option causes the preprocessor macro `__FAST_MATH__' to be
> defined.
>
> This option should never be turned on by any `-O' option since it
> can result in incorrect output for programs which depend on an
> exact implementation of IEEE or ISO rules/specifications for math
> functions.
>
> Please note that the same kind of options enabling agressive
> optimization (and sometimes leading to incorrect FP behaviour) exist in
> other compilers too:
>
> $ ifort a.f90 -O2 -complex-limited-range && ./a.out
> 1.389121338912134E+276 -0.166000000000000 -1.195000000000000E-277
> (Infinity,NaN) (-0.166000000000000,0.000000000000000E+000)
> (-1.195000000000000E-277,0.000000000000000E+000)
While you're right in principle, FX, maybe there should be a more fine-grained
switch controlling whether the unsafe division algorithm is used or not, jsut
as there is in ifort. Ron, can you open a bug report for this, after
double-checking the documentation that there is no such option?
Thanks,
- Tobi
More information about the Fortran
mailing list