• 中国计算机学会会刊
  • 中国科技核心期刊
  • 中文核心期刊

Computer Engineering & Science ›› 2023, Vol. 45 ›› Issue (09): 1532-1543.

• High Performance Computing • Previous Articles     Next Articles

Performance optimization of  RISC-V basic math library

LI Fei,GUO Shao-zhong,ZHOU Bei,SONG Guang-hui,HAO Jiang-wei,XU Jin-chen   

  1. (School of Cyberspace Security,University of Information Engineering,Zhengzhou 450001,China)
  • Received:2023-02-06 Revised:2023-04-11 Accepted:2023-09-25 Online:2023-09-25 Published:2023-09-12

Abstract: The basic mathematical library is one of the fundamental software libraries in a computer system, and its performance is one of the key factors affecting the efficiency of higher-level applications. The existing RISC-V basic mathematical library can achieve correct calculations, but it contains a large number of memory access instructions and redundant instructions in its source code, which leads to suboptimal function performance. Additionally, the assembly code for RISC-V mathematical functions is large and involves complex branch conditions, which increases the difficulty of direct optimization. To address these issues, this paper follows a local-to-global optimization approach from and proposes a method for automatically detecting critical paths in RISC-V mathematical functions. This method focuses on solving the problem of other branch registers being easily modified when optimizing critical branches. By using a queue-based register allocation strategy, the registers within the same path are reallocated, which improves register utilization and minimizes the number of memory access instructions. Furthermore, redundant instructions are also combined and functionally refactored. Experimental results show that the average execution cycles for 67 RISC-V mathematical functions have been optimized from 144 cycles to 85 cycles, resulting in an average performance improvement of 29.61%.

Key words: RISC-V, math library, critical path, register scheduling, performance optimization