

浏览全部资源
扫码关注微信
1.信息工程大学,河南郑州 450002
2.数学工程与先进计算国家重点实验室,河南郑州 450002
Received:08 April 2022,
Revised:2022-10-25,
Published:25 May 2024
移动端阅览
李飞, 郭绍忠, 郝江伟, 等. 面向RISC-V的基础数学库实现[J]. 电子学报, 2024, 52(05): 1633-1647.
LI Fei, GUO Shao-zhong, HAO Jiang-wei, et al. Basic Math Library Implementation for RISC-V[J]. Acta Electronica Sinica, 2024, 52(05): 1633-1647.
李飞, 郭绍忠, 郝江伟, 等. 面向RISC-V的基础数学库实现[J]. 电子学报, 2024, 52(05): 1633-1647. DOI:10.12263/DZXB.20220375
LI Fei, GUO Shao-zhong, HAO Jiang-wei, et al. Basic Math Library Implementation for RISC-V[J]. Acta Electronica Sinica, 2024, 52(05): 1633-1647. DOI:10.12263/DZXB.20220375
RISC-V指令集架构(Instruction Set Architecture,ISA)作为一种新兴的精简ISA,因免费、开源、自由等特点而得到快速发展.由于国内外对RISC-V的研究主要集中在硬件开发,软件生态相较于成熟ISA还很薄弱,实现一套RISC-V指令集高性能基础数学库可以进一步丰富RISC-V软件生态.本文基于自动化移植技术实现申威数学库到RISC-V的移植,为RISC-V指令架构提供首个使用向量指令优化的基础数学库系统.本文提出向量寄存器自动分支查表法与路径标记插入法,重点解决不同架构间寄存器映射过程中的寄存器复用问题,实现寄存器正确高效映射,并依据不同指令等价转换策略自动化移植数学函数69个.测试结果表明,RISC-V基础数学库函数可实现正确计算,最大误差为1.90ULP,函数性能平均为157.03节拍.
RISC-V instruction set architecture (ISA)
as a new streamlined ISA
has developed rapidly due to its characteristics of free
open source
and freedom. Since the research on RISC-V at home and abroad mainly focuses on hardware development
the software ecosystem is still weak compared to mature ISAs. Implementing a set of high-performance basic math libraries for the RISC-V instruction set can further enrich the RISC-V software ecosystem. This paper realizes the transplantation of Sunway math library to RISC-V based on automatic transplantation technology
and provides the first basic math library system using vector instruction optimization for RISC-V instruction architecture. This paper proposes an automatic branch look-up table method and a path marker insertion method for vector registers
focusing on solving the problem of register multiplexing in the process of register mapping between different architectures
realizing the correct and efficient mapping of registers
and automatically transplanting 69 mathematical functions according to different instruction equivalence conversion strategies. The test results show that the RISC-V basic math library function can achieve correct calculation
the maximum error is 1.90ULP
and the average performance of functions is 157.03 beats.
HU Y M , YANG H L , LUAN Z Z , et al . Massively scaling seismic processing on sunway taihulight supercomputer [J ] . IEEE Transactions on Parallel and Distributed Systems , 2020 , 31 ( 5 ) : 1194 - 1208 .
QI H Y , XU J C , GUO S Z . Detection of the maximum error of mathematical functions [J ] . The Journal of Supercomputing , 2018 , 74 ( 11 ): 6275 - 6290 .
郭绍忠 , 许瑾晨 , 陈建勋 . 一种改进的超越函数通用算法 [J ] . 计算机工程 , 2012 , 38 ( 15 ): 31 - 34 .
GUO S Z , XU J C , CHEN J X . Improved transcendental function general algorithm [J ] . Computer Engineering , 2012 , 38 ( 15 ): 31 - 34 . (in Chinese)
INTEL CORPORATION . Intel math kernel library [EB/OL ] . ( 2020 )[2022 ] . https://software.intel.com/en-us/mkl https://software.intel.com/en-us/mkl .
CORPORATION IBM , The mathematical acceleration subsystem (MASS) library [EB/OL ] . ( 2019 )[2022 ] . https://www.ibm.com/docs/en https://www.ibm.com/docs/en .
刘畅 , 武延军 , 吴敬征 , 等 . RISC-V指令集架构研究综述 [J ] . 软件学报 , 2021 , 32 ( 12 ): 3992 - 4024 .
LIU C , WU Y J , WU J Z , et al . Survey on RISC-V system architecture research [J ] . Journal of Software , 2021 , 32 ( 12 ): 3992 - 4024 . (in Chinese)
MPFR . The multiple precision floating-point reliable library [EB/OL ] . ( 2021 )[2022 ] . https://www.mpfr.org/ https://www.mpfr.org/ .
GLIBC . The GNU C library [EB/OL ] . ( 2018 )[2022 ] . http://www.gnu.org/software/libc/ http://www.gnu.org/software/libc/ .
周蓓 , 黄永忠 , 许瑾晨 , 等 . 向量数学库的向量化方法研究 [J ] . 计算机科学 , 2019 , 46 ( 1 ): 320 - 324 .
ZHOU B , HUANG Y Z , XU J C , et al . Study on SIMD method of vector math library [J ] . Computer Science , 2019 , 46 ( 1 ): 320 - 324 . (in Chinese)
DAVID P , ANDREW W . The RISC-V Reader [M ] . Berkeley : Strawberry Canyon , 2017 . 73 - 82 .
曹浩 , 郭绍忠 , 刘聃 , 等 . 面向64位RISC-V的基础数学库自动化移植 [J ] . 计算机科学 , 2021 , 48 ( 6 ): 41 - 47 .
CAO H , GUO S Z , LIU D , et al . Automatic porting of basic mathematics library for 64-bit RISC-V [J ] . Computer Science , 2021 , 48 ( 6 ): 41 - 47 . (in Chinese)
曹代 , 郭绍忠 , 张辛 . 基于申威26010处理器的扩展函数库实现与优化 [J ] . 计算机工程 , 2017 , 43 ( 1 ): 61 - 66, 71 .
CAO D , GUO S Z , ZHANG X . Implementation and optimization of extended function library based on SW26010 Processor [J ] . Computer Engineering , 2017 , 43 ( 1 ): 61 - 66, 71 . (in Chinese)
CHAITIN G J . Register allocation and spilling via graph coloring [C ] // Proceedings of the SIGPLAN Symposium on Compiler Construction-SIGPLAN’82 . New York : ACM , 1982 : 98 - 101 .
MASSIMILIANO P , VIVEK S . Linear scan register allocation [J ] . ACM Transactions on Programming Languages and Systems (TOPLAS) , 1999 , 21 ( 5 ): 895 - 913 .
王向前 , 王昊 . 分簇结构向量寄存器分配策略研究 [J ] . 单片机与嵌入式系统应用 , 2017 , 17 ( 7 ): 10 - 12 .
WANG X Q , WANG H . Research on vector register allocation method for clustering [J ] . Microcontrollers & Embedded Systems , 2017 , 17 ( 7 ): 10 - 12 . (in Chinese)
KRSTE A , ANDREW W . RISCV-v-spec-1 .0[EB/OL ] . ( 2021 )[2022 ] . https://github.com/riscv/riscv-v-spec/releases/tag/v1.0 https://github.com/riscv/riscv-v-spec/releases/tag/v1.0 .
夏军 . 基于申威架构实现RISC-V浮点指令 [D ] . 合肥 : 安徽大学 , 2020 .
XIA J . Implementation of RISC-V Floating Point Instructions Based on Shenwei Architecture [D ] . Hefei : Anhui University , 2020 . (in Chinese)
FLORIAN G , LUKAS G , GUILLERMO P V . Evolutionary algorithms for instruction scheduling, operation merging, and register allocation in VLIW compilers [J ] . Journal of Signal Processing Systems , 2020 , 92 ( 7 ): 655 - 678 .
LUK C K , MOWRY T C . Compiler-based prefetching for recursive data struchtures [C ] // Proceedings of the Seventh International Conference on Architectural Support for Programming Languages and Operating Systems . New York : ACM , 1996 : 222 - 233 .
沈洁 , 龙标 , 姜浩 , 等 . 飞腾处理器上向量三角函数的设计实现与优化 [J ] . 计算机研究与发展 , 2020 , 57 ( 12 ): 2610 - 2620 .
SHEN J , LONG B , JIANG H , et al . Implementation and optimization of vector trigonometric functions on phytium processors [J ] . Journal of Computer Research and Development , 2020 , 57 ( 12 ): 2610 - 2620 . (in Chinese)
刘聃 , 郭绍忠 , 郝江伟 , 等 . 基于SIMD扩展部件的长向量超越函数实现方法 [J ] . 计算机科学 , 2021 , 48 ( 6 ): 26 - 33 .
LIU D , GUO S Z , HAO J W , et al . Implementation of transcendental functions on vectors based on SIMD extensions [J ] . Computer Science , 2021 , 48 ( 6 ): 26 - 33 . (in Chinese)
叶锡聪 , 庄灿锋 , 王宇木 , 等 . RISC-V向量指令集的Compute Library函数库移植 [J ] . 单片机与嵌入式系统应用 , 2021 , 21 ( 1 ): 8 - 13 .
YE X C , ZHUANG C F , WANG Y M , et al . Transplantation of compute library of RISC-V vector instruction set [J ] . Microcontrollers & Embedded Systems , 2021 , 21 ( 1 ): 8 - 13 . (in Chinese)
许瑾晨 , 黄永忠 , 郭绍忠 , 等 . 一个浮点数学函数库测试平台 [J ] . 软件学报 , 2015 , 26 ( 6 ): 1306 - 1321 .
XU J C , HUANG Y Z , GUO S Z , et al . Testing platform for floating mathematical function libraries [J ] . Journal of Software , 2015 , 26 ( 6 ): 1306 - 1321 . (in Chinese)
SPIKE . The RISC-V ISA simulator [EB/OL ] . ( 2017 )[2022 ] . https://github.com/riscv/riscv-isa-sim https://github.com/riscv/riscv-isa-sim .
GEM 5. The gem 5 simulator [EB/OL ] . ( 2016 )[2022 ] . https://github.com/plctlab/plct-gem5 https://github.com/plctlab/plct-gem5 .
UBUNTU . The Ubuntu 20.04.3 LTS [EB/OL ] . ( 2020 )[2022 ] . https://ubuntu.com/download/desktop https://ubuntu.com/download/desktop .
PALMER D . GNU toolchain for RISC-V [EB/OL ] . ( 2015 )[2022 ] . https://github.com/riscv-collab/riscv-gnu-toolchain https://github.com/riscv-collab/riscv-gnu-toolchain .
INTER . Inter one API math kernel library [EB/OL ] . ( 2017 )[2022 ] . https://software.intel.com/content/www/us/en/develop/documentation/onemkl-vmperfdata/top.html https://software.intel.com/content/www/us/en/develop/documentation/onemkl-vmperfdata/top.html .
0
Views
17
下载量
0
CSCD
Publicity Resources
Related Articles
Related Author
Related Institution
京公网安备11010802024621