计算机科学 ›› 2021, Vol. 48 ›› Issue (6): 41-47.doi: 10.11896/jsjkx.201200058

• 计算机体系结构* • 上一篇    下一篇

面向64位RISC-V的基础数学库自动化移植

曹浩, 郭绍忠, 刘聃, 许瑾晨   

  1. 数学工程与先进计算国家重点实验室(信息工程大学) 郑州450002
  • 收稿日期:2020-12-07 修回日期:2021-03-22 出版日期:2021-06-15 发布日期:2021-06-03
  • 通讯作者: 许瑾晨(atao728208@126.com)
  • 基金资助:
    国家自然科学基金(61802434)

Automatic Porting of Basic Mathematics Library for 64-bit RISC-V

CAO Hao, GUO Shao-zhong, LIU Dan, XU Jin-chen   

  1. State Key Laboratory of Mathematical Engineering and Advanced Computing,PLA Information Engineering University,Zhengzhou 450002,China
  • Received:2020-12-07 Revised:2021-03-22 Online:2021-06-15 Published:2021-06-03
  • About author:CAO Hao,born in 1991,postgraduate.His main research interests include high performance computing and so on.(2227078931@qq.com)
    XU Jin-chen,born in 1987,Ph.D,lecturer,is a member of China Computer Fe-deration.His main research interests include high performance computing.
  • Supported by:
    National Natural Science Foundation of China(61802434).

摘要: 受制于核心技术和知识产权等客观条件,国产自主芯片的研发困难重重。RISC-V作为一个开源指令集架构(ISA),具有简洁、模块化等优点,成为了国产处理器的新选择。基础数学库作为计算机系统最基础的核心软件库之一,对国产处理器的软件生态建设和健康发展尤为重要,而目前RISC-V还没有相关的基础数学库。因此,文中旨在将基于国产申威处理器的基础数学库移植到64位RISC-V平台。为了解决基础数学库的高效移植问题,首先设计了一个自动化移植框架,该框架通过功能模块间的松耦合,来实现高可扩展性;然后根据64位RISC-V指令集架构的特点,提出了基于全局的主动式寄存器分配方法和基于层次的指令选择策略;最后应用该框架,实现了对申威平台基础数学库中典型函数的移植,测试结果表明移植后函数功能正确且相对于GLIBC库在性能上有一定的提升。

关键词: RISC-V, 基础数学库, 汇编, 自动化移植

Abstract: Subject to the core technology and intellectual property rights and other objective conditions,the research and development of domestic independent chip is highly restricted.RISC-V has the advantages of simplicity and modularity as an open source instruction set architecture(ISA),and it will become a new choice of domestic processor.As one of the most basic core software libraries of computer system,basic mathematics library is particularly important to the software ecological construction and healthy development of domestic processors.However,RISC-V has no relevant basic mathematics library at present.Therefore,this paper aims at porting basic mathematics library based on domestic Shenwei processor to the 64-bit RISC-V platform.In order to solve the problem of efficient transportation of the library,an automatic porting framework is designed at first,which can achieve high scalability through loose coupling between functional modules.Secondly,based on the characteristics of 64-bit RISC-V ISA,a global active register allocation method and a hierarchical instruction selection strategy are proposed.Finally,the framework is applied to bring about the transportation of some typical functions in the Shenwei basic mathematics library.Test results show that the ported functions are working correctly and the performance is improved compared with GLIBC.

Key words: RISC-V, Basic mathematic library, Assembler, Automatic porting

中图分类号: 

  • TP313
