I have an assignment that requires me to generate Redheffer matrix on GPU using Cuda.
A Redheffer matrix1 is a matrix where each entry a[i][j] is defined by  
a[i][j] =  
1 if j = 1,   
1 if j is divisible by i  
0 otherwise.
Here is my code
    #define SIZE = 20000
    #define BLOCK_WIDTH 16
   /* Launch the CUDA kernel */
    int numBlocks = ceil(SIZE / BLOCK_WIDTH);
    dim3 dimGrid(BLOCK_WIDTH,BLOCK_WIDTH,1);
    dim3 dimBlock(numBlocks,numBlocks,1);
    redhefferMatrix<<<dimGrid, dimBlock>>>(d_M, SIZE);
I have code to verify if the output is right, it return error message when matrix element value computed is not correct. When I run my program, I get this error.
GPU number 0 is assigned to this job
    Row 0 column 5000 is incorrect. Should be:1 Is actually: 0
My logic to compute values is
int Row= blockIdx.y*blockDim.y + threadIdx.y;
int Col= blockIdx.x*blockDim.x + threadIdx.x;
.
.
if(i < 20000 && j < 20000)
{   
    {
        if(j == 1 || j % i == 0)
            d_M[i*SIZE+ j] = 1;
        else
            d_M[i*SIZE+ j] = 0;
    }
}
Can someone give me an idea where i might be wrong. Thank you in advance.
 
     
     
    