TL;DR
This paper introduces NLP-DSE, a framework that automates the insertion of optimization pragmas in High-Level Synthesis (HLS) by modeling the problem as a Non-Linear Program (NLP). By using static analysis to create an analytical performance model that acts as a guaranteed lower bound on latency, the system can prune billions of sub-optimal hardware designs in seconds, delivering up to 17x better performance than state-of-the-art tools.
What Problem Does This Paper Address?
High-Level Synthesis (HLS) allows developers to write hardware descriptions in C/C++, which a compiler then transforms into digital logic (RTL) for FPGAs. However, getting high performance requires "pragmas"—directives that tell the compiler how to unroll loops, pipeline operations, or cache data.
The challenge is that the "design space" (the combination of all possible pragma settings) is astronomical—often exceeding billions of configurations. Traditional Design Space Exploration (DSE) is either:
- Extremely Slow: Running the full HLS toolchain for every candidate design can take hours per run.
- Inaccurate: Machine learning "black-box" models often fail to generalize to new, unseen code structures.
The authors aim to bridge this gap by creating a mathematically rigorous, analytical model that can navigate this space without needing to run the full HLS tool for every point.
Methods
The authors propose NLP-DSE, which treats pragma insertion as a mathematical optimization problem.
- Polyhedral Analysis: The system uses static analysis (specifically for "affine" programs—loops with predictable bounds and dependencies) to extract an Abstract Syntax Tree (AST) and property vectors for every loop.
- Analytical Modeling: They develop a performance and resource model where variables (like unroll factors and initiation intervals) are the unknowns. Because optimizations in nested loops often involve products of variables (e.g., unrolling an outer loop by $X$ and an inner loop by $Y$ results in $X \times Y$ parallelism), the model is Non-Linear.
- The Lower Bound Property: A core contribution is proving that their model provides a lower bound on actual HLS latency. This is a "killer feature" for search: if the model predicts a design's best possible latency is already worse than a design they've already found, they can safely discard it and its derivatives.
- NLP Solver: They encode these constraints into the AMPL modeling language and solve them using BARON, a global optimization solver.
- Lightweight DSE: The NLP solver identifies the most promising candidates, which are then validated by a few actual HLS runs to account for compiler-specific quirks.
Datasets
The framework was evaluated on:
- Polybench/C 4.2.1: A standard suite of 47 kernels covering linear algebra, image processing, physics simulations, and data mining.
- CNN Layer: A convolutional neural network layer to demonstrate applicability to modern deep learning hardware.
- Problem Sizes: Evaluations were conducted across "Small," "Medium," and "Large" datasets to test the robustness of the model against varying data footprints.
Key Insights and Ideas
- Math over Heuristics: Instead of "guessing" which loop to optimize first (bottleneck-driven), the NLP solver looks at the entire program holistically to find the global optimum.
- Pruning is Power: By proving the "lower bound" property, the authors can mathematically ignore 99.9% of the search space. This allows them to "explore" billions of designs in minutes.
- Handling Compiler "Conservatism": The authors acknowledge that HLS compilers sometimes fail to apply pragmas as requested. Their DSE loop accounts for this by iteratively refining the search if the predicted performance isn't met in reality.
- Resource Sharing: The model includes optimistic estimates for DSP and BRAM usage, ensuring that the suggested designs actually fit on the target FPGA (an AMD/Xilinx Alveo U200).
Key Results
The authors compared NLP-DSE against AutoDSE (a bottleneck-driven tool) and HARP (a machine-learning-based tool):
- Throughput: NLP-DSE achieved an average 17.24x higher throughput (GigaFlops/s) compared to AutoDSE.
- Exploration Speed: The DSE process was 5.69x faster on average. For some kernels, NLP-DSE found better designs in minutes than AutoDSE found in 20 hours.
- Generalization: Unlike ML models (HARP), which struggled with large problem sizes or kernels not in their training set, the NLP approach remained accurate because it is based on the fundamental logic of the code.
- Efficiency: For 20 out of 47 benchmarks, the very first design the NLP solver suggested was the best one found in the entire search.
Limitations and Future Work
- Affine Constraint: The current model is restricted to "affine" programs (regular loops). It cannot currently handle complex control flow like
whileloops with data-dependent exits or recursive functions. - Supported Operations: Some operations, like
sqrt(), and certain loop structures (negative strides) are not yet supported by the underlying static analysis tool (PolyOpt-HLS). - Beyond Pragmas: The current work focuses on inserting pragmas into existing code. The authors suggest that future versions could integrate code transformations (like loop reordering or tiling) directly into the NLP formulation to find even better hardware architectures.
Summary updated