Skip to main content

oxicuda_graph/optimizer/
mod.rs

1//! Optimisation passes for the OxiCUDA computation graph.
2//!
3//! Three complementary passes transform a validated [`ComputeGraph`] into
4//! a form ready for execution:
5//!
6//! * [`fusion`] — Identifies chains of element-wise kernels that can be
7//!   merged into a single PTX kernel, reducing kernel-launch overhead and
8//!   improving cache behaviour.
9//!
10//! * [`fusion_reduction`] — Identifies reduction-chained element-wise regions
11//!   (`LayerNorm`, `softmax`, …) — single-entry/single-exit broadcast diamonds
12//!   that the linear chain fuser cannot capture — and collapses each into one
13//!   fused kernel.
14//!
15//! * [`memory`] — Assigns device memory slots to logical buffers using
16//!   live-interval graph colouring, maximising buffer reuse and minimising
17//!   peak device memory usage.
18//!
19//! * [`stream`] — Partitions independent nodes onto separate CUDA streams
20//!   for concurrent GPU execution, and identifies the cross-stream event
21//!   synchronisation points needed to enforce dependencies.
22//!
23//! [`ComputeGraph`]: crate::graph::ComputeGraph
24
25pub mod fusion;
26pub mod fusion_reduction;
27pub mod memory;
28pub mod stream;
29
30pub use fusion::{FusionGroup, FusionPlan, analyse as fusion_analyse};
31pub use fusion_reduction::{
32    ReductionFusionGroup, ReductionFusionPlan, ReductionPattern,
33    analyse as reduction_fusion_analyse, rewrite as reduction_fusion_rewrite,
34};
35pub use memory::{MemoryPlan, SlotAssignment, analyse as memory_analyse};
36pub use stream::{StreamPlan, SyncPoint, analyse as stream_analyse};