I’m modelling water particles, and to calculate the density I evaluate a simple expression and accumulate the values. I’m trying to compare two possible approaches of accumulating this; coalesce/shared memory, and textures.
I have been working in emulation mode and found that i get slightly different answers. The initial density is the same in both, interacting particles are the same in both, and the contributions to the density are the same in both, and yet the final density is slightly different.
The coalesce accumulates as
w = kernelw(r,mhsml); rhocont = shMass[j]*w; myRho+= rhocont;
while the texture accumulates as
rhocont = FETCH(d_sorted_mass,index2)*kernelw(r,mhsml); *(myRho)+= rhocont;
NB the initial values of myRho and every value of mass, w and rhocont for each interaction in both approaches is exactly the same.
And yet the final values are the same to only the 3rd decimal place!
The processor is a C1060.
How can this be?