[1] ISEN C,JOHN L K,JOHN E.A Tale of Two Processors:Revisiting the RISC-CISC Debate[C]//Computer Performance Evaluation and Benchmarking.Berlin,Heidelberg:Springer,2009.
[2] The RISC-V Instruction Set Manual.Volume I:User-LevelISA;Volume II:Privileged Architecture[EB/OL].https//riscv.org/specifications/.238 pages.2019.
[3] CHAITIN G.Register allocation and spilling via graph coloring[C]//ACM.2004:66-74.
[4] DAS D,AHMAD S A,VENKATARAMANAN K.Deep Lear-ning-based Hybrid Graph-Coloring Algorithm for Register Allocation [EB/OL].[2020-01-16] https//www.researchgate.net.
[5] POLETTO M,SARKAR V.Linear scan register allocation [J].ACM Transactions on Programming Languages and Systems,1999,21(5):895-913.
[6] CAO H Y,ZHANG Y.Highly Portable Light-Weight x86 Emulator [J].Computer Systems & Applications,2011,20(5):101-104,143.
[7] BLINDELL G H,CARLSSON M,LOZANO R C,et al.Complete and Practical Universal Instruction Selection[J].Acm Transactions on Embedded Computing Systems,2017,16(5s):1-18.
[8] COOPER K D,TORCZON L.Engineering a Compiler,Second Edition[M].USA:Morgan Kaufmann,2003.
[9] SURHONE L M,TENNOE M T,HENSSONOW S F.Instruction Selection[M].Switzerland:Springer International Publi-shing,2016.
[10] GUO Z H,GUO S Z.Register Allocation Strategy for Hierarchy Structure in Base Mathematics Library[J].Computer Enginee-ring,2012,38(24):266-268.
[11] PATTERSON D,WATERMAN A.The RISC-V Reader[M].USA:Strawberry Canyon,2017.
[12] XU J C,HUANG Y Z,GUO S Z.Testing Platform for Floating Mathematical Function Libraries [J].Journal of Software,2015,26(6):1306-1321.
[13] QEMU.A generic and open source machine emulator and virtua-lizer[CP/OL].[2020-01-16],https//www.qemu.org/.
[14] FEDORA/RISC-V,a complete Fedora experience on the RISC-V(64bit,RV64GC) architecture[CP/OL].[2020-01-16],https//fedoraproject.org/wiki/Architectures/RISC-V.
[15] Spike,the RISC-V ISA Simulator[CP/OL].[2020-01-16].https//github.com/riscv/riscv-isa-sim.
[16] MPFR,the Multiple Precision Floating-Point Reliable Library[CP/OL].[2020-01-16],https//www.mpfr.org/.
[17] QI H Y,XU J N,GUO S Z.Detection of the maximum error of mathematical functions[J].Supercomput,2018,74:6275-6290.
[18] GLIBC.The GNU C Library [CP/OL].[2020-01-16].http//www.gnu.org/software/libc/.
[1] 刘聃, 郭绍忠, 郝江伟, 许瑾晨. 基于SIMD扩展部件的长向量超越函数实现方法[J]. 计算机科学, 2021, 48(6): 26-33.
[2] 龚彤艳,张广婷,贾海鹏,袁良. 一种偶数基Cooley-Tukey FFT高性能实现方法[J]. 计算机科学, 2020, 47(1): 31-39.
[3] 崔晨,李清宝,胡刚,王炜. 基于中断向量表重构的固件代码反汇编技术[J]. 计算机科学, 2012, 39(7): 302-204.
[4] 孙国梓 陈丹伟 蔡强. 子程序花指令模糊变换逻辑一致性研究[J]. 计算机科学, 2009, 36(8): 89-91.
[5] 田硕,梁洪亮. 二进制程序安全缺陷静态分析方法的研究综述[J]. 计算机科学, 2009, 36(7): 8-14.
[6] . 基于汇编代码的指令调度器的设计与实现[J]. 计算机科学, 2009, 36(3): 45-47.
[7] 杨慕晗. 一种基于中断处理机制的动态反汇编算法[J]. 计算机科学, 2008, 35(12): 280-284.
[8] . 一种基于重定位信息的二次反汇编算法[J]. 计算机科学, 2007, 34(7): 284-287.
[9] . 一种基于反汇编技术的二进制补丁分析方法[J]. 计算机科学, 2006, 33(10): 283-287.
[10] 汪文勇 王学东 向渝 唐科 刘利枚. 汇编嵌入式软件程序流程图自动生成的研究[J]. 计算机科学, 2005, 32(2): 173-175.
[11] 陆洪毅 戴葵 王志英. 一种基于汇编代码的单重循环向量化方法[J]. 计算机科学, 2003, 30(4): 116-117.
[12] 郭帆 陈意云 胡荣贵. 基于语言的移动代码安全问题[J]. 计算机科学, 2002, 29(11): 110-114.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
[1] 伍建辉,黄中祥,李武,吴健辉,彭鑫,张生. 城市道路建设时序决策的鲁棒优化[J]. 计算机科学, 2018, 45(4): 89 -93 .
[2] 庞博,金乾坤,合尼古力·吾买尔,齐兴斌. 软件定义网络中基于网络切片和ILP模型的路由方案[J]. 计算机科学, 2018, 45(4): 143 -147 .
[3] 郑秀林,宋海燕,付伊鹏. MORUS-1280-128算法的区分分析[J]. 计算机科学, 2018, 45(4): 152 -156 .
[4] 厉柏伸,李领治,孙涌,朱艳琴. 基于伪梯度提升决策树的内网防御算法[J]. 计算机科学, 2018, 45(4): 157 -162 .
[5] 罗霄阳,霍宏涛,王梦思,陈亚飞. 基于多残差马尔科夫模型的图像拼接检测[J]. 计算机科学, 2018, 45(4): 173 -177 .
[6] 朱淑芹,王文宏,李俊青. 针对基于感知器模型的混沌图像加密算法的选择明文攻击[J]. 计算机科学, 2018, 45(4): 178 -181 .
[7] 冉正,罗蕾,晏华,李允. AUTOSAR可运行实体-任务自动映射方法研究[J]. 计算机科学, 2018, 45(4): 190 -195 .
[8] 张景,朱国宾. 基于CBOW-LDA主题模型的Stack Overflow编程网站热点主题发现研究[J]. 计算机科学, 2018, 45(4): 208 -214 .
[9] 李昊阳,符云清. 基于标签聚类与项目主题的协同过滤推荐算法[J]. 计算机科学, 2018, 45(4): 247 -251 .
[10] 蔡莉,梁宇,朱扬勇,何婧. 数据质量的历史沿革和发展趋势[J]. 计算机科学, 2018, 45(4): 1 -10 .