Abstract
High-Level Synthesis (HLS) has significantly lowered the barrier to FPGA design by allowing developers to use C/C++. However, the optimization process—selecting the ideal combination of pragmas—remains a major bottleneck due to the exponential design space and long evaluation times of commercial tools. This paper introduces GNN-DSE, a framework that utilizes Graph Neural Networks (GNNs) as a high-speed surrogate for performance and resource prediction. By representing programs as pragma-aware graphs, GNN-DSE enables rapid design space exploration, achieving orders-of-magnitude speedups in optimization while generalizing effectively to unseen applications.
Introduction
Designing custom hardware for FPGAs is traditionally a slow process. While HLS tools allow engineers to write code in C/C++, the "optimization" phase is often a "needle in a haystack" problem. Developers must insert pragmas to control features like loop pipelining, unrolling, or tiling. A few loops with multiple options can lead to millions of possible configurations, and commercial HLS tools can take hours to evaluate just one.
GNN-DSE addresses these challenges by replacing slow synthesis tools with a fast GNN-based predictive model. This allows for rapid evaluation of the design space, enabling automated optimization that was previously computationally prohibitive.
Methodology
The GNN-DSE framework consists of three main components: a trainer for model development, an inference engine for rapid evaluation, and a design space exploration (DSE) loop.
Pragma-Aware Graph Representation
Standard code representations often overlook optimization directives. GNN-DSE extends PrograML, a graph-based program representation, to include pragma nodes. These nodes are connected directly to the specific instructions (e.g., loop headers) they modify, allowing the model to capture the semantic interaction between optimization directives and underlying code logic.
Advanced GNN Architecture
The predictive model employs several state-of-the-art techniques:
- TransformerConv: Incorporates edge features (data flow vs. control flow) into the learning process.
- Jumping Knowledge Network (JKN): Aggregates information from varying neighborhood sizes to capture both local instruction details and global program structure.
- Node Attention: Learns to prioritize critical code segments, such as innermost loops, during performance prediction.
Design Space Exploration
The trained GNN acts as a surrogate model, testing thousands of pragma combinations per minute. A heuristic search prioritizes inner-loop optimizations, and only the "Top M" predicted designs are sent to commercial HLS tools for final verification.
Results and Discussion
The framework was evaluated using kernels from the MachSuite and Polybench benchmarks on a Xilinx Virtex Ultrascale+ FPGA.
- Speed: GNN-DSE performs approximately 22 inferences per second, exploring 80,000 design points in an hour—a task that would take years with standard HLS tools.
- Accuracy and Generalization: The model demonstrated strong transfer learning capabilities, providing accurate predictions for unseen kernels like
gesummvandbicg. - Performance: Compared to
AutoDSE, GNN-DSE found designs with comparable or superior performance in a fraction of the time. For thebicgkernel, it identified a design 1.05x faster than the one found by a 21-hour search.
Conclusion
GNN-DSE demonstrates that GNNs can effectively model the complex relationships between high-level code, optimization pragmas, and hardware performance. By treating pragmas as first-class citizens in a graph representation, the framework enables efficient, automated FPGA optimization. Future work will focus on reducing initial training data costs and expanding the framework to handle more irregular code structures.
Summary updated