Repository navigation
docs(compiler): the shuffle dispatch these pages show does not exist - #816
Merged
Merged
Conversation
Continuation of NVIDIA#797, which corrected Stage 2 of the intrinsics guide for the generated/hand-written split. Stage 3 has the same rot and NVIDIA#797 did not touch it. `adding-new-intrinsics.md` and `mir-importer.md` both show `"cuda_device::warp::shuffle_xor"` dispatching to `intrinsics::warp::emit_warp_shuffle_i32`. That function does not exist. The file they cite does -- `intrinsics/warp.rs`, 118 lines -- but it defines only `emit_warp_redux`, and the string `"cuda_device::warp:: shuffle_xor"` appears nowhere in a hand-written match. The shuffles are catalog intrinsics. `shuffle_xor` is in `intrinsics/catalog.json`, so its arm is generated into `intrinsics/generated.rs` (line 1660 and around) beside the generated ops that NVIDIA#797 documented. A reader following either page looks for a dispatch that was never there in this form. Scoped like NVIDIA#797: the guide is told what is generated rather than rewritten. mir-importer.md's match keeps its two genuinely hand-written arms and gains a paragraph on where the rest come from; the guide's Stage 3 gains the same note, and its illustrative emitter is renamed `emit_two_operand_intrinsic` so nobody greps the tree for a symbol that is not in it. The op names those pages cite -- `ShflSyncBflyI32Op`, `convert_shuffle_i32` -- are real and untouched. Also on mlir-dialects.md: "intrinsic functions like `thread::index_x()` or `warp::shfl_sync_bfly()`" named two functions that do not exist either. The real ones are `thread::index_1d()` and `warp::shuffle_xor()`; `shfl_sync_bfly` is the PTX instruction, not the Rust entry point. Its mangled-symbol example further down said `thread_index_x` and now agrees. Verified: every name these pages now cite exists in the tree, no nonexistent one remains on any page, and `sphinx-build -W --keep-going` succeeds. Signed-off-by: Vyncint Ng <[email protected]>
…nerated dispatcher Signed-off-by: nihalpasham <[email protected]>
Collaborator
|
Gist: right to kill Verified here:
Landing once CI is green. |
nihalpasham
approved these changes
Aug 12, 2026
nihalpasham
added a commit
that referenced
this pull request
Aug 12, 2026
* docs(compiler): the shuffle dispatch these pages show does not exist Continuation of #797, which corrected Stage 2 of the intrinsics guide for the generated/hand-written split. Stage 3 has the same rot and #797 did not touch it. `adding-new-intrinsics.md` and `mir-importer.md` both show `"cuda_device::warp::shuffle_xor"` dispatching to `intrinsics::warp::emit_warp_shuffle_i32`. That function does not exist. The file they cite does -- `intrinsics/warp.rs`, 118 lines -- but it defines only `emit_warp_redux`, and the string `"cuda_device::warp:: shuffle_xor"` appears nowhere in a hand-written match. The shuffles are catalog intrinsics. `shuffle_xor` is in `intrinsics/catalog.json`, so its arm is generated into `intrinsics/generated.rs` (line 1660 and around) beside the generated ops that #797 documented. A reader following either page looks for a dispatch that was never there in this form. Scoped like #797: the guide is told what is generated rather than rewritten. mir-importer.md's match keeps its two genuinely hand-written arms and gains a paragraph on where the rest come from; the guide's Stage 3 gains the same note, and its illustrative emitter is renamed `emit_two_operand_intrinsic` so nobody greps the tree for a symbol that is not in it. The op names those pages cite -- `ShflSyncBflyI32Op`, `convert_shuffle_i32` -- are real and untouched. Also on mlir-dialects.md: "intrinsic functions like `thread::index_x()` or `warp::shfl_sync_bfly()`" named two functions that do not exist either. The real ones are `thread::index_1d()` and `warp::shuffle_xor()`; `shfl_sync_bfly` is the PTX instruction, not the Rust entry point. Its mangled-symbol example further down said `thread_index_x` and now agrees. Verified: every name these pages now cite exists in the tree, no nonexistent one remains on any page, and `sphinx-build -W --keep-going` succeeds. Signed-off-by: Vyncint Ng <[email protected]> * docs(api-ref): the shuffle i32 variants documented here do not exist The quick reference's warp section advertises an `i32` form for all four shuffles -- a `// i32 variants` code line calling `warp::shuffle_xor_i32`, and a table whose four rows are written `shuffle_xor_{f32,i32}` and so on. No `_i32` function exists in `cuda_device::warp`, so the code line does not compile and the table sends a reader looking for three more that are not there. The real widths are the unsuffixed name for `u32`, plus `_f32`, `_f64` and `_u64`, each with a `_sync` form taking an explicit member mask. Worth more than deleting the wrong line: the page showed only the `_f32` forms, so it never mentioned the `u32` ones at all -- a reader shuffling integers had nothing correct to copy. The example now uses the unsuffixed form and the table lists the widths that exist, with a note that an `i32` should be reinterpreted and passed through the `u32` form, since a shuffle moves bits without interpreting them. Verified: every function the page now names exists in crates/cuda-device/src/warp.rs, no `_i32` shuffle claim remains in any user-facing page, and `sphinx-build -W --keep-going` succeeds. Signed-off-by: Vyncint Ng <[email protected]> * ci: guard the device-API names the book shows in Rust blocks A Rust code block in the book is something a reader pastes. When a device function is renamed or never existed, nothing fails: the book renders, CI is green, and the reader finds out. That has now bitten three times -- #797 (op files that no longer existed), the `warp::shuffle_xor_i32` entry in the API quick reference, and a dispatch helper in the compiler pages replaced by generated code. All three were found by hand, months apart. `scripts/check-book-api-names.sh` resolves every `warp::`, `thread::`, `grid::` and `cluster::` call the book shows against the functions `cuda-device` exports. On the current tree that is 26 calls across 271 Rust blocks against 1,148 exports. Scope is what makes it precise rather than merely broad: * Only ```rust fenced blocks. In prose a name may legitimately be a PTX instruction (`shfl.sync.bfly`), a module path, or another project's API; inside a Rust block it is a call and has to exist. Restricting to code blocks is what takes this from dozens of false positives to none. * Only the four device modules. Host APIs are already covered by rustdoc, which builds under `-D warnings`. * Existence only, never arity or types -- those change for good reasons and the compiler catches them. A name that is simply absent is the silent case. The lookbehind rejecting a qualified prefix is load-bearing and I only found it by running the guard against this branch: `warp` and `thread` are also module names inside the compiler, so the intrinsics guide's `intrinsics::warp::emit_two_operand_intrinsic(...)` -- a mir-importer path with no business resolving against cuda-device -- was flagged until the pattern learned to skip it. Verified: passes here; reverting the two book pages to their pre-fix state reports `warp::shuffle_xor_i32`, the defect it exists for; a synthetic rename is caught; the compiler-internal path is ignored; and a missing or truncated cuda-device tree fails rather than passing vacuously. Stacked on #815 and #816, whose fixes this guard requires to be green -- review only the third commit. Signed-off-by: Vyncint Ng <[email protected]> * fix(ci): match mixed-case device-API names in the book guard Signed-off-by: nihalpasham <[email protected]> --------- Signed-off-by: Vyncint Ng <[email protected]> Signed-off-by: nihalpasham <[email protected]> Co-authored-by: nihalpasham <[email protected]>
nihalpasham
pushed a commit
that referenced
this pull request
Aug 12, 2026
…that hid (#833) `pub mod translator` made every item under it reachable API, so `dead_code` was off for the whole module tree. The only in-tree consumer reaches the translator through `pipeline`, and the two predicates outsiders need are already re-exported from the crate root, so the module is now `pub(crate)`. That switches the lint back on and it finds six orphans, all removed: - `intrinsics::warp::emit_warp_redux` -- the whole 118-line module. Called out as dead in the #816 merge note; the redux family is catalog-generated. Its doc claimed to be "shared by the whole integer reduction family", which is what sent the book's Stage 3 to the wrong place twice. - `intrinsics::indexing::emit_index_2d` and its `generated_sreg_op` helper. Its own doc says the dispatcher routes index helpers as normal function calls instead; `try_dispatch_intrinsic` returns `Ok(None)` for all of them. - `helpers::emit_nvvm_intrinsic` / `emit_nvvm_intrinsic_u64` -- the pre-catalog twins of `emit_generated_nvvm_intrinsic{,_u}`, differing only in not stamping the ABI marker. - `translator::translate_function` -- the crate doc example's entry point. The example passed four arguments to a five-argument function, so it had not been compiled against reality in some time. - `types::get_f32_type`. `index_1d_sreg_ops_carry_their_exact_generated_markers` built its ops with the dead `generated_sreg_op`, so it could not have caught a regression in what the compiler actually emits. It now asserts the same three markers against the target table the backend reads back at verification time, which cross-checks the two generated artifacts against each other. The seventh orphan is generated: `generated_intrinsic_marker`, a 2142-line path-keyed table whose only callers are the generated tests in the same file. Gated on `cfg(test)` in the renderer rather than deleted, since whether the catalog should still render it is a generator decision. If you want it gone, that is one more line in `render.rs` and -10k in output. Book and crate docs updated where they named a removed symbol: the quick-reference checklist pointed new contributors at `emit_nvvm_intrinsic`, and both flow diagrams still started at `translate_function()`. No behaviour change: nothing deleted had a caller. Signed-off-by: Vyncint Ng <[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.
Continuation of #797, which corrected Stage 2 of the intrinsics guide for the
generated/hand-written split. Stage 3 has the same rot and #797 did not touch
it.
The defect
adding-new-intrinsics.mdandmir-importer.mdboth show"cuda_device::warp::shuffle_xor"dispatching tointrinsics::warp::emit_warp_shuffle_i32.That function does not exist. The file they cite does —
crates/mir-importer/src/translator/terminator/intrinsics/warp.rs, 118 lines —but it defines only
emit_warp_redux, and the string"cuda_device::warp::shuffle_xor"appears in no hand-written match.The shuffles are catalog intrinsics:
shuffle_xoris inintrinsics/catalog.json, so its dispatch arm is generated intointrinsics/generated.rs(line 1660 and around), beside the generated ops #797documented. A reader following either page hunts for a dispatch that was never
there in this form.
The fix, scoped like #797
The guide is told what is generated rather than rewritten:
mir-importer.md's match keeps its two genuinely hand-written arms and gains aparagraph on where the rest come from;
renamed
emit_two_operand_intrinsic— it is teaching the shape of atwo-argument emitter, so it should not wear the name of a symbol that is not in
the tree.
The op names these pages cite —
ShflSyncBflyI32Op,convert_shuffle_i32— Ichecked and both are real, so they are untouched.
Also on
mlir-dialects.mdNeither exists. The real ones are
thread::index_1d()andwarp::shuffle_xor();shfl_sync_bflyis the PTX instruction name, not the Rust entry point. Itsmangled-symbol example further down said
thread_index_xand now agrees with thecorrected name.
Verification
emit_warp_redux,index_1d,shuffle_xor,ShflSyncBflyI32Op,convert_shuffle_i32).sphinx-build -W --keep-going -b htmlsucceeds.(Found by diffing every API-shaped name the book cites against what the tree
exports — the same sweep that produced #815.)