Schedulers.Multicore
module Backend : Backend_impl.For_add_scheduler
include Backend_intf.Backend_device_common
with type buffer_ptr = Backend.buffer_ptr
include Backend_intf.Device with type buffer_ptr = Backend.buffer_ptr
include Backend_intf.Device_types with type buffer_ptr = Backend.buffer_ptr
include Backend_intf.Device_config with type buffer_ptr = Backend.buffer_ptr
include Backend_intf.Buffer with type buffer_ptr = Backend.buffer_ptr
type buffer_ptr = Backend.buffer_ptr
include sig ... end
val sexp_of_dev : dev -> Sexplib0.Sexp.t
val sexp_of_runner : runner -> Sexplib0.Sexp.t
An event tracks if a stream finished computing past a particular point in its schedue. These values are used internally for scheduling across streams of the backend, and can be used for explicit scheduling.
val sexp_of_event : event -> Sexplib0.Sexp.t
type nonrec device = (buffer_ptr, dev, runner, event) Backend_intf.device
val sexp_of_device : device -> Sexplib0.Sexp.t
type nonrec stream = (buffer_ptr, dev, runner, event) Backend_intf.stream
val sexp_of_stream : stream -> Sexplib0.Sexp.t
type nonrec context = (buffer_ptr, stream) Backend_intf.context
val sexp_of_context : context -> Sexplib0.Sexp.t
include Backend_intf.Alloc_buffer
with type buffer_ptr := buffer_ptr
and type stream := stream
include Backend_intf.Buffer with type buffer_ptr := buffer_ptr
include sig ... end
val alloc_buffer :
?old_buffer:buffer_ptr Backend_intf.buffer ->
size_in_bytes:Base.int ->
stream ->
buffer_ptr Backend_intf.buffer
val alloc_zero_init_array :
Ops.prec ->
dims:Base.int Base.array ->
stream ->
buffer_ptr
val free_buffer : (stream -> buffer_ptr -> Base.unit) Base.option
val make_context :
?ctx_arrays:buffer_ptr Backend_intf.ctx_arrays ->
stream ->
context
Returns a context without a parent.
val make_child :
?ctx_arrays:buffer_ptr Backend_intf.ctx_arrays ->
context ->
context
Returns a context with the same Backend_intf.context.stream
, and Backend_intf.context.ctx_arrays
if omitted, as the given context's, which is also the Backend_intf.context.parent
.
val get_name : stream -> Base.string
include Backend_intf.Backend_any_common with type buffer_ptr := buffer_ptr
include Backend_intf.Buffer with type buffer_ptr := buffer_ptr
val sexp_of_buffer_ptr : buffer_ptr -> Sexplib0.Sexp.t
include sig ... end
type nonrec buffer = buffer_ptr Backend_intf.buffer
val sexp_of_buffer : buffer -> Sexplib0.Sexp.t
type nonrec ctx_arrays = buffer_ptr Backend_intf.ctx_arrays
val sexp_of_ctx_arrays : ctx_arrays -> Sexplib0.Sexp.t
val initialize : Backend_intf.config -> Base.unit
Initializes a backend before first use. Typically does nothing if the backend is already initialized, but some backends can do some safe cleanups.
Returns false if there was no previous initialize
call. If it returns false, one must call initialize
before using the backend.
val sync : event -> Base.unit
Blocks 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.bool
Whether the event completed.
Schedules waiting for the given event on the context's stream.
NOTE: it should rarely be needed to call will_wait_for
explicitly, because it should always be called internally when necessary.
val get_used_memory : device -> Base.int
Returns (an upper bound of) the memory used for arrays, in bytes.
Global debug information; backend-specific and might evolve independently on the backends.
val get_debug_info : stream -> Base.Sexp.t
Per-stream debug information; backend-specific and might evolve independently on the backends
val await : stream -> Base.unit
Blocks till the stream becomes idle, i.e. synchronizes the stream.
Returns the event indicating if any currently running or scheduled computations on the stream have completed.
val is_idle : stream -> Base.bool
Whether the stream is currently waiting for work.
val get_device : ordinal:Base.int -> device
val suggested_num_streams : device -> Base.int
The optimal number of streams for the given device to follow the Backend_intf.config
strategy.