Skip to content

docs(api-ref): the shuffle i32 variants documented here do not exist - #815

Merged
nihalpasham merged 2 commits into
NVIDIA:mainfrom
vyncint:docs/api-ref-no-i32-shuffle
Aug 12, 2026
Merged

nihalpasham merged 2 commits into
NVIDIA:mainfrom
vyncint:docs/api-ref-no-i32-shuffle

Conversation

@vyncint

@vyncint vyncint commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

The quick reference's warp section advertises an i32 form for all four
shuffles. None exist.

// i32 variants
let partner_i = warp::shuffle_xor_i32(val, mask);   // does not compile
| `shuffle_xor_{f32,i32}(val, mask)`    | ...   <- four rows, all claiming i32
| `shuffle_down_{f32,i32}(val, delta)`  | ...
| `shuffle_up_{f32,i32}(val, delta)`    | ...
| `shuffle_{f32,i32}(val, src)`         | ...

cuda_device::warp has no _i32 function at any width. The real set is the
unsuffixed name for u32, plus _f32, _f64 and _u64, each with a
_sync form taking an explicit member mask.

This is the page most likely to be copied from, and the code line does not
compile.

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, which is
plausibly how the fictional i32 entry got written in the first place. So 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.

Verification

  • Every function the page now names checked against
    crates/cuda-device/src/warp.rs — shuffle, shuffle_xor, shuffle_down,
    shuffle_up, the _f32/_f64/_u64 suffixes and a _sync sample, all
    present.
  • No _i32 shuffle claim remains in any user-facing page.
  • sphinx-build -W --keep-going -b html succeeds.

(Found by diffing every warp::/thread::-style name the book cites against
what cuda-device exports. Three more citations in the compiler-internals pages
also fail to resolve; those are a separate PR, since they name mir-importer
helpers rather than user API.)

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]>
@nihalpasham nihalpasham added documentation Improvements or additions to documentation intrinsics Device intrinsics and libdevice math mappings labels Aug 12, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

Gist: right fix, nearly complete: supported-features.md still carried two i32-shuffle claims, and the same fence showed warp::popc(mask) for a function that takes a bool predicate. Pushed 08456db extending the diff to cover both.

Verified here:

  • every name the new table cites exists in warp.rs (u32-canonical unsuffixed, _f32/_u64/_f64 variants, _sync forms; no _i32 shuffle at any width);
  • post-fix grep: no user-facing i32-shuffle or popc(mask) text remains; the surviving i32 mentions are compiler-internal pages naming the real NVVM intrinsic.

Landing once CI is green.

@nihalpasham
nihalpasham merged commit f648fd6 into NVIDIA:main Aug 12, 2026
41 checks passed
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 13, 2026
#819 reads only ```rust fenced blocks, and said so: a call is something a reader
pastes, while a name in running text might be a PTX mnemonic or another
project's function. That scoping left half of the very bug it was written for
uncovered.

#815 removed two things from the API quick reference. One code-block line,
`warp::shuffle_xor_i32(val, mask)`, which #819 now catches. And four *table*
rows, written `shuffle_xor_{f32,i32}(val, mask)` -- which it does not, because
they are not in a code block and not literal names. Reinstating that row today
passes the guard.

Adds a second pass over everything outside a fenced block, restricted to
backticked, module-qualified names. Backticks are what make it precise: a
backticked `warp::foo` is a claim about this API wherever it appears, so the
false positives that motivated the code-block-only scope do not arise.
Unqualified table entries stay out of scope -- deciding which module a bare
`shuffle_xor` belongs to is guesswork, and that is the one thing this cannot do
without inventing a mapping.

`_{a,b,c}` families are expanded, so a family with one bad member fails on that
member instead of passing as an unrecognised literal. That notation is live
today in `thread::threadIdx_{x,y,z}()`, and it is what carried #815's rows.

Both passes now self-test for a non-empty result, since the new regex is the
likelier of the two to break quietly.

Verified: passes clean (34 calls in 271 blocks, 31 names in prose and tables,
against 1161 exported fns) and exits 1 under four mutations -- #815's exact
table row reinstated (reports `warp::shuffle_xor_i32`), a bad axis in the live
shorthand (reports `thread::threadIdx_q`), a broken call in a code block
(the pre-existing pass, unchanged), and a rotted prose regex (self-test).

