[openssl/openssl] 9a41a3: LoongArch64 assembly pack: add ChaCha20 modules

zhoumin2 noreply at github.com
Sun Sep 10 22:51:11 UTC 2023


  Branch: refs/heads/master
  Home:   https://github.com/openssl/openssl
  Commit: 9a41a3c6a453a90d6c6cf106480a4a72b08b14f9
      https://github.com/openssl/openssl/commit/9a41a3c6a453a90d6c6cf106480a4a72b08b14f9
  Author: Min Zhou <zhoumin at loongson.cn>
  Date:   2023-09-11 (Mon, 11 Sep 2023)

  Changed paths:
    A crypto/chacha/asm/chacha-loongarch64.pl
    M crypto/chacha/build.info

  Log Message:
  -----------
  LoongArch64 assembly pack: add ChaCha20 modules

This assembly implementation for ChaCha20 includes three code paths:
scalar path, 128-bit LSX path and 256-bit LASX path. We prefer the
LASX path or LSX path if the hardware and system support these
extensions.

There are 32 vector registers avaialable in the LSX and LASX
extensions. So, we can load the 16 initial states and the 16
intermediate states of ChaCha into the 32 vector registers for
calculating in the implementation. The test results on the 3A5000
and 3A6000 show that this assembly implementation significantly
improves the performance of ChaCha20 on LoongArch based machines.
The detailed test results are as following.

Test with:
$ openssl speed -evp chacha20

3A5000
type               16 bytes     64 bytes    256 bytes    1024 bytes    8192 bytes   16384 bytes
C code           178484.53k   282789.93k   311793.70k    322234.99k    324405.93k    324659.88k
assembly code    223152.28k   407863.65k   989520.55k   2049192.96k   2127248.70k   2131749.55k
                   +25%         +44%         +217%        +536%         +556%         +557%

3A6000
type               16 bytes     64 bytes     256 bytes    1024 bytes    8192 bytes   16384 bytes
C code           214945.33k   310041.75k    340724.22k    349949.27k    352925.01k    353140.74k
assembly code    299151.34k   492766.34k   2070166.02k   4300909.91k   4473978.88k   4499084.63k
                   +39%         +59%         +508%         +1129%        +1168%        +1174%

Signed-off-by: Min Zhou <zhoumin at loongson.cn>

Reviewed-by: Tomas Mraz <tomas at openssl.org>
Reviewed-by: Paul Dale <pauli at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21998)




More information about the openssl-commits mailing list