Skip to content

docs(book): point the intrinsics guide at op files that exist - #797

Merged
nihalpasham merged 1 commit into
NVIDIA:mainfrom
vyncint:docs/intrinsics-guide-op-locations
Aug 11, 2026
Merged

nihalpasham merged 1 commit into
NVIDIA:mainfrom
vyncint:docs/intrinsics-guide-op-locations

Conversation

@vyncint

@vyncint vyncint commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

The defect

adding-new-intrinsics.md — the page a new contributor follows to add an
intrinsic — tells them to define the dialect-nvvm op in:

  • Stage 2: crates/dialect-nvvm/src/ops/thread.rs
  • Stage 2 (second walkthrough): crates/dialect-nvvm/src/ops/warp.rs

Neither file exists.

Following the guide is worse than hitting a dead path, because both ops it uses
as examples are now generated. read_ptx_sreg_tid_x and shfl_sync_bfly_i32
are both entries in intrinsics/catalog.json, so cuda-intrinsics-gen emits
their ops into crates/dialect-nvvm/src/ops/generated/ (sreg.rs and
warp_shuffle.rs), and every file there opens with:

// @generated by cuda-intrinsics-gen 0.1.0. DO NOT EDIT.

So a contributor either creates a file nothing includes, or hand-writes an op
into a generated file and loses it on the next generator run. Both failures are
quiet.

The change

Stage 2 now names the seven modules that really are hand-written — asm.rs,
atomic.rs, cluster.rs, debug.rs, grid.rs, memory.rs, wgmma.rs — and
states the split plainly: ops described by the catalog are generated, bespoke
ops are not, and the example code shows the shape either kind takes. The second
occurrence cross-references the first rather than repeating it.

The example code itself is unchanged — it is still a correct illustration of an
op definition, which is what that section is teaching.

Scope

Deliberately limited to correcting what is wrong. The generator workflow itself
— how to add a catalog entry and regenerate — is not documented anywhere in
the book
(no page mentions cuda-intrinsics-gen or the catalog at all).
Writing that guide is a larger piece than this fix and probably wants your view
on the intended contributor path, so I have left it alone rather than inventing
one. Happy to follow up if you want it.

Verification

  • Every crates/... path this page names now resolves on disk (checked
    mechanically; it was these two that did not).
  • Both example ops confirmed present in intrinsics/catalog.json, and
    cuda-intrinsics-gen/src/generate.rs confirmed to write to
    crates/dialect-nvvm/src/ops/generated.
  • sphinx-build -W --keep-going -b html, as the book gate runs it: exit 0.

`adding-new-intrinsics.md` tells a contributor to define the new
`dialect-nvvm` op in `crates/dialect-nvvm/src/ops/thread.rs`, and later in
`ops/warp.rs`. Neither file exists.

Following the guide is worse than a dead path, because both ops it uses as
examples are now generated. `tid.x` and the warp shuffles are both entries
in `intrinsics/catalog.json`, so `cuda-intrinsics-gen` emits their ops into
`crates/dialect-nvvm/src/ops/generated/` -- `sreg.rs` and `warp_shuffle.rs`
respectively -- and every file there opens with

    // @generated by cuda-intrinsics-gen 0.1.0. DO NOT EDIT.

So a contributor either creates a file nothing includes, or hand-writes an
op into a generated file and loses it on the next generator run.

Stage 2 now names the seven modules that really are hand-written (`asm`,
`atomic`, `cluster`, `debug`, `grid`, `memory`, `wgmma`) and states the
split: catalog-described ops are generated, bespoke ops are not, and the
example code shows the shape either kind takes. The second occurrence
cross-references the first rather than repeating it.

Scoped deliberately to correcting what is wrong. The generator workflow
itself -- how to add a catalog entry and regenerate -- is not documented in
the book at all, and writing that guide is a larger piece than this fix.

Verified: every `crates/...` path this page names now resolves on disk, and
`sphinx-build -W --keep-going` succeeds as the book gate runs it.

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 11, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

Gist: the guide pointed at op files that no longer exist. Since the catalog generator landed, tid.x-class ops are generated into ops/generated/ and only bespoke ops are hand-written; following the old text either creates an orphan file that never registers or edits a DO-NOT-EDIT generated file. Both mistakes fail silently.

Verified here:

  • all seven hand-written module paths and the generated split match main;
  • book builds warning-free under the CI gate.

Merging. Please do file the follow-up issue for documenting the catalog workflow.

@nihalpasham
nihalpasham merged commit 1e29c57 into NVIDIA:main Aug 11, 2026
38 checks passed
nihalpasham added a commit that referenced this pull request Aug 12, 2026
…816)

* 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(compiler): align the intrinsic-dispatch walkthroughs with the generated dispatcher

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 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 added a commit that referenced this pull request Aug 18, 2026
…ted in #406 (#977)

* docs(mir-lower): the intrinsic converter table names two modules deleted in #406

`README.md`'s "GPU Intrinsic Converters (`convert/intrinsics/`)" table has 13
rows for a directory holding 24 modules. Two of the 13 do not exist:

  convert/intrinsics/stmatrix.rs   deleted in 6a9a637 (#406)
  convert/intrinsics/tcgen05.rs    deleted in 6a9a637 (#406)

Both were removed when "Generate CUDA intrinsics from pinned LLVM metadata"
moved those families onto the catalog path. The table still describes them as
hand-written converters with an "Inline PTX" strategy; `stmatrix` and
`tcgen05` are mentioned 460 times in `convert/generated_intrinsics.rs` today.
So a reader looking for where either is lowered is sent to a file that has not
existed for many releases. Same shape as #797, one crate over.

A third row, `generated_intrinsics`, is real but not in that directory -- it is
`convert/generated_intrinsics.rs`, one level up. That is the row most worth
getting right, since it is where nearly every intrinsic now goes.

Fourteen modules that do exist had no row at all: `asm`, `cp_async`,
`dotprod`, `execution_control`, `extended_minmax`, `integer_minmax`,
`ldmatrix`, `memory`, `packed`, `prmt`, `scalar_arithmetic`,
`scalar_conversion`, `scalar_math`, `wmma`. `integer_minmax` arrived last
batch with #967.

Rewritten as one row per file, with each description taken verbatim from that
module's own `//!` doc comment, so the table cannot drift from the code
without the doc comment drifting first. The "Strategy" and "GPU" columns are
dropped: they were per-module guesses at what are per-intrinsic properties,
and the catalog already records the PTX version and minimum SM for each,
rendered into `intrinsics/generated-reference.md` alongside the sources. The
page now points there instead of keeping a second copy by hand -- the same
treatment #964 gave the book's dialect-nvvm table.

The Core Modules table on the same page was short by four: the top-level
`type_conversion_interface`, `scalarize_block_args` and
`wgmma_deferred_accumulator`, plus `convert/enum_payload_storage`.

Verified by script: the converter table's rows are now exactly the set of
`.rs` files in `convert/intrinsics/` (24 and 24, no ghost and no missing), and
every top-level `src/*.rs` module and every `convert/*.rs` module has a row.

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

* docs(mir-lower): add the convert/type_interface_impls row

The Core Modules table listed convert/interface_impls but not its
type-conversion counterpart; description taken from the module's
own doc comment.

---------

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