Widely used compilers like GCC and LLVM usually have hundreds of optimizations controlled by optimization flags, which are enabled or disabled during compilation to improve runtime performance (e.g., small execution time) of the compiler program. Due to the large number of optimization flags and their combination, it is difficult for compiler users to manually tune compiler optimization flags. In the literature, a number of auto-tuning techniques have been proposed, which tune optimization flags for a compiled program by comparing its actual runtime performance with different optimization flag combination. Due to the huge search space and heavy actual runtime cost, these techniques suffer from the widely-recognized efficiency problem. To reduce the heavy runtime cost, in this paper we propose a lightweight learning approach which uses a small number of actual runtime performance data to predict the runtime performance of a compiled program with various optimization flag combination. Furthermore, to reduce the search space, we design a novel particle swarm algorithm which tunes compiler optimization flags with the prediction model. To evaluate the performance of the proposed approach CompTuner, we conduct an extensive experimental study on two popular C compilers GCC and LLVM with two widely used benchmarks cBench and PolyBench. The experimental results show that CompTuner significantly outperforms the five compared techniques, including the state-of-art technique BOCA.
翻译:广泛使用的编译器(如GCC和LLVM)通常包含数百个由优化标志控制的优化选项,这些标志在编译过程中被启用或禁用,以提升编译程序的实际运行性能(例如,缩短执行时间)。由于优化标志数量庞大且组合复杂,编译器用户难以手动调节编译器优化标志。文献中已提出多种自动调优技术,通过比较编译程序在不同优化标志组合下的实际运行性能来调整优化标志。然而,由于搜索空间巨大且实际运行开销过高,这些技术普遍面临效率低下的问题。为降低高额的实际运行开销,本文提出一种轻量级学习方法,仅使用少量实际运行性能数据来预测编译程序在不同优化标志组合下的运行性能。此外,为缩小搜索空间,我们设计了一种新型粒子群算法,结合预测模型对编译器优化标志进行调优。为评估所提方法CompTuner的性能,我们在两款常用C编译器(GCC和LLVM)上,使用两个广泛使用的基准测试集(cBench和PolyBench)进行了大量实验。实验结果表明,CompTuner显著优于五种对比技术,包括当前最先进的BOCA方法。