Abstract
As deep learning models grow in complexity, the demand for high-efficiency hardware accelerators has led to the development of domain-specific architectures like the Xilinx Versal Adaptive Compute Acceleration Platform (ACAP). This paper explores the optimization of General Matrix Multiplication (GEMM)—the fundamental operation for modern AI—on the Versal AI Engine (AIE). By adapting the Basic Linear Algebra Instantiation Software (BLIS) framework to the AIE's unique memory hierarchy and hand-tuning a micro-kernel using hardware intrinsics, this research demonstrates a path to achieving 86.7% of theoretical peak performance for 16-bit integer operations.
Introduction
The slowdown of Moore’s Law has necessitated a shift from general-purpose CPUs to domain-specific accelerators. The Xilinx Versal ACAP, featuring a massive array of AI Engines, represents a significant leap in potential throughput for AI inference. However, the "exotic" nature of these architectures—characterized by specialized SIMD units and non-traditional memory structures—presents a steep programming challenge. To address this, we investigate how to map the cornerstone of deep learning, the GEMM kernel, onto the Versal AIE to maximize computational efficiency.
Methodology: Adapting the BLIS Framework
To optimize GEMM on the Versal, we adopted the BLIS design methodology, which utilizes five nested loops to partition large matrices into smaller blocks and panels. This approach allows for efficient data movement across the memory hierarchy.
Memory Mapping Strategy
Unlike standard CPUs with hardware-managed caches, the Versal requires explicit management of data movement. We treated the heterogeneous memory of the Versal as a traditional cache hierarchy:
- L2 Cache Equivalent: Matrix A (weights) is pre-packed into the FPGA RAMs.
- L1 Cache Equivalent: Matrix B (activations) is streamed from DDR4 into the AIE tile’s 32 KB local memory.
- Registers: The final computation occurs within the vector registers of the AIE.
The Micro-kernel Design
The core of the implementation is a hand-tuned micro-kernel written with AIE-specific intrinsics, such as mac16. We focused on 16-bit integer (INT16) precision, as it provides an optimal balance between numerical precision and hardware throughput for deep learning inference. The micro-kernel performs the actual multiply-accumulate operations directly on the vector registers, aiming to keep the arithmetic units saturated.
Performance and Insights
Our prototype implementation achieved a throughput of 27.5 MACs (Multiply-Accumulates) per cycle, representing 86.7% of the hardware's theoretical peak of 32 MACs per cycle for INT16 operands.
The Impact of Register Spilling
A critical finding during the optimization process involved the sizing of the micro-tile. While a $32 \times 4$ micro-tile theoretically offers more parallelism, it resulted in lower performance than a $16 \times 4$ configuration. This was due to "register spilling": the larger tile exceeded the capacity of the physical accumulator registers, forcing the compiler to move data back to local memory. This observation underscores the necessity of aligning software kernels with the specific physical constraints of the accelerator hardware.
Deterministic Communication
While the requirement for explicit data management increases programming complexity, it offers the advantage of deterministic communication. By manually encoding every data transfer, we can eliminate the unpredictable latency often associated with hardware-managed caches, which is a vital feature for real-time AI inference applications.
Conclusion and Future Work
This research demonstrates that classical linear algebra optimization principles—specifically hierarchical blocking and packing—remain highly effective for modern domain-specific accelerators. By carefully managing the memory hierarchy and avoiding register spilling, we achieved near-peak performance on a single AIE tile.
Future research will focus on three key areas:
- Scaling: Expanding the implementation from a single tile to the full array of up to 400 tiles available on the Versal chip.
- Datatype Support: Adapting the micro-kernel for INT8 operations, which could potentially quadruple throughput, and FP32 for high-precision tasks.
- Offloading Packing: Moving the matrix packing operations from the ARM scalar processor to the programmable logic (FPGA fabric) to eliminate current bottlenecks and further reduce end-to-end latency.
Summary updated