You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Shared arrays lack a raw-pointer escape hatch for disjoint thread writes #623
codegenDevice code-generation pipeline (Rust MIR to IR to PTX)enhancementNew feature or requestintrinsicsDevice intrinsics and libdevice math mappingssafetyMemory safety, soundness, or undefined behavior
Shared arrays lack a raw-pointer escape hatch for disjoint thread writes
Problem
SharedArray::as_mut_ptr requires &mut self. When every CUDA thread needs a
pointer into one static mut SharedArray, obtaining that receiver can create
multiple overlapping &mut SharedArray references even when the threads only
access disjoint elements. The intended memory-access pattern is valid for CUDA,
but the only public pointer conversion expresses a stronger Rust aliasing claim
than the caller can uphold.
Why this matters
Per-thread writes into shared scratch storage are a basic building block for
reductions, tiled kernels, and cooperative algorithms. Users should be able to
express those writes without manufacturing whole-allocation mutable references.
The unsafety belongs at the point where callers establish disjoint access and
synchronization, not in an unavoidable aliasing violation in the API shape.
Expected behavior
SharedArray should offer an unsafe raw-receiver conversion that accepts a *mut SharedArray, normally produced with &raw mut, and returns a mutable
element pointer. CUDA codegen should lower it through the same shared-to-generic
address conversion as the existing borrowed as_ptr and as_mut_ptr methods.
Acceptance criteria
CUDA threads can derive element pointers from &raw mut shared storage
without first creating &mut SharedArray.
The returned pointer is classified as generic address space 0, consistently
with the existing public SharedArray pointer conversions.
Intrinsic dispatch and result address-space classification use one exact
recognizer, including rejection of similarly named methods and types.
A multithreaded GPU regression writes disjoint shared elements, synchronizes,
and checks the computed result.
codegenDevice code-generation pipeline (Rust MIR to IR to PTX)enhancementNew feature or requestintrinsicsDevice intrinsics and libdevice math mappingssafetyMemory safety, soundness, or undefined behavior
Activity