I use magma_zmconvert function in GPU.

Try dense to CSR and CSR to DENSE in GPU or CPU.

In CPU,

DENSE to CSR of CPU is based on RowMajor.

CSR to DENSE of CPU is based on RowMajor.

CSR to DENSE of GPU is based on ColMajor.

I don't know how DENSE to CSR of GPU does, because it will return just dimension or some element not in origin array.

For example,

A= [1, 2, 3; 4, 5, 6];

array of A in CPU = [1 2 3 4 5 6]

Convert it to CSR in CPU, transfer it to GPU and then convert it to DENSE.

array will become [1 4 2 5 3 6]

So the matrix will become [ 1 4 2; 5 3 6]

I think it needs to change function of CPU to colmajor or function of GPU to rowmajor.

I guess changing function of CPU to colmajor is better because other routine are based on colmajor.

But I need to check whether it will impact another function. After checking it, I will try to fix it.

Thanks.

The following is my code.

- Code: Select all
`#include <iostream>`

#include <string>

#include <complex>

#include <cstdio>

#include <cstdlib>

#include <sstream>

#include "cublas_v2.h"

#include "magma_v2.h"

#include "magmasparse.h"

#include "magma_lapack.h"

int main(){

magma_init();

magma_int_t dev=0;

magma_queue_t queue=NULL;

magma_queue_create(dev, &queue);

magma_z_matrix oA, A;

magma_z_matrix dA;

int m=5, n=3;

magmaDoubleComplex *val;

val=new magmaDoubleComplex[m*n];

magma_z_matrix cA,ddA, cdA, ccA,csrdA, csrA;

for (int i=0; i<m*n; i++){

val[i]=MAGMA_Z_MAKE(i,0);

}

magma_zvset(m,n,val,&oA,queue);

magma_zmconvert(oA,&A,Magma_DENSE, Magma_CSR, queue);

write_z_csrtomtx(A,"C.mtx",queue);

magma_zmtransfer( A, &dA, Magma_CPU, Magma_DEV, queue );

magma_zmtransfer( dA, &cA, Magma_DEV, Magma_CPU, queue );

write_z_csrtomtx(cA,"CTT.mtx",queue);

magma_zmconvert(dA, &ddA, Magma_CSR, Magma_DENSE, queue);

magma_zmtransfer(ddA, &cdA, Magma_DEV, Magma_CPU, queue);

for (int i=0;i<m*n;i++)

std::cout<<MAGMA_Z_REAL(cdA.val[i])<<" ";

magma_zmconvert(cdA, &ccA, Magma_DENSE, Magma_CSR, queue);

write_z_csrtomtx(ccA,"CTCTC.mtx",queue);

magma_zmconvert(ddA, &csrdA, Magma_DENSE, Magma_CSR, queue);

magma_zmtransfer(csrdA, &csrA, Magma_DEV, Magma_CPU, queue);

write_z_csrtomtx(csrA,"CSRA.mtx",queue);

return 0;

}