User account creation filtered due to spam.
On current x86 and x86_64 processors denormal numbers are handled as a special case and very slowly. This can have a detrimental impact on the performance of numerical programs. A common fix for this problem, at the cost of some numerical stability, is to set the processor flag to flush denormals to zero.
This can be achieved in C with the following on SSE machines:
However it is not desirable to include C in a fortran program or library. Other compiler tackle this by adding flags (ifort, NAG f95) or environment variables (g95) which set this flush mode during program initialization. It would be good if gfortran offered a similar facility (I have not been able to locate any reference to one at the moment).
Compiling with -ffast-math will automatically do that at program startup time
via linking against crtfastmath.o.
-ffast-math also enables other (even more unsafe?) optimizations which may not be desirable.
I am looking for both Optimized like O2 and FTZ. I have a large Fortran program. Without FTZ it gets weird crashes that should not be happening (no problems on any other compilers!) Without optimization it runs way too slow.
Any optimization overrides any attempts at FTZ, such as
The tradeoff of "either FTZ or Optimized" I think will not work for me.
(In reply to comment #3)
> The tradeoff of "either FTZ or Optimized" I think will not work for me.
Find crtfastmath.o in gcc build directory and link it to your final executable.
I'm still not getting FTZ ... unless I misunderstood your suggestion, here's what I did after compiling with -O2:
root@nick-desktop:/home/test408# gfortran -o test4f /usr/lib/gcc/i486-linux-gnu/4.4.0/crtfastmath.o TEST4SRC1.o TEST4SRC2.o TEST4SRCU.o