by **hartwig anzt** » Tue Feb 14, 2017 1:38 pm

Dear Akrem Benatia,

assuming you have your matrix of size n in the CSR-array *row *col *val on the CPU, you can pass this matrix to MAGMA-sparse via

magma_d_matrix A={Magma_CSR},

magma_zcsrset( n, n, row, col, val &A, queue );

Then, you may want to initialize vectors on the GPU and copy the system to the device:

magma_d_matrix dA={Magma_CSR}, dx={Magma_DENSE}, dy={Magma_DENSE};

magma_dvinit( &dx, Magma_DEV, n, 1, 1.0, queue );

magma_dvinit( &dx, Magma_DEV, n, 1, 0.0, queue );

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

Now you can run your CSR-SpMV y=Ax:

magma_d_spmv( 1.0, A, x, 0.0, y, queue );

In case you want to use a different format, e.g. SELLP,, you have to convert the matrix first:

magma_d_matrix B={Magma_CSR}, dA={Magma_CSR}, dx={Magma_DENSE}, dy={Magma_DENSE};

magma_dvinit( &dx, Magma_DEV, n, 1, 1.0, queue );

magma_dvinit( &dx, Magma_DEV, n, 1, 0.0, queue );

// you can modify parameters in SELLP:

B.blocksize = 32; // as example: row-blocks of 32

B.alignment = 1; // as example: 1 thread per row, multiple are possible

magma_dmconvert( A, &B, Magma_CSR, Magma_SELLP, queue );

magma_dmtransfer( B, &dA, Magma_CPU, Magma_DEV, queue );

Now you can run your SELLP-SpMV y=Ax:

magma_d_spmv( 1.0, A, x, 0.0, y, queue );

Hope this helps! Please let me know if you have further questions.

Hartwig