matrix row sum in cuda : <p>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</p>

<pre><code>__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];
}
</code></pre>

<p>but in the same case not able to convert it into matrix row sum. i tried following code</p>

<pre><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 &lt; N &amp;&amp; j &lt; M)
              sums[j] += matrix[i][j];

 } 
</code></pre>
