Skip to content

Instantly share code, notes, and snippets.

Created January 7, 2021 07:05
What would you like to do?
Check availability and length of SVE
#include <cstdio>
#include <arm_sve.h>
int main() {
int n = 0;
n = svcntb() * 8;
if (n) {
printf("SVE is available. The length is %d bits\n", n);
} else {
printf("SVE is unavailable.\n");
Copy link

$ aarch64-linux-gnu-g++ -static sve_check.cpp 
$ qemu-aarch64 ./a.out
SVE is unavailable.

$ aarch64-linux-gnu-g++ -march=armv8-a+sve -static sve_check.cpp 
$ qemu-aarch64 -cpu max,sve128=on ./a.out
SVE is available. The length is 128 bits
$ qemu-aarch64 -cpu max,sve256=on ./a.out
SVE is available. The length is 256 bits
$ qemu-aarch64 -cpu max,sve512=on ./a.out
SVE is available. The length is 512 bits
$ qemu-aarch64 -cpu max,sve=off ./a.out
qemu: uncaught target signal 4 (Illegal instruction) - core dumped
Illegal instruction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment