Module Spoc_core.Vector_storage

val next_id : int Stdlib.ref

Global vector ID counter

Creation

val create_scalar : ('a, 'b) Vector_types.scalar_kind -> ?dev:Device.t -> int -> ('a, 'b) Vector_types.t

Create a new scalar vector on CPU

val create : 'a 'b. ('a, 'b) Vector_types.kind -> ?dev:Device.t -> int -> ('a, 'b) Vector_types.t

Create from kind (allocates storage for custom types too)

val create_custom : 'a Vector_types.custom_type -> ?dev:Device.t -> int -> ('a, unit) Vector_types.t

Create a custom vector with explicit type descriptor

Creation from Existing Data

val of_bigarray : ('a, 'b) Vector_types.scalar_kind -> ('a, 'b, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t -> ('a, 'b) Vector_types.t

Create from existing Bigarray (shares memory)

val of_ctypes_ptr : 'a Vector_types.custom_type -> unit Ctypes.ptr -> int -> ('a, unit) Vector_types.t

Create from existing ctypes pointer (shares memory)

Accessors

val to_bigarray : 'a 'b. ('a, 'b) Vector_types.t -> ('a, 'b, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t
val of_list : 'a 'b. ('a, 'b) Vector_types.kind -> 'a list -> ('a, 'b) Vector_types.t

Create from OCaml list

val of_array : 'a 'b. ('a, 'b) Vector_types.kind -> 'a array -> ('a, 'b) Vector_types.t

Create from OCaml array

Device buffer bookkeeping

val has_buffer : ('a, 'b) Vector_types.t -> Device.t -> bool

Check if vector has buffer on specific device

val get_buffer : ('a, 'b) Vector_types.t -> Device.t -> Vector_types.device_buffer option

Get device buffer if allocated

Subvector Metadata

type sub_meta = {
  1. parent_id : int;
  2. start : int;
  3. ok_range : int;
  4. ko_range : int;
  5. depth : int;
}
val subvector_meta : (int, sub_meta) Stdlib.Hashtbl.t
val is_sub : ('a, 'b) Vector_types.t -> bool
val get_sub_meta : ('a, 'b) Vector_types.t -> sub_meta option
val depth : ('a, 'b) Vector_types.t -> int
val parent_id : ('a, 'b) Vector_types.t -> int option
val sub_start : ('a, 'b) Vector_types.t -> int option
val sub_ok_range : ('a, 'b) Vector_types.t -> int option
val sub_ko_range : ('a, 'b) Vector_types.t -> int option

Copy & Slicing

val copy_host_only : ('a, 'b) Vector_types.t -> ('a, 'b) Vector_types.t

Copy vector (CPU data only). Caller must ensure sync if needed.

val sub_vector_host : ('a, 'b) Vector_types.t -> start:int -> len:int -> ('a, 'b) Vector_types.t

Create subvector that views the same host storage with an offset

val sub_vector : ('a, 'b) Vector_types.t -> start:int -> len:int -> ok_range:int -> ko_range:int -> ('a, 'b) Vector_types.t

Create subvector and record metadata

val partition_host : ('a, 'b) Vector_types.t -> Device.t array -> ('a, 'b) Vector_types.t array

Partition host storage evenly across devices (no device buffers)