I am observing floating point inconsistencies when running on different hardware and using Intel Fortran Version 2016.0.3.059 integrated into Visual Studio 2013.
I did not observe these inconsistencies when using Intel FORTRAN Composer XE 2013, Service Pack 1, Update 3, Build 202.
Take the following code:
x = 0.0174532924
y = -86.5400009155
z = COS(x*y)
Running in 64bit release, with optimization turned off, and floating point settings set to 'strict' I get different values for variable z and zz between two different machines:
- Specs: A modern laptop: Intel(R) Core(TN) i7-4900MQ CPU @ 2.80GHz
- z = 6.0351707E-02
- zz = 6.035170704126358D-002
- Specs: A virtual machine running on a somewhat modern server: Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.4GHz
- z = 6.0351703E-02
- zz = 6.035170331597328D-002
- Specs: old TI-83 calculator
- z = 6.03516896E-02
This is just an example, in the actual code these differences are building up and leading to large differences.
Is there anything I can do to fix this? i.e. get consistent results on different hardware (between Machine 1 and Machine 2)
Any idea why this didn't occur with the previous compiler version I mentioned?
I expect floating points results to change between compiler versions, but the differences on different hardware with the same compiler and these mentioned project settings is a new one to me.
Another point: single precision reals have 24 bits of precision, or about 7 digits in decimal. The product x*y that you chose is close to -π/2, the difference containing only five significant digits, value = 0.060388. The sine of a small argument, being approximately equal to the argument, also has only five significant digits. In this case, then, reproducibility does not imply accuracy.
As your newer CPU supports fused multiply-add, it may not be surprising that default options choose a different COS implementation, which appears to differ in the least significant bit of your result. If such differences are crucial in your application, it seems you may require attention to numerical stability or use double precision.