Signed-off-by: Vyncint Ng <[email protected]>
nihalpasham added a commit that referenced this pull request Aug 17, 2026
…m the tree (#964)

* docs(book): the dialect inventories in mlir-dialects have drifted from the tree

All four hand-maintained inventories on this page are stale and nothing
checks any of them. Counts below are from the tree at a766fc2.

**dialect-mir types: seven -> nine.** `mir.union` (Rust unions, every field
a view of the same bytes) and `mir.fp16` (`f16`) both have
`#[pliron_type(...)]` declarations in `dialect-mir/src/types.rs` and no row.
`mir.union` is load-bearing right now -- #857 and #927 are both about union
constants.

**dialect-mir operations: 54 across 11 categories -> 62 across 12.** Six
categories are short and one whole module is missing:

  control_flow   5 -> 6    `mir.unroll_hint`
  memory         9 -> 11   `mir.memcpy`, `mir.memmove`
  comparison     6 -> 7    `mir.cmp`
  aggregate      8 -> 10   `mir.construct_slice`, `mir.construct_disjoint_slice`
  enum_ops       3 -> 4    `mir.set_discriminant`
  debug          - -> 1    `mir.dbg_value`, absent from the table entirely

**LLVM dialect: 62 -> 69**, counted at the pinned `pliron` revision
(8447aa42), where `pliron-llvm/src/ops.rs` declares 51 ops with
`#[pliron_op(` plus 18 through its binop macros. The table gains
`indirectbr`, `insert_element`, `shuffle_vector`, `poison`, and a row for
the four with no existing category (`freeze`, `va_arg`, `blockaddress`,
`blocktag`).

Two of the names in it are wrong rather than merely missing:

  * `inline_asm_multi` does not exist. It is in no version of `pliron-llvm`
    and nowhere in this repository -- this page is the only place the string
    appears. Same shape as the fictional `shuffle_xor_{f32,i32}` rows #815
    removed from the API quick reference.
  * `extractelement` is spelled `llvm.extract_element`.

Also notes that `llvm-export` contributes one op of its own, `llvm.dbg_value`,
which the surrounding prose did not mention, and that this table tracks an
upstream crate -- so it moves when the pin moves (as it did in #919), not
when this repository changes.

**dialect-nvvm: 123 -> 543.** This one is not a drift so much as a different
tree. Six of the twelve modules listed no longer exist: `thread` and `warp`
are gone (the warp ops are now split across `warp_shuffle`, `redux`, `vote`,
`warp_match`, `warp_barrier`, `active_mask` and `elect`), and `mbarrier`
split into `mbarrier_basic` and `mbarrier_extended`. The counts for those
that do exist are 4x-9x low: `tcgen05` is listed at 24 and has 210, `tma` at
15 and has 111. Eighteen modules are missing outright, including `sreg` at 44
ops.

Rewritten around the split `adding-new-intrinsics.md` already documents --
7 hand-written modules (18 ops) against 34 generated ones (525 ops, resolved
from 986 catalog entries) -- because that is what decides where a
contributor would add an op, and a table that says `warp` when the file is
`ops/generated/warp_shuffle.rs` sends them to the wrong place.

The per-module "Minimum SM / GPU Family" columns go with it. Those
requirements are per intrinsic, not per module, and the catalog already
records them: `intrinsics/generated-reference.md` renders the PTX version and
minimum SM for each of the 986 entries and is regenerated with the ops. The
page now points there instead of keeping a second copy by hand.

`crates/dialect-mir/README.md` carries its own copy of the operation
inventory, stale in the same way and by a different amount (it says 55, and
already had `set_discriminant` the book was missing). That is a separate
file with no overlap here and is fixed separately.

Verified: every count above recomputed from the tree; `just book`
(`sphinx-build -W --keep-going`) succeeds; check-book-api-names,
check-toolchain-parity and check-cli-doc-coverage all pass.

Signed-off-by: Vyncint Ng <[email protected]>

* docs(book): stamp the dialect-nvvm counts to the catalog SHA

The page's own thesis is that unchecked hand counts drift. The LLVM
table got an "at the pinned pliron revision" stamp; give the
dialect-nvvm totals the equivalent anchor: the catalog SHA-256 that
every ops/generated/ file header prints. A reader can now tell at a
glance whether 543/41/986 describe the catalog they are looking at.

---------

Signed-off-by: Vyncint Ng <[email protected]>
Co-authored-by: nihalpasham <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation intrinsics Device intrinsics and libdevice math mappings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants