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

学习如何使更高效的优化

Learning to Make Compiler Optimizations More Effective

Technical University of Darmstadt(达姆施塔特工业大学);University of Stuttgart(斯图加特大学)

Rahim Mammadli, Marija Selakovic, Felix Wolf, Michael Pradel

摘要:

由于循环执行其主体多次,编译器开发人员非常重视其优化。然而,鉴于高度多样化的源代码和硬件,编译器仍然难以产生最佳的目标代码。可能的循环优化(包括它们的组合)的绝对数量进一步加剧了问题。今天的编译器使用硬编码的语法来决定何时、是否以及应用有限的优化集合中的哪一个。通常,这会导致非常不稳定的行为,使得编译器优化的成功取决于循环的精确编写方式。本文介绍了LoopLearner,它解决了编译器不稳定的问题,通过预测编写循环的方式将导致有效的编译代码。为此,我们训练一个神经网络,以找到语义不变的源代码级转换的循环,帮助编译器生成更有效的代码。我们的模型学习从原始源代码中提取有用的特征,并预测给定转换可能产生的加速。我们使用来自各种性能相关基准的1,895个循环来评估LoopLearner。在编译之前应用我们的模型认为最有利的转换会产生1.14倍的平均加速。当尝试前3个建议的转换时,平均加速甚至增加到1.29倍。将该方法与通过所有可用代码转换的详尽搜索进行比较,表明LoopLearner有助于在几个数量级的时间内识别最有益的转换。

英文摘要:

Because loops execute their body many times, compiler developers place much emphasis on their optimization. Nevertheless, in view of highly diverse source code and hardware, compilers still struggle to produce optimal target code. The sheer number of possible loop optimizations, including their combinations, exacerbates the problem further. Today's compilers use hard-coded heuristics to decide when, whether, and which of a limited set of optimizations to apply. Often, this leads to highly unstable behavior, making the success of compiler optimizations dependent on the precise way a loop has been written. This paper presents LoopLearner, which addresses the problem of compiler instability by predicting which way of writing a loop will lead to efficient compiled code. To this end, we train a neural network to find semantically invariant source-level transformations for loops that help the compiler generate more efficient code. Our model learns to extract useful features from the raw source code and predicts the speedup that a given transformation is likely to yield. We evaluate LoopLearner with 1,895 loops from various performance-relevant benchmarks. Applying the transformations that our model deems most favorable prior to compilation yields an average speedup of 1.14x. When trying the top-3 suggested transformations, the average speedup even increases to 1.29x. Comparing the approach with an exhaustive search through all available code transformations shows that LoopLearner helps to identify the most beneficial transformations in several orders of magnitude less time.

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

↑