论文标题
静态神经编译器通过深度加固学习优化
Static Neural Compiler Optimization via Deep Reinforcement Learning
论文作者
论文摘要
多年来,现代编译器的相位订购问题引起了研究社区的广泛关注,但仍无法解决。暴露于用户的各种优化序列是由编译器开发人员手动设计的。在设计这样的序列时,开发人员必须在序列中选择一组优化通过,其参数和排序。最终的序列通常无法达到给定源代码的最佳运行时,与未优化版本相比,有时甚至可能会降低性能。在本文中,我们采用了一种深入的增强学习方法来解决相位订购问题。根据构成LLVM的O3序列的子序列,我们的代理商学会了在用于训练和实现验证集的一系列源代码上的O3序列,在验证集上实现了竞争性能,在先前未观察的程序上获得了高达1.32倍的速度。值得注意的是,我们的方法与自动传动方法的不同之处在于不依赖于程序的一个或多个测试运行以做出成功的优化决策。它不依赖任何动态功能,而仅对源代码的静态可靠中间表示。我们认为,使用我们的方法训练的模型可以将其作为神经优化剂集成到现代编译器中,最初是为了补充,并最终取代了手工制作的优化序列。
The phase-ordering problem of modern compilers has received a lot of attention from the research community over the years, yet remains largely unsolved. Various optimization sequences exposed to the user are manually designed by compiler developers. In designing such a sequence developers have to choose the set of optimization passes, their parameters and ordering within a sequence. Resulting sequences usually fall short of achieving optimal runtime for a given source code and may sometimes even degrade the performance when compared to unoptimized version. In this paper, we employ a deep reinforcement learning approach to the phase-ordering problem. Provided with sub-sequences constituting LLVM's O3 sequence, our agent learns to outperform the O3 sequence on the set of source codes used for training and achieves competitive performance on the validation set, gaining up to 1.32x speedup on previously-unseen programs. Notably, our approach differs from autotuning methods by not depending on one or more test runs of the program for making successful optimization decisions. It has no dependence on any dynamic feature, but only on the statically-attainable intermediate representation of the source code. We believe that the models trained using our approach can be integrated into modern compilers as neural optimization agents, at first to complement, and eventually replace the hand-crafted optimization sequences.