320 likes | 529 Views
Pipelining and Retiming. Prepared by Mark Jarvin. Agenda. Synchronous circuit retiming Pipelining Software pipelining. The Retiming Problem: Example. D = 4 T = 4 Latency = 4 Throughput = 4. How can this be improved? Pipelining?. The Retiming Problem: Example. Latency = 6
E N D
Pipelining and Retiming Prepared by Mark Jarvin
Agenda • Synchronous circuit retiming • Pipelining • Software pipelining
The Retiming Problem: Example • D = 4 • T = 4 • Latency = 4 • Throughput = 4 • How can this be improved? • Pipelining?
The Retiming Problem: Example • Latency = 6 • Throughput = 3 • Delay is not balanced • This can still be improved
The Retiming Problem: Example • Latency = 4 • Throughput = 2 • Now, delay is balanced
Observations • Some basic transformations can be used for cycle time reduction • The retiming transformation moves registers across gates
Observations • Levelization doesn’t help • Only useful for acyclic circuits
Naïve Algorithm while ( not timed ) { pick a candidate gate; apply retiming transformation; do timing analysis; }
Questions • Can we apply retiming in batch mode? • i.e., simultaneously on all gates • Can we make sure the retimed circuit is optimal? • Can we achieve this in polynomial time?
Metrics • Path delay: • Path weight:
Metrics • Define weight and delay metrics for any given vertex pair: • Both quantities are undefined if there is no path p from u to v
The Retiming Transformation • How do we represent retiming? • How does it affect G? • Informally: • The transformation is fundamentally moving registers across gates • Represent it as the number of registers to push from a gate’s outputs to its inputs • Define this number for all gates
The Retiming Transformation • Definition: a retiming of a network is an integer-valued vertex labelling that transforms into where for each edge :
The Retiming Transformation • Initially: • Apply retiming: • Finally: • Note: retiming will change the number of registers in general, but not the number of registers in a given cycle
Legal and Feasible Retiming • A retiming is legal if the retimed network doesn’t contain negative weights: • For a given cycle time , the network is timing feasible if it can correctly operate under • This holds if for all
Feasible Retiming • Furthermore: • Finally:
Feasible Test Algorithm • Any retiming must satisfy the system of difference constraints: • General approach: integer linear programming • Special form: single-source longest path problem • Note: we can skip the second inequality wherever or
Feasible Test Algorithm • Longest path problem can be solved with Bellman-Ford • Build a constraint graph with an edge from i to j if we have a constraint of the form
Feasible Test Algorithm • The solution is feasible if there are no positive cycles • If feasible, the longest distance of each vertex provides the retiming function • For the previous example, with reference node vh: • There are no positive cycles; hence, is a feasible clock period
Feasible Test Algorithm • Here, there is a positive cycle: • Hence, a clock period of 12 is not feasible
Optimal Retiming • Binary search of minimum cycle time optimalRetiming ( G ) { min = 0; max = MAX; while ( min ≠ max ) { mid = ( max – min ) / 2; if ( feasibleTest ( G, mid ) ) max = mid; else min = mid; } return min; }
Optimal Retiming • Do we really need to search all clock periods? No… • Optimal cycle time must be one of D(i,j) • So, sort and search O(V2) clock periods • Computing each D(i,j) requires O(VE+V2 lgV) time • Overall, the complexity is O(VE lgV)
Optimal Retiming • Can we do better? Yes… • Look at the delay-to-register ratios and maximum node delay of the cycles in the circuit, where delay-to-register ratio and maximum node delay are defined as: • Then, the minimum feasible clock period lies in the range: • This improves the overall running time to O(VE lgD)
Pipelining • Can be thought of as a special case of retiming
Software Pipelining • This can also be thought of in terms of retiming