RISC-V 指令集架构的快速发展为软件开发者带来了新的机遇与挑战。仅仅将面向 x86-64 优化的高性能软件重新编译到 RISC-V CPU 上是否足够?当前编译器能否有效优化 C 和 C++ 代码,还是必须使用 intrinsics 或汇编?能否在缺乏成熟性能分析工具的情况下分析并改进性能?标准优化技术是否有效?是否存在需要考虑的 RISC-V 特有特性?这些问题及其他问题都需要审慎考量。本文介绍了我们在 RISC-V 处理器上优化四种带状矩阵运算 BLAS 算法的经验。我们展示了如何通过改进计算密集型循环的向量化,显著加速面向 RISC-V 优化的 OpenBLAS 算法实现。分别在 Lichee Pi 4A 和 Banana Pi BPI-F3 设备上使用 RVV 0.7.1 与 RVV 1.0 向量指令集进行的实验表明,相对于 OpenBLAS 基线,根据运算不同可获得 1.5 倍至 10 倍的加速。特别地,成功结合 RVV 使用向量寄存器分组能够带来显著的性能提升。
英文摘要:
The rapid development of RISC-V instruction set architecture presents new opportunities and challenges for software developers. Is it sufficient to simply recompile high-performance software optimized for x86-64 onto RISC-V CPUs? Are current compilers capable of effectively optimizing C and C++ codes or is it necessary to use intrinsics or assembler? Can we analyze and improve performance without well-developed profiling tools? Do standard optimization techniques work? Are there specific RISC-V features that need to be considered? These and other questions require careful consideration. In this paper, we present our experience optimizing four BLAS algorithms for band matrix operations on RISC-V processors. We demonstrate how RISC-V-optimized implementations of OpenBLAS algorithms can be significantly accelerated through improved vectorization of computationally intensive loops. Experiments on Lichee Pi 4A and Banana Pi BPI-F3 devices using RVV 0.7.1 and RVV 1.0 vector instruction sets respectively, show speedups of 1.5x to 10x depending on the operation compared to the OpenBLAS baseline. In particular, the successful use of vector register grouping with RVV can lead to significant performance improvements.
Generation of the Single Precision BLAS library for the Parallella platform, with Epiphany co-processor acceleration, using the BLIS framework
The Apriella是一个混合计算平台,是Adapteva的Kickstarter项目的结果。它由高性能、高能效、多核架构、Epiphany芯片(用作协处理器)和一个Zynq-7000系列芯片组成,该芯片通常运行常规Linux操作系统版本,作为主处理器,并在其内部FPGA中实现“胶水逻辑”,以与P2P中的许多接口进行通信。在这篇论文中,我们创建了一个Epiphany加速的BLAS库,它适用于Epiphany平台(也适用于类似的混合平台,包括Epiphany芯片作为协处理器)。在实际实施双语法例及会计系统时,我们采用了双语法例及会计系统的架构。在这个平台上,以前已经有过矩阵-矩阵乘法的实现,在Epiphany芯片内实现了非常好的性能(高达峰值的85%),但对于完整的Sparkella平台来说并不是那么好(由于芯片间数据传输带宽限制)。这项工作的主要目的是为了更接近实际的线性代数应用程序的整个Atelella平台,与科学计算的观点。