pub struct Graph { /* private fields */ }Expand description
A CUDA graph — DAG of operations, replayable via Graph::instantiate.
Implementations§
Source§impl Graph
impl Graph
Sourcepub fn instantiate(&self) -> Result<GraphExec>
pub fn instantiate(&self) -> Result<GraphExec>
Compile this graph into an executable form.
Sourcepub fn node_count(&self) -> Result<usize>
pub fn node_count(&self) -> Result<usize>
Approximate node count (for debugging).
pub fn as_raw(&self) -> cudaGraph_t
Sourcepub fn add_empty_node(&self, dependencies: &[GraphNode]) -> Result<GraphNode>
pub fn add_empty_node(&self, dependencies: &[GraphNode]) -> Result<GraphNode>
Add an empty “barrier” node with the given dependencies.
Sourcepub 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>
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.
Sourcepub fn add_memset_u32_node(
&self,
dependencies: &[GraphNode],
dst: *mut c_void,
value: u32,
count: usize,
) -> Result<GraphNode>
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.
Sourcepub unsafe fn add_host_node(
&self,
dependencies: &[GraphNode],
fn_: unsafe extern "C" fn(*mut c_void),
user_data: *mut c_void,
) -> Result<GraphNode>
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.
Sourcepub fn add_child_graph_node(
&self,
dependencies: &[GraphNode],
child: &Graph,
) -> Result<GraphNode>
pub fn add_child_graph_node( &self, dependencies: &[GraphNode], child: &Graph, ) -> Result<GraphNode>
Add a child-graph node.
Sourcepub fn add_event_record_node(
&self,
dependencies: &[GraphNode],
event: &Event,
) -> Result<GraphNode>
pub fn add_event_record_node( &self, dependencies: &[GraphNode], event: &Event, ) -> Result<GraphNode>
Add an event-record node.
Sourcepub fn add_event_wait_node(
&self,
dependencies: &[GraphNode],
event: &Event,
) -> Result<GraphNode>
pub fn add_event_wait_node( &self, dependencies: &[GraphNode], event: &Event, ) -> Result<GraphNode>
Add an event-wait node.
Sourcepub fn add_mem_alloc_node(
&self,
dependencies: &[GraphNode],
device: &Device,
bytesize: usize,
) -> Result<(GraphNode, *mut c_void)>
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.
Sourcepub unsafe fn add_mem_free_node(
&self,
dependencies: &[GraphNode],
dptr: *mut c_void,
) -> Result<GraphNode>
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.
Sourcepub fn conditional_handle_create(
&self,
default_launch_value: u32,
flags: u32,
) -> Result<u64>
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.
Sourcepub unsafe fn add_node_raw(
&self,
dependencies: &[GraphNode],
node_params: *mut c_void,
) -> Result<GraphNode>
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§impl Graph
impl Graph
Sourcepub fn retain_user_object(
&self,
object: &UserObject,
count: u32,
flags: u32,
) -> Result<()>
pub fn retain_user_object( &self, object: &UserObject, count: u32, flags: u32, ) -> Result<()>
Have this graph retain count references to object.