Module Sarek_tuple_vec

L13 — host-side custom_type builders for tuple-typed vector elements.

Build the Spoc_core.Vector.custom_type needed by Vector.create_custom for a ('a * 'b) vector (or 3-tuple), so tuples can be stored/read from the host with OCaml tuple literals while the kernel manipulates them on device. The byte layout is taken from the shared layout authority so it matches the device element layout exactly. Only scalar-primitive components are supported in this tier.

module Vector = Spoc_core.Vector
type 'a component

A scalar tuple component.

val float32 : float component
val float64 : float component
val int32 : int32 component
val int64 : int64 component
val pair : 'a component -> 'b component -> ('a * 'b) Vector.custom_type

pair a b builds the custom type for a (a, b) tuple vector element.

val triple : 'a component -> 'b component -> 'c component -> ('a * 'b * 'c) Vector.custom_type

triple a b c builds the custom type for an (a, b, c) tuple vector element.

val descriptor_by_name : string -> 'a Vector.custom_type

descriptor_by_name name returns the canonical custom_type registered for a mangled tuple-shape name (e.g. "_tup_float32_int32") by a previous pair/triple call. Generated Native kernel code uses this to obtain the same Type_id the host vector carries. Raises if the shape was never built on the host. Not normally called directly.

type field_layout = {
  1. fl_name : string;
  2. fl_elttype : Sarek_ir_types.elttype;
  3. fl_offset : int;
}

Byte layout of one positional field (_0, _1, ...) of a tuple element.

type shape = {
  1. sh_name : string;
  2. sh_size : int;
  3. sh_fields : field_layout list;
}

The byte layout of a tuple-shape element: total size and per-field layout, taken from the shared layout authority so it matches the raw element bytes the host composite bridge marshals.

val lookup_shape : string -> shape option

lookup_shape name returns the registered byte layout of the tuple shape name (e.g. "_tup_float32_int32"), or None if no pair/triple has instantiated it yet. Used by the Interpreter to decode/encode tuple vector elements without depending on the interpreter's value model.