Sarek_interp.Sarek_ir_interptype value = Sarek_ir_interp_value.value = Re-export value type and constructors for external callers
val to_int : Sarek_ir_interp_value.value -> intval to_int32 : Sarek_ir_interp_value.value -> int32val to_int64 : Sarek_ir_interp_value.value -> int64val to_float32 : Sarek_ir_interp_value.value -> floatval to_float64 : Sarek_ir_interp_value.value -> floatval to_bool : Sarek_ir_interp_value.value -> booltype thread_state = Sarek_ir_interp_value.thread_state = {thread_idx : int * int * int;block_idx : int * int * int;block_dim : int * int * int;grid_dim : int * int * int;}Re-export thread_state type for external callers
type env = Sarek_ir_interp_value.env = {vars : (int, value) Stdlib.Hashtbl.t;vars_by_name : (string, value) Stdlib.Hashtbl.t;arrays : (string, value array) Stdlib.Hashtbl.t;funcs : (string, Sarek_ir_types.helper_func) Stdlib.Hashtbl.t;policy : Sarek_policy.Budget.t;coopmats : (int * string, value array) Stdlib.Hashtbl.t;}Re-export env type for external callers
val create_env :
?policy:Sarek_policy.Budget.t ->
unit ->
Sarek_ir_interp_value.envval copy_env : Sarek_ir_interp_value.env -> Sarek_ir_interp_value.envval bind_var :
Sarek_ir_interp_value.env ->
Sarek_ir_types.var ->
Sarek_ir_interp_value.value ->
unitval lookup_var :
Sarek_ir_interp_value.env ->
Sarek_ir_types.var ->
Sarek_ir_interp_value.valueval eval_binop :
Sarek_ir_types.binop ->
Sarek_ir_interp_value.value ->
Sarek_ir_interp_value.value ->
Sarek_ir_interp_value.valueval eval_unop :
Sarek_ir_types.unop ->
Sarek_ir_interp_value.value ->
Sarek_ir_interp_value.valueval eval_expr :
Sarek_ir_interp_value.thread_state ->
Sarek_ir_interp_value.env ->
Sarek_ir_types.expr ->
Sarek_ir_interp_value.valueval exec_stmt :
Sarek_ir_interp_value.thread_state ->
Sarek_ir_interp_value.env ->
Sarek_ir_types.stmt ->
unitBlocks run on Cpu_domain_pool, shared with the Native barrier path, created on the first parallel launch and retired when idle.
val run_grid_parallel :
Sarek_ir_interp_value.env ->
Sarek_ir_types.stmt ->
(int * int * int) ->
(int * int * int) ->
unitRun all blocks in a grid (parallel - distributes blocks across domain pool)
val run_grid :
Sarek_ir_interp_value.env ->
Sarek_ir_types.stmt ->
(int * int * int) ->
(int * int * int) ->
unitRun all blocks in a grid (uses parallel or sequential based on flag)
val run_kernel :
Sarek_ir_types.kernel ->
block:(int * int * int) ->
grid:(int * int * int) ->
(string * arg) list ->
unitRun a kernel on CPU
These functions work with typed Kernel_arg.t values. This is the preferred interface for Native/Interpreter backends.
val vector_to_array : 'a 'b. ('a, 'b) Spoc_core.Vector.t -> value arrayConvert V2 Vector to interpreter value array. Uses the vector's element type to create properly typed values.
val array_to_vector : 'a 'b. value array -> ('a, 'b) Spoc_core.Vector.t -> unitWrite interpreter value array back to V2 Vector
Existential wrapper to track V2 Vector + its interpreter array for writeback
type exec_writeback = | Exec_writeback : (module Spoc_framework.Typed_value.EXEC_VECTOR)
* value array -> exec_writebackval same_vector :
'a 'b 'c 'd. ('a, 'b) Spoc_core.Vector.t ->
('c, 'd) Spoc_core.Vector.t ->
boolWhether two vectors are the same vector.
Physical identity, taken on the vector's own device_buffers table: it is allocated once per vector and never replaced, it has one type whatever the vectors' element types (so two vectors of different types can be compared without Obj), and a comparison of the records themselves would need both to have the same type. The vector id is deliberately NOT used: ids come from a non-atomic counter and can collide across domains (R-1).
val bind_vector :
writeback list Stdlib.ref ->
('a, 'b) Spoc_core.Vector.t ->
to_array:(('a, 'b) Spoc_core.Vector.t -> value array) ->
value arrayThe value array bound to vec: the one already bound among writebacks if vec is a vector passed before, otherwise a fresh one from to_array, which is recorded in writebacks.
Two kernel parameters bound to the same vector must share ONE value array: a private copy each would make a write through one invisible to a read through the other, and the writebacks would then overwrite each other in an order that depends on the entry point. Binding by identity gives the semantics of the device, where both parameters are the same buffer.
val value_of_bytes : bytes -> Sarek_tuple_vec.field_layout -> valueval bytes_of_shape : Sarek_tuple_vec.shape -> value array -> bytesval value_of_typed_value : Spoc_framework.Typed_value.typed_value -> valueval typed_value_of_value :
(module Spoc_framework.Typed_value.EXEC_VECTOR with type elt = 'a) ->
value ->
Spoc_framework.Typed_value.typed_value optionval exec_vector_to_array :
(module Spoc_framework.Typed_value.EXEC_VECTOR) ->
value arrayval array_to_exec_vector :
(module Spoc_framework.Typed_value.EXEC_VECTOR) ->
value array ->
unitval same_exec_vector :
(module Spoc_framework.Typed_value.EXEC_VECTOR) ->
(module Spoc_framework.Typed_value.EXEC_VECTOR) ->
boolWhether two EXEC_VECTOR wrappers stand for the same vector.
Their underlying values can only be compared once their types are known to be equal, which the type ids witness. Execute.exec_arg_of_vector gives every wrapper of a Vector.t the SAME stable underlying_type_id (per element kind) and underlying = v, so two arguments that are one vector compare physically equal. A wrapper that mints a fresh id per instance (the interpreter plugin's own buffer wrapper) never matches: it wraps a device buffer, not a host vector, and no launch built from host vectors reaches it.
val bind_exec_vector :
exec_writeback list Stdlib.ref ->
(module Spoc_framework.Typed_value.EXEC_VECTOR) ->
value arraybind_vector for an EXEC_VECTOR argument.
val args_from_exec_args :
Sarek_ir_types.kernel ->
Spoc_framework.Framework_sig.exec_arg list ->
(string * arg) list * exec_writeback listval run_kernel_with_exec_args :
Sarek_ir_types.kernel ->
block:(int * int * int) ->
grid:(int * int * int) ->
Spoc_framework.Framework_sig.exec_arg list ->
unitval args_from_kernel_args :
Sarek_ir_types.kernel ->
Spoc_core.Kernel_arg.t list ->
(string * arg) list * writeback listConvert Kernel_arg.t list to interpreter args, tracking vectors for writeback
val run_kernel_with_args :
Sarek_ir_types.kernel ->
block:(int * int * int) ->
grid:(int * int * int) ->
Spoc_core.Kernel_arg.t list ->
unitRun kernel with V2 Vector arguments (Kernel_arg.t list). This is the preferred entry point for Native/Interpreter backends. Handles conversion to/from interpreter format with proper writeback.