How to reshape a matrix on device in CUBLAS

Hi, I met a problem when I did a matrix multiplication in CUBLAS.

I need to reshape a complex matrix from [rowsA, colsA] to [rowsA*colsA,1] which means to reshape it to a linear vector. This complex matrix is already on device which is got from a kernel function. I know cublasSetMatrix can do the reshape when setting up the matrix, but this only works when copying memory from CPU to GPU. I don’t want to copy that matrix to CPU first and back to GPU by using cublasSetMatrix. I think I should look for a way to do the reshape on device.

I used this function cudaMemcpy2D just like this:

cudaMemcpy2D(d_A2, RowsA*ColsA*sizeof(cuComplex), d_C, RowsA*sizeof(cuComplex), RowsA*sizeof(cuComplex), ColsA, cudaMemcpyDeviceToDevice);

But the result is wrong.

Is anyone knows how to solve this problem?? Thank you in advance.

If LDA (so the pitch of the array) is the same as rowsA, ie. no padding, then you shouldn’t have to do anything. The array will be stored as a linear array, equivalent to the vec(A) operation on any matrix A.

Thank you so much! You are right. I do not need do anything and the result is right now.