Cuda.GraphCUDA graphs: capture a sequence of stream operations once, then replay it with a single launch call. See: Graph Management.
A graph under construction (a template of work, not yet executable). The graph value retains the OCaml-side resources of the operations captured into it (kernels — and through them their modules — kernel parameters, device pointers), so a Stream.synchronize of the capture stream cannot free resources a replay still needs. See CUgraph.
An instantiated, executable graph; retains the captured operations' resources like t. See CUgraphExec.
val sexp_of_t : t -> Sexplib0.Sexp.tval sexp_of_exec : exec -> Sexplib0.Sexp.ttype capture_mode = | GLOBAL| THREAD_LOCAL| RELAXEDSee CUstreamCaptureMode. GLOBAL (the CUDA default) invalidates the capture on potentially unsafe API calls from any thread; THREAD_LOCAL restricts that to the capturing thread; RELAXED imposes no cross-thread restrictions.
val sexp_of_capture_mode : capture_mode -> Sexplib0.Sexp.tval begin_capture : ?mode:capture_mode -> Stream.t -> unitStarts capturing work submitted to the stream instead of executing it. mode defaults to GLOBAL. Between begin_capture and end_capture, operations enqueued on the stream (e.g. Stream.launch_kernel) are recorded as graph nodes, not run. See cuStreamBeginCapture.
Ends the capture begun by begin_capture and returns the captured graph. Raises Cuda_error if the capture was invalidated. The graph value is finalized using cuGraphDestroy; it can also be released eagerly with destroy. See cuStreamEndCapture.
Creates an executable graph from a captured graph; the template can be destroyed afterwards. The exec value is finalized using cuGraphExecDestroy; it can also be released eagerly with exec_destroy, but only once no launch of it is pending (synchronize the stream first). See cuGraphInstantiate.
Enqueues the whole captured work sequence on the stream, as one API call. The stream retains the exec until it is synchronized (mirroring Stream.launch_kernel's argument retention), so dropping the last reference to a launched exec cannot destroy it while the launch is pending. See cuGraphLaunch.
val destroy : t -> unitEagerly destroys the graph template. Idempotent; the finalizer covers the non-eager case.
val exec_destroy : exec -> unitEagerly destroys the executable graph. Idempotent; the finalizer covers the non-eager case.