Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some utility routines to LayoutCS #25244

Merged
merged 1 commit into from
Jun 13, 2024

Conversation

bradcray
Copy link
Member

@bradcray bradcray commented Jun 13, 2024

This PR adds some new utility routines to the CS[R|C] sparse layout implemented in LayoutCS. The new routines are:

  • rows() / cols(): These are procedures on CS[R|C] domains and arrays that return the dense range of rows or columns that the domain/array spans
  • colsAndVals() / rowsAndVals(): Given a row/col index, these are sparse array iterators that yield all of the col/row indices and non-zeroes that are within that row/column. These are each only supported on the flavor of CS[R|C] that naturally supports them, and generate an error in other cases

Note that these routines are currently being added specifically to the CSR/C layout because they are both very 2D-specific and our more general, default sparse array layout can support 1D, 3D, nD domains and arrays as well, so it's not clear how to generalize them to those cases.

I've also added a test that checks that these new routines work on CSR|C domains and arrays.

These have not received any significant discussion or design review, but have been very handy in prototyping sparse matrix-matrix multiplication routines in Chapel and are features that users of 2D sparse arrays have been requesting for some time. My thought is that it would be better to have the features in an non-design-reviewed form for now to continue exploring sparse computations and learning from those explorations, leaning on the instabiliy of sparse features for now.

These have been very useful in my CSC*CSR matrix-multiplication study

---
Signed-off-by: Brad Chamberlain <[email protected]>
@bradcray bradcray marked this pull request as ready for review June 13, 2024 15:55
Copy link
Contributor

@jeremiah-corrado jeremiah-corrado left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@bradcray bradcray merged commit 4d95213 into chapel-lang:main Jun 13, 2024
7 checks passed
@bradcray bradcray deleted the layoutCSutils branch June 13, 2024 19:32
bradcray added a commit that referenced this pull request Jun 14, 2024
This is a code I've been writing, looking at sparse matrix-matrix
multiplication in Chapel to start to get more experience with our sparse
features, look for gaps, check performance, etc. So far, the effort has
resulted in improvements in the forms of PRs #25152, #25244, #24391, and
#25243. This is a work-in-progress that almost certainly needs
additional improvements in terms of performance, generality, ergonomics,
but it's a good start and in a state to start exercising some of the
aforementioned PRs. See the README for additional details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants