Program-to-Circuit: Exploiting GNNs for Program Representation and Circuit Translation

Nan Wu, Huake He, Yuan Xie, Pan Li, Cong HaoarXiv 2021 · OpenReview

TL;DR

This paper introduces the "Program-to-Circuit" problem, framing circuit quality prediction as a graph-based task solvable by Graph Neural Networks (GNNs). They provide a new benchmark of 40k C/C++ programs translated to circuits, analyze existing GNNs, and highlight challenges for future research in this domain.

What Problem Does This Paper Address?

Designing integrated circuits (ICs) is a complex and time-consuming process, especially when it comes to evaluating the quality of the resulting circuit (e.g., its size, speed, power consumption). Traditional methods for this evaluation can take hours or even days, hindering agile hardware development. High-Level Synthesis (HLS) tools automate the translation from high-level programming languages (like C/C++) to hardware description languages (HDLs), but they still require significant time for synthesis and accurate quality estimation. This paper aims to bridge this gap by proposing a way to quickly and accurately predict circuit quality directly from program representations, thereby accelerating the hardware design cycle.

Methods

The core idea is to represent programs as graphs and then use GNNs to learn the mapping from these program graphs to circuit quality metrics. Specifically, they use intermediate representations (IRs) of C/C++ programs, such as Data Flow Graphs (DFGs) and Control Data Flow Graphs (CDFGs), as the input to GNNs. These graphs capture the program's operations, data dependencies, and control flow. The GNNs are trained to predict hardware quality metrics like Digital Signal Processors (DSPs), Flip-Flops (FFs), Look-Up Tables (LUTs), SLICEs (a combination of LUTs and FFs), and Critical Path (CP) timing on FPGAs. The paper analyzes 14 state-of-the-art GNN models to understand their strengths and weaknesses on this task.

Datasets

The authors introduce a new benchmark consisting of 40,000 synthetic C/C++ programs. These programs are translated into corresponding circuit designs, and their hardware quality metrics are collected. This benchmark is divided into two sets:

  • DFG dataset: 19,120 programs translated into DFGs.
  • CDFG dataset: 18,570 programs translated into CDFGs.

In addition to synthetic data, they also use three sets of real-world benchmarks for evaluating the generalization capabilities of GNNs:

  • MachSuite: 16 applications.
  • CHStone: 10 applications.
  • PolyBench/C: 30 applications.

Key Insights and Ideas

  • Program-to-Circuit as a GNN problem: The paper successfully frames circuit quality prediction as a graph-based regression problem, opening up new avenues for applying GNNs in the Electronic Design Automation (EDA) domain.
  • IR graphs are rich representations: DFGs and CDFGs, readily available from compiler front-ends, provide a suitable and standardized input for GNNs, abstracting away language-specific details.
  • CDFG complexity challenges GNNs: Predicting circuit quality from CDFGs is significantly harder than from DFGs. This is attributed to larger graph sizes, the presence of complex control flow (loops), and the introduction of additional nodes/edges representing control signals, which are less directly related to resource usage.
  • Relational information is crucial: Models that effectively leverage edge information (representing data and control dependencies) and employ multiple aggregators (like PNA and RGCN) tend to perform better, highlighting the importance of capturing fine-grained relationships within the program graph.
  • Generalization gap exists: GNNs trained on synthetic data show a notable performance degradation when applied to real-world benchmarks, indicating challenges in generalizing to larger, more complex, and potentially out-of-distribution program structures.

Key Results

  • The paper provides a comprehensive analysis of 14 GNN models on the Program-to-Circuit task.
  • Models like PNA and RGCN demonstrated superior performance on the synthetic datasets, achieving relatively low error rates (e.g., around 6.14% for CP timing on DFGs with RGCN).
  • Relative errors on CDFGs were significantly larger than on DFGs, with CP timing errors reaching up to 8.79% for GCN and 14.71% for PNA.
  • Generalization to real-world benchmarks showed a large performance degradation compared to synthetic data, with relative errors often exceeding 20-30% for various metrics.
  • Despite the challenges, GNN predictions were found to be comparable to, and sometimes better than, commercial HLS tools in timing prediction, while being significantly faster.

Limitations and Future Work

  • Generalization to real-world applications: The significant performance drop on real-world benchmarks highlights the need for GNNs that can better generalize across varying graph sizes, complex loop structures, and unusual program operations.
  • Handling complex loop structures: The paper identifies loops as a major challenge for GNNs, suggesting that future work should focus on developing GNN architectures that can effectively model and reason about intricate loop topologies.
  • Regression vs. Classification: The paper notes that graph-level regression tasks, like predicting exact circuit values, are more demanding than classification tasks, implying a need for GNNs with enhanced representational power.
  • Domain-specific insights: The authors suggest that incorporating more domain-specific knowledge into GNN features or architectures could further improve performance.
  • Program-to-X framework: The authors envision this work as a stepping stone for the broader "Program-to-X" framework, encouraging research into other program-based analysis tasks using GNNs.

Summary updated

Abstract

Circuit design is complicated and requires extensive domain-specific expertise. One major obstacle stuck on the way to hardware agile development is the considerably time-consuming process of accurate circuit quality evaluation. To significantly expedite the circuit evaluation during the translation from behavioral languages to circuit designs, we formulate it as a Program-to-Circuit problem, aiming to exploit the representation power of graph neural networks (GNNs) by representing C/C++ programs as graphs. The goal of this work is four-fold. First, we build a standard benchmark containing 40k C/C++ programs, each of which is translated to a circuit design with actual hardware quality metrics, aiming to facilitate the development of effective GNNs targeting this high-demand circuit design area. Second, 14 state-of-the-art GNN models are analyzed on the Program-to-Circuit problem. We identify key design challenges of this problem, which should be carefully handled but not yet solved by existing GNNs. The goal is to provide domain-specific knowledge for designing GNNs with suitable inductive biases. Third, we discuss three sets of real-world benchmarks for GNN generalization evaluation, and analyze the performance gap between standard programs and the real-case ones. The goal is to enable transfer learning from limited training data to real-world large-scale circuit design problems. Fourth, the Program-to-Circuit problem is a representative within the Program-to-X framework, a set of program-based analysis problems with various downstream tasks. The in-depth understanding of strength and weaknesses in applying GNNs on Program-to-Circuit could largely benefit the entire family of Program-to-X. Pioneering in this direction, we expect more GNN endeavors to revolutionize this high-demand Program-to-Circuit problem and to enrich the expressiveness of GNNs on programs.
BibTeX
@misc{wu2021program,
  author = {Nan Wu and Huake He and Yuan Xie and Pan Li and Cong Hao},
  title = {{Program-to-Circuit: Exploiting GNNs for Program Representation and Circuit Translation}},
  year = {2021},
  eprint = {2109.06265},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2109.06265},
}
Figure