Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
168 Views

Floating Point Differences Between Machines

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:

REAL*4::x,y,z
REAL*8::zz
x = 0.0174532924
y = -86.5400009155
z = COS(x*y)
zz=z

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:

Machine 1: 
- Specs: A modern laptop: Intel(R) Core(TN) i7-4900MQ CPU @ 2.80GHz
- Results: 
  - z = 6.0351707E-02
  - zz = 6.035170704126358D-002

Machine 2: 
- Specs: A virtual machine running on a somewhat modern server: Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.4GHz
- Results:
  - z = 6.0351703E-02
  - zz = 6.035170331597328D-002

Machine 3:
- Specs: old TI-83 calculator
- Results
  - 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.

0 Kudos
4 Replies
Highlighted
168 Views

Read this.

443546

0 Kudos
Highlighted
Beginner
168 Views

Thanks Steve!  Limited testing seems to indicate the "/Qimf-arch-consistency=true" option will fix the problem I'm seeing.

0 Kudos
Highlighted
Black Belt
168 Views

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.

0 Kudos
Highlighted
Black Belt
168 Views

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.

0 Kudos