Schedulers.Multidevmodule Backend : Ir.Backend_impl.For_add_schedulerinclude Ir.Backend_intf.Backend_device_commoninclude Ir.Backend_intf.Deviceinclude Ir.Backend_intf.Device_typesinclude Ir.Backend_intf.Device_config_commonval sexp_of_dev : dev -> Sexplib0.Sexp.tval sexp_of_runner : runner -> Sexplib0.Sexp.tAn event tracks if a device's runner finished computing past a particular point in its schedule. These values are used internally for scheduling across devices/queues of the backend, and can be used for explicit scheduling.
val sexp_of_event : event -> Sexplib0.Sexp.ttype nonrec device = (dev, runner, event) Ir.Backend_intf.deviceval sexp_of_device : device -> Sexplib0.Sexp.ttype nonrec context = (dev, runner, event) Ir.Backend_intf.contextval sexp_of_context : context -> Sexplib0.Sexp.tinclude Ir.Backend_intf.Slab_alloc with type device := deviceval alloc_pool :
?mode:Ir.Tnode.memory_mode ->
device ->
pool_id:Base.int ->
size_in_bytes:Base.int ->
alignment:Base.int ->
Base.unitAllocates the slab for pool_id on device. The optional ?mode carries the tnode's memory mode so backends can pick a storage mode (Metal private vs. shared); backends that do not care ignore it.
val free_pool : (device -> pool_id:Base.int -> Base.unit) Base.optionFrees the slab for pool_id and drops its table entry. None for backends that rely on GC.
val has_pool : device -> pool_id:Base.int -> Base.boolWhether the backend's private pool table currently holds an entry for (device, pool_id).
val zero_ranges :
device ->
(Ir.Backend_intf.buffer_loc * Base.int) Base.list ->
Base.unitZero-initializes each (loc, size_in_bytes): size_in_bytes at base_of loc.pool_id + loc.offset. When it returns, every range reads as zero to a later host write, transfer or kernel on device. One call for all of a context delta's ranges (gh-ocannl-1675): Metal fills them in one command buffer and waits once, where a call per range waited for a GPU round trip each.
val make_context :
?ctx_buffers:Ir.Backend_intf.ctx_buffers ->
?optimize_ctx:Ir.Low_level.optimize_ctx ->
device ->
contextReturns a context without a parent.
val make_child :
?ctx_buffers:Ir.Backend_intf.ctx_buffers ->
?optimize_ctx:Ir.Low_level.optimize_ctx ->
?merge_buffer_node:Ir.Tnode.t Base.option ->
context ->
contextReturns a context with the same Backend_intf.context.device, Backend_intf.context.ctx_buffers, Backend_intf.context.optimize_ctx, Backend_intf.context.merge_buffer_node if omitted, as the given context's, which is also the Backend_intf.context.parent.
val get_name : device -> Base.stringval event_device_id : event -> Base.int Base.optionThe device that recorded the event. None only for the synchronous CPU backend, whose events are already complete and whose waits cannot expire. Used by the shared wedge guard.
val sync : event -> Base.unitBlocks till the event completes, if it's not done already.
It is rarely needed to call sync explicitly, because it should always be called internally when necessary, in particular before extracting values from host.
val is_done : event -> Base.boolWhether the event completed.
Schedules waiting for the given event on the context's device.
NOTE: it should rarely be needed to call will_wait_for explicitly, because it should always be called internally when necessary.
Returns a sexp description of the properties of all devices, in the shape device_dump documents and parse_static_properties reads: (<backend>_devices (device (key value) ...) (device (key value) ...) ...) -- a group atom naming the dump, then exactly one Sexp.message-shaped entry per device, in ordinal order. See parse_static_properties for the full contract (gh-ocannl-710).
A function so that computing it (device enumeration) does not run at backend-module initialization: singleton backends instantiate eagerly at program startup, where touching a driver could fail runs that never use the backend.
val timing_identity : device -> Ir.Backend_intf.timing_identity Base.optionConcrete device identity, with best available toolchain metadata. Outer None means device discovery is unavailable and disables persistent schedule AND placement I/O. Missing toolchain metadata alone does not disable persistence. Query lazily, never at initialization.
val align_timing_queue :
device ->
await:(Base.unit -> Base.unit) ->
Ir.Hip_timing_phase.probe_event Base.optionPrepare the selected runner for a timing call. await supplies the caller's bounded wait for the probe and any padding. Returns Some probe when preparation submitted work and decoded a phase probe, or None when no phase probe is active on this runner.
val hardware_limits : Base.unit -> Ir.Backend_intf.hardware_limitsConservative per-workgroup device limits: on multi-device backends the minimum across the devices, so code compiled once (compilation is not per-device) is valid wherever it links. All-None for backends that do not bind hardware axes. A function for the same reason as static_properties: computing it (device enumeration) must not run at backend-module initialization.
val thread_scratch_limit : device -> Base.int Base.optionPer-work-item private (scratch) memory budget enforced at link time on this device, in bytes, or None when no post-link per-device scratch limit is enforced (non-HIP backends, HIP with ocannl_hip_scratch_validation=false, or a device reporting no usable occupancy figures). Unlike hardware_limits, which is conservative across all devices of a backend, this queries device itself and returns the exact limit the backend's post-link validator enforces (gh-ocannl-2404).
val codegen_capabilities : Base.unit -> Ir.Backend_intf.codegen_capabilitiesFacts from the backend's C-syntax configuration. A function, like hardware_limits, so policy-dependent fields reflect the current process configuration.
val backend_facts : Ir.Backend_intf.backend_factsThe backend's capability facts (gh-ocannl-1723): one of cc_facts, cuda_facts, hip_facts, metal_facts. A value, not a function: static, it touches no driver.
val classify_failure :
Ir.Schedule_outcome.phase ->
Base.exn ->
Ir.Schedule_outcome.classified_cause Base.optionRecognizes backend-owned failures at a tagged boundary. Returning None leaves the common policy to treat the exception as unclassified.
val get_used_memory : device -> Base.intReturns (an upper bound of) the memory used for arrays, in bytes.
val get_free_and_total_memory : device -> (Base.int * Base.int) Base.optionThe driver's free and total bytes of the device's memory, read now; None where the backend has no such reading (the CPU backends and Metal). Device-global, unlike get_used_memory: it counts every allocation on the device, other processes' and the driver's own (contexts, loaded code, local memory, instantiated graphs) included, in allocation granules (gh-ocannl-1424).
Global debug information; backend-specific and might evolve independently on the backends.
val get_debug_info : device -> Base.Sexp.tPer-device debug information; backend-specific and might evolve independently on the backends
val await : device -> Base.unitBlocks till the device becomes idle, i.e. synchronizes the device's runner.
Returns the event indicating if any currently running or scheduled computations on the device have completed.
val is_idle : device -> Base.boolWhether the device's runner is currently waiting for work.
val get_device : ordinal:Base.int -> deviceinclude Ir.Backend_impl.Buffer with type buffer_ptr = Backend.buffer_ptrtype buffer_ptr = Backend.buffer_ptrval sexp_of_buffer_ptr : buffer_ptr -> Sexplib0.Sexp.tval resolve_pool : device -> Ir.Backend_intf.buffer_loc -> buffer_ptrBackend-private buffer_loc -> base resolution, used by the backend's own transfer/link implementations. Not part of Backend_intf.
val bounded_await : (device -> seconds:Base.float -> Base.bool) Base.optiongh-ocannl-2134: the backend's own body for Backend_intf.Backend.await_within, without the device mark the shared layer adds. None (the Device default) takes the shared body: poll is_idle, then await. A backend whose is_idle cannot see a reported failure (Metal: a failed buffer never signals) or a dead runner supplies its own, which answers true only having done everything its await does (raising a failure, draining routine logs).