operations on a 2D array in CUDA kernel for matlab

前端 未结 2 1117
星月不相逢
星月不相逢 2021-01-25 09:30

suppose I have the following serial C:

int add(int* a, int* b, int n)
{
    for(i=0; i

        
2条回答
  •  余生分开走
    2021-01-25 09:56

    I am assuming you are working with n-by-n, row major order array. Try the following :

    __global__ void calc(int *A, int *B, int n)
    {
        int i= blockIdx.x * blockDim.x + threadIdx.x;
        int j= blockIdx.y * blockDim.y + threadIdx.y;
    
        if (i

提交回复
热议问题