Repository navigation
feat(cuda-device): expose raw shared-array pointer - #624
Merged
nihalpasham merged 1 commit intoAug 1, 2026
Merged
Conversation
Signed-off-by: nik <[email protected]>
Collaborator
|
LGTM. Every thread deriving a pointer into one Verified on hardware:
One item for the toolchain-bump checklist: recognition depends on rustc's def-path rendering, so a future pretty-printing change would silently un-intercept these methods — worth a canary test eventually. Merging; closes #623. |
5 tasks done
nihalpasham
approved these changes
Aug 1, 2026
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.
Closes #623.
Summary
SharedArray::as_mut_ptrforces callers to create a whole-allocation mutablereference before multiple CUDA threads can derive disjoint element pointers.
This adds an unsafe
as_raw_mut_ptr(*mut Self)entry point and lowers it throughthe same shared-to-generic conversion as the borrowed pointer methods. The
caller retains responsibility for disjoint accesses and CUDA synchronization,
while the API no longer requires an overlapping
&mut SharedArray.What changed
Raw receiver and lowering rule
SharedArray::as_raw_mut_ptr, with safety documentation centered onraw
static mutprovenance, per-thread disjointness, kernel lifetime, andsynchronization.
as_ptrandas_mut_ptrafter their explicit conversion from shared address space 3.public entry points share the same lowering implementation.
Coverage and related paths
both intrinsic dispatch and call-result address-space classification.
cuda_devicecrate, an exactSharedArraypathcomponent, and exact method names; unit tests cover canonical names and
nearby false matches.
addressof_sharedarrayregression without introducinganother artifact: one 32-thread kernel writes distinct shared elements from
the raw receiver, synchronizes, and checks their sum while retaining the
original issue-54 behavior.
Known separate limitations
prove that concurrent accesses are disjoint and place the required CUDA
barriers. A higher-level safe partitioning API is separate work.
upstream/mainis independently blockedon CUDA 12.8 by cubin validation requiring generic ELF
e_version == 1;nvJitLink emits the CUDA format value
0x80. The raw-pointer branch remainsindependent of that validator fix. Its PTX route passes directly, and the
LTOIR route passes when tested with only that validator correction stacked
transiently.
Testing
bead880cd7461c67a14bc69d10fa7def538f3394,scripts/smoketest.sh --only '^addressof_sharedarray$' --no-colorfailedduring device compilation with Rust error E0599 because
SharedArray::as_raw_mut_ptrdid not exist.cargo oxide run addressof_sharedarray --arch=sm_86preserved the originalresult (
21) and produced the 32-thread raw-pointer sum (528).applied transiently,
scripts/smoketest.sh --only '^addressof_sharedarray$' --no-colorpassed1/1. Removing that unrelated condition reproduces
Finalizer(InvalidCubin)after nvJitLink has produced a valid 5,152-byte CUDA ELF.
cargo test -p mir-importer -p cuda-device --all-targetspassed(892 mir-importer tests, 76 cuda-device unit tests, the config extension
test, and all 25 thread-index trybuild cases).
cargo clippy -p mir-importer -p cuda-device --all-targets -- -D warningspassed.
cargo clippy --all-targets -- -D warnings, workspace and exampleformatting checks, and
git diff --checkpassed.Checklist
main, or its dependency is explicit.mainand passes on this branch.