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, 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§
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§
- declined_
by_ name - The by-name refusal of the first declined statement in
kernel(at any depth), orNone. - lower_
kernel - Lower
kernelto source indialect, or say why it cannot. - operator
- The operator text
ophas intable, if any.