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)
Fri, Dec 13, 11:57 PM
Unknown Object (File)
Nov 10 2024, 12:04 PM
Unknown Object (File)
Nov 10 2024, 12:04 PM
Unknown Object (File)
Nov 10 2024, 12:04 PM
Unknown Object (File)
Nov 10 2024, 12:04 PM
Unknown Object (File)
Nov 10 2024, 12:04 PM
Unknown Object (File)
Nov 10 2024, 11:22 AM
Unknown Object (File)
Nov 6 2024, 10:30 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.