SEER: Super-Optimization Explorer for HLS using E-graph Rewriting with MLIR

Jianyi Cheng, Samuel Coward, Lorenzo Chelini, Rafael Barbalho, Theo DranearXiv 2023 · DOI

TL;DR

SEER is a super-optimization framework designed to solve the phase-ordering problem in High-Level Synthesis (HLS). By utilizing e-graphs to represent thousands of equivalent program versions simultaneously and applying hardware-aware cost models, SEER discovers designs up to 38× faster than standard tools, often outperforming manual expert optimizations.

The Performance Gap in High-Level Synthesis

High-Level Synthesis (HLS) enables developers to generate hardware from software languages like C or C++. However, a significant performance gap persists between code written by software engineers and that optimized by hardware experts.

The primary obstacle is the phase-ordering problem. Traditional compilers apply optimization passes—such as loop fusion, unrolling, or constant folding—in a fixed, linear sequence. Because the "best" order depends on the specific program and target hardware, one pass might inadvertently block a more beneficial optimization later in the sequence. Furthermore, standard software compilers often lack the hardware awareness necessary to predict how code changes affect physical area or clock cycles until synthesis is complete.

Conceptual comparison of SEER's parallel exploration vs. traditional linear HLS tools.

Methodology: Parallel Exploration via E-graphs

SEER addresses these challenges by moving away from linear optimization sequences in favor of a massive, parallel exploration of the design space using Equivalence Graphs (e-graphs).

System Architecture

SEER is integrated with the Multi-Level Intermediate Representation (MLIR) framework. The workflow involves translating MLIR code into a custom S-expression language, SeerLang, which is then processed by the e-graph engine (egg).

The SEER system architecture, showing the transformation from MLIR to SeerLang and the e-graph optimization loop.

Key Components

  • E-graphs: Instead of maintaining a single program version, SEER stores a set of functionally equivalent expressions in a compact, shared structure. For example, (x * 2) and (x << 1) are stored together as equivalent nodes.
  • Multi-Level Rewriting: SEER applies rewrites across the control path (loop fusion, unrolling), data path (arithmetic simplifications), and gate level (bit-level customizations).
  • Two-Phase Extraction: To select the optimal design from millions of possibilities, SEER uses a specialized cost model. It first extracts the version that maximizes performance (minimizing latency) and then selects the version within that performance tier that minimizes hardware area.
  • Formal Verification: To ensure logical consistency, SEER utilizes a formal equivalence checker (Synopsys VC Formal) to validate the final output against the original source code.

Key Insights and Ideas

  • Breaking Analysis Tension: Hardware-efficient code (e.g., bit-shifts) is often difficult for compilers to analyze. SEER can temporarily rewrite code into an "analysis-friendly" form (e.g., using multipliers) to trigger other optimizations, before reverting to the hardware-efficient version for final synthesis.
  • Orchestration: Rather than replacing existing compilers, SEER orchestrates them. It calls existing MLIR passes as external rewrites, leveraging decades of compiler research while intelligently exploring pass ordering.
  • Efficient Search: Because e-graphs are highly efficient, SEER can explore different loop fusion combinations simultaneously without the combinatorial explosion that plagues traditional compilers.

Results and Performance

The researchers evaluated SEER using the MachSuite benchmark and industrial code from Intel. Key findings include:

  • Speedups: SEER achieved an average speedup of 2.9×, with peak performance reaching 38× over standard baselines.
  • Area Efficiency: These gains were achieved with a minimal average area overhead of only 6%.
  • Expert-Level Performance: In an Intel case study (byte_enable_calc), SEER produced a design faster and smaller than one manually optimized by hardware experts, achieving a 4.8× improvement in the Power-Performance-Area (PPA) metric.
  • Scalability: Despite the massive search space, most benchmarks were optimized in under a minute.

Limitations and Future Work

While e-graphs are compact, extremely large programs may lead to "e-graph explosion." Future work includes partitioning large programs into smaller sub-graphs and developing explicit power-aware cost models. Additionally, deeper integration to operate directly on MLIR could further reduce translation overhead.

Summary updated

BibTeX
@misc{cheng2023seer,
  author = {Jianyi Cheng and Samuel Coward and Lorenzo Chelini and Rafael Barbalho and Theo Drane},
  title = {{SEER: Super-Optimization Explorer for HLS using E-graph Rewriting with MLIR}},
  year = {2023},
  eprint = {2308.07654},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2308.07654},
}
Figure