I have the following code in C which adds a constant multiple of a part of a column of a rectangular matrix to part of column of another matrix. The function is implemented as follows:

[codebox]

void elmcol(int l, int u, int i, int j, float **a, float ** b, float x)

{

for (; l < u; ++l) a[l][i] += b[l][j] * x;

}[/codebox]

is there any way to achieve the same using CUBLAS?

In principle, if the matrix is column major ordered, then you should be able to use saxpy for that operation. But you can’t you CUBLAS on the sort of arrays your subroutine is using (they are arrays of pointers, not linear memory).

Yes, the code was just to show how it would work on CPU. The data on the device is indeed linearly laid as you pointed out and looks like saxpy is the way to do it.