计算机科学 ›› 2025, Vol. 52 ›› Issue (7): 248-254.doi: 10.11896/jsjkx.241000181

• 人工智能 • 上一篇    下一篇

基于粒子群算法的自动向量化收益评估模型研究

刘梦真1, 周清雷1, 韩林2, 聂凯2, 李浩然2, 陈梦尧1, 刘浩浩2   

  1. 1 郑州大学计算机与人工智能学院 郑州 450001
    2 郑州大学国家超级计算郑州中心 郑州 450001
  • 收稿日期:2024-10-31 修回日期:2025-02-12 发布日期:2025-07-17
  • 通讯作者: 聂凯(ieknie@zzu.edu.cn)
  • 作者简介:(liumzcs@163.com)
  • 基金资助:
    2024河南省重大科技专项(241100210100);2024河南省科技攻关项目(242102211094);2023国家重点研发计划高性能计算专项(2023YFB3002505);2022河南省重大科技专项(221100210600)

Research on Automatic Vectorization Benefit Evaluation Model Based on Particle SwarmAlgorithm

LIU Mengzhen1, ZHOU Qinglei1, HAN Lin2, NIE Kai2, LI Haoran2, CHEN Mengyao1, LIU Haohao2   

  1. 1 School of Computer Science and Artificial Intelligence, Zhengzhou University, Zhengzhou 450001, China
    2 National Supercomputing Center in Zhengzhou, Zhengzhou University, Zhengzhou 450001, China
  • Received:2024-10-31 Revised:2025-02-12 Published:2025-07-17
  • About author:LIU Mengzhen,born in 2000,postgra-duate.Her main research interests include compiler optimization and high-performance computing.
    NIE Kai,born in 1987,Ph.D,senior engineer,graduate advisor.His main research interests include advanced compilation techniques,high-performance computing and so on.
  • Supported by:
    2024 Henan Provincial Major Science and Technology Project(241100210100),2024 Henan Provincial Science and Technology Research Project(242102211094),2023 National Key R&D Program for High-Performance Computing(2023YFB3002505) and 2022 Henan Provincial Major Science and Technology Project(221100210600).

摘要: 自动向量化技术利用SIMD部件加速程序的执行,减轻了程序员的负担,是GCC编译器中的重要优化过程之一。但GCC编译器中自动向量化的收益评估模型并不准确,会影响GCC编译器是否应该进行向量化转换的判定。为了提升申威平台上的自动向量化效率,基于申威平台上的GCC编译器,构建了一套新的自动向量化收益评估模型。针对申威处理器的后端指令集设计不同种类的代价,通过粒子群算法训练相对应的代价值,以提高申威平台上自动向量化收益评估模型的准确性。在SPEC2006和SPEC2017上进行了实验测试,与GCC编译器默认的收益评估模型相比,所提模型在SPEC2006课题上加速比最高提升7.6%,在SPEC2017课题上加速比最高提升5.75%,验证了模型的有效性。实验结果表明,所提出的模型可进一步完善基础自动向量化功能,提升申威平台编译系统的易用性。

关键词: 申威平台, GCC编译器, 自动向量化, 收益评估模型, 粒子群算法

Abstract: Automatic vectorization leverages SIMD components to accelerate program execution,easing the programmers' workload and serving as a key optimization in the GCC compiler.However,the current benefit evaluation model in GCC lacks precision,affecting vectorization decisions.To improve vectorization efficiency on the Sunway platform,this study introduces a new benefit evaluation model within GCC.The model designs cost metrics specific to the Sunway processor's backend instruction set and applies a particle swarm algorithm to optimize these costs,enhancing evaluation accuracy and vectorization performance.Experimental results on SPEC2006 and SPEC2017 benchmarks show that the proposed model delivers up to 7.6% and 5.75% performance gains,respectively,over the default GCC model.These outcomes confirm the model's effectiveness in refining automatic vectorization and improving the usability of the Sunway compilation system.With more accurate evaluations,the model supports better optimization decisions,resulting in enhanced platform performance.

Key words: Sunway, GCC compiler, Auto-vectorization, Cost model, Particle swarm optimization

中图分类号: 

  • TP314
[1]AMIRIH,SHAHBAHRAMI A,POHL A,et al.Performance Evaluation of Implicit and Explicit SIMDization[J].Microprocessors and Microsystems,2018,63:158-168.
[2]FENG J G,HE Y P,TAO Q M.Automatic Vectorization:Recent Advances and Future Perspectives[J].Journal of Communications,2022,43(3):180-195.
[3]GAO W,ZHAO R C,HAN L,et al.Overview of SIMD Automatic Vectorization Compiler Optimization[J].Journal of Software,2015,26(6):1265-1284.
[4]LI W.Research on Automatic Vectorization Optimization Method Based on Improved VEGEN[D].Harbin:Harbin Engineering University,2022.
[5]CHEN M Y.Research on Loop Distribution Techniques for the Sunway GCC Compilation System[D].Zhengzhou:Zhengzhou University,2021.
[6]ASHOURIA H,KILLIAN W,CAVAZOS J,et al.A survey on compiler autotuning using machine learning[J].ACM Computing Surveys,2018,51(5):1-42.
[7]TANGY,WANG C.Performance modeling on DaVinci AI core[J].Journal of Parallel and Distributed Computing,2023,175:134-149.
[8]LEATHERH,CUMMINS C.Machine learning in compilers:Past,present and future[C]//2020 Forum for Specification and Design Languages(FDL).New York:IEEE,2020:1-8.
[9]STOCKK,POUCHET L N,SADAYAPPAN P.Using machine learning to improve automatic vectorization[J].ACM Transactions on Architecture and Code Optimization,2012,8(4):1-23.
[10]POHLA,COSENZA B,JUURLINK B.Vectorization cost mo-deling for NEON,AVX and SVE[J].Performance Evaluation,2020,140:102106.
[11]WANG Z,NIE K,HAN L.An Automatic Vectorization CostModel Based on Instruction MKS[J].Computer Science,2024,51(4):78-85.
[12]TRIFUNOVIC K,NUZMAN D,COHEN A,et al.Polyhedral-model guided loop-nest auto-vectorization[C]//Proceedings of 2009 18th International Conference on Parallel Architectures and Compilation Techniques.IEEE,2009:327-337.
[13]ZHANG Y Y,ZHAO R C,HAN L.A Vectorization Benefit Evaluation Method Based on Polyhedral Representation[J].Computer Engineering,2012,38(7):266-268,272.
[14]LI C J,XU Y,DONG Y S.Research on Automatic Vectorization Cost Model for Multi-core Multi-SIMD Architectures[C]//Proceedings of the 18th Annual Conference on Computer Engineering and Technology and the 4th Microprocessor Technology Forum.2014:111-116.
[15]LI J N.LLVM Automatic Vectorization Porting and Optimization for the Sunway Platform[D].Zhengzhou:Zhengzhou University,2021.
[16]HAN Y,YU M.A Review of the Application of Particle Swarm Optimization in Robot Path Planning[J].Manufacturing Technology & Machine Tools,2024(7):85-90.
[17]DORIT N,IRA R,AYAL Z.Auto-vectorization of interleaved data for SIMD[J].Association for Computing Machinery,2006,6:132-143.
[18]TAN H,CHEN H,SHENG L,et al.Modeling and evaluation for gather/scatter operations in VectorSIMD architectures[C]//2017 IEEE 28th International Conference on Application-specific Systems,Architectures and Processors(ASAP).New York:IEEE,2017.
[19]LI J N,HAN L,CHAI Y D.LLVM Automatic VectorizationPorting and Optimization for Domestic Platforms[J].Computer Engineering,2022,48(1):142-148.
[20]HUANG J J,LI C J,XU Y.Analysis of the Automatic Vectori-zation Cost Model in GCC[C]//Proceedings of the 17th AnnualConference on Computer Engineering and Technology and the 3rd Microprocessor Technology Forum.2013:271-280.
[21]GHASEMIM,AKBARI E,RAHIMNEJAD A,et al.Phasor particle swarm optimization:A simple and efficient variant of PSO[J].Soft Computing,2019,23(19):9701-9718.
[22]JAKUBIK J,BINDING A,FEUERRIEGUL S.Directed particle swarm optimization with Gaussian-process-based function forecasting[J].European Journal of Operational Research,2021,295(1):157-169.
[23]MALEKIS,GAO Y,GARZARÁN M J,et al.An Evaluation of Vectorizing Compilers[C]//International Conference on Parallel Architectures & Compilation Techniques.IEEE,2011:372-382.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!