1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//! OxiCUDA Graph — CUDA Graph execution engine.
//!
//! `oxicuda-graph` provides a high-level, Rust-native computation graph
//! framework that sits above the raw CUDA driver API. It models GPU
//! workloads as directed acyclic graphs (DAGs) of operations, applies a
//! suite of optimisation passes, and lowers the result to an
//! `oxicuda_driver::graph::Graph` for low-overhead CUDA graph submission.
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────┐
//! │ GraphBuilder │ ← ergonomic API
//! └──────────────────┬──────────────────────────┘
//! │ .build()
//! ┌──────────────────▼──────────────────────────┐
//! │ ComputeGraph │ ← DAG of GraphNodes
//! └──────────────────┬──────────────────────────┘
//! ┌─────────┴──────────┐
//! │ Analysis Passes │
//! │ ┌─────────────┐ │
//! │ │ topo │ │ ASAP/ALAP, slack, levels
//! │ │ liveness │ │ buffer live intervals
//! │ │ dominance │ │ Lengauer–Tarjan dominator tree
//! │ └─────────────┘ │
//! └─────────┬──────────┘
//! ┌─────────┴──────────┐
//! │ Optimisation Passes│
//! │ ┌─────────────┐ │
//! │ │ fusion │ │ element-wise kernel merging
//! │ │ memory │ │ interval-graph buffer colouring
//! │ │ stream │ │ multi-stream partitioning
//! │ └─────────────┘ │
//! └─────────┬──────────┘
//! ┌──────────────────▼──────────────────────────┐
//! │ ExecutionPlan │ ← ordered PlanSteps
//! └──────────────────┬──────────────────────────┘
//! ┌─────────┴──────────┐
//! │ Executor Backends│
//! │ ┌─────────────┐ │
//! │ │ sequential │ │ CPU simulator (testing)
//! │ │ cuda_graph │ │ driver::graph::Graph capture
//! │ └─────────────┘ │
//! └────────────────────┘
//! ```
//!
//! # Quick start
//!
//! ```rust
//! use oxicuda_graph::builder::GraphBuilder;
//! use oxicuda_graph::executor::{ExecutionPlan, SequentialExecutor};
//! use oxicuda_graph::node::MemcpyDir;
//!
//! // 1. Build a computation graph.
//! let mut b = GraphBuilder::new();
//!
//! let buf_in = b.alloc_buffer("input", 4096);
//! let buf_mid = b.alloc_buffer("mid", 4096);
//! let buf_out = b.alloc_buffer("output", 4096);
//!
//! let upload = b.add_memcpy("upload", MemcpyDir::HostToDevice, 4096);
//! let k0 = b.add_kernel("relu", 4, 256, 0)
//! .fusible(true)
//! .inputs([buf_in])
//! .outputs([buf_mid])
//! .finish();
//! let k1 = b.add_kernel("scale", 4, 256, 0)
//! .fusible(true)
//! .inputs([buf_mid])
//! .outputs([buf_out])
//! .finish();
//! let download = b.add_memcpy("download", MemcpyDir::DeviceToHost, 4096);
//!
//! b.chain(&[upload, k0, k1, download]);
//!
//! let graph = b.build().expect("graph builder produces a valid DAG");
//!
//! // 2. Compile to an execution plan.
//! let plan = ExecutionPlan::build(&graph, /*max_streams=*/ 4).expect("graph is valid for plan compilation");
//!
//! // 3. Execute (sequential CPU simulation).
//! let stats = SequentialExecutor::new(&plan).run().expect("sequential executor runs a valid plan");
//! assert!(stats.kernels_launched <= 2); // relu+scale may be fused to 1
//! ```
// Re-export the most commonly used types at the crate root.
pub use GraphBuilder;
pub use ;
pub use betweenness_centrality;
pub use closeness_centrality;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ComputeGraph;
pub use ;
pub use ;