Adopt a CSR Representation for Sparse Matrices (Arecibo backport) #232
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Shifts the sparse matrix representation from COO (Coordinate List) to CSR (Compressed Sparse Row).
Note
COO vs. CSR
In brief, while COO represents a sparse matrix as a list of (row, column, value) tuples, CSR takes a different approach. It makes use of three one-dimensional arrays to store the non-zero elements, the extents of the rows, and the column indices of the elements. The real charm of CSR lies in the contiguity of value representation for the same rows, making it amenable to auto-vectorizers.
The change shows a small 5-10% improvement on recursive proofs, where a matrix-vector product is used in committing to R1CS matrices (and that's on an M2 machine .. on most x86s, more significative benefits are the norm).
Complete bench run:
https://gist.github.com/huitseeker/63bae83503c61b0cf643f58ccf0a7dad
Credits
argumentcomputer/arecibo#38
Work mostly done by @winston-h-zhang, I'm just the ferryman.