diff options
author | Kulin Seth <kulin_seth@apple.com> | 2022-07-26 18:25:24 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-26 18:25:24 -0700 |
commit | 09d8642de66a7b9b62ea1984b9fae543d75a7da0 (patch) | |
tree | be06d026ad6513b8bdb9aeb34da9e1437df59c89 | |
parent | 503937b094c01144945f2fc50f9ea4cc81e6bc60 (diff) | |
download | cpuinfo-09d8642de66a7b9b62ea1984b9fae543d75a7da0.tar.gz |
Add support for Arm FHM (#102)
* Add support for Arm FHM
Co-authored-by: Developer-Ecosystem-Engineering <65677710+Developer-Ecosystem-Engineering@users.noreply.github.com>
-rw-r--r-- | include/cpuinfo.h | 9 | ||||
-rw-r--r-- | src/arm/linux/aarch64-isa.c | 3 | ||||
-rw-r--r-- | src/arm/linux/cpuinfo.c | 4 | ||||
-rw-r--r-- | src/arm/mach/init.c | 11 | ||||
-rw-r--r-- | tools/isa-info.c | 2 |
5 files changed, 29 insertions, 0 deletions
diff --git a/include/cpuinfo.h b/include/cpuinfo.h index e7ce9ed..e3d7b08 100644 --- a/include/cpuinfo.h +++ b/include/cpuinfo.h @@ -1474,6 +1474,7 @@ static inline bool cpuinfo_has_x86_sha(void) { bool dot; bool jscvt; bool fcma; + bool fhm; bool aes; bool sha1; @@ -1727,6 +1728,14 @@ static inline bool cpuinfo_has_arm_neon_fp16_arith(void) { #endif } +static inline bool cpuinfo_has_arm_fhm(void) { + #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 + return cpuinfo_isa.fhm; + #else + return false; + #endif +} + static inline bool cpuinfo_has_arm_neon_dot(void) { #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 return cpuinfo_isa.dot; diff --git a/src/arm/linux/aarch64-isa.c b/src/arm/linux/aarch64-isa.c index 9019949..44a8f4d 100644 --- a/src/arm/linux/aarch64-isa.c +++ b/src/arm/linux/aarch64-isa.c @@ -138,5 +138,8 @@ void cpuinfo_arm64_linux_decode_isa_from_proc_cpuinfo( if (features2 & (CPUINFO_ARM_LINUX_FEATURE2_BF16 | CPUINFO_ARM_LINUX_FEATURE2_SVEBF16)) { isa->bf16 = true; } + if (features & CPUINFO_ARM_LINUX_FEATURE_ASIMDFHM) { + isa->fhm = true; + } } diff --git a/src/arm/linux/cpuinfo.c b/src/arm/linux/cpuinfo.c index bc98c14..817da12 100644 --- a/src/arm/linux/cpuinfo.c +++ b/src/arm/linux/cpuinfo.c @@ -287,6 +287,10 @@ static void parse_features( #if CPUINFO_ARCH_ARM64 processor->features |= CPUINFO_ARM_LINUX_FEATURE_ASIMDRDM; #endif + } else if (memcmp(feature_start, "asimdfhm", feature_length) == 0) { + #if CPUINFO_ARCH_ARM64 + processor->features |= CPUINFO_ARM_LINUX_FEATURE_ASIMDFHM; + #endif #if CPUINFO_ARCH_ARM } else if (memcmp(feature_start, "fastmult", feature_length) == 0) { processor->features |= CPUINFO_ARM_LINUX_FEATURE_FASTMULT; diff --git a/src/arm/mach/init.c b/src/arm/mach/init.c index 3ced773..244d530 100644 --- a/src/arm/mach/init.c +++ b/src/arm/mach/init.c @@ -408,6 +408,17 @@ void cpuinfo_arm_mach_init(void) { cpuinfo_isa.i8mm = true; } + const uint32_t has_feat_fhm = get_sys_info_by_name("hw.optional.arm.FEAT_FHM"); + if (has_feat_fhm != 0) { + cpuinfo_isa.fhm = true; + } else { + // Prior to iOS 15, use 'hw.optional.armv8_2_fhm' + const uint32_t has_feat_fhm_legacy = get_sys_info_by_name("hw.optional.armv8_2_fhm"); + if (has_feat_fhm_legacy != 0) { + cpuinfo_isa.fhm = true; + } + } + uint32_t num_clusters = 1; for (uint32_t i = 0; i < mach_topology.cores; i++) { cores[i] = (struct cpuinfo_core) { diff --git a/tools/isa-info.c b/tools/isa-info.c index 1b8f81c..da61e50 100644 --- a/tools/isa-info.c +++ b/tools/isa-info.c @@ -144,6 +144,7 @@ int main(int argc, char** argv) { printf("\tNEON FP16 arithmetics: %s\n", cpuinfo_has_arm_neon_fp16_arith() ? "yes" : "no"); printf("\tNEON complex: %s\n", cpuinfo_has_arm_fcma() ? "yes" : "no"); printf("\tNEON dot product: %s\n", cpuinfo_has_arm_neon_dot() ? "yes" : "no"); + printf("\tNEON VFMLAL/VFMLSL: %s\n", cpuinfo_has_arm_fhm() ? "yes" : "no"); printf("Cryptography extensions:\n"); printf("\tAES: %s\n", cpuinfo_has_arm_aes() ? "yes" : "no"); @@ -157,6 +158,7 @@ int main(int argc, char** argv) { printf("\tARM v8.1 atomics: %s\n", cpuinfo_has_arm_atomics() ? "yes" : "no"); printf("\tARM v8.1 SQRDMLxH: %s\n", cpuinfo_has_arm_neon_rdm() ? "yes" : "no"); printf("\tARM v8.2 FP16 arithmetics: %s\n", cpuinfo_has_arm_fp16_arith() ? "yes" : "no"); + printf("\tARM v8.2 FHM: %s\n", cpuinfo_has_arm_fhm() ? "yes" : "no"); printf("\tARM v8.2 BF16: %s\n", cpuinfo_has_arm_bf16() ? "yes" : "no"); printf("\tARM v8.3 dot product: %s\n", cpuinfo_has_arm_neon_dot() ? "yes" : "no"); printf("\tARM v8.3 JS conversion: %s\n", cpuinfo_has_arm_jscvt() ? "yes" : "no"); |