Page MenuHomeFreeBSD

Use arm64 sha256 intrinsics in libmd
ClosedPublic

Authored by andrew on Jul 23 2021, 10:12 AM.
Tags
None
Referenced Files
F83410027: D31284.id93539.diff
Fri, May 10, 3:36 AM
Unknown Object (File)
Wed, May 8, 2:00 AM
Unknown Object (File)
Wed, May 8, 2:00 AM
Unknown Object (File)
Tue, May 7, 10:56 PM
Unknown Object (File)
Thu, May 2, 9:07 AM
Unknown Object (File)
Sat, Apr 27, 12:36 PM
Unknown Object (File)
Sun, Apr 21, 9:25 PM
Unknown Object (File)
Sun, Apr 21, 6:11 PM

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
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 40690
Build 37579: arc lint + arc unit

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
198

I might throw this in a header file.

201

Static?

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

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.