CUDA "even-easier" introduction - question for calculation

in the example [1] the loop:

for (int i = index; i < n; i += stride)

would calculate with thread#x the following data:

t1: 0, 256, 512,
t2: 1, 257, 514

what if the code starts thread number 256, wouldnt that overwrite the calculation already done by thread#0 ?


The stride is the total number of threads (in the grid, i.e. for that kernel launch).

If the stride is 256, then that means there are 256 threads, numbered from 0 to 255.

If the code started a thread number 256, then that would imply that the calculated stride value must be 257 or greater.