Skip to content

Commit 209b00c

Browse files
authored
Add detection for sme on aarch64. (#257)
This is based on the ARM ComputeLibrary implementation [here](https://github.com/ARM-software/ComputeLibrary/blob/f1929dc994d8e5afae5c77ca66446344119a8592/src/common/cpuinfo/CpuIsaInfo.cpp#L75).
1 parent 16bfc16 commit 209b00c

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

include/cpuinfo.h

+9
Original file line numberDiff line numberDiff line change
@@ -1670,6 +1670,7 @@ struct cpuinfo_arm_isa {
16701670
bool sve;
16711671
bool sve2;
16721672
bool i8mm;
1673+
bool sme;
16731674
uint32_t svelen;
16741675
#endif
16751676
bool rdm;
@@ -2052,6 +2053,14 @@ static inline uint32_t cpuinfo_get_max_arm_sve_length(void) {
20522053
#endif
20532054
}
20542055

2056+
static inline bool cpuinfo_has_arm_sme(void) {
2057+
#if CPUINFO_ARCH_ARM64
2058+
return cpuinfo_isa.sme;
2059+
#else
2060+
return false;
2061+
#endif
2062+
}
2063+
20552064
#if CPUINFO_ARCH_RISCV32 || CPUINFO_ARCH_RISCV64
20562065
/* This structure is not a part of stable API. Use cpuinfo_has_riscv_* functions
20572066
* instead. */

src/arm/linux/aarch64-isa.c

+3
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ void cpuinfo_arm64_linux_decode_isa_from_proc_cpuinfo(
144144
if (features2 & CPUINFO_ARM_LINUX_FEATURE2_SVE2) {
145145
isa->sve2 = true;
146146
}
147+
if (features2 & CPUINFO_ARM_LINUX_FEATURE2_SME) {
148+
isa->sme = true;
149+
}
147150
// SVEBF16 is set iff SVE and BF16 are both supported, but the SVEBF16
148151
// feature flag was added in Linux kernel before the BF16 feature flag,
149152
// so we check for either.

src/arm/linux/api.h

+1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ struct cpuinfo_arm_linux_proc_cpuinfo_cache {
137137
#define CPUINFO_ARM_LINUX_FEATURE2_DGH UINT32_C(0x00008000)
138138
#define CPUINFO_ARM_LINUX_FEATURE2_RNG UINT32_C(0x00010000)
139139
#define CPUINFO_ARM_LINUX_FEATURE2_BTI UINT32_C(0x00020000)
140+
#define CPUINFO_ARM_LINUX_FEATURE2_SME UINT32_C(0x00800000)
140141
#endif
141142

142143
#define CPUINFO_ARM_LINUX_VALID_ARCHITECTURE UINT32_C(0x00010000)

0 commit comments

Comments
 (0)