I cannot understand why this code is unpredictable. I am trying to copy data from a smaller 3D array “y” (N1,N2,N3) to a larger 3D arary “x” (n1,n2,n3):
static global void copy_charge3D_kernel(float x, float y, int n1, int n2, int N1, int N2, int N3)
{
const int ig = blockIdx.xblockDim.x+threadIdx.x;
const int jg = blockIdx.yblockDim.y+threadIdx.y;
int k;
if (ig < N1 && jg < N2)
{
for (k = 0; k < N3; k++)
{
x[k*n1*n2+jg*n1+ig] = y[k*N1*N2+jg*N1+ig];
}
}
__syncthreads();
}
Does anyone see any problems with this kernel? Any help is appreciated.