From c82f5e3d28f0e617b232c34173f0a07ef95e2b04 Mon Sep 17 00:00:00 2001 From: Marat Dukhan Date: Wed, 26 Dec 2018 20:20:23 -0800 Subject: Detect ARMv8.1 Atomics and FP16 compute on iOS --- src/arm/mach/init.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src') diff --git a/src/arm/mach/init.c b/src/arm/mach/init.c index 3cca223..91d0353 100644 --- a/src/arm/mach/init.c +++ b/src/arm/mach/init.c @@ -316,6 +316,25 @@ void cpuinfo_arm_mach_init(void) { break; #endif } + /* + * Support for ARMv8.1 Atomics & FP16 arithmetic instructions is supposed to be detected via + * sysctlbyname calls with "hw.optional.armv8_1_atomics" and "hw.optional.neon_fp16" arguments + * (see https://devstreaming-cdn.apple.com/videos/wwdc/2018/409t8zw7rumablsh/409/409_whats_new_in_llvm.pdf), + * but on new iOS versions these calls just fail with EPERM. + * + * Thus, we whitelist CPUs known to support these instructions. + */ + switch (cpu_family) { + case CPUFAMILY_ARM_MONSOON_MISTRAL: +#ifdef CPUFAMILY_ARM_VORTEX_TEMPEST + case CPUFAMILY_ARM_VORTEX_TEMPEST: +#else + case 0xe81e7ef6: + /* Hard-coded value for older SDKs which do not define CPUFAMILY_ARM_VORTEX_TEMPEST */ +#endif + cpuinfo_isa.atomics = true; + cpuinfo_isa.fp16arith = true; + } uint32_t num_clusters = 1; for (uint32_t i = 0; i < mach_topology.cores; i++) { -- cgit v1.2.3