Skip to content

Armv8.2 SM3和SM4

Sun Yimin edited this page Dec 29, 2021 · 31 revisions

SM3 arm64 plain asm on arm64-graviton2

go test -v -short -bench . -run=^$ ./...
goos: linux
goarch: arm64
pkg: github.com/emmansun/gmsm/sm3
BenchmarkHash8Bytes
BenchmarkHash8Bytes-2     	 2738724	       438.4 ns/op	  18.25 MB/s
BenchmarkHash1K
BenchmarkHash1K-2         	  192519	      6232 ns/op	 164.32 MB/s
BenchmarkHash8K
BenchmarkHash8K-2         	   24950	     48112 ns/op	 170.27 MB/s
BenchmarkHash8K_SH256
BenchmarkHash8K_SH256-2   	  223354	      5369 ns/op	1525.81 MB/s
PASS
ok  	github.com/emmansun/gmsm/sm3	5.857s

和CPU指令级别的差距基本上是10倍!

找不到相关CPU环境,mark先。

Reference

  1. Summary of A64 cryptographic instructions
  2. Arm A64 Instruction Set Architecture
  3. linux arm64 crypto / (https://github.com/torvalds/linux/tree/master/arch/arm64/crypto)
  4. A Quick Guide to Go's Assembler
  5. Golang arm instructions mapping
  6. A C/C++ header file that converts Intel SSE intrinsics to Arm/Aarch64 NEON intrinsics.
  7. asm2go