Expand description
CUDA Graph API for recording and replaying sequences of GPU operations.
CUDA Graphs allow capturing a sequence of operations (kernel launches, memory copies, memsets) into a graph data structure that can be instantiated and launched repeatedly with minimal CPU overhead.
§Architecture
This module exposes a Rust-side graph representation that records
operations as nodes with explicit dependency edges. Graph::instantiate
translates that representation into the native CUDA Graph API
(cuGraphCreate, cuGraphAdd*Node, cuGraphInstantiate) whenever a
CUDA driver is available, and GraphExec::launch issues a real
cuGraphLaunch. On macOS (or any host without a driver) the graph is
still built and validated CPU-side, and launching reports
CudaError::NotInitialized.
§Example
let mut graph = Graph::new();
let n0 = graph.add_memcpy_node(MemcpyDirection::HostToDevice, 4096);
let n1 = graph.add_kernel_node(
"vector_add",
(4, 1, 1),
(256, 1, 1),
0,
);
let n2 = graph.add_memcpy_node(MemcpyDirection::DeviceToHost, 4096);
graph.add_dependency(n0, n1).ok();
graph.add_dependency(n1, n2).ok();
assert_eq!(graph.node_count(), 3);
assert_eq!(graph.dependency_count(), 2);Structs§
- Graph
- A CUDA graph representing a DAG of GPU operations.
- Graph
Exec - An instantiated, executable graph.
- Stream
Capture - Records GPU operations submitted to a stream into a
Graph.
Enums§
- Graph
Node - A single operation node within a
Graph. - Memcpy
Direction - Direction of a memory copy operation within a graph node.