论文标题

汇编:一种快速而灵活的编译器内部机器学习任务数据的方式

Compilation Forking: A Fast and Flexible Way of Generating Data for Compiler-Internal Machine Learning Tasks

论文作者

Mosaner, Raphael, Leopoldseder, David, Kisling, Wolfgang, Stadler, Lukas, Mössenböck, Hanspeter

论文摘要

编译器优化决策通常基于以几个既定基准套件为中心的手工制作的启发式方法。或者,可以从编译过程中产生的功能和性能数据中学到它们。但是,基于机器学习模型的数据驱动的编译器优化需要大量的质量数据进行培训,以便匹配甚至超过现有的人工制作的启发式方法。在静态汇编设置中,相关工作通过迭代汇编解决了这个问题。但是,动态编译器可能会根据动态选择的编译策略产生不同的数据,从而加剧了可比较数据的生成。我们提出了汇编,这是一种从任意,动态编译程序中生成一致的功能和性能数据的技术。具有相同分析和编译历史记录的程序零件的不同版本在单个程序运行中执行,以最大程度地减少动态汇编和运行时环境的噪声。我们的方法促进了编译器优化决策的大规模绩效评估。此外,汇编通过提供模型培训的数据来支持基于机器学习的域特异性编译策略。我们以编程语言语言方式在GRAALVM编译器中实施了汇编。为了评估生成数据的质量,我们培训了几种机器学习模型,以取代与循环相关的优化的编译器启发式方法。在比较基准套件表演的几何平均值时,受过训练的模型与高度调整的编译器启发式方法的表现同样好。对几个基准测试的较大影响范围从20%的加速到17%的速度。提出的方法可以在任何动态编译器中实现。我们认为,它可以帮助分析编译决策并利用机器学习在动态汇编中的使用。

Compiler optimization decisions are often based on hand-crafted heuristics centered around a few established benchmark suites. Alternatively, they can be learned from feature and performance data produced during compilation. However, data-driven compiler optimizations based on machine learning models require large sets of quality data for training in order to match or even outperform existing human-crafted heuristics. In static compilation setups, related work has addressed this problem with iterative compilation. However, a dynamic compiler may produce different data depending on dynamically-chosen compilation strategies, which aggravates the generation of comparable data. We propose compilation forking, a technique for generating consistent feature and performance data from arbitrary, dynamically-compiled programs. Different versions of program parts with the same profiling and compilation history are executed within single program runs to minimize noise stemming from dynamic compilation and the runtime environment. Our approach facilitates large-scale performance evaluations of compiler optimization decisions. Additionally, compilation forking supports creating domain-specific compilation strategies based on machine learning by providing the data for model training. We implemented compilation forking in the GraalVM compiler in a programming-language-agnostic way. To assess the quality of the generated data, we trained several machine learning models to replace compiler heuristics for loop-related optimizations. The trained models perform equally well to the highly-tuned compiler heuristics when comparing the geometric means of benchmark suite performances. Larger impacts on few single benchmarks range from speedups of 20% to slowdowns of 17%. The presented approach can be implemented in any dynamic compiler. We believe that it can help to analyze compilation decisions and leverage the use of machine learning into dynamic compilation.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源