Page MenuHomeFreeBSD

Use arm64 sha256 intrinsics in libmd
ClosedPublic

Authored by andrew on Jul 23 2021, 10:12 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Jan 10, 1:58 AM
Unknown Object (File)
Fri, Jan 6, 7:20 PM
Unknown Object (File)
Dec 21 2022, 11:08 AM
Unknown Object (File)
Dec 12 2022, 2:18 AM
Unknown Object (File)
Dec 12 2022, 2:12 AM
Unknown Object (File)
Dec 12 2022, 2:12 AM
Unknown Object (File)
Dec 12 2022, 2:05 AM
Unknown Object (File)
Dec 9 2022, 11:48 AM

Details

Summary

When running on a CPU that supports the arm64 sha256 intrinsics use them
to improve perfromance of sha256 calculations.

With this changethe following improvement has been seen on an Apple M1
with FreeBS running under Parallels, with similar results on a
Neoverse-N1 r3p1.

x sha256.orig
+ sha256.arm64
+--------------------------------------------------------------------+

++ x x
+++ xxx
AA

+--------------------------------------------------------------------+

N           Min           Max        Median           Avg        Stddev

x 5 3.41 3.5 3.46 3.458 0.042661458
+ 5 0.47 0.54 0.5 0.504 0.027018512
Difference at 95.0% confidence

-2.954 +/- 0.0520768
-85.4251% +/- 0.826831%
(Student's t, pooled s = 0.0357071)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Phabricator doesn't like the ministat plot so I've copied it here:

x sha256.orig
+ sha256.arm64
+--------------------------------------------------------------------+
|++                                                               x x|
|+++                                                              xxx|
||A                                                               |A||
+--------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x   5          3.41           3.5          3.46         3.458   0.042661458
+   5          0.47          0.54           0.5         0.504   0.027018512
Difference at 95.0% confidence
        -2.954 +/- 0.0520768
        -85.4251% +/- 0.826831%
        (Student's t, pooled s = 0.0357071)
sys/crypto/sha2/sha256c.c
199

I might throw this in a header file.

202

Static?

andrew added inline comments.
sys/crypto/sha2/sha256c.c
199

The only reason I didn't is because I didn't want to add it to sha256.h as it shouldn't be used outside of this code and I didn't want to create a new header just for 2 lines.

Create a new header for the SHA256_Transform_arm64_impl signature

This revision is now accepted and ready to land.Aug 6 2021, 4:34 PM
This revision was automatically updated to reflect the committed changes.