Module Sarek_metal.Metal_api

val memcpy_lazy : (unit Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr) lazy_t

memcpy from libc for memory transfers, with the OCaml runtime lock released (a large copy would otherwise stop every other domain's minor collections). Both arguments are raw addresses, which the call does not root: the caller keeps the memory behind them allocated until memcpy returns (bigarrays end with ignore (Sys.opaque_identity ba); MTLBuffer contents stays valid while the buffer is retained). See Metal_bindings.msg_void_blocking_lazy.

val memcpy : dst:unit Ctypes_static.ptr -> src:unit Ctypes_static.ptr -> size:int -> unit

Exceptions

exception Metal_error of string

Deprecated: no longer raised. check below now raises the canonical Metal_error.Metal_error (a Backend_error alias) via the shared Sarek_backend_error.Backend_error.Make.check funnel. Kept only so out-of-tree code matching on Metal_api.Metal_error msg still compiles (this library is opam-published).

  • deprecated no longer raised; Metal_api.check now raises Metal_error.Metal_error (Backend_error) - catch that instead
val check : string -> Metal_types.mtl_error -> unit

Check Metal result and raise a canonical Backend_error on failure.

Device Management

module Device : sig ... end

Host memory

val page_size : unit -> int

The OS page size in bytes (16384 on Apple silicon).

val alloc_aligned : byte_size:int -> nativeint

byte_size bytes of host memory aligned to the OS page size (posix_memalign), uninitialised. Released only by free_aligned.

val free_aligned : nativeint -> unit

Command Queue Management

module CommandQueue : sig ... end
val mark_fast_math_fallback : unit -> unit

Without the conformant compile options the device compiler runs in Metal's fast-math mode, which may reassociate: a fused epilogue kernel is then no longer guaranteed to equal the unfused pair. Mark Metal inexact so epilogue fusion stays off (docs/fp-contraction-policy.md section 14, Spoc_framework_registry.Fp_exactness).

val probe_conformant_options : unit -> unit

Build the conformant options once at start-up, so a fallback is known before the first launch decides whether to fuse an epilogue.

val force_all : unit -> unit

Force every lazily built FFI stub on the launch, copy and release paths (see Metal_bindings.force_all).

module Pending : sig ... end

Memory Management

module Memory : sig ... end

Library and Function Management

module Library : sig ... end

Compute Pipeline Management

module ComputePipeline : sig ... end

Kernel Execution

module Kernel : sig ... end

Synchronization

val synchronize : 'a -> unit

Profiling

module Profiling : sig ... end