Module Device.Multi_buffer
Buffers spanning multiple devices.
A multi-device buffer holds one Buffer.t per device, all sharing the same size and dtype. Operations apply element-wise across the per-device buffers.
Types
Constructors
val create :
devices:string list ->
size:int ->
dtype:Tolk_uop.Dtype.t ->
?spec:Buffer_spec.t ->
unit ->
tcreate ~devices ~size ~dtype ?spec () is a multi-device buffer with one underlying buffer per device name in devices, each resolved through the device registry (get).
spec defaults to Buffer_spec.default. The trailing unit argument is needed because spec is optional.
Raises Invalid_argument if devices is empty and Failure if a device name cannot be opened.
of_bufs bufs is a multi-device buffer stacking the per-device buffers bufs.
Raises Invalid_argument if bufs is empty or the buffers disagree in size or dtype.
val view : t -> size:int -> dtype:Tolk_uop.Dtype.t -> offset:int -> tview t ~size ~dtype ~offset is a multi-device buffer viewing each underlying buffer at byte offset for size elements of dtype. See Buffer.view.
Accessors
bufs t is the underlying per-device buffers, one per device in the order given to create.
val size : t -> intsize t is the element count (same across all buffers).
val dtype : t -> Tolk_uop.Dtype.tdtype t is the element dtype (same across all buffers).
val is_allocated : t -> boolis_allocated t is true iff all underlying buffers are allocated.