I have a cuda loop where a variable cumul store an accumulation in double :
double cumulative_value = (double)0;
loop(...)
{
// ...
double valueY = computeValueY();
// ...
cumulative_value += valueY
}
This code is compiled on different SDK and run on two computers :
M1 : TeslaM2075 CUDA 5.0
M2 : TeslaM2075 CUDA 7.5
At step 10, results are differents. Values for this addition (double precision representation in hexadecimal) are:
0x 41 0d d3 17 34 79 27 4d => cumulative_value
+ 0x 40 b6 60 1d 78 6f 09 b0 => valueY
-------------------------------------------------------
=
0x 41 0e 86 18 20 3c 9f 9b (for M1)
0x 41 0e 86 18 20 3c 9f 9a (for M2)
Rounding mode is not specified as I can see in the ptx cuda file ( == add.f64) but M1 seems to use round to plus Infinity and M1 an other mode.
If I force M2 with one of the 4 rounding modes (__dadd_XX()) for this instruction, cumulative_value is always different than M1 even before step 10.
But if I force M1 and M2 with the same rounding mode, results are the same but not equals to M1 before modification.
My aim is to get M1 (cuda 5.0) results on M2 machine (cuda 7.5) but I don't understand the default rounding mode behavior at runtime. I am wondering if the rouding mode is dynamic at runtime if not specified. Do you have you an idea ?
After another ptx analysis and in my case, valueY is computed from a FMA instruction on cuda 5.0 while cuda 7.5 compiler uses MUL and ADD instructions. Cuda documentation explains there is only one rounding step using single FMA instruction while there are two rounding steps using MUL and ADD. Thank you very much for helping me :)