cublasSgemm and tansposed results is it possible to calculate trans(trans(A) * trans(B))

Hi everybody.

I am pretty new to CUBLAS programming and I was wondering if there is a way to calculate the transpose of the result of a matrix multiplication “in place”.
Since I have a C++ programm working with row-mayor matrices I was wondering if it was possible to hide that CUBLAS is working with colum-mayor format.
If it was possible to calculate trans(trans(A) * trans(B)) then that would be quite easy.
Of course I could calculate trans(A) * trans(B) with cublasSgemm and then transpose the result but I guess that would be quite slow.

Is there a way to do the above?

Thanks in advance for any help.


trans( trans(A) * trans(B))= trans(trans(B)) * trans(trans(A))= B*A

That was pretty stupid of me.
So if I want to calculate the product AB of two row-mayor matrices wis cublasSgemm I just let it calculate BA in colum mayor.
I don’t know why that wasn’t obvious to me.


Thinking about it again, that does not work out.
While the equality above is of course true, it ignores how the matrices are in the memory.
I can calculate trans(A * B) for two matrices in row-mayor using cublasSgemm by multiplying trans(B) and trans(A). But I can not calculate B * A.

So the question remains: is there a way to transpose the result of a matrix multiplication?

So does assuming that a matrix transpose of row-major storage will be the same as the data stored in column major order. You would be better off either working in column major order (after all that is what CUBLAS is designed for), or adapting something like the matrix multiply kernel from the SDK to your needs.

I’m sure you can…

maybe you’ve wrong something with m, n and k…


Thanks for the answers.
I think I will re-implement my code using column mayor.