tvm_tirx.backend.cuda.ptx#
Table-driven PTX dialect (T.ptx).
One table (table), one generic engine (engine), thin
generators (gen_helpers, gen_stubs, and gen_coverage). Importing this package
registers every table entry as a TVM Op with a generic codegen; the
T.ptx namespace itself is installed by the CUDA backend’s
register_backend() via script_namespaces().
Classes#
|
|
Functions#
|
Return table entries and resolved modifiers for a fully spelled opcode. |
|
Return validated PTX text in table slot order, without binding operands. |
Instruction entries#
python/tvm_tirx/backend/cuda/ptx/table.py defines TABLE and its
InstructionEntry records. Each entry describes one operand shape;
multiple entries may share a user-facing instruction mnemonic.
Field |
Meaning |
|---|---|
|
Operand order, register or address kind, read/write direction, dtype, and register-group size. |
|
Modifier positions, legal tokens, and optional positions. |
|
Checks for modifier combinations and concrete immediate values. |
|
Inline-assembly retention and compiler memory-ordering requirements. |
|
Architecture used by instruction certification tests. |
Predication and special operands#
PTX call destinations are leading operands, and the call itself returns
no value. Inside TVMScript, the keyword-only pred gates an instruction.
For example, a predicated load can preserve the destination’s existing
value when the predicate is false:
T.ptx.ld.global_.b32(value, pointer, pred=predicate, preserve_dst=True)
Here value must be an initialized writable destination, and
pointer selects the memory to read. Special operand helpers include:
Helper |
Meaning |
|---|---|
|
Mark an operand as a PTX |
|
Form an immediate-offset address for an instruction that accepts it. |
|
Supply PTX’s |
Developer generators#
Run these commands from the repository root with the Python package available:
python -m tvm_tirx.backend.cuda.ptx.gen_helpers add -o /tmp/ptx_add.cuh
python -m tvm_tirx.backend.cuda.ptx.gen_stubs -o /tmp/ptx_stubs.pyi
python -m tvm_tirx.backend.cuda.ptx.gen_coverage > /tmp/ptx_coverage.txt
gen_helpers renders the selected family’s supported instruction forms.
gen_stubs generates signatures for editor tooling, and gen_coverage
reports instruction families and variants. These files support inspection;
runtime code generation reads the instruction table directly. Each command’s
--help describes its available options. The PTX TableGen guide follows an instruction through the implementation.