Spoc_core_base.Makemodule Ops : CUSTOM_OPStype ('a, 'b) scalar_kind = | Float16 : (float, Stdlib.Bigarray.float16_elt) scalar_kind| Float32 : (float, Stdlib.Bigarray.float32_elt) scalar_kind| Float64 : (float, Stdlib.Bigarray.float64_elt) scalar_kind| Int32 : (int32, Stdlib.Bigarray.int32_elt) scalar_kind| Int64 : (int64, Stdlib.Bigarray.int64_elt) scalar_kind| Char : (char, Stdlib.Bigarray.int8_unsigned_elt) scalar_kind| Complex32 : (Stdlib.Complex.t, Stdlib.Bigarray.complex32_elt) scalar_kindtype location = | CPU| GPU of Ops.device_t| Both of Ops.device_t| Stale_CPU of Ops.device_t| Stale_GPU of Ops.device_ttype 'a custom_type = {elem_size : int;type_id : 'a Sarek_ir_types.Type_id.t;vector_type_id : ('a, unit) t Sarek_ir_types.Type_id.t;get : Ops.handle -> int -> 'a;set : Ops.handle -> int -> 'a -> unit;name : string;ir_fields : (string * Sarek_ir_types.elttype) list option;Immediate fields of the element type in declaration order, when the element is a flat scalar record whose byte layout is derivable by Sarek_ir_layout.record_layout; None when it is not (variants, hand-written descriptors, unsupported field types). None means "no SoA plan derivable", never "no fields".
Carries the same trust as elem_size: it is untyped metadata about 'a that the type system does not relate to get/set. It is sound only because each producer derives the field list, the size and the accessors from a single layout computation.
}and (_, _) kind = | Scalar : ('a, 'b) scalar_kind -> ('a, 'b) kind| Custom : 'a custom_type -> ('a, unit) kindand (_, _) host_storage = | Bigarray_storage : ('a, 'b, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t ->
('a, 'b)
host_storage| Custom_storage : {ptr : Ops.handle;custom : 'a custom_type;length : int;} -> ('a, unit) host_storageand soa_binding = {soa_num_leaves : int;soa_aos_stride : int;soa_scatter : unit -> unit;soa_gather : unit -> unit;soa_to_device : Ops.device_t -> unit;soa_leaf_bufs : Ops.device_t -> Ops.device_buf list;soa_from_device : Ops.device_t -> unit;Inverse of soa_to_device: read every leaf back, then gather into the packed AoS host buffer. Without it a kernel's output is silently lost — the packed device buffer an ordinary Transfer.to_cpu reads is the one the SoA launch did not write.
soa_free_leaves : Ops.device_t option -> unit;Release the leaf device buffers — Some dev on that device, None on every device — then NARROW soa_leaves_live: still set iff it already was and some leaf survives. Without the release, Transfer.free_all_buffers returned ZERO bytes on a transparent SoA vector (the packed buffer it iterates is never allocated under this ABI): a leak, not wrong data, since each leaf also carries a Gpu_memory.register_finalizer. Without consulting the surviving leaves — it used to assign false — a per-device free disowned live leaves on every OTHER device, and that IS wrong data: the drain-before-free consults this flag. Without the conjunction with the PREVIOUS value it was wrong in the mirror direction: a packed launch clears the flag and leaves those buffers allocated, so deriving from allocation alone resurrected ownership of leaves that had already been gathered and given up.
soa_leaves_live : bool Stdlib.ref;Does the device hold results in the LEAVES rather than in the packed AoS buffer? What lets the read-back path follow the launch's ABI decision instead of re-deriving it.
Four writers, and only four, of which exactly one can SET it: soa_to_device sets it; Execute.transfer_vectors_to_device clears it when a launch takes the packed ABI; Transfer.to_device clears it after a packed host->device upload; soa_free_leaves narrows it. So it states the ABI of the most recent operation that made a device copy authoritative, rather than of some operation. Every read-back path only READS it. false whenever the launch used the packed AoS ABI — an external source through run_source, or any non-CUDA/PTX backend.
}Opt-in Structure-of-Arrays binding for a custom (flat-record) vector (backlog-54); present iff the vector came from Soa_vector.create_transparent, its only producer. There is no Vector.create ~layout:SoA and no layout parameter — the Tier 1b handoff proposed one and it was rejected as a layer inversion.
Deliberately closures and plain ints rather than a Soa.plan. This library is FFI-free and also builds as .bc.js (sarek/core/ffi_free_gate enforces both), while Soa/Soa_vector use Ctypes and live above it — so the transpose crosses down as behaviour, not as types. See the implementation for the full rationale, including why this is a record field instead of the host_storage constructor the Tier 1b handoff proposed.
and ('a, 'b) t = {host : ('a, 'b) host_storage;device_buffers : (int, Ops.device_buf) Stdlib.Hashtbl.t;length : int;kind : ('a, 'b) kind;mutable location : location;mutable auto_sync : bool;id : int;mutable soa : soa_binding option;None for every vector but one from Soa_vector.create_transparent (no ~layout parameter exists — see soa_binding). Read only by the launch path; every host-side operation ignores it, which is why get/set and the PPX accessors are unchanged.
}val to_bigarray_kind : ('a, 'b) scalar_kind -> ('a, 'b) Stdlib.Bigarray.kindval scalar_elem_size : ('a, 'b) scalar_kind -> intval elem_size : ('a, 'b) kind -> intval scalar_kind_name : ('a, 'b) scalar_kind -> stringval kind_name : ('a, 'b) kind -> stringval float16_type_id : float Sarek_ir_types.Type_id.tval float32_type_id : float Sarek_ir_types.Type_id.tval float64_type_id : float Sarek_ir_types.Type_id.tval int32_type_id : int32 Sarek_ir_types.Type_id.tval int64_type_id : int64 Sarek_ir_types.Type_id.tval char_type_id : char Sarek_ir_types.Type_id.tval complex32_type_id : Stdlib.Complex.t Sarek_ir_types.Type_id.tval scalar_type_id : ('a, 'b) scalar_kind -> 'a Sarek_ir_types.Type_id.tval type_id : ('a, 'b) kind -> 'a Sarek_ir_types.Type_id.tval float16_vector_type_id :
(float, Stdlib.Bigarray.float16_elt) t Sarek_ir_types.Type_id.tval float32_vector_type_id :
(float, Stdlib.Bigarray.float32_elt) t Sarek_ir_types.Type_id.tval float64_vector_type_id :
(float, Stdlib.Bigarray.float64_elt) t Sarek_ir_types.Type_id.tval int32_vector_type_id :
(int32, Stdlib.Bigarray.int32_elt) t Sarek_ir_types.Type_id.tval int64_vector_type_id :
(int64, Stdlib.Bigarray.int64_elt) t Sarek_ir_types.Type_id.tval char_vector_type_id :
(char, Stdlib.Bigarray.int8_unsigned_elt) t Sarek_ir_types.Type_id.tval complex32_vector_type_id :
(Stdlib.Complex.t, Stdlib.Bigarray.complex32_elt) t Sarek_ir_types.Type_id.tval vector_type_id : ('a, 'b) kind -> ('a, 'b) t Sarek_ir_types.Type_id.tval create_scalar :
('a, 'b) scalar_kind ->
?dev:Ops.device_t ->
int ->
('a, 'b) tval create : ('a, 'b) kind -> ?dev:Ops.device_t -> int -> ('a, 'b) tval create_custom : 'a custom_type -> ?dev:Ops.device_t -> int -> ('a, unit) tval of_bigarray :
('a, 'b) scalar_kind ->
('a, 'b, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t ->
('a, 'b) tval of_raw_handle : 'a custom_type -> nativeint -> int -> ('a, unit) tval to_bigarray :
('a, 'b) t ->
('a, 'b, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.tval has_buffer : ('a, 'b) t -> Ops.device_t -> boolval get_buffer : ('a, 'b) t -> Ops.device_t -> Ops.device_buf optionval custom_to_bytes : 'a custom_type -> 'a -> bytesSerialize a custom-type value to bytes. Delegates to Ops.custom_to_bytes. Raises on jsoo builds (custom-type device path not yet implemented).
val custom_of_bytes : 'a custom_type -> bytes -> 'aDeserialize bytes to a custom-type value. Delegates to Ops.custom_of_bytes. Raises on jsoo builds (custom-type device path not yet implemented).
val is_sub : ('a, 'b) t -> boolval depth : ('a, 'b) t -> intval parent_id : ('a, 'b) t -> int optionval sub_start : ('a, 'b) t -> int optionval sub_ok_range : ('a, 'b) t -> int optionval sub_ko_range : ('a, 'b) t -> int optionval partition_host : ('a, 'b) t -> Ops.device_t array -> ('a, 'b) t arrayval register_sync_callback : sync_callback -> unitval ensure_cpu_sync : ('a, 'b) t -> unitval host_handle : ('a, 'b) t -> Ops.handleval host_raw : ('a, 'b) t -> nativeintval float32 : (float, Stdlib.Bigarray.float32_elt) kindval float64 : (float, Stdlib.Bigarray.float64_elt) kindval int32 : (int32, Stdlib.Bigarray.int32_elt) kindval int64 : (int64, Stdlib.Bigarray.int64_elt) kindval char : (char, Stdlib.Bigarray.int8_unsigned_elt) kindval complex32 : (Stdlib.Complex.t, Stdlib.Bigarray.complex32_elt) kind