Skip to main content

Crate vulkane_kernel_text

Crate vulkane_kernel_text 

Source
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.

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 1 or 0 in 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), or None.
lower_kernel
Lower kernel to source in dialect, or say why it cannot.
operator
The operator text op has in table, if any.
scalarize
kernel with every packed local, Pack and Extract replaced by scalars, or None when it has no packed local (the common case: nothing to do).