cuSPARSE CSR sparse matrix representation


In the cuSPARSE documentation ( it’s written:

“Sparse matrices in CSR format are assumed to be stored in row-major CSR format, in other words, the index arrays are first sorted by row indices and then within the same row by column indices. It is assumed that each pair of row and column indices appears only once.”

So it is said that the inner column index array is supposed to be sorted by column indices. Do you know which cuSPARSE functions require this inner column sorting, and if any of the functions work also with inner column indices in any order?


I assume all functions require that sorting. Search for cusparseXcsrsort(), it is a function (inside the cusparse library) that will help you sort the column indices.

Thank you for letting me know about the sorting function, I somehow missed it before. It resolves my problem.

This has solved a problem I have been banging my head against for a while. Thanks a lot!

The exact requirements of the CSR format, and the use of the sort functions is really not very well explained in the documentation.