Skip to main content

Graph

Struct Graph 

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

A CUDA graph — DAG of operations, replayable via Graph::instantiate.

Implementations§

Source§

impl Graph

Source

pub fn new() -> Result<Self>

Create an empty graph.

Source

pub fn instantiate(&self) -> Result<GraphExec>

Compile this graph into an executable form.

Source

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

Approximate node count (for debugging).

Source

pub fn as_raw(&self) -> cudaGraph_t

Source

pub fn add_empty_node(&self, dependencies: &[GraphNode]) -> Result<GraphNode>

Add an empty “barrier” node with the given dependencies.

Source

pub unsafe fn add_kernel_node( &self, dependencies: &[GraphNode], kernel: &Kernel, grid: Dim3, block: Dim3, shared_mem_bytes: u32, args: &mut [*mut c_void], ) -> Result<GraphNode>

Add a kernel-launch node.

§Safety

Same discipline as crate::LaunchBuilder::launch: argument count/order/types must match the kernel’s C signature.

Source

pub fn add_memset_u32_node( &self, dependencies: &[GraphNode], dst: *mut c_void, value: u32, count: usize, ) -> Result<GraphNode>

Add a memset node filling count 4-byte words at dst with value.

Source

pub unsafe fn add_host_node( &self, dependencies: &[GraphNode], fn_: unsafe extern "C" fn(*mut c_void), user_data: *mut c_void, ) -> Result<GraphNode>

Add a host-function node. fn_ runs on a driver-owned thread when this node executes.

§Safety

fn_ must remain callable with user_data as long as any GraphExec derived from this graph is alive.

Source

pub fn add_child_graph_node( &self, dependencies: &[GraphNode], child: &Graph, ) -> Result<GraphNode>

Add a child-graph node.

Source

pub fn add_event_record_node( &self, dependencies: &[GraphNode], event: &Event, ) -> Result<GraphNode>

Add an event-record node.

Source

pub fn add_event_wait_node( &self, dependencies: &[GraphNode], event: &Event, ) -> Result<GraphNode>

Add an event-wait node.

Source

pub fn add_mem_alloc_node( &self, dependencies: &[GraphNode], device: &Device, bytesize: usize, ) -> Result<(GraphNode, *mut c_void)>

Add a stream-ordered mem-alloc node. Returns the node plus the device pointer the node will allocate at launch time.

Source

pub unsafe fn add_mem_free_node( &self, dependencies: &[GraphNode], dptr: *mut c_void, ) -> Result<GraphNode>

Add a stream-ordered mem-free node for dptr.

§Safety

dptr must be a pointer returned by a prior mem-alloc node in this graph.

Source

pub fn conditional_handle_create( &self, default_launch_value: u32, flags: u32, ) -> Result<u64>

Create a conditional-node handle (CUDA 12.3+). The returned u64 is an opaque driver handle used by cuGraphAddNode-style conditional-node construction, which the runtime exposes via cudaGraphAddNode. default_launch_value is the handle’s starting value (commonly 0 = “don’t execute”), flags = 0 for the default. Returns crate::Error::FeatureNotSupported on older CUDA.

Source

pub unsafe fn add_node_raw( &self, dependencies: &[GraphNode], node_params: *mut c_void, ) -> Result<GraphNode>

Low-level cudaGraphAddNode — add a node from a tagged cudaGraphNodeParams struct. baracuda-runtime exposes typed builders for the common node types (kernel, memset, host, etc.); this escape hatch exists for the node types the typed API does not cover (notably conditional nodes on CUDA 12.3+).

§Safety

node_params must point at a correctly-tagged cudaGraphNodeParams whose union payload matches the type field.

Source

pub fn add_dependencies( &self, from: &[GraphNode], to: &[GraphNode], ) -> Result<()>

Add dependency edges from[i] -> to[i].

Source§

impl Graph

Source

pub fn retain_user_object( &self, object: &UserObject, count: u32, flags: u32, ) -> Result<()>

Have this graph retain count references to object.

Source

pub fn release_user_object(&self, object: &UserObject, count: u32) -> Result<()>

Trait Implementations§

Source§

impl Clone for Graph

Source§

fn clone(&self) -> Graph

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Graph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Graph

§

impl RefUnwindSafe for Graph

§

impl Send for Graph

§

impl Sync for Graph

§

impl Unpin for Graph

§

impl UnsafeUnpin for Graph

§

impl UnwindSafe for Graph

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.