Expand description
The shared text walker for Vulkane’s kernel emitters (ROADMAP rows 8a, 8b and 8g for GLSL and WGSL).
lower_kernel takes an Unpopped kernel-layer KernelFn and a
Dialect and writes shader source. The walk (scope checks, statements, control flow, the
structure of a For) is written once; a dialect supplies only the spellings that differ between
GLSL and WGSL: declarations, the entry point, literals, operators, barriers.
§What it lowers (v1)
Integer kernels (I32/U32): buffer parameters, static Shared arrays, locals, Let, Load,
Assign, Store, MaskedLoad and MaskedStore (ROADMAP 9e: a guarded plain access, so the memory is not touched
where the mask is false), Barrier and Fence, If, For, While, Break, Continue, Return, and
the expressions Local, ConstInt, Exec (thread, block, BlockDim, GridDim), Add, Sub,
Mul, the comparisons, BitAnd/BitOr/BitXor, Shl/Shr (the count masked to the width, as
the SPIR-V emitter does) and Select. Anything else is a typed
UnsupportedKernel naming it.
§Semantics shared with the SPIR-V emitter
A comparison gives 1 or 0 in the compute dtype. A For evaluates its bounds once; a zero step
leaves the loop at once (a shader cannot trap). A barrier under thread-divergent control is refused
by check_kernel (BarrierDivergent) before any text is written.
§Refused by name
The twelve NVIDIA-only statements of board 434 C and its extension (CopyAsync, Collective,
MbarInit, WgmmaWait, …) are refused by name, at any nesting depth, before the walk starts.
Structs§
- Decl
- A buffer or shared array the prologue declares.
- Layout
- Everything the prologue needs.
- Subgroup
Collective - One subgroup collective (board 506 “A”, narrowed) for a dialect to spell: the ruled reductions, shuffles, votes and broadcasts
of
crate::collective_is_ruled. The walker has already lowered the value and the operand to text, and the checker (check_kernel) has already refused a collective after a lane-divergentReturn(CollectiveAfterReturn) or under lane-divergent control (BarrierDivergent).
Enums§
- Coverage
- What the emitters of this repository do with a statement.
Constants§
- BIT_OPS
- The bitwise operators both dialects spell with the same operator text.
- COMPARISONS
- The comparisons both dialects spell with the same operator text; each gives
1or0in the dtype. - DECLINED_
434C - The reason text the four board 434 C refusals carry, so a caller and a test can recognise it.
- DECLINED_
434C_ EXT - The reason text the seven board 434 C extended refusals carry.
Traits§
- Dialect
- The spellings of one target language.
Functions§
- collective_
is_ ruled - Whether a
Collectiveofkindoverscopeis in the set CireSnave ruled liftable on non-NVIDIA targets (board 506 “A”, narrowed, 2026-11-26): subgroup-scope reductions (sum, product, max, min, and, or, xor), shuffles, votes and broadcasts. Everything else stays declined by name with the 434 C marker: scans (inclusive or exclusive, any op), user combines (ReduceWith,ScanWith),CollectiveTuple, and everyBlock-scope collective. - coverage
- The coverage of
stmt. This match has no wildcard arm on purpose: it names everyStmtvariant, so a new statement inunpoppedfails to compile here until someone decides which of the four it is. - declined_
by_ name - The by-name refusal of the first declined statement in
kernel(at any depth), orNone. - declined_
by_ name_ with - As
declined_by_name, for a target that lowers the ruled subgroup collectives (lift_subgroup: seecollective_is_ruled); the other collectives, and every other declined statement, are still refused by name. - lower_
kernel - Lower
kernelto source indialect, or say why it cannot. - not_
lowered_ note - The sentence an emitter adds to its “not lowered” refusal of
stmt: the row it waits for, the by-name ruling or the NVIDIA-specific reason, orNonefor a statement the emitters lower (a refusal of one is about its operands). - operator
- The operator text
ophas intable, if any. - scalarize
kernelwith every packed local,PackandExtractreplaced by scalars, orNonewhen it has no packed local (the common case: nothing to do).