Skip to content

Commit

Permalink
Merge pull request #3169 from juju812/bugfix/i8mm-check
Browse files Browse the repository at this point in the history
CPURuntime: Bugfix: check i8mm support by AT_HWCAP2
  • Loading branch information
jxt1234 authored Jan 21, 2025
2 parents b500a46 + c0e14f2 commit 9889cc1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions source/backend/cpu/CPURuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
#include <sys/types.h>
#include <dirent.h>

// HWCAP flags
#define CPUINFO_ARM_LINUX_FEATURE_FPHP UINT32_C(0x00000200)
#define CPUINFO_ARM_LINUX_FEATURE_ASIMDHP UINT32_C(0x00000400)
#define CPUINFO_ARM_LINUX_FEATURE_ASIMDDP UINT32_C(0x00100000)
// ref: https://cs.android.com/android/platform/superproject/+/master:bionic/libc/kernel/uapi/asm-arm64/asm/hwcap.h;drc=04da58f5b3bc40dbbafb4f8422aa2991479d9e1e;l=70
#define CPUINFO_ARM_LINUX_FEATURE_I8MM UINT32_C(0x00002000)
#define CPUINFO_ARM_LINUX_FEATURE_SVE UINT32_C(0x00400000)
// HWCAP2 flags
#define CPUINFO_ARM_LINUX_FEATURE_SVE2 UINT32_C(0x00000002)
// ref: https://cs.android.com/android/platform/superproject/+/master:bionic/libc/kernel/uapi/asm-arm64/asm/hwcap.h;drc=04da58f5b3bc40dbbafb4f8422aa2991479d9e1e;l=70
#define CPUINFO_ARM_LINUX_FEATURE_I8MM UINT32_C(0x00002000)
#endif

#include <algorithm>
Expand Down Expand Up @@ -1288,6 +1290,7 @@ static void _getInfoApple(MNNCPUInfo* cpuinfo_isa) {
static void _getInfoAux(MNNCPUInfo* cpuinfo_isa) {
// Use AUX to get info for linux-aarch64
uint32_t isa_features = 0;
// HWCAP features
isa_features = (uint32_t)getauxval(AT_HWCAP);
if (isa_features & CPUINFO_ARM_LINUX_FEATURE_ASIMDDP) {
cpuinfo_isa->dot = true;
Expand All @@ -1296,10 +1299,11 @@ static void _getInfoAux(MNNCPUInfo* cpuinfo_isa) {
if ((isa_features & fp16arith_mask) == fp16arith_mask) {
cpuinfo_isa->fp16arith = true;
}
// HWCAP2 features
isa_features = (uint32_t)getauxval(AT_HWCAP2);
if (isa_features & CPUINFO_ARM_LINUX_FEATURE_I8MM) {
cpuinfo_isa->i8mm = true;
}
isa_features = (uint32_t)getauxval(AT_HWCAP2);
if (isa_features & CPUINFO_ARM_LINUX_FEATURE_SVE2) {
cpuinfo_isa->sve2 = true;
}
Expand Down

0 comments on commit 9889cc1

Please sign in to comment.