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

Enable bulk transfers of sparse arrays #25243

Merged
merged 6 commits into from
Jun 13, 2024

Conversation

bradcray
Copy link
Member

@bradcray bradcray commented Jun 13, 2024

This PR adds the doiBulkTransfer[To|From]Known() routines to the two sparse layouts we currently support in order to enable sparse arrays to be initialized using patterns like var copy = mySparseArray; where, previously, this resulted in a complaint about being unable to zip sparse arrays due to falling into the most general implementation of array-array transfers.

Here, I'm adding some tests of this capability using the domain localization PR that I merged today (#24391) to prove that sparse arrays can be localized and accessed without incurring communication. I've turned on comm counts to track how many transfers are required, where I expect we could significantly reduce this over time by adding support for bulk transfer of the sparse domains themselves in the future (?).

Interestingly, one of the two cases that ought to cause my domain localization optimization to fire doesn't currently, suggesting that we don't set up definedConst properly for sparse subdomains; happily, the case I care about (const array, non-const domain) does work properly, so here I've checked in the tests to show that the other case doesn't work—another area for future improvement and a pre-existing issue not related to this effort.

This uses a new doi routine in a specific place to enable localization
of sparse domains when doing my new optimization.  Engin has told me
the more principled way to do it, but I wanted to get this into a commit
in a standalone branch first before refactoring.

Interestingly, my test here seems to show that we don't correctly
store 'definedConst' for sparse subdomains at present; though it
does work for const arrays, which is the case I actually care about
at present.  So future work here to generalize this.

---
Signed-off-by: Brad Chamberlain <bradcray@users.noreply.github.com>
---
Signed-off-by: Brad Chamberlain <bradcray@users.noreply.github.com>
---
Signed-off-by: Brad Chamberlain <bradcray@users.noreply.github.com>
@bradcray bradcray marked this pull request as ready for review June 13, 2024 05:18
Copy link
Contributor

@e-kayrakli e-kayrakli left a comment

Choose a reason for hiding this comment

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

Nice. A small addition to testing (different but equivalent domains) would be nice.

test/arrays/sparse/copyRemoteSparse-cs.chpl Show resolved Hide resolved
test/arrays/sparse/copyRemoteSparse-cs.chpl Outdated Show resolved Hide resolved
modules/internal/DefaultSparse.chpl Show resolved Hide resolved
(though he technically didn't request it)

---
Signed-off-by: Brad Chamberlain <bradcray@users.noreply.github.com>
…f domain

This adds a test Engin requested in his review to make sure that the
bulk assignment logic between sparse arrays is comparing domain index
sets precisely, and not relying on identity.  Though other tests
(including my not-yet-checked in sparse matrix-matrix multiplication)
arguably do this by virtue of the domain localization optimization,
this does it more expicitly by creating two domains with different
identities but the same indices, and assigning arrays back and forth
between them, modifying the arrays slightly along the way.

For a multilocale run, I'm creating the arrays on different locales,
but the domains on the same locale, somewhat arbitrarily; this
arguably covers a slightly different case than the existing
tests of the localization optimization, since in that case, the
domains and arrays are on different locales.

---
Signed-off-by: Brad Chamberlain <bradcray@users.noreply.github.com>
Forgot that this test existed in the second-to-previous commit

---
Signed-off-by: Brad Chamberlain <bradcray@users.noreply.github.com>
Copy link
Contributor

@e-kayrakli e-kayrakli left a comment

Choose a reason for hiding this comment

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

One minor question, but no need to check with me again before merging. Thanks!

test/arrays/sparse/copyRemoteSparse-cs.chpl Show resolved Hide resolved
@bradcray bradcray merged commit 849d748 into chapel-lang:main Jun 13, 2024
7 checks passed
@bradcray bradcray deleted the enable-sparse-array-localization branch June 13, 2024 19:40
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