Make reduction bound temporaries use PRIVATE address space - #649
Conversation
b8d690a to
cf59861CompareThere 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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
7d0c686 to
fdaee05Compare…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
8dc6267CompareUh oh!
There was an error while loading. Please reload this page.
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.