计算机科学 ›› 2026, Vol. 53 ›› Issue (6A): 260300057-9.doi: 10.11896/jsjkx.260300057

• 计算机软件&体系结构 • 上一篇    下一篇

基于程序特征的智能化编译优化技术研究

黄亮明, 张佳慧, 蔡淳豪   

  1. 无锡先进技术研究院 江苏 无锡 214122
  • 出版日期:2026-06-16 发布日期:2026-06-12
  • 通讯作者: 黄亮明(liangming_huang@126.com)
  • 基金资助:
    科技部重点支持项目(GG20210701);国家重点研发计划(2020YFB0204602)

Research on Intelligent Compiler Optimization Techniques Based on Program Features

HUANG Liangming, ZHANG Jiahui, CAI Chunhao   

  1. Wuxi Institute of Advanced Technology,Wuxi,Jiangsu 214122,China
  • Published:2026-06-16 Online:2026-06-12
  • About author:HUANG Liangming,born in 1988,Ph.D,assistant researcher.His main research interests include compiler design and optimization,and inference optimization for large language models.
  • Supported by:
    Key Project of the Ministry of Science and Technology(GG20210701) and National Key Research and Development Program(2020YFB0204602).

摘要: 传统编译器优化面临规则固化、场景局限和人工设计效率天花板的问题,难以满足不同程序的高效编译需求。对此,研究者提出了自动调优、贝叶斯优化等算法进行优化选项和参数的寻优。然而,现有方法面临两方面的问题:一是需迭代运行目标码,成本高,面对大规模程序不可行;二是将程序作为黑盒,导致存在依赖初始配置、陷入局部最优、面对新程序需重新调优等问题。对此,提出基于程序特征的智能化编译优化技术,通过编译器采集程序特征信息,利用包含程序特征及较优选项组合的数据集训练深度学习模型,使其根据输入程序特征预测适配的选项组合;此外,针对循环展开等优化过程,以细粒度的参数寻优为目标,结合机器学习模型和程序特征实现关键参数的智能化选择。采用标准规模的SPEC CPU2017整数课题进行测试,相较O3优化级别,使用所提模型预测得到的优化选项和参数具有7.2%的性能提升,且模型平均推理时间仅为7.11 s,产生的编译时特征提取时间开销仅为1.02%。实验结果表明,该技术能有效预测不同程序的匹配编译优化选项和参数,且与现有技术相比有显著的成本优势。

关键词: 编译优化, 程序特征, 基于学习的优化, 编译配置选择, 性能预测

Abstract: Traditional compiler optimizations face challenges such as rigid rules,limited adaptability across scenarios,and the efficiency ceiling imposed by manual design,making it difficult to meet the diverse demands of efficient compilation for different programs.To address this,researchers have proposed algorithms such as auto-tuning and Bayesian optimization to search for optimal optimization flags and parameters.However,existing methods suffer from two major drawbacks.Firstly,they require iterative execution of the target code,which is computationally expensive and infeasible for large-scale programs.Secondly,they treat programs as black boxes,leading to dependence on initial configurations,susceptibility to local optima,and the need for re-optimization when applied to new programs.To overcome these limitations,this paper proposes an intelligent compiler optimization technique based on program features.The approach involves collecting program feature information through the compiler and training a deep learning model on a dataset containing both program features and high-performing optimization flag combinations,enabling the model to predict suitable optimization options based on input program characteristics.Furthermore,for optimization processes such as loop unrolling,fine-grained parameter tuning is achieved by combining machine learning models with program features to enable intelligent selection of key parameters.Evaluated on the standard-scale SPEC CPU2017 integer benchmark suite,the proposed method achieves a 7.2% performance improvement over the O3 optimization level,with an average model inference time of only 7.11 seconds and a feature extraction overhead of just 1.02% of total compilation time.Experimental results demonstrate that the technique can effectively predict appropriate optimization flags and parameters for different programs,offering significant cost advantages over existing approaches.

Key words: Compiler optimization, Program features, Learning-based optimization, Compiler configuration selection, Performance prediction

中图分类号: 

  • TP314
