Informations about struct "magma_s_sparse_matrix"

Open discussion for MAGMA library (Matrix Algebra on GPU and Multicore Architectures)
Post Reply
Noran
Posts: 27
Joined: Fri Sep 26, 2014 3:47 am

Informations about struct "magma_s_sparse_matrix"

Post by Noran » Thu Oct 30, 2014 9:18 am

Hello everybody,
I started using the magma routines for sparse Matrices. Especially I need matrix-matrix-multiplication. So I looked in the documentation and found "magma_scuspmm", an interface to the cuSparse function "csrmm". But then I got stucked, because the definition of the struct "magma_[z,c,s,d]_sparse matrix" is without documentation. I even checked the cuSparse documentation but couldn't find out all. Can somebody help me, please?
I found the header file (see below). Some of the variables open up to me clearly. But others are not so self-explaining like:
  • diagorder_type - There are 4 types, what means every type?
  • nnz - It's an integer, and i don't know which meaning it has.
  • max_nnz_row - same like nnz.
  • diameter - same like nnz.
  • diag - A float pointer, but i don't know what it means.
  • row, rowidx, col - normally the crs-format has 3 arrays: value, row pointer, column index. Col is clearly the column index but what mean the other two: row, rowidx
  • blockinfo - an integer pointer but I don't know the meaning
  • blocksize, numblocks, alignment - all are integers but I don't know the meanings

Code: Select all

typedef struct magma_s_sparse_matrix{

    magma_storage_t    storage_type;
    magma_location_t   memory_location;
    magma_symmetry_t   sym;
    magma_diagorder_t  diagorder_type;
    magma_int_t        num_rows;
    magma_int_t        num_cols; 
    magma_int_t        nnz; 
    magma_int_t        max_nnz_row;
    magma_int_t        diameter;
    float              *val;
    float              *diag;
    magma_index_t      *row; 
    magma_index_t      *rowidx; 
    magma_index_t      *col;
    magma_index_t      *blockinfo;
    magma_int_t        blocksize;
    magma_int_t        numblocks;
    magma_int_t        alignment;

}magma_s_sparse_matrix;

hartwig anzt
Posts: 90
Joined: Tue Sep 02, 2014 5:44 pm

Re: Informations about struct "magma_s_sparse_matrix"

Post by hartwig anzt » Thu Oct 30, 2014 2:46 pm

Noran,

I apologize for the missing documentation. For passing a CSR matrix to MAGMA, the following information may be useful:

#######################################################################
magma_storage_t storage_type; // matrix format - CSR, ELL, SELL-P
magma_location_t memory_location; // CPU or DEV
magma_symmetry_t sym; // opt: indicate symmetry
magma_diagorder_t diagorder_type; // opt: only needed for factorization matrices
magma_int_t num_rows; // number of rows
magma_int_t num_cols; // number of columns
magma_int_t nnz; // opt: number of nonzeros
magma_int_t max_nnz_row; // opt: max number of nonzeros in one row
magma_int_t diameter; // opt: max distance of entry from main diagonal
magmaDoubleComplex *val; // array containing values
magmaDoubleComplex *diag; // opt: store the diagonal seperately
magma_index_t *row; // row pointer
magma_index_t *rowidx; // opt: array containing row indices
magma_index_t *col; // array containing col indices
magma_index_t *blockinfo; // opt: for BCSR format
magma_int_t blocksize; // opt: info for SELL-P/BCSR
magma_int_t numblocks; // opt: info for SELL-P/BCSR
magma_int_t alignment; // opt: info for SELL-P/BCSR

#######################################################################

In the next release (November) there will be functions handling that issue:

magma_int_t
magma_zcsrset(
magma_int_t m,
magma_int_t n,
magma_index_t *row,
magma_index_t *col,
magmaDoubleComplex *val,
magma_z_sparse_matrix *A );

magma_int_t
magma_zcsrget( magma_z_sparse_matrix A,
magma_int_t *m,
magma_int_t *n,
magma_index_t **row,
magma_index_t **col,
magmaDoubleComplex **val );

If you want to use them, I can email them to you, but you would have to tweak in the compilation into the Makefiles.

Just let me know. Thanks, Hartwig

Noran
Posts: 27
Joined: Fri Sep 26, 2014 3:47 am

Re: Informations about struct "magma_s_sparse_matrix"

Post by Noran » Sat Nov 01, 2014 5:53 am

Thank you Hartwig for you're help :)
We want to do later some other things with sparse matrices (i.e. using the linear solver). So can you please send me the explanation to adding the functions you mentioned?
I'm not scared to edit the makefiles. I had to do this so often untill now in different situations.

Greetz Noran

Noran
Posts: 27
Joined: Fri Sep 26, 2014 3:47 am

Re: Informations about struct "magma_s_sparse_matrix"

Post by Noran » Mon Nov 03, 2014 2:34 am

Thank you Hartwig for the files.

Noran
Posts: 27
Joined: Fri Sep 26, 2014 3:47 am

Re: Informations about struct "magma_s_sparse_matrix"

Post by Noran » Tue Nov 04, 2014 10:05 am

Hi again,
the workaround worked well. But I didn't find how to send the matrix to the Device, can you help me again, please?

Greetz Noran

hartwig anzt
Posts: 90
Joined: Tue Sep 02, 2014 5:44 pm

Re: Informations about struct "magma_s_sparse_matrix"

Post by hartwig anzt » Tue Nov 04, 2014 10:12 am

Noran,

just use the function
magma_z_mtransfer( magma_z_sparse_matrix A,
magma_z_sparse_matrix *B,
magma_location_t src,
magma_location_t dst );

If you have a matrix A in CPU memory, and want a copy (magma_z_sparse_matrix B) on the GPU, call
> magma_z_mtransfer( A, &B, Magma_CPU, Magma_DEV );

As you can guess, magma_z_mtransfer( B, &C, Magma_DEV, Magma_CPU ); copies a matrix from GPU to host.

Hartwig

Noran
Posts: 27
Joined: Fri Sep 26, 2014 3:47 am

Re: Informations about struct "magma_s_sparse_matrix"

Post by Noran » Tue Nov 04, 2014 10:19 am

Ah ok, I've seen that function. But thought it was to copy the matrices only on CPU. I looked for something like the dense function: magma_ssetmatrix(...)

Thanks Noran

Post Reply