面向RISC-V的基础数学库实现
Basic Math Library Implementation for RISC-V
李飞 1郭绍忠 1郝江伟 1侯明 1宋广辉 1许瑾晨1
作者信息
- 1. 信息工程大学,河南郑州 450002;数学工程与先进计算国家重点实验室,河南郑州 450002
- 折叠
摘要
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节拍.
Abstract
RISC-V instruction set architecture(ISA),as a new streamlined ISA,has developed rapidly due to its char-acteristics of free,open source,and freedom.Since the research on RISC-V at home and abroad mainly focuses on hard-ware 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.
关键词
RISC-V/申威/汇编/向量/数学库/自动化移植Key words
RISC-V/Sunway/assembly/vector/math library/automatic porting引用本文复制引用
出版年
2024