TL;DR
CODO is an automated, MLIR-based compiler designed to generate high-performance, deadlock-free dataflow accelerators on FPGAs. By jointly co-optimizing hardware correctness, communication efficiency, and task parallelism, it eliminates complex dataflow violations and delivers massive end-to-end speedups for deep learning and large language model (LLM) workloads.
What Problem Does This Paper Address?
Field Programmable Gate Arrays (FPGAs) are highly effective for dataflow architectures because they can process streaming data through pipelined tasks, minimizing power-hungry external memory accesses. To avoid writing low-level Hardware Description Languages (HDLs), developers turn to High-Level Synthesis (HLS) tools to compile C/C++ code directly to hardware.
However, a massive gap remains between standard software code and efficient dataflow hardware. Commercial HLS tools enforce strict coding styles and constraints, such as the single-producer, single-consumer rule. Real-world applications like Deep Neural Networks (DNNs) break these rules constantly with complex topologies (e.g., residual bypass connections). Furthermore, maximizing throughput requires using First-In, First-Out (FIFO) buffers rather than ping-pong buffers, but mismatched data access orders or counts between tasks can cause catastrophic, silent hardware deadlocks.
Prior automated compilers handle correctness, communication, and parallelism in a decoupled manner. Optimizing one aspect often breaks another, leading to synthesis failures or severely degraded performance.
Methods
CODO introduces a holistic compilation flow built on the Multi-Level Intermediate Representation (MLIR) framework to jointly optimize these three pillars.
- Dataflow Violation Elimination:
- Coarse-grained: CODO automatically detects multi-consumer patterns (like residual blocks) and resolves them using pattern-aware code transformations, such as node fusion and buffer duplication.
- Fine-grained: To enable safe FIFO streaming, CODO rewrites reduction operations (e.g., pooling, normalization) using temporary arrays to prevent redundant FIFO transactions. It also automatically generates permutation maps to align the loop nesting orders of adjacent producer and consumer tasks.
- Efficient Data Communication: The compiler prioritizes high-performance FIFO buffers wherever possible. It automatically generates optimized on-chip line and window reuse buffers for computation-intensive kernels and schedules efficient off-chip burst transfers across multiple High Bandwidth Memory (HBM) channels.
- Automated Dataflow Scheduling: CODO features a resource-aware, bottleneck-centric Design Space Exploration (DSE) engine that operates in three stages:
- Initial Parallelism Allocation (PA): Allocates loop tiling and unrolling factors proportional to estimated task latencies.
- Upscaling (UP): Iteratively boosts the parallelism of bottleneck loops.
- Downscaling (DP): Scales down over-optimized, non-critical loops to reclaim valuable hardware resources without sacrificing overall throughput.
Datasets
The authors evaluated CODO across a diverse set of workloads:
- Standard Compute Kernels: PolyBench benchmarks (Atax, Gesummv, Gemm, Mvt, 3mm).
- DNN Layers & Blocks: Residual MLPs, Autoencoders, Deepwise Convolutional blocks, and Multi-Head Attention layers.
- Full DNN Models: ResNet-18, VGG-16, MobileNet, ZFNet, and YOLO.
- Large Language Model (LLM): GPT-2 Medium (evaluated across various input/output sequence lengths).
Key Insights and Ideas
- The Interdependence of Optimization: You cannot optimize parallelism without considering communication. For instance, aggressively unrolling a loop changes its memory access pattern, which can instantly introduce a fine-grained dataflow violation and cause a hardware deadlock. CODO succeeds because its passes pass guidance information to subsequent stages.
- FIFO-First over Ping-Pong: While ping-pong buffers are safer because they allow random access, they introduce high latency (the consumer must wait for the entire block to be written) and double the memory footprint. Resolving fine-grained violations unlocks the true performance and resource-saving potential of FIFOs.
- The Power of Downscaling: In a pipelined dataflow architecture, the overall throughput is dictated by the slowest stage (the bottleneck). CODO’s "Downscaling" phase recognizes when a non-bottleneck task is over-optimized and dials back its parallelism, saving massive amounts of BRAM and DSP blocks with zero performance penalty.
Key Results
The authors compared CODO against six state-of-the-art (SOTA) FPGA compilers and frameworks, validating results via both HLS synthesis and physical on-board execution on an AMD Alveo U280 FPGA.
- Kernel-Level Speedups: CODO achieved a geometric mean latency speedup of 292.1$\times$ over unoptimized baselines, outperforming frameworks like StreamHLS (200.9$\times$) and Allo (64.7$\times$).
- DNN Model Synthesis: CODO delivered 3.7$\times$ to 33.8$\times$ speedups over SOTA frameworks while drastically reducing on-chip BRAM utilization.
- On-Board Deployment: In physical hardware evaluations, CODO achieved an average 7.3$\times$ end-to-end speedup on CNN models and a 2.07$\times$ average speedup on the GPT-2 model compared to SOTA tools. It also demonstrated up to 77.1$\times$ better energy efficiency than the baseline.
Limitations and Future Work
While CODO successfully generates highly optimized code, it still relies on commercial downstream tools (like AMD Vitis HLS) for final bitstream generation. The authors noted that inaccurate resource estimation within Vitis HLS occasionally prevented physical on-board implementation for exceptionally large and complex models (such as YOLO), despite successful compiler synthesis. Future work could involve integrating more precise hardware resource models directly into the compiler's DSE engine to prevent these downstream tool failures.
Summary updated