We use cookies to improve your experience with our site.

HI-SM3:基于异构GPU的SM3哈希算法高性能实现

HI-SM3: High-Performance Implementation of SM3 Hash Function on Heterogeneous GPUs

  • 摘要:
    研究背景 哈希函数在密码学中发挥着关键作用,广泛应用于数据完整性检测、消息认证、数字签名等。哈希函数是一类函数的统称,包含多个具体算法,如 SHA-1、SHA-2、SHA-3、RIPEMD、MD5、SM3等。SM3密码算法是中国国家密码管理局2010年公布的中国商用哈希密码算法标准,并在2018年成为ISO/IEC国际标准。随着信息技术的快速发展,信息安全的需求与日俱增,快速高效的国密算法已成为研究热点。随着图形处理单元(GPU)的深入发展,其高浮点运算性能、高带宽独立显存、计算能力强大的优势愈发突出,并行处理能力也显著提升,已被广泛应用于科学计算、数据分析、密码工程等领域。
    目的 CPU-GPU异构平台充分发挥了CPU的逻辑控制能力和GPU的计算处理能力,可有效提升高并发场景下SM3国密算法的效率,对密码的实时性具有重要意义。本研究针对性地解决SM3哈希算法效率较低的问题,以满足其应用过程中实时性的需求,推动国密的进一步发展,同时为其他国密算法及密码学相关算法在该平台的实施与优化工作提供参考。
    方法 本研究基于GPU/DCU平台,使用单线程完整实现SM3哈希算法,显著提升吞吐性能。首先通过合并消息扩展和压缩迭代步骤,使得消息扩展在压缩函数计算过程中即时完成;同时优化寄存器使用,从528字节减少至128字节。其次,采用适用于GPU/DCU的内联汇编指令集加速计算过程,并通过CUDA/HIP流处理技术实现数据复制和计算操作,从而有效减少整体计算时间。此外,采用新的数据存储方法,结合合并访问技术和CUDA/HIP中的INT4指令,在实验中表现出了更高的吞吐和更低的时延。
    结果 本文提出的HI-SM3 在NVIDIA RTX 4090 GPU实现了高达454.74 GB/s的峰值性能,比高端服务器CPU(E5-2699V3)16核版的实现性能高出150倍。在中国自主研发的Hygon DCU上,HI-SM3的性能为113.77 GB/s。此外,与已知最快的GPU-based SM3实现相比,HI-SM3在相同平台上的性能提升达到3.12倍。即使在功耗低于40W的嵌入式GPU上,HI-SM3的吞吐量也能达到5.90 GB/s,比服务器级CPU实现的性能高出两倍。HI-SM3展现了显著的性能优势。
    结论 本研究选择异构GPU作为国产SM3哈希算法高性能并行加速平台,围绕高吞吐量、可扩展和高灵活性等目标,从并行、访存、指令等角度进行优化,在兼顾安全性的基础上取得显著性能优势。本研究提出的方法适用于其他类型的哈希算法高性能实现,所提出的优化思路也适用于其他算法的GPU平台高性能实现。

     

    Abstract: Hash functions are essential in cryptographic primitives such as digital signatures, key exchanges, and blockchain technology. SM3, built upon the Merkle-Damgard structure, is a crucial element in Chinese commercial cryptographic schemes. Optimizing hash function performance is crucial given the growth of Internet of Things (IoT) devices and the rapid evolution of blockchain technology. In this paper, we introduce a high-performance implementation framework for accelerating the SM3 cryptography hash function, short for HI-SM3, using heterogeneous GPU (graphics processing unit) parallel computing devices. HI-SM3 enhances the implementation of hash functions across four dimensions: parallelism, register utilization, memory access, and instruction efficiency, resulting in significant performance gains across various GPU platforms. Leveraging the NVIDIA RTX 4090 GPU, HI-SM3 achieves a remarkable peak performance of 454.74 GB/s, surpassing OpenSSL on a high-end server CPU (E5-2699V3) with 16 cores by over 150 times. On the Hygon DCU accelerator, a Chinese domestic graphics card, it achieves 113.77 GB/s. Furthermore, compared with the fastest known GPU-based SM3 implementation, HI-SM3 on the same GPU platform exhibits a 3.12x performance improvement. Even on embedded GPUs consuming less than 40W, HI-SM3 attains a throughput of 5.90 GB/s, which is twice as high as that of a server-level CPU. In summary, HI-SM3 provides a significant performance advantage, positioning it as a compelling solution for accelerating hash operations.

     

/

返回文章
返回