Skip to main content

Module stream

Module stream 

Source
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:

  1. Obtain the topological priority order (zero-slack nodes first).
  2. Maintain a set of “available” streams (initially empty).
  3. 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.
  4. 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§

StreamAssignment
The stream assignment for a single node.
StreamPlan
The result of stream partitioning.
SyncPoint
A pair of nodes on different streams where from must complete before to begins.

Functions§

analyse
Runs the stream partitioning pass.