This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Sparse matrix format in armPL

I'm new with armPL and I have some questions about the sparse matrix formats.

1) I know the COO format is not efficient for sparse matrix operations. If I build COO sparse matrix in armPL, the optimization function that I have to call before each operation makes the internal format efficient, or is it better to create the matrix in CSR format?

2) In case of better performance with CSR format, if I have to convert a COO matrix into CSR matrix can I use the export functions (like armpl_spmat_export_csr_s) for building the input data of CSR matrix?

Parents
  • Hi,

    Thanks for your post.

    1. If you create your matrix using e.g. armpl_spmat_create_coo_s with the final `flag` parameter set to 0 then the library takes a copy of your data. If instead you set the `flag` parameter to `ARMPL_SPARSE_CREATE_NOCOPY` then the library references your data (and you must not deallocate it). In the first case (flag=0) then when you later call e.g.armpl_spmv_optimize the library copy of your matrix may be transformed into CSR or another sparse format which should give better performance. In the second case (flag=..._NOCOPY) then the optimization call will not change the format of your matrix. Therefore, so long as you are creating your matrix with flag=0 the performance you see from COO input should be similar to what you would see from CSR input, so in that case the answer to the question "is is better to create the matrix in CSR format?" is "no".

    2. If you did want to have a CSR representation of your matrix, then yes one way to do the conversion is to create a COO matrix and then use then call the CSR export function e.g. armpl_spmat_export_csr_s.

    I hope that helps!

    Thanks,

    Chris.

Reply
  • Hi,

    Thanks for your post.

    1. If you create your matrix using e.g. armpl_spmat_create_coo_s with the final `flag` parameter set to 0 then the library takes a copy of your data. If instead you set the `flag` parameter to `ARMPL_SPARSE_CREATE_NOCOPY` then the library references your data (and you must not deallocate it). In the first case (flag=0) then when you later call e.g.armpl_spmv_optimize the library copy of your matrix may be transformed into CSR or another sparse format which should give better performance. In the second case (flag=..._NOCOPY) then the optimization call will not change the format of your matrix. Therefore, so long as you are creating your matrix with flag=0 the performance you see from COO input should be similar to what you would see from CSR input, so in that case the answer to the question "is is better to create the matrix in CSR format?" is "no".

    2. If you did want to have a CSR representation of your matrix, then yes one way to do the conversion is to create a COO matrix and then use then call the CSR export function e.g. armpl_spmat_export_csr_s.

    I hope that helps!

    Thanks,

    Chris.

Children