TL;DR
This paper introduces "Dynamic Common Sub-expression Elimination" (CSE), a novel technique that integrates CSE directly into the scheduling phase of high-level synthesis. By exploiting opportunities created by speculative code motions, this dynamic approach significantly outperforms traditional, pre-scheduling CSE, leading to more efficient hardware designs with improved performance and reduced area.
What Problem Does This Paper Address?
High-level synthesis (HLS) aims to translate high-level behavioral descriptions (like C code) into hardware designs. A key challenge in HLS is optimizing the generated hardware for performance and size. Traditional compiler optimizations, such as Common Sub-expression Elimination (CSE), are often applied as a separate pass before scheduling. However, in control-intensive designs with complex conditional logic and loops, these optimizations can miss opportunities. This is because speculative code motions, which reorder, duplicate, or move operations to improve performance, can alter the control flow in ways that traditional CSE cannot anticipate. These code motions, while beneficial for performance, can create new, dynamic opportunities for CSE that are missed if CSE is applied only statically before scheduling.
Methods
The core contribution is Dynamic CSE, a technique integrated directly into the scheduling heuristic. Instead of a static pass, Dynamic CSE operates during the scheduling process. When an operation is scheduled, the system checks the remaining unscheduled operations for common sub-expressions. If a common sub-expression is found and the control flow (specifically, the dominance relationship between basic blocks) allows, the common sub-expression in the unscheduled operation is replaced with the result of the just-scheduled operation.
This dynamic approach is enabled by speculative code motions (like speculation, reverse speculation, and conditional speculation) that are also part of the Spark HLS framework. These motions allow operations to be moved across basic blocks and conditional boundaries, creating new dominance relationships that Dynamic CSE can exploit. The paper also extends this concept to Dynamic Copy Propagation, which helps eliminate redundant copy operations generated by these transformations, further enabling CSE opportunities.
Datasets
The paper evaluates their approach using benchmarks derived from two real-life applications:
- MPEG-1 Prediction block: Two functions,
pred0_1andpred2. - GIMP image processing tool: Two functions,
tile(a combination ofscaleandtiletransforms) andcalc_undistorted_coordsfrom thePolarizetransform.
These benchmarks are described as moderately complex and control-intensive.
Key Insights and Ideas
- Dynamic CSE is crucial for control-intensive designs: Traditional CSE, applied statically, misses significant optimization opportunities created by speculative code motions.
- Scheduling and optimization are intertwined: Integrating CSE directly into the scheduler allows it to leverage the dynamic opportunities created by code motion, leading to better results than a separate optimization pass.
- Speculative code motions create new CSE possibilities: By reordering and duplicating operations, these motions can establish dominance relationships that were previously absent, enabling Dynamic CSE.
- Unexpected register reduction: The authors observed a significant reduction in register usage, which they attribute to shorter schedule lengths, earlier variable lifetimes, and the elimination of duplicate operations through CSE and copy propagation.
- Dynamic CSE outperforms traditional CSE: The experimental results consistently show that Dynamic CSE yields better improvements in performance, controller size, and area compared to classical CSE alone.
Key Results
The paper reports significant improvements using Dynamic CSE:
- Performance: Up to 31% improvement in execution cycles (longest path).
- Controller Size: Up to 22% reduction in the number of states in the finite state machine controller.
- Area: Up to 35% reduction in area after logic synthesis.
- Registers: A notable reduction in the number of registers required, with one function showing a 55% decrease.
These improvements are consistently better than those achieved by traditional CSE applied before scheduling. When both traditional CSE and Dynamic CSE are applied, the benefits are largely driven by the Dynamic CSE component.
Limitations and Future Work
- Resource Binding: The paper notes that their resource binding methodology sometimes prioritizes interconnect and area over register usage, which can lead to slightly higher register counts in some combined CSE/Dynamic CSE scenarios.
- Future Work: The authors suggest exploring other transformations that can be applied dynamically during scheduling to leverage the benefits of code motion. They also mention the potential to incorporate control costs into the cost function for scheduling.
Summary updated