Module Spoc_core.Host_ptr_buffer

type error =
  1. | Refused of {
    1. device : string;
    2. reason : Spoc_framework.Framework_sig.host_ptr_refusal;
    }
    (*

    The backend refused (device type, alignment, size, backend).

    *)
  2. | Unknown_framework of {
    1. framework : string;
    }
  3. | Not_bigarray_backed of {
    1. vector_id : int;
    }
    (*

    Custom-type or device-only vector: no Bigarray to share.

    *)
  4. | Buffer_exists of {
    1. vector_id : int;
    2. device : string;
    }
    (*

    The vector already has a buffer on the device; sharing would leave two device copies. Free it first (Transfer.free_buffer).

    *)

Why a vector could not be given a host-pointer buffer.

val refusal_message : Spoc_framework.Framework_sig.host_ptr_refusal -> string
val error_message : error -> string
val install : ('a, 'b) Vector.t -> Device.t -> ('a, 'b, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t -> ('a, 'b) Vector.scalar_kind -> (unit, error) Stdlib.result
val attach : ('a, 'b) Vector.t -> Device.t -> (unit, error) Stdlib.result

attach vec dev gives vec a buffer on dev created over its Bigarray's memory. See the module header for the lifetime, alignment and synchronisation contract.

val of_bigarray : Device.t -> ('a, 'b) Vector.scalar_kind -> ('a, 'b, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t -> (('a, 'b) Vector.t, error) Stdlib.result

A vector over ba (no copy), attached to dev.

How vec's buffer on dev relates to its host storage; None when it has no buffer there.

val publish_host_writes : ('a, 'b) Vector.t -> Device.t -> unit

Declares the Bigarray authoritative and makes its contents visible to launches on dev enqueued afterwards (map/unmap for a host-pointer buffer, a copy for any other). Any device-side change not yet read back is discarded.

val acquire_device_writes : ('a, 'b) Vector.t -> Device.t -> unit

Makes the writes of the launches on dev issued so far visible in the Bigarray (blocking map for reading; waits for them). No-op when vec's device copy is not on dev.