ACPO: AI-Enabled Compiler-Driven Program Optimization

Amir H. Ashouri,Muhammad Asif Manzoor,Duc Minh Vu,Raymond Zhang,Ziwen Wang,Angel Zhang,Bryan Chan,Tomasz S. Czajkowski,Yaoqing Gao
2024-03-12
Abstract:The key to performance optimization of a program is to decide correctly when a certain transformation should be applied by a compiler. This is an ideal opportunity to apply machine-learning models to speed up the tuning process; while this realization has been around since the late 90s, only recent advancements in ML enabled a practical application of ML to compilers as an end-to-end framework. This paper presents ACPO: \textbf{\underline{A}}I-Enabled \textbf{\underline{C}}ompiler-driven \textbf{\underline{P}}rogram \textbf{\underline{O}}ptimization; a novel framework to provide LLVM with simple and comprehensive tools to benefit from employing ML models for different optimization passes. We first showcase the high-level view, class hierarchy, and functionalities of ACPO and subsequently, demonstrate a couple of use cases of ACPO by ML-enabling the Loop Unroll and Function Inlining passes and describe how ACPO can be leveraged to optimize other passes. Experimental results reveal that ACPO model for Loop Unroll is able to gain on average 4\% compared to LLVM's O3 optimization when deployed on Polybench. Furthermore, by adding the Inliner model as well, ACPO is able to provide up to 4.5\% and 2.4\% on Polybench and Cbench compared with LLVM's O3 optimization, respectively.
Programming Languages,Artificial Intelligence,Machine Learning,Performance
What problem does this paper attempt to address?
The main goal of this paper is to propose a new framework called ACPO (AI-Enabled Compiler-Driven Program Optimization), which aims to improve the compiler-driven program optimization process using machine learning techniques, specifically targeting the LLVM compiler framework. Specifically, the objectives of the ACPO framework include: 1. **Problems Addressed**: - Improve program performance: By more accurately deciding when to apply specific code transformations or optimizations to enhance the performance of the compiled program. - Accelerate optimization decisions using machine learning: Applying machine learning models during the compilation process to reduce tuning time and improve optimization effectiveness. 2. **Main Contributions**: - Provides a comprehensive toolset that allows compiler engineers to easily replace LLVM's existing hard-coded heuristic rules with machine learning. - Achieves seamless integration between the machine learning API and the compiler while keeping them relatively independent, meaning that changes in compiler versions, machine learning models, or frameworks will not break the functionality of ACPO. - Demonstrates the application of ACPO in two optimization paths, Loop Unroll and Function Inlining, and validates its effectiveness and generality. 3. **Experimental Results**: - On the Polybench benchmark, the loop unrolling model of ACPO achieved an average performance improvement of 4% compared to LLVM's O3 optimization level. - Combining the loop unrolling and function inlining models resulted in performance gains of up to 4.5% on Polybench and 2.4% on Cbench. In summary, the ACPO framework improves compiler optimization decisions by introducing machine learning techniques, thereby enhancing the execution efficiency of the final generated code. The framework is modular, extensible, and easy to use, facilitating collaboration between compiler developers and machine learning experts.