Enable AES and SHA3 optimisations on Apple Silicon M3-based macOS systems
authorTom Cosgrove <tom.cosgrove@arm.com>
Wed, 8 Nov 2023 22:45:55 +0000 (22:45 +0000)
committerTomas Mraz <tomas@openssl.org>
Tue, 14 Nov 2023 07:10:54 +0000 (08:10 +0100)
AES gets a performance enhancement of 19-36%, similar to the M1 and M2.

SHA3 gets an improvement of 4-7% on buffers 256 bytes or larger.

Tested on an M3 Pro, but the CPU cores are the same on M3 and M3 Max.

Change-Id: I2bf40bbde824823bb8cf2efd1bd945da9f23a703

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

crypto/armcap.c

index 3b1447456d71ed058ea7d873d8e3fdbb2282d640..b13da3be81ca9619ecf7ddccf67a95cc7cde01a8 100644 (file)
@@ -298,7 +298,8 @@ void OPENSSL_cpuid_setup(void)
             size_t len = sizeof(uarch);
             if ((sysctlbyname("machdep.cpu.brand_string", uarch, &len, NULL, 0) == 0) &&
                ((strncmp(uarch, "Apple M1", 8) == 0) ||
-                (strncmp(uarch, "Apple M2", 8) == 0))) {
+                (strncmp(uarch, "Apple M2", 8) == 0) ||
+                (strncmp(uarch, "Apple M3", 8) == 0))) {
                 OPENSSL_armcap_P |= ARMV8_UNROLL8_EOR3;
                 OPENSSL_armcap_P |= ARMV8_HAVE_SHA3_AND_WORTH_USING;
             }