Expand description
Stream partitioning — assigns nodes to independent CUDA streams.
Concurrent GPU execution requires independent work to be submitted on
different CUDA streams. This pass analyses the dependency graph and
assigns each node a StreamId such that:
- Dependent nodes (connected by an edge) are on the same stream or the dependency is enforced by an event record/wait pair.
- Independent subgraphs (no dependency path between them) are placed on different streams.
- The number of streams is minimised (up to a user-specified cap).
§Algorithm
We use a list-scheduling heuristic on the topological order, guided by the ASAP/ALAP slack computed in the topo analysis pass:
- Obtain the topological priority order (zero-slack nodes first).
- Maintain a set of “available” streams (initially empty).
- For each node in priority order: if it has predecessors, assign it to
the stream whose last node is a direct predecessor; otherwise open a
new stream (up to
max_streams). Source nodes always get a new stream. - Record cross-stream sync points (pairs of nodes on different streams where one depends on the other).
§Limitations
This is a heuristic, not an optimal ILP formulation. For production use, the result can be refined by a second pass that inserts event nodes.
Structs§
- Stream
Assignment - The stream assignment for a single node.
- Stream
Plan - The result of stream partitioning.
- Sync
Point - A pair of nodes on different streams where
frommust complete beforetobegins.
Functions§
- analyse
- Runs the stream partitioning pass.