Skip to content

book: the intrinsics guide covers only hand-written ops; the cuda-intrinsics-gen catalog workflow is undocumented #808

Closed

Description

@vyncint

Filing the follow-up asked for in the #797 review.

What #797 fixed, and what it left

#797 corrected cuda-oxide-book/compiler/adding-new-intrinsics.md, which told contributors to define new dialect-nvvm ops in crates/dialect-nvvm/src/ops/thread.rs and ops/warp.rs. Neither file exists: both example ops are catalog entries, generated into ops/generated/. Following the old text either created a file nothing registers or edited a DO NOT EDIT generated file, and both fail quietly.

That PR's fix was to scope the page honestly — name the seven hand-written modules, and warn that catalog-described ops are generated. It deliberately did not document the generator, because that is a larger piece and the intended contributor path is yours to define.

So the page is now correct but incomplete: it explains the path for bespoke ops and tells you the other path exists without saying how to walk it. For scale, that other path is the majority — 986 catalog entries across 35 generated files.

What is undocumented today

No page in the book mentions cuda-intrinsics-gen or intrinsics/catalog.json except the warning #797 added. A contributor adding a catalog intrinsic gets no guidance on any of the following, all of which exist and are load-bearing:

The generator's surface, from its own usage text:

cuda-intrinsics-gen extract --intrinsics-json FILE --nvptx-json FILE
cuda-intrinsics-gen extract --llvm-src DIR --llvm-tblgen FILE
cuda-intrinsics-gen generate
cuda-intrinsics-gen check
cuda-intrinsics-gen coverage [--family NAME]
cuda-intrinsics-gen check-abi-history --base-ref REF
cuda-intrinsics-gen probe [--all | --intrinsic ID] [--llc FILE] [--skip-terminal]
cuda-intrinsics-gen probe --candidate --intrinsic ID --llc FILE --gpu-target TARGET --ptx-feature FEATURE (--ptxas FILE | --skip-terminal)

Three CI gates that a catalog change has to satisfy (unit-tests.yml), none of them discoverable from the docs:

gate what it enforces
cuda-intrinsics-gen -- check the committed generated sources match what the generator produces
cuda-intrinsics-gen -- probe --all --skip-terminal the pinned llc identity and the exact emitted PTX per route
cuda-intrinsics-gen -- check-abi-history --base-ref <sha> the intrinsic ABI ledger stays append-only

Two non-obvious environment facts sit with those: the ABI-history job needs fetch-depth: 0, and the generator shells out to rustfmt when it writes sources (which is why the pin carries that component — #727).

And the concepts a reader needs before touching the catalog: what catalog.json's schema / catalog_version / intrinsic_abi / generator_version fields mean, why the ABI ledger is append-only (cf. #604, where positional ID assignment conflicted with it), and what probe evidence is for.

Why it is worth writing

The failure mode is the one #797 hit: a contributor reads the only page named "Adding New Intrinsics", follows it, and produces something that either does not register or gets overwritten on the next generator run. #797 stops the page from misleading them, but the majority path is still tribal knowledge, and three CI gates fail on a PR without explaining what to run locally first.

Suggested shape, entirely your call

A "Catalog-generated intrinsics" section or sibling page covering: when an intrinsic belongs in the catalog versus a hand-written op; the add-a-catalog-entry → generate → check loop; the three CI gates and their local invocations; and the ABI-ledger constraint. Cross-linked from the Stage 2 note #797 added, so the reader who hits "this one is generated" has somewhere to go.

Happy to write it if you want it from me — but I would rather you set the intended contributor path than infer one from the code, which is why this is an issue and not a PR. If some of it is deliberately internal and not for the book, saying so here is a useful answer too.

Activity

  1. added
    documentationImprovements or additions to documentation
    intrinsicsDevice intrinsics and libdevice math mappings
    on Aug 12, 2026
  2. nihalpasham commented on Aug 30, 2026

    @nihalpasham
    Collaborator

    Policy decision, so #1171 can come off hold. The contributor path #1171 inferred from the code is now the official one:

    add a catalog intrinsic:
      1. extend the family's overlay shard        (reviewed input)
      2. append one entry to abi-v1.toml          (reviewed input, append-only)
      3. record/refresh evidence JSON             (reviewed input, local tools)
      4. cargo run -p cuda-intrinsics-gen -- generate
      5. just check-intrinsics upstream/main      (same three gates CI runs)
    
    never touched by hand: anything stamped "@generated ... DO NOT EDIT",
    including catalog.json itself
    

    Ratified rules, in the chapter's own terms:

    #1171 gets a conformance pass plus the accuracy fixes noted there (the schema 44 vs 46 gloss, catalog.json's header fields, the two CI environment facts), then lands and closes this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationintrinsicsDevice intrinsics and libdevice math mappings

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions