Make reduction bound temporaries use PRIVATE address space#649
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix global temporaries for reduction bounds
Make reduction bound temporaries use PRIVATE address space
Mar 17, 2026
b8d690a to
cf59861
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts Pytato’s Loopy code generation so that scalar temporaries created for non-affine reduction bounds are placed in PRIVATE address space (instead of GLOBAL), preventing races in parallel kernels. It also adds a regression test and updates Sphinx reference aliasing for the new Loopy symbol.
Changes:
- Generate reduction-bound temporaries with
lp.AddressSpace.PRIVATEto avoid cross-thread races. - Extend
add_store/get_loopy_temporaryto accept anaddress_spaceparameter (defaulting to GLOBAL for existing behavior). - Add a regression test asserting reduction-bound temps use PRIVATE address space; add a Sphinx missing-reference alias for
lp.AddressSpace.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
pytato/target/loopy/codegen.py |
Adds address_space plumbing and uses PRIVATE for reduction bound temporaries. |
test/test_codegen.py |
Adds regression test checking address space of reduction-bound temporaries. |
doc/conf.py |
Adds Sphinx missing-reference alias for lp.AddressSpace. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
7d0c686 to
fdaee05
Compare
…ess space Co-authored-by: inducer <352067+inducer@users.noreply.github.com> Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
fdaee05 to
8dc6267
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Scalar temporaries generated to store non-affine reduction bounds were allocated in
GLOBALaddress space, causing race conditions when parallel threads share those locations.Changes
get_loopy_temporary: Addaddress_spaceparameter (defaultlp.AddressSpace.GLOBALpreserves existing behavior).add_store: Addaddress_spaceparameter, forwarded toget_loopy_temporarywhenoutput_to_temporary=True.address_space=lp.AddressSpace.PRIVATEwhen storing non-affine reduction bound scalars, giving each thread its own copy.test_reduction_bound_temps_are_privateuses a CSR matrix multiply (which triggers non-affine bounds) and asserts all generated*_lbound/*_uboundtemporaries havePRIVATEaddress space.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.