Enable AES and SHA3 optimisations on Apple Silicon M3-based macOS systems

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)
This commit is contained in:
Tom Cosgrove 2023-11-08 22:45:55 +00:00 committed by Tomas Mraz
parent f63e1b48ac
commit 7602bf8715

View 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;
}