Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Important Update: Community Platform Migration​. Learn more​>
29649 Discussions

Real*4 computation result differs with Optimize/Debug versions

merckx
Beginner
1,463 Views
Working with Compaq Visual Fortran 6.6, I've observed that results of Real*4 computations differs when using the Optimized Or Debug version of the subroutine.
OK, it's only the last significant digit.
Nevertheless, is it "normal" (or acceptable following the Fortran specification) ?
What can I do to fix that ?
Thanks,
Christian
0 Kudos
2 Replies
TimP
Honored Contributor III
1,463 Views
As CVF employs only x87 extended precision instructions, rounding to single precision occurs only when storing to memory. Optimization removes many of these roundings, in order to improve performance, usually improving accuracy as well. In most cases, use of extra precision is clearly acceptable within the Fortran standard.

Among the more satisfactory ways to eliminate the variations:

1. Assure that you have written your source code with expressions evaluated in an accurate manner. For example, A*(B-C) rather than A*B - A*C. The Fortran standard specifically encourages compilers to perform this optimization.

2. Employ the /fltconsistency switch, to eliminate some of those optimizations.

3. Promote the critical calculations to double precision in source code, so that the debug and optimized versions are effectively the same.

4. Employ a compiler such as IFL which can generate SSE single precision instructions.
0 Kudos
merckx
Beginner
1,463 Views
Thanks for your help.
It appears that the /ftpconsistency option solves the problem.
I will make some tests in order to evaluate the performance deterioration.

Christian
0 Kudos
Reply