Skip to content

Commit d554c4b

Browse files
committed
Use arm_cpu_features
1 parent 8a3bf50 commit d554c4b

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

include/xsimd/config/xsimd_cpuid.hpp

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@
1313
#define XSIMD_CPUID_HPP
1414

1515
#include "../types/xsimd_all_registers.hpp"
16+
#include "./xsimd_cpu_features_arm.hpp"
1617
#include "./xsimd_cpu_features_x86.hpp"
1718
#include "xsimd_inline.hpp"
1819

19-
#if defined(__linux__) && (defined(__ARM_NEON) || defined(_M_ARM) || defined(__riscv_vector))
20+
#if XSIMD_WITH_LINUX_GETAUXVAL
2021
#include <asm/hwcap.h>
2122
#include <sys/auxv.h>
22-
23-
#ifndef HWCAP2_I8MM
24-
#define HWCAP2_I8MM (1 << 13)
2523
#endif
2624

2725
#endif
@@ -92,29 +90,24 @@ namespace xsimd
9290
vsx = 1;
9391
#endif
9492

95-
#if defined(__aarch64__) || defined(_M_ARM64)
96-
neon = 1;
97-
neon64 = 1;
98-
#if defined(__linux__) && (!defined(__ANDROID_API__) || __ANDROID_API__ >= 18)
99-
i8mm_neon64 = bool(getauxval(AT_HWCAP2) & HWCAP2_I8MM);
100-
sve = bool(getauxval(AT_HWCAP) & HWCAP_SVE);
101-
#endif
102-
103-
#elif defined(__ARM_NEON) || defined(_M_ARM)
104-
105-
#if defined(__linux__) && (!defined(__ANDROID_API__) || __ANDROID_API__ >= 18)
106-
neon = bool(getauxval(AT_HWCAP) & HWCAP_NEON);
107-
#endif
93+
#if XSIMD_WITH_LINUX_GETAUXVAL
94+
#if defined(__riscv_vector) && defined(__riscv_v_fixed_vlen) && __riscv_v_fixed_vlen > 0
10895

109-
#elif defined(__riscv_vector) && defined(__riscv_v_fixed_vlen) && __riscv_v_fixed_vlen > 0
110-
111-
#if defined(__linux__) && (!defined(__ANDROID_API__) || __ANDROID_API__ >= 18)
11296
#ifndef HWCAP_V
11397
#define HWCAP_V (1 << ('V' - 'A'))
11498
#endif
11599
rvv = bool(getauxval(AT_HWCAP) & HWCAP_V);
116100
#endif
117101
#endif
102+
103+
// Safe on all platforms, it will be all false if non arm.
104+
const auto arm_cpu = xsimd::arm_cpu_features();
105+
106+
neon = arm_cpu.neon();
107+
neon64 = arm_cpu.neon64();
108+
i8mm_neon64 = arm_cpu.neon64() && arm_cpu.i8mm();
109+
sve = arm_cpu.sve();
110+
118111
// Safe on all platforms, it will be all false if non x86.
119112
const auto x86_cpu = xsimd::x86_cpu_features();
120113

0 commit comments

Comments
 (0)