Module Opencl_api.Memory

type 'a buffer = {
  1. handle : Opencl_types.cl_mem;
  2. size : int;
  3. elem_size : int;
  4. context : Context.t;
  5. host_alias : nativeint option;
}
val alloc : Context.t -> int -> ('a, 'b) Stdlib.Bigarray.kind -> 'c buffer
val host_ptr_usable : align_bytes:int -> nativeint -> bool

Whether USE_HOST_PTR over addr is aliased by the runtime rather than privately copied: the address must meet the device's alignment.

val host_ptr_refusal : accept_device:bool -> align_bytes:int -> max_alloc_bytes:Stdlib.Int64.t -> address:nativeint -> byte_size:int -> Spoc_framework.Framework_sig.host_ptr_refusal option

Why a USE_HOST_PTR buffer of byte_size bytes at address is refused, cheapest check first; None when it is accepted. accept_device: the device takes host-pointer buffers (a CPU device). Pure: no device is touched.

val alloc_with_host_ptr : Context.t -> int -> ('a, 'b) Stdlib.Bigarray.kind -> unit Ctypes_static.ptr -> 'c buffer

Allocate buffer over the host pointer (CL_MEM_USE_HOST_PTR). Host access must go through sync_host.

val alloc_custom : Context.t -> size:int -> elem_size:int -> 'a buffer

Allocate buffer for custom types with explicit element size in bytes

val aliases_host : 'a buffer -> nativeint -> bool

aliases_host buf addr: buf is a USE_HOST_PTR buffer over addr, so host copies at addr become map/unmap synchronisation.

val sync_host : CommandQueue.t -> 'a buffer -> flags:Opencl_types.cl_bitfield -> byte_size:int -> unit
val free : 'a buffer -> unit
val host_to_device : CommandQueue.t -> src:('a, 'b, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t -> dst:'c buffer -> unit
val device_to_host : CommandQueue.t -> src:'a buffer -> dst:('b, 'c, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t -> unit
val host_ptr_to_device : CommandQueue.t -> src_ptr:unit Ctypes.ptr -> byte_size:int -> dst:'a buffer -> unit

Transfer from raw pointer to device buffer (for custom types)

val device_to_host_ptr : CommandQueue.t -> src:'a buffer -> dst_ptr:unit Ctypes.ptr -> byte_size:int -> unit

Transfer from device buffer to raw pointer (for custom types)