skills/platform/arm-sve/SKILL.md
ARM SVE skill for scalable vector extension programming. Use when writing SVE intrinsics, predicate registers, VLA loops with svcnt, auto-vectorization with -march=armv9-a+sve2, or debugging SVE in GDB. Activates on queries about SVE, SVE2, predicate registers, svld1, svcnt, arm_sve.h, or Graviton SVE.
npx skillsauth add mohitmishra786/low-level-dev-skills arm-sveInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Guide agents through ARM Scalable Vector Extension (SVE/SVE2) programming: vector-length agnostic (VLA) code, predicate registers, SVE intrinsics via <arm_sve.h>, runtime vector length with svcnt, compiler flags, platform differences (Graviton3, Apple M4), and GDB debugging of SVE registers.
-march=armv9-a+sve2| | NEON | SVE/SVE2 | |---|------|----------| | Vector width | Fixed (128-bit) | Scalable (128–2048 bits, hardware dependent) | | Predication | Limited | Full predicate registers P0–P15 | | Portability across ARM CPUs | Same width everywhere | VLA — adapts to hardware VL | | Apple Silicon | Always available | M4+ has SVE2 |
SVE registers
├── Z0–Z31 — scalable vector data registers
└── P0–P15 — predicate (mask) registers
Vector Length (VL) — determined at runtime per CPU
svcntb() → bytes per vector
svcntw() → 32-bit elements per vector
Code written once runs at full width on any SVE-capable CPU.
#include <arm_sve.h>
#include <stddef.h>
void saxpy_sve(float *y, const float *x, float alpha, size_t n) {
svbool_t pg = svwhilelt_b32(0, n);
size_t i = 0;
do {
svfloat32_t vx = svld1_f32(pg, &x[i]);
svfloat32_t vy = svld1_f32(pg, &y[i]);
vy = svmla_n_f32_x(pg, vy, vx, alpha); // y += alpha * x
svst1_f32(pg, &y[i], vy);
i += svcntw(); // advance by vector length in 32-bit elements
pg = svwhilelt_b32(i, n);
} while (svptest_any(svptrue_b32(), pg));
}
gcc -march=armv9-a+sve2 -O3 -o saxpy saxpy.c
| Intrinsic | Purpose |
|-----------|---------|
| svld1_f32(pg, ptr) | Masked load |
| svst1_f32(pg, ptr, val) | Masked store |
| svmul_f32_x(pg, a, b) | Multiply under predicate |
| svmla_f32_x(pg, acc, a, b) | Fused multiply-add |
| svwhilelt_b32(i, n) | Predicate for active lanes where i < n |
| svcntw() | 32-bit lanes per vector |
| svptrue_b32() | All-true predicate |
// SVE handles tails via predicates — no separate scalar epilogue
for (size_t i = 0; i < n; ) {
svbool_t pg = svwhilelt_b32(i, n);
// ... vector ops with pg ...
i += svcntw();
}
Contrast with NEON: often needs scalar cleanup for n % 4 != 0.
# GCC vectorization remarks
gcc -march=armv9-a+sve2 -O3 -fopt-info-vec -o app app.c
# Clang
clang -march=armv9-a+sve2 -O3 -Rpass=vectorize -o app app.c
#pragma omp simd // may use SVE when available
for (int i = 0; i < n; i++)
c[i] = a[i] + b[i];
| Platform | SVE support | |----------|-------------| | AWS Graviton3 (Neoverse V1) | SVE (no SVE2) | | AWS Graviton4 (Neoverse V2) | SVE + SVE2 | | Apple M4 | SVE2 | | Apple M1/M2/M3 | NEON only (no SVE) |
# Check SVE on Linux
grep -i sve /proc/cpuinfo # "sve" or "sve2" in Features
# Or: cat /sys/devices/system/cpu/cpu0/regs/identification/id_aa64pfr0_el1
SVE2 adds integer dot product, crypto, and bitwise operations:
#include <arm_sve.h>
svint32_t dot = svdot_s32(svptrue_b32(),
svld1_s8(pg, a), svld1_s8(pg, b));
Use for ML inference kernels on Graviton.
gcc -g -march=armv9-a+sve2 -o saxpy saxpy.c
gdb ./saxpy
(gdb) break saxpy_sve
(gdb) run
(gdb) p $z0 # print SVE vector register
(gdb) p $p0 # print predicate register
(gdb) info registers z0 z1 p0
Requires GDB 10+ with SVE support and SVE-capable hardware.
Migration checklist
├── Replace fixed loops (i += 4) with svcntw() strides
├── Add svwhilelt predicates for tails
├── Use _x (merging) vs _z (zeroing) predicated ops intentionally
└── Test on multiple VL hardware or use QEMU sve-max-vq
# QEMU SVE emulation
qemu-aarch64 -cpu max ./saxpy
| Symptom | Cause | Fix |
|---------|-------|-----|
| Illegal instruction | No SVE hardware | Check cpuinfo; use NEON fallback |
| Wrong results in tail | Inactive lanes modified | Use _x predicated ops, not unpredicated |
| Slower than NEON | Short arrays | SVE setup cost; scalar for n < VL |
| Auto-vec failed | Unknown trip count | -fno-trapping-math; pragma simd |
| Apple M3 build fails | No SVE on M3 | Guard with __ARM_FEATURE_SVE |
| GDB can't print Z regs | Old GDB | Upgrade GDB; run on SVE hardware |
skills/low-level-programming/assembly-arm — AArch64 assembly and NEONskills/low-level-programming/simd-intrinsics — general SIMD conceptsskills/platform/apple-silicon — Apple M-series specificsskills/compilers/gcc — -march flagsskills/compilers/clang — vectorization remarksskills/low-level-programming/cpu-cache-opt — memory layout for SIMDdevelopment
QEMU/KVM skill for virtualization and kernel development. Use when running qemu-system-x86_64 with KVM, configuring virtio devices, VFIO passthrough, QMP monitor, libvirt, or booting custom kernels. Activates on queries about QEMU, KVM, virtio, VFIO, virsh, virt-install, or -kernel -append.
development
Hardware virtualization internals skill for Intel VT-x and AMD-V. Use when studying VMCS/VMCB, EPT/NPT page tables, VMEXIT handling, APIC virtualization, or building minimal hypervisors. Activates on queries about VMX, SVM, VMCS, EPT, NPT, VMEXIT, or type-1 hypervisor.
testing
Linux containers internals skill for namespaces, cgroups, and OCI. Use when understanding clone/unshare namespaces, cgroups v2 limits, overlayfs, runc, seccomp profiles, capabilities, or escape mitigations. Activates on queries about namespaces, cgroups, overlayfs, runc, seccomp-bpf, OCI spec, or container escape.
tools
Reverse engineering skill for binary analysis. Use when decompiling with Ghidra, analyzing with radare2, scripting RE tools, triaging with strings/file/xxd, or diffing binaries. Activates on queries about Ghidra, radare2, r2, decompiler, Binary Ninja, Diaphora, or stripped binary analysis.