计算机科学 ›› 2026, Vol. 53 ›› Issue (10): 384-395.doi: 10.11896/jsjkx.250700009
梁军达, 王磊, 张旭林, 牛梦锦, 郜振琦
LIANG Junda, WANG Lei, ZHANG Xulin, NIU Mengjin, GAO Zhenqi
摘要: 随着数值计算领域的快速发展,浮点程序的精度优化已成为提升计算可靠性的关键问题。传统方法如混合精度优化、近似正确舍入误差、误差检测与修复及表达式优化重写等,虽然取得了一定进展,但仍面临搜索空间庞大、优化效率低下、依赖专家经验等局限性。为了解决这些问题,提出了一种基于强化学习的浮点表达式自适应优化方法,并实现了表达式优化工具ExprRL,通过结合强化学习与动态精度优化经验库,实现了高效且自适应的精度优化。ExprRL采用Tree-LSTM模型计算表达式的符号、结构和语义特征嵌入向量,并通过余弦相似度检索匹配经验库中的优化策略,加速优化过程;若匹配失败,则启动强化学习模块,将表达式优化问题建模为马尔可夫决策过程,通过Q-learning算法探索最优重写动作序列,并动态更新至经验库中。实验选取FPBench标准数据集中的31个表达式作为测试集,结果表明经过ExprRL优化后,平均ulp误差降低41.42%,最大ulp误差降低46.92%,ExprRL性能优于传统精度优化工具Herbie和exprAuto。
中图分类号:
| [1] ZOU D,GU Y,SHI Y,et al.Oracle-free repair synthesis for floating-point programs[J].Proceedings of the ACM on Programming Languages,2022,6(OOPSLA2):957-985. [2] FOUSSE L,HANROT G,LEFÈVRE V,et al.MPFR:A multiple-precision binary floating-point library with correct rounding[J].ACM Transactions on Mathematical Software,2007,33(2):1-15. [3] ZURAS D,COWLISHAW M,AIKEN A,et al.IEEE Standard for Floating-Point Arithmetic[S].IEEE Std 754-2008. [4] GOLDBER G,DAVI D.What every computer scientist shouldknow about floating-point arithmetic[J].ACM Computing Surveys,1991,23(1):5-48. [5] ASHOK P,CHATTERJEE K,DACA P,et al.Value Iteration for Long-run Average Reward in Markov Decision Processes[C]//LNCS.Cham:Springer,2017:201-221. [6] CHAPMAN D,KAELBLING L P.Input Generalization in Delayed Reinforcement Learning:An Algorithm and Performance Comparisons[C]//Proceedings of the 12th International Joint Conference on Artificial Intelligence-Volume 2.1991. [7] JANG B,KIM M,HARERIMANA G,et al.Q-learning Algo-rithms:A Comprehensive Classification and Applications[J].IEEE Access,2019,7:133653-133667. [8] YI J,JIALU F,TIANYOU C,et al.Data-Driven Flotation Industrial Process Operational OptimalControl Based on Reinforcement Learning[J].IEEE Transactions on Industrial Informatics,2018,14(5):1974-1989. [9] KHAN G S,HERRMANN G,LEWIS L F,et al.Reinforcement learning and optimal adaptive control:An overview and implementation examples[J].Annual Reviews in Control,2012,36(1):42-59. [10] MOERLAND T M,BROEKENS J,JONKER C M.Emotion in Reinforcement Learning Agents and Robots:A Survey[J].Machine Learning,2017,107(2):1-38. [11] YU Z,CAO R,TANG Q,et al.Order Matters:Semantic-AwareNeural Networks for Binary Code Similarity Detection[C]//Association for the Advancement of Artificial Intelligence.2020:1145-1152. [12] LI T,WANG J.Binary code similarity detection based on attention mechanism and Child-Sum Tree-LSTM[J].Cybersecurity and Data Governance,2023,42(11):8-14,34. [13] ZHAO G,HUANG J.DeepSim:deep learning code functionalsimilarity[C]//Proceedings of the 2018 26th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering.2018:141-151. [14] CHOWDHARY S,NAGARAKATTE S.Fast shadow execution for debugging numerical errors using error free transformations[J].Proceedings of the ACM on Programming Languages.2022,6(OOPSLA2):1845-1872. [15] YI X,CHEN L,MAO X,et al.Efficient automated repair of high floating-point errors in numerical libraries[J].Proceedings of the ACM on Programming Languages,2019,3(POPL):1-29. [16] HOU M,GUO S Z,WANG P J,et al.Mixed precision optimization method based on sensitivity[J].Journal of Information Engineering University,2022,23(6):718-723. [17] HAO J G,ZHOU B,XU J C,et al.Mixed precision optimization method using multi-precision basis functions[J].Journal of Information Engineering University,2024,25(6):703-709. [18] ARZELIER D,BREHARD F,JOLDES M.Exchange Algorithm for Evaluation and Approximation Error-Optimized Polynomials[C]//2019 IEEE 26th Symposium on Computer Arithmetic,IEEE,2019. [19] AANJANEYA M,LIM J P,NAGARAKATTE S.Progressive polynomial approximations for fast correctly rounded math libraries[C]//Proceedings of the 43rd ACM SIGPLAN International Conference on Programming Language Design and Implementation.2022:552-565. [20] LIM J P,NAGARAKATTE S.High performance correctlyrounded math libraries for 32-bit floating point representations[C]//Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation.2021:359-374. [21] PANCHEKHA P,SANCHEZ-STERN A,WILCOX J R,et al.Automatically improving accuracy for floating point expressions[J].ACM Sigplan Notices,2015,50(6):1-11. [22] WANG X,WANG H,SU Z,et al.Global optimization of numerical programs via prioritized stochastic algebraic transformations[C]//2019 IEEE/ACM 41st International Conference on Software Engineering(ICSE).IEEE,2019:1131-1141. [23] DAMOUCHE N,MARTEL M.Salsa:An Automatic Tool toImprove the Numerical Accuracy of Programs[C]//AFM@ NFM.2017:63-76. [24] WANG Y Z,WANG L,XU F J,et al.Floating point program precision defect repair method based on program rewriting[J].Journal of Computer Applications,2023,43(S1):177-181. [25] HAO J W,YANG H R,XIA Y Y,et al.Floating-point expression precision optimization method based on multi-type calculation rewriting[J].Computer Science,2024,51(4):86-94. [26] LI Z,DONG X X,HUANG C C,et al.Floating-point expression design space exploration method based on heuristic search[J].Computer Applications,2020,40(9):2665-2669. [27] XIAO A X,ZHANG S X,TANG E Y,et al.An empirical library-guided floating-point programoptimization acceleration strategy [J].Chinese Journal of Computers,2022,45(9):2014-2028. [28] XIAO Y,AHMED N K.A Graph-Based Learning Framework for Compiler Loop Auto-Vectorization[J].Intelligent Computing,2025,4:0113. [29] LI J,ZHENG Q.Reinforcement Learning for Automated Pragma-Based Loop Optimization[C]//2025 IEEE 8th Information Technology and Mechatronics Engineering Conference(ITOEC).IEEE,2025:1643-1647. [30] WEI A,SURESH T,TAN H,et al.Improving Assembly Code Performance with Large Language Models via Reinforcement Learning[J].arXiv:2505.11480,2025. |
|
||