AutoAnnotate: Reinforcement Learning based Code Annotation for High Level Synthesis

Hafsah Shahzad1, Ahmed Sanaullah2, Sanjay Arora2, Ulrich Drepper2, Martin Herbordt1
1Boston University, 2RedHat Inc.


High Level Synthesis (HLS) allows custom hardware generation using developer-friendly programming languages. It is often the case, however, that the HLS compiler is unable to output high quality results. One approach is to pre-process the source code to restructure the computational flow and/or insert compiler hints using annotations/pragmas. But these techniques also require developer expertise regarding hardware design patterns and even compiler internals; an incorrect annotation strategy can worsen performance and/or result in compilation deadlocks.

To address these challenges, this work presents AutoAnnotate, an automatic code annotation framework for HLS. It demonstrates the efficacy, novelty and benefit of applying ML methods to code annotation. AutoAnnotate replaces the need for developer expertise by using Reinforcement Learning to determine the best set of annotations for a given input code. To demonstrate the effectiveness of our approach, we ran AutoAnnotate on a number of common FPGA benchmarks derived, e.g., from Rodinia and OpenDwarfs, and state-of-art HLS tools (Xilinx Vitis and Intel HLS). We obtained a geometric mean of 42x performance improvement for Vitis HLS and 3.78x for Intel HLS. We then hand optimized these codes using standard best practices and again applied AutoAnnotate, this time still achieving 6.7x performance improvement for Vitis HLS and 3.1x for Intel HLS.