diff options
author | Marat Dukhan <maratek@google.com> | 2022-07-12 23:23:27 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-12 23:23:27 +0300 |
commit | 53298db833c5c5a1598639e9b47cc1a602bbac26 (patch) | |
tree | 96e51e68648633d4635c882087d060a2121bfe21 | |
parent | 9d65bfa0e392766c3d8d66c6d56f0a1c54e4e087 (diff) |
Cleanup detection of ARM BF16 extension (#98)
- Remove unneeded svebf16 extension flag, instead use the Linux feature flag to detect bf16 extension
- Group fp16 arith and bf16 together with other floating-point extensions
- Rename cpuinfo_has_arm_svebf16 to cpuinfo_has_arm_sve_bf16
- Add cpuinfo_has_arm_neon_bf16 API
-rw-r--r-- | include/cpuinfo.h | 43 | ||||
-rw-r--r-- | src/arm/linux/aarch64-isa.c | 8 | ||||
-rw-r--r-- | tools/isa-info.c | 1 |
3 files changed, 29 insertions, 23 deletions
diff --git a/include/cpuinfo.h b/include/cpuinfo.h index 258abd0..7bcb931 100644 --- a/include/cpuinfo.h +++ b/include/cpuinfo.h @@ -1466,7 +1466,6 @@ static inline bool cpuinfo_has_x86_sha(void) { bool atomics; bool bf16; bool sve; - bool svebf16; bool sve2; #endif bool rdm; @@ -1629,6 +1628,22 @@ static inline bool cpuinfo_has_arm_vfpv4_d32(void) { #endif } +static inline bool cpuinfo_has_arm_fp16_arith(void) { + #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 + return cpuinfo_isa.fp16arith; + #else + return false; + #endif +} + +static inline bool cpuinfo_has_arm_bf16(void) { + #if CPUINFO_ARCH_ARM64 + return cpuinfo_isa.bf16; + #else + return false; + #endif +} + static inline bool cpuinfo_has_arm_wmmx(void) { #if CPUINFO_ARCH_ARM return cpuinfo_isa.wmmx; @@ -1711,17 +1726,17 @@ static inline bool cpuinfo_has_arm_neon_fp16_arith(void) { #endif } -static inline bool cpuinfo_has_arm_fp16_arith(void) { +static inline bool cpuinfo_has_arm_neon_dot(void) { #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 - return cpuinfo_isa.fp16arith; + return cpuinfo_isa.dot; #else return false; #endif } -static inline bool cpuinfo_has_arm_neon_dot(void) { - #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 - return cpuinfo_isa.dot; +static inline bool cpuinfo_has_arm_neon_bf16(void) { + #if CPUINFO_ARCH_ARM64 + return cpuinfo_isa.bf16; #else return false; #endif @@ -1791,25 +1806,17 @@ static inline bool cpuinfo_has_arm_sve(void) { #endif } -static inline bool cpuinfo_has_arm_sve2(void) { - #if CPUINFO_ARCH_ARM64 - return cpuinfo_isa.sve2; - #else - return false; - #endif -} - -static inline bool cpuinfo_has_arm_bf16(void) { +static inline bool cpuinfo_has_arm_sve_bf16(void) { #if CPUINFO_ARCH_ARM64 - return cpuinfo_isa.bf16; + return cpuinfo_isa.sve && cpuinfo_isa.bf16; #else return false; #endif } -static inline bool cpuinfo_has_arm_svebf16(void) { +static inline bool cpuinfo_has_arm_sve2(void) { #if CPUINFO_ARCH_ARM64 - return cpuinfo_isa.svebf16; + return cpuinfo_isa.sve2; #else return false; #endif diff --git a/src/arm/linux/aarch64-isa.c b/src/arm/linux/aarch64-isa.c index 7b18095..4090d10 100644 --- a/src/arm/linux/aarch64-isa.c +++ b/src/arm/linux/aarch64-isa.c @@ -130,10 +130,10 @@ void cpuinfo_arm64_linux_decode_isa_from_proc_cpuinfo( if (features2 & CPUINFO_ARM_LINUX_FEATURE2_SVE2) { isa->sve2 = true; } - if (features2 & CPUINFO_ARM_LINUX_FEATURE2_BF16) { + // SVEBF16 is set iff SVE and BF16 are both supported, but the SVEBF16 feature flag + // was added in Linux kernel before the BF16 feature flag, so we check for either. + if (features2 & (CPUINFO_ARM_LINUX_FEATURE2_BF16 | CPUINFO_ARM_LINUX_FEATURE2_SVEBF16)) { isa->bf16 = true; } - if (features2 & CPUINFO_ARM_LINUX_FEATURE2_SVEBF16) { - isa->svebf16 = true; - } } + diff --git a/tools/isa-info.c b/tools/isa-info.c index 7320b74..1b8f81c 100644 --- a/tools/isa-info.c +++ b/tools/isa-info.c @@ -164,7 +164,6 @@ int main(int argc, char** argv) { printf("SIMD extensions:\n"); printf("\tARM SVE: %s\n", cpuinfo_has_arm_sve() ? "yes" : "no"); - printf("\tARM SVE BF16: %s\n", cpuinfo_has_arm_svebf16() ? "yes" : "no"); printf("\tARM SVE 2: %s\n", cpuinfo_has_arm_sve2() ? "yes" : "no"); printf("Cryptography extensions:\n"); |