i am trying to calculate matrix row sum in the cuda. since cuda is used for parallel processing so there is no need of looping. I have done matrix sum operation and the code is
__global__ void MatAdd(int A[][N], int B[][N], int C[][N]){
int i = threadIdx.x;
int j = threadIdx.y;
C[i][j] = A[i][j] + B[i][j];
}
but in the same case not able to convert it into matrix row sum. i tried following code
__global__ void rowSums(float* matrix, float* sums, int rows, int cols)
{
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * blockDim.x + threadIdx.x;
if (i < N && j < M)
sums[j] += matrix[i][j];
}