Module Realize.Buffers

Maps buffer UOps to concrete device buffers.

A Tolk_uop.Ops.t.Buffer node is backed by a fresh allocation the first time it is resolved — on the node's own device placement, resolved through the device registry (Device.get), with one allocation per device for multi-device placements — then cached by node identity; seeding a node with seed overrides that allocation.

type t

The type for buffer bindings.

val create : device:Device.t -> t

create ~device is an empty binding allocating on device the nodes that carry no device placement of their own.

val seed : t -> Tolk_uop.Uop.t -> Device.Buffer.t -> unit

seed t node buf binds node to buf, overriding lazy allocation.

val seed_multi : t -> Tolk_uop.Uop.t -> Device.Multi_buffer.t -> unit

seed_multi t node mbuf binds node to the multi-device buffer mbuf, overriding lazy allocation.

val remove : t -> Tolk_uop.Uop.t -> unit

remove t node drops node's binding, if any.

val mem : t -> Tolk_uop.Uop.t -> bool

mem t node is true iff node is bound.

val find_buffer : t -> Tolk_uop.Uop.t -> buffer option

find_buffer t node is the buffer bound to node, if any.

val find_opt : t -> Tolk_uop.Uop.t -> Device.Buffer.t option

find_opt t node is the single-device buffer bound to node, if any.

Raises Invalid_argument if node is bound to a multi-device buffer.

val buffer_of_node : t -> Tolk_uop.Uop.t -> buffer

buffer_of_node t node is the buffer backing the Tolk_uop.Ops.t.Buffer node, allocating and caching it on first use.

val of_buffer_node : t -> Tolk_uop.Uop.t -> Device.Buffer.t

of_buffer_node t node is buffer_of_node for a node backed by a single-device buffer.

Raises Invalid_argument if node is backed by a multi-device buffer.

val iter : t -> (buffer -> unit) -> unit

iter t f applies f to every bound buffer.

val clear : t -> unit

clear t drops all bindings.