Expand description
Buffer liveness analysis.
For each buffer in a ComputeGraph, this pass computes the live
interval [def_pos, last_use_pos] in terms of positions in the
topological order. The memory planner uses these intervals to determine
which buffers can share the same physical memory allocation.
§Algorithm
- Run a topological sort to get a linear order of nodes.
- For each node at position
p:- For every output buffer
bit writes: recorddef_pos[b] = p. - For every input buffer
bit reads: recordlast_use_pos[b] = max(last_use_pos[b], p).
- For every output buffer
- The live interval for buffer
bis[def_pos[b], last_use_pos[b]]. Buffers that are only written (no reads) havelast_use_pos = def_pos. Buffers that are only read (external inputs) havedef_pos = 0.
Two buffers a and b interfere if their live intervals overlap, i.e.
a.def <= b.last_use && b.def <= a.last_use.
Structs§
- Live
Interval - The live interval of a buffer in topological-order position space.
- Liveness
Analysis - Result of running liveness analysis on a
ComputeGraph.
Functions§
- analyse
- Computes live intervals for all buffers referenced in
graph.