Following Code:
global
void add(int n, float *x, float *y)
{
int index = threadIdx.x;
int stride = blockDim.x;
for (int i = index; i < n; i += stride)
y[i] = x[i] + y[i];
}`
if i assign 32 threads to this kernel, blockDIM.x will be 32. Why do I need to add 32 to i? Wouldn’t that just jump over 32 elements of the array?
Your kernel design is a block-striding loop, which is a single-block variant of a grid striding loop.
