Cuda.DeviceptrThis module introduces the type of pointers into on-device global memory, and stream-independent memory management functions. All functions from this module run synchronously. See: Memory Management.
A pointer to a memory location on a device. See CUdeviceptr.
A non-owning borrow of a sub-region of a device allocation. The base Deviceptr.t retains ownership and its finalizer will free the allocation; the region is never freed independently and carries no finalizer. offset_bytes is the byte offset into base; offset 0 addresses the same location as base itself. Use offset to construct a region and region_of to inject a bare Deviceptr.t at offset 0.
offset ptr ~bytes:n returns a region starting n bytes into ptr's allocation. ptr retains ownership; the region is a non-owning borrow. bytes is in bytes. Offset 0 reproduces the same address as ptr.
region_of ptr is offset ptr ~bytes:0: a region at byte offset 0, i.e. the same address as ptr. Useful when a consuming site requires a region.
val sexp_of_t : t -> Sexplib0.Sexp.tval hash : t -> intConverts the pointer to an OCaml int using Unsigned.UInt64.to_int (truncating bits as needed).
val string_of : t -> stringHexadecimal representation of the pointer.
val mem_alloc : size_in_bytes:int -> tThe memory is aligned, is not cleared. See cuMemAlloc.
The pointer is finalized using cuMemFree. This is safe without needing to set the proper context.
val mem_free : t -> unitDouble-freeing is prevented by a flag: multiple calls on the same Deviceptr.t are safe. See cuMemFree.
val memcpy_H_to_D_unsafe :
dst:t ->
src:unit Ctypes.ptr ->
size_in_bytes:int ->
unitSee cuMemcpyHtoD.
val memcpy_H_to_D :
?host_offset:int ->
?length:int ->
?dst_offset:int ->
dst:t ->
src:('a, 'b, 'c) Stdlib.Bigarray.Genarray.t ->
unit ->
unitCopies the bigarray (or its interval) into the device memory. host_offset and length are in numbers of elements. dst_offset is a device-side byte offset into dst (default 0), letting the copy target a sub-region of a larger allocation; when length is not given the copied size is reduced by dst_offset so it does not write past the end of dst. See memcpy_H_to_D_unsafe.
val alloc_and_memcpy : ('a, 'b, 'c) Stdlib.Bigarray.Genarray.t -> tCombines mem_alloc and memcpy_H_to_D.
val memcpy_D_to_H_unsafe :
dst:unit Ctypes.ptr ->
src:t ->
size_in_bytes:int ->
unitSee cuMemcpyDtoH.
val memcpy_D_to_H :
?host_offset:int ->
?length:int ->
?src_offset:int ->
dst:('a, 'b, 'c) Stdlib.Bigarray.Genarray.t ->
src:t ->
unit ->
unitCopies from the device memory into the bigarray (or its interval). host_offset and length are in numbers of elements: length is the count of elements copied (not an end index), filling dst.(host_offset .. host_offset + length) and mirroring how memcpy_H_to_D reads src.(host_offset .. host_offset + length). src_offset is a device-side byte offset into src (default 0), letting the copy read from a sub-region of a larger allocation; when length is not given the copied size is reduced by src_offset so it does not read past the end of src. See memcpy_D_to_H_unsafe.
val memcpy_D_to_D :
?kind:('a, 'b) Stdlib.Bigarray.kind ->
?length:int ->
?size_in_bytes:int ->
?dst_offset:int ->
?src_offset:int ->
dst:t ->
src:t ->
unit ->
unitCopies between two memory positions on the same device. The size to copy can optionally be provided in numbers of elements via kind and length. Provide either both kind and length, or just size_in_bytes. dst_offset and src_offset are device-side byte offsets into dst and src respectively (default 0), letting either end target a sub-region of a larger allocation. See cuMemcpyDtoD.
val memcpy_peer :
?kind:('a, 'b) Stdlib.Bigarray.kind ->
?length:int ->
?size_in_bytes:int ->
?dst_offset:int ->
?src_offset:int ->
dst:t ->
dst_ctx:Context.t ->
src:t ->
src_ctx:Context.t ->
unit ->
unitCopies between memory positions on two different devices. The size to copy can optionally be provided in numbers of elements via kind and length. Provide either both kind and length, or just size_in_bytes. dst_offset and src_offset are device-side byte offsets into dst and src respectively (default 0), letting either end target a sub-region of a larger allocation. See cuMemcpyPeer.
val memset_d8 : ?offset:int -> t -> Unsigned.uchar -> length:int -> unitoffset is a device-side byte offset into t (default 0), letting the memset target a sub-region of a larger allocation. See cuMemsetD8.
val memset_d16 : ?offset:int -> t -> Unsigned.ushort -> length:int -> unitlength is in number of elements. offset is a device-side byte offset into t (default 0). See cuMemsetD16.
val memset_d32 : ?offset:int -> t -> Unsigned.uint32 -> length:int -> unitlength is in number of elements. offset is a device-side byte offset into t (default 0). See cuMemsetD32.