I am using a 1D global index constructed from the blockidx and threadidx:
indx = blockDim%x*(blockIdx%x-1) + threadIdx%x
I then deconstruct this 1D array (e.g. 1,2,3…1000000) into a 7D index, i.e. array(1,3,2,4,1,2,3), through some maths, e.g.:
Iterator1 = MOD(indx-1, 20)+1
Iterator2 = MOD((indx-1)/20, 20)+1
Iterator3 = MOD((indx-1)/(20*20), 10)+1
and so on allowing me to reference the array, array(iterator1,iterator2,…)
I then print out what it is supposed to be (i.e. me referencing the 7D array element) and then deconstructing the value back:
WRITE(5,'(10I3, F20.6)') Iterator1, Iterator2,..., Array(Iterator1,Iterator2,...)
I get the following output:
First line is input, second line is output
Various deconstructed values Overall 1D index
12 -1 -2 1 18 17 11 1 1 33444738.000000
12 -1 -2 1 18 17 11 1 1 33444738
12 -1 -2 1 19 17 11 1 1 33444740.000000
12 -1 -2 1 20 17 11 1 1 33444740
12 -1 -2 1 20 17 11 1 1 33444740.000000
12 -1 -2 1 20 17 11 1 1 33444740
12 -1 -2 1 1 18 11 1 1 33444740.000000
12 -1 -2 1 20 17 11 1 1 33444740
12 -1 -2 1 2 18 11 1 1 33444742.000000
12 -1 -2 1 2 18 11 1 1 33444742
As can be seen I am getting rounding errors, the first set is 33444738, it should be followed by 33444739, but instead is followed by 33444740, as a result I am incorrectly calculating the values.
This doesnt occur at low values for the 1D index, only at larger values (>1m). What could be causing this?
The larger the index the more errors occur (at around ~150m there are 15 values merged).