arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2404.16077cs.PLcs.LG
收藏

CompilerDream: 学习编译器世界模型以实现通用代码优化

CompilerDream: Learning a Compiler World Model for General Code Optimization

School of Software, BNRist Tsinghua University Beijing China(软件学院、北师大清华大学北京中国);Tsinghua University(清华大学)

Chaoyi Deng, Jialong Wu, Ningya Feng, Jianmin Wang, Mingsheng Long

AI总结:

提出基于模型的强化学习方法CompilerDream,通过编译器世界模型模拟优化pass属性并训练智能体,实现跨应用场景和语言的通用代码优化,在零样本泛化上超越LLVM内置优化。

摘要:

编译器中的有效代码优化对计算机和软件工程至关重要。这些优化的成功主要取决于应用于代码的优化pass的选择和排序。虽然大多数编译器依赖固定的优化pass序列,但当前寻找最优序列的方法要么使用不切实际的慢速搜索算法,要么使用难以泛化到训练时未见代码的学习方法。我们提出了CompilerDream,一种基于模型的强化学习方法,用于通用代码优化。CompilerDream包含一个编译器世界模型,该模型准确模拟优化pass的内在属性,以及一个在此模型上训练以产生有效优化策略的智能体。通过在大规模程序数据集上训练,CompilerDream能够作为跨各种应用场景和源代码语言的通用代码优化器。我们的广泛实验首先突出了CompilerDream在自动调优方面的强大优化能力,它引领了CompilerGym排行榜。更重要的是,大规模训练的编译器世界模型和智能体的零样本泛化能力在多个数据集上表现出色,在值预测和端到端代码优化两种设置中均超越了LLVM的内置优化和其他最先进方法。

英文摘要:

Effective code optimization in compilers is crucial for computer and software engineering. The success of these optimizations primarily depends on the selection and ordering of the optimization passes applied to the code. While most compilers rely on a fixed sequence of optimization passes, current methods to find the optimal sequence either employ impractically slow search algorithms or learning methods that struggle to generalize to code unseen during training. We introduce CompilerDream, a model-based reinforcement learning approach to general code optimization. CompilerDream comprises a compiler world model that accurately simulates the intrinsic properties of optimization passes and an agent trained on this model to produce effective optimization strategies. By training on a large-scale program dataset, CompilerDream is equipped to serve as a general code optimizer across various application scenarios and source-code languages. Our extensive experiments first highlight CompilerDream's strong optimization capabilities for autotuning, where it leads the CompilerGym leaderboard. More importantly, the zero-shot generalization ability of large-scale trained compiler world model and agent, excels across diverse datasets, surpassing LLVM's built-in optimizations and other state-of-the-art methods in both settings of value prediction and end-to-end code optimization.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