Repository navigation
fix(#219): remove dead/wrong get_mut and get_unchecked_mut arms from DisjointSlice dispatch - #244
Merged
Merged
Conversation
…ice dispatch `get_mut` and `get_unchecked_mut` are marked `#[inline]` in cuda-device and are always inlined by rustc before MIR reaches the translator, so the dispatch arms for them were effectively unreachable. Worse, routing them to `emit_get_thread_local` was wrong: that helper returns a raw `*mut T` pointer, but both methods return `Option<&mut T>`, so any path that did reach this code would produce a type mismatch. Remove both methods from the match; `get_thread_local` and `len` remain as the only routed DisjointSlice methods.
meefs
pushed a commit
to meefs/cuda-oxide
that referenced
this pull request
Sep 30, 2026
DivHint::from_ptr narrowed the device address to i32 before taking its lowest set bit. An address whose low 32 bits are exactly 0x8000_0000 (2 GiB mod 4 GiB) narrows to i32::MIN, whose lowest set bit does not fit in a positive i32 — the divisor came out NEGATIVE, and the entry generator's div > 1 guard silently dropped the assume_div_by for a pointer that is in fact 16-byte aligned. A missed optimization plus a spurious extra cache specialization, never a soundness issue: the guard fails conservative. from_ptr now computes trailing zeros on the u64 directly (zero keeps meaning maximally aligned). The sibling latent case in the i32 helper, val = i32::MIN, is pinned to a positive power of two. Regression tests cover the exact failing bit pattern, realistic high-bit addresses, unaffected neighbors, and the negative-value paths. Signed-off-by: Melih Elibol <[email protected]>
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.
What
Closes #219.
The DisjointSlice method dispatch in
terminator/mod.rsincludedget_mutandget_unchecked_mutas candidates to route toemit_get_thread_local. Both of these are bugs:#[inline]in cuda-device; rustcinlines them before the translator sees them. The arms were
unreachable in practice.
emit_get_thread_localreturns a raw*mut Tpointer, butget_mutandget_unchecked_mutreturnOption<&mut T>. Any call that did reach this path would producea type mismatch.
Fix
Remove
"get_mut" | "get_unchecked_mut"from the match.get_thread_localand
lenare the only methods that actually need translation-time dispatch.A comment explains why the two inlined methods are intentionally absent.
Test plan
cargo oxide run vecadd(no regression in baseline kernel)cargo test -p mir-importer