This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Runtime detection of SVE2 not working as expected

Hello, I used the following guide in order to write code for CPU feature detection at runtime: https://community.arm.com/arm-community-blogs/b/operating-systems-blog/posts/runtime-detection-of-cpu-features-on-an-armv8-a-cpu I modified the HWCAP example so that it reports SVE features:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdio.h>
#include <sys/auxv.h>
#include <asm/hwcap.h>
int main()
{
long hwcaps = getauxval(AT_HWCAP);
printf("FP: %d\n", hwcaps & HWCAP_FP);
printf("SVE: %d\n", hwcaps & HWCAP_SVE);
printf("SVE2: %d\n", hwcaps & HWCAP2_SVE2);
printf("SVEF32MM: %d\n", hwcaps & HWCAP2_SVEF32MM);
printf("SVEF64MM: %d\n", hwcaps & HWCAP2_SVEF64MM);
return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

When I run the program on RPi4, I get strange values for SVE2 and SVEF64MM:

Fullscreen
1
2
3
4
5
FP: 1
SVE: 0
SVE2: 2
SVEF32MM: 0
SVEF64MM: 2048
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I am supposed to get 0es. Why am I getting 2 and 2048?

0