让编译器自动优化代码生成顺序,提升性能且易于集成。
Protean Compiler: An Agile Framework to Drive Fine-grain Phase Ordering
- 基于机器学习构建细粒度优化顺序框架,支持动态调整。
- 在Cbench上平均提速4.1%,部分应用最高达15.7%。
- 可轻松对接第三方ML模型,适合编译器研究与工程优化。
自20世纪70年代以来,编译器优化阶段排序问题始终未解,因其优化空间巨大且无边界,难以找到有限解。传统方法依赖手工编码算法,仅针对少量基准测试调优,更换测试集时需大量重调。过去20年虽尝试用机器学习构建性能模型以改进优化选择与排序,但这些方法未能无缝集成到编译器中,也未在代码片段层面实现细粒度应用。本文提出Protean Compiler:一个可嵌入LLVM的敏捷框架,首次实现细粒度优化顺序的内置能力。该框架包含超过140种手工设计的静态特征提取方法,覆盖不同作用域。实验表明,仅增加数秒编译时间,可在Cbench上实现平均4.1%、部分应用最高15.7%的性能提升。此外,Protean支持与第三方机器学习框架及大语言模型集成,两步优化策略分别在Susan和Jpeg应用上带来10.1%和8.5%的加速。Protean已无缝集成至LLVM,可作为增强版完整编译器使用,计划近期开源。
原文摘要 · Abstract (English)
The phase ordering problem has been a long-standing challenge since the late 1970s, yet it remains an open problem due to having a vast optimization space and an unbounded nature, making it an open-ended problem without a finite solution, one can limit the scope by reducing the number and the length of optimizations. Traditionally, such locally optimized decisions are made by hand-coded algorithms tuned for a small number of benchmarks, often requiring significant effort to be retuned when the benchmark suite changes. In the past 20 years, Machine Learning has been employed to construct performance models to improve the selection and ordering of compiler optimizations, however, the approaches are not baked into the compiler seamlessly and never materialized to be leveraged at a fine-grained scope of code segments. This paper presents Protean Compiler: An agile framework to enable LLVM with built-in phase-ordering capabilities at a fine-grained scope. The framework also comprises a complete library of more than 140 handcrafted static feature collection methods at varying scopes, and the experimental results showcase speedup gains of up to 4.1% on average and up to 15.7% on select Cbench applications wrt LLVM's O3 by just incurring a few extra seconds of build time on Cbench. Additionally, Protean compiler allows for an easy integration with third-party ML frameworks and other Large Language Models, and two applications of this two-step optimization show a gain of 10.1\% and 8.5\% speedup w.r.t. -O3 on CBench's Susan and Jpeg applications. Protean compiler is seamlessly integrated into LLVM and can be used as a new, enhanced, full-fledged compiler. We plan to release the project to the open-source community in the near future.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。