Show us the full code. The declarations of the particular variables involved are likely to be particularly important. My first guess is that dataIndex is a float variable, and we’re seeing rounding. Possibly even rounding my the print statement, rather than anything numerical.
If this expression is somehow getting cast to a float by the compiler, then the problem is that on the GPU it will be done with single precision, which only has 24 bits of mantissa. Your final value exceeds this precision, so you will start to lose digits. On the CPU, it will most likely use double precision, which has 53 bits of mantissa. Integers have 31 bits of mantissa (in a manner of speaking), which is plenty for this calculation.
So, yes, we need a little more context to understand why the compiler is computing your index expression with floating point, rather than integers.
global void calculateInitialDensity(float *v, float * initialD, float * densities, float dx, float dy, float dz, int as)
int index = idy*as+idx;
int xCoord; // data x index coord
int yCoord; // data y index coord
int zCoord; // data z index coord
float currX; // node X value
float currY; // node Y value
float currZ; // node Z value
xCoord = (int)currX;
yCoord = (int)currY;
zCoord = (int)currZ;
dataIndex = ((512*512)*zCoord)+(512*yCoord)+xCoord;
initialD[index/3] = densities[dataIndex];
extern “C” int * initialDensityCalc(float *vArray,float * densities, float * initD, int vSize, int dSize, int nodes, float dx, float dy, float dz)