Skip to main content

CapturedCudaGraph

Struct CapturedCudaGraph 

Source
pub struct CapturedCudaGraph { /* private fields */ }
Expand description

Instantiated CUDA Graph with owned graph + exec handles.

Destruction may wait for recorded execution events and their stream-prefix dependencies, directly or when another capture drains deferred destruction. Satisfy the module-level lifecycle contract before release or capture. This waiting behavior belongs to the wrapper, not GraphExecDestroy. Modules captured through XLOG launches remain alive until replay completes.

Implementations§

Source§

impl CapturedCudaGraph

Source

pub fn bind_resident_lifecycle(self, runtime: &XlogDeviceRuntime) -> Self

Tie resident lifecycle accounting to this real graph/exec owner.

Binding is idempotent. The lease is created only after graph instantiation has succeeded and is dropped after this type’s Drop implementation destroys the executable and parent graph handles.

Source

pub fn conditional_while_on_stream<F>( stream: &CudaStream, initial_value: u32, assign_default_on_launch: bool, populate_body: F, ) -> Result<Self, CudaConditionalGraphUnavailable>

Create, populate, and instantiate a parent graph containing exactly one root conditional-WHILE node.

The body is borrowed only during construction; it cannot escape the callback or modify an instantiated graph. Its numeric conditional handle remains valid until this graph is dropped. CUDA permits only one live executable instantiation of a graph containing a conditional node.

Source

pub unsafe fn instantiate_owned_graph( graph: CUgraph, context: Arc<CudaContext>, ) -> Result<Self, CudaConditionalGraphUnavailable>

Instantiate and assume sole ownership of graph.

The graph is destroyed on instantiation failure. On success, this value destroys the executable first and the source graph second.

§Safety

graph must be a valid, unowned graph in context, and no other owner may destroy or instantiate it while this value exists. The caller must retain modules and allocations referenced by this foreign graph through its last execution. Ownership of raw CUDA nodes does not transfer ownership of their external resources.

Source

pub fn capture_on_stream<F>(stream: &CudaStream, record: F) -> Result<Self>
where F: FnOnce() -> Result<()>,

Capture work submitted by record on stream, instantiate it, and take ownership of the resulting graph handles.

Capture setup and cleanup may wait for deferred destruction under the module-level lifecycle contract, including on errors and callback unwind. The resulting graph has not executed at that point.

Source

pub fn launch(&self, stream: &Arc<CudaStream>) -> Result<()>

Replay after admitting the complete current memory manifest on this stream. Submission is asynchronous; dropping the graph may wait for completion.

Source

pub fn launch_in(&self, enqueue: &CudaEnqueue<'_>) -> Result<()>

Replay inside an existing admission without acquiring an overlapping group or a new capture pin.

Source

pub fn node_count(&self) -> Result<usize>

Number of nodes in the captured graph. Used by bounded CSM CUDA Graph cache-key and node-inventory certs to prove topology stability.

Source

pub fn nodes(&self) -> Result<Vec<CudaGraphNode>>

Return graph nodes in CUDA’s enumeration order with their node type.

CUDA does not define this list as dependency or execution order. Use Self::linear_chain_node_kinds when a linear topology is required.

Source

pub fn linear_chain_node_kinds(&self) -> Result<Vec<CudaGraphNodeKind>>

Return actual node kinds in root-to-leaf dependency order.

This fails unless the graph is one connected linear chain with exactly one root, one leaf, one immediate dependency per non-root node, and no branches, duplicate dependencies, foreign dependencies, or cycles.

Source

pub fn kernel_node_params( &self, node: CudaGraphNode, ) -> Result<CUDA_KERNEL_NODE_PARAMS>

Read CUDA’s raw kernel-node params for inventory/update code.

The returned kernelParams pointer is CUDA-owned capture metadata. Treat it as read-only unless constructing a fresh params object for a complete admitted parameter update.

Source

pub fn memset_node_params( &self, node: CudaGraphNode, ) -> Result<CUDA_MEMSET_NODE_PARAMS>

Read CUDA’s raw memset-node params for inventory/update code.

Source

pub unsafe fn set_memset_node_params_in( &mut self, node: CudaGraphNode, params: &CUDA_MEMSET_NODE_PARAMS, enqueue: &CudaEnqueue<'_>, ) -> Result<()>

Update one memset node using a complete admitted candidate manifest.

§Safety

The candidate admission must cover all unchanged graph accesses as well as the new destination. Parameters must obey CUDA’s memset-node ABI.

Source

pub fn graph(&self) -> CUgraph

Raw graph handle for low-level node inventory/update code.

Source

pub fn exec(&self) -> CUgraphExec

Raw instantiated graph handle for low-level graph-exec update code. Executions submitted outside Self::launch are not tracked by this owner. The unsafe raw-API caller must finish them before dropping it.

Trait Implementations§

Source§

impl Drop for CapturedCudaGraph

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for CapturedCudaGraph

Source§

impl Sync for CapturedCudaGraph

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.