Check for features support
Hello,
Is there an easy way to check whether a CPU supports FEAT_DotProd and/or FEAT_I8MM ?
I can successfully build the project but trying to run kleidiai_test
fails with:
❯ file kleidiai_test (kleidiai-env)
kleidiai_test: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, with debug_info, not stripped
❯ ./kleidiai_test (kleidiai-env)
Running main() from /home/mgrigorov/git/kleidiai/build/_deps/googletest-src/googletest/src/gtest_main.cc
[==========] Running 151 tests from 5 test suites.
[----------] Global test environment set-up.
[----------] 1 test from matmul_clamp_f32_qsi8d32p4x8_qsi4c32p4x8_8x4x32_neon_i8mm
[ RUN ] matmul_clamp_f32_qsi8d32p4x8_qsi4c32p4x8_8x4x32_neon_i8mm.EndToEnd
fish: Job 1, './kleidiai_test' terminated by signal SIGILL (Illegal instruction)
The CPU is Hisilicon Kunpeng 920:
❯ lscpu (kleidiai-env)
Architecture: aarch64
CPU op-mode(s): 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Vendor ID: HiSilicon
Model name: Kunpeng-920
Model: 0
Thread(s) per core: 1
Core(s) per socket: 8
Socket(s): 1
Stepping: 0x1
Frequency boost: disabled
CPU max MHz: 2400.0000
CPU min MHz: 2400.0000
BogoMIPS: 200.00
Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma dcpop asimddp asimdfhm
Caches (sum of all):
L1d: 512 KiB (8 instances)
L1i: 512 KiB (8 instances)
L2: 4 MiB (8 instances)
L3: 32 MiB (1 instance)
NUMA:
NUMA node(s): 1
NUMA node0 CPU(s): 0-7
Vulnerabilities:
Gather data sampling: Not affected
Itlb multihit: Not affected
L1tf: Not affected
Mds: Not affected
Meltdown: Not affected
Mmio stale data: Not affected
Retbleed: Not affected
Spec rstack overflow: Not affected
Spec store bypass: Vulnerable
Spectre v1: Mitigation; __user pointer sanitization
Spectre v2: Not affected
Srbds: Not affected
Tsx async abort: Not affected
AFAIK this CPU implements ARMv8.2a and according to "Current supported Arm® CPUs technologies and features" those features are optional in 8.2, so I am not sure whether the "Illegal instruction" failure is caused by a missing feature.
Would it be a good idea to add a Cmake check for the features/instructions and fail early at build time (cmake ...
) if a feature is not supported on the build machine ?
Similar for runtime: add a check and give better error message to the user instead of failing with SIGILL.
Thank you!