The Arithmetic difference in fortran cuda

I run a cuda fortran program in Nvidia M2050. I use the clause

ve(m,0) = ( vn(m,0)*3.0_8 - vn(m,-1) ) / 2.0_8

and the clause

ve(m,0) = ( vn(m,0)+vn(m,0)+vn(m,0) - vn(m,-1) ) / 2.0_8

, In most case , the results are same. But in some case , as an example, the former result is 3.2936043089008556E-002 while the latter result is 3.2936043089008549E-002. The array Vn, Ve is kind of real(8), which Digits of Precision is 15~16. If I only output 15 digits, the former result is 3.29360430890086E-002, and the latter result is 3.29360430890085E-002. [/b]

Hi shyboy_6104,

The first version might be using a Fuse-Multiply-Add instruction (FMA) which will be different then the three adds. Try adding the flag “-Mcuda=nofma”.

  • Mat