Module Sarek_interp.Sarek_ir_interp_eval

val positional_field_index : string -> int option

Positional tuple-field index for a synthesized _tup_* record: "_0" -> Some 0, "_12" -> Some 12, any other name -> None. Used to resolve tuple-element field access without a record-registry entry.

val eval_intrinsic : Sarek_ir_interp_value.thread_state -> string list -> string -> Sarek_ir_interp_value.value list -> Sarek_ir_interp_value.value

Main intrinsic dispatcher - tries each category in order

val eval_intrinsic_by_type : string list -> string -> Sarek_ir_interp_value.value list -> Sarek_ir_interp_value.value

Try type-specific intrinsics based on path

Expression Evaluation

Array expression evaluation

Record and variant expression evaluation

Control flow expression evaluation

Cast and intrinsic expression evaluation

Main expression evaluator - dispatches to specialized handlers

val get_array : Sarek_ir_interp_value.env -> string -> Sarek_ir_interp_value.value array

Statement Execution

Cooperative matrix — backlog-62 slice 3

The interpreter is the ORACLE every backend is checked against, so this is not a courtesy implementation: test_vulkan_coopmat_ir_e2e compares the GLSL backend's output against these numbers bit for bit, and a skip here would let a coopmat kernel "agree" with an interpreter that never computed the product.

Every invocation holds the whole matrix and performs the whole operation; see Sarek_ir_interp_value.env.coopmats for why that is exact rather than approximate.

Only the INTEGER configurations are evaluated. Float accumulation is refused, and refused HERE rather than left to produce a plausible number, because the interpreter cannot honestly model it: SPV_KHR_cooperative_matrix leaves the ORDER of the k+1 additions to the implementation, so there is no single value a strict oracle could compare against (design document §5.1). Integer accumulation has no such freedom — the specification states it is exact at the precision of the result type — which is the entire reason the integer path lands under Sarek's existing strict contract.

val coopmat_refuse_float : 'a. Sarek_coopmat_types.component_type -> 'a
val coopmat_narrow : Sarek_coopmat_types.component_type -> int32 -> int32

Narrow an accumulated Int32 to the declared component type.

This is what makes the interpreter a faithful oracle for the 8-bit operand types rather than merely a plausible one: a value loaded into a u8 fragment from a buffer holding 300 is 44 on the device, and an oracle that kept 300 would disagree with correct hardware.

val get_coopmat : Sarek_ir_interp_value.env -> string -> Sarek_ir_interp_value.value array

Kernel Execution

val run_block : Sarek_ir_interp_value.env -> Sarek_ir_types.stmt -> (int * int * int) -> (int * int * int) -> (int * int * int) -> unit

Run all threads in a block with BSP barrier synchronization

val run_grid_sequential : Sarek_ir_interp_value.env -> Sarek_ir_types.stmt -> (int * int * int) -> (int * int * int) -> unit

Run all blocks in a grid (sequential)