[1] AHO A V,LAM M S,SETHI R,et al.Compilers:principles,techniques,and tools[M].Beijing:China Machine Press,2011.
[2] HALL M,PADUA D,PINGALI K.Compiler research:the next 50 years[J].Communications of the ACM,2009,52(2):60-67.
[3] GNU PROJECT.GNU Compiler Collection[EB/OL].[2026-04-09] .https://gcc.gnu.org/.
[4] LLVM PROJECT.LLVM:low level virtual machine[EB/OL].[2026-04-09] .https://llvm.org/.
[5] LATTNER C.LLVM and clang:next generation compiler technology[C]//The BSD Conference.2008:1-20.
[6] CHI H Y,CHEN C B.Survey on Automatic Tuning of Compi-lers by Machine Learning[J].Computer Science,2022,49(1):241-251.
[7] GAO G J,REN Z L,ZHANG J X,et al.Selection of com-piler-optimization sequences[J].SCIENTIA SINICA Informationis,2019,49(10):1267-1282.
[8] GARCIARENA U,SANTANA R.Evolutionaryoptimization ofcompiler flag selection by learning and exploiting flags interactions[C]//Proceedings of the 2016 on Genetic and Evolutionary Computation Conference Companion.2016:1159-1166.
[9] ASHOURI A H,KILLIAN W,CAVAZOS J,et al.A survey on compiler autotuning using machine learning[J].ACM computing surveys,2018,51(5):96:1-96:42.
[10] ASHOURI A H,HUA Y,WANG X,et al.MLGOPerf:an ML guided inliner to optimize performance[J].arXiv:2207.08389,2022.
[11] WANG Z,BOYLE M O.Machine learning in compiler optimization[C]//Proceedings of the IEEE.2018:1879-1901.
[12] ANSEL J,KAMIL S,VEERAMACHANENI K,et al.Open-Tuner:An extensible framework for program autotuning[C]//Proceedings of the 23rd International Conference on Parallel Architectures and Compilation.2014:303-315.
[13] KALYAN M,WANG X,ELTANTAWY A.Code region based auto-tuning enabled compilers[C]//Workshop on the Intersection of High Performance Computing and Machine Learning(HPCaML).ACM,2019.
[14] PARK S,LATIFI S,PARK Y,et al.SRTuner:effective compiler optimization customization by exposing synergistic relations[C]//2022 IEEE/ACM International Symposium on Code Generation and Optimization(CGO).2022:118-130.
[15] CHEN J J,XU N X,CHEN P Q,et al.Efficient compiler autotuning via bayesian optimization[C]//2021 IEEE/ACM 43rd International Conference on Software Engineering(ICSE).IEEE,2021:1198-1209.
[16] SEEKER V,CUMMINS C,COLE M,et al.Revealing compiler heuristics through automated discovery and optimization[C]//2024 IEEE/ACM International Symposium on Code Generation and Optimization(CGO).2024:55-66.
[17] ZHENG Z C,WU Y,ZHANG X W.mLOOP:optimize loop unrolling in compilation with a ML-based approach[C]//2024 International Conference on Networking,Architecture and Storage(NAS).2024.
[18] TROFIN M,QIAN Y,BREVDO E,et al.MLGO:a machinelearning guided compiler optimizations framework[J].arXiv:2101.04808,2021.
[19] HUANG L M,JIANG J,GAO X W.Structure Peeling Based on Link Time Optimization in the GCC compiler[C]//2022 3rd International Conference on Information Science,Parallel and Distributed Systems(ISPDS).2022:317-322.
[20] HENNING J.Spec cpu2006 benchmark descriptions[J].ACM SIGARCH Computer ArchitectureNews,2006,34(4):1-17.
[21] FURSIN G,TEMAM O.Collective optimization:a practical collaborative approach[J].ACM Transactions on Architecture and Code Optimization(TACO),2010,7(4):20:1-20:20.
[22] GEWERS F L,FERREIRA G R,DE ARRUDA H F,et al.Principal component analysis:a natural approach to data exploration[J].ACM Computing Surveys,2011,50(4):70:1-70:34.
[23] CHEN T Q,GUESTRIN C.XGBoost:a scalable tree boosting system[C]//Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining(KDD'16).2016:785-794.
[24] STANDARD PERFORMANCE EVALUATION CORPORA-TION(SPEC).SPEC CPU2017 Benchmark Suite[EB/OL].[2026-03-11] .https://www.spec.org/cpu2017/.
[25] LIMAYE A,ADEGBIJA T.A workload characterization of the SPEC CPU2017 benchmark suite[C]//2018 IEEE International Symposium on Performance Analysis of Systems and Software(ISPASS).2018:149-158.
[26] JIANG J,GU X Y,XU K K,et al.Design and Research ofSIMD Programming Interface for Sunway [J].Computer Science,2025,52(6):66-73.
[27] WEICKER R P.Dhrystone:a synthetic systems programmingbenchmark[J].Communications of the ACM,1984,27(10):1013-1030.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!