Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPURuntime: Bugfix: check i8mm support by AT_HWCAP2 #3169

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading