arm-sve — Claude Code skill: AArch64 SIMD
arm-sve — a skill for Scalable Vector Extension programming on ARM servers. Teaches vector-length agnostic SIMD code that adapts to hardware vector width on Graviton, Apple M4, and other AArch64 platforms.
MIT 361 installs ★ 298 updated 2026-06-27
npx skills add mohitmishra786/low-level-dev-skills --skill arm-sve -a claude-codeWhat arm-sve does
SVE scales SIMD operations across variable vector widths without fixing to 128 bits. This skill covers predicates (P0–P15), scalable data registers (Z0–Z31), and runtime vector length queries with svcntw(). It's essential for high-performance compute on AWS Graviton3/4, where long vectors unlock throughput that fixed-width NEON cannot match.
The skill demonstrates masked loads via svld1_f32(), predicated loops with svwhilelt_b32() for tail handling, and fused operations like svmla_f32_x(). Compiler flags -march=armv9-a+sve2 enable auto-vectorization and SVE2 features (dot-product, crypto). You'll also learn GDB debugging of SVE state and migration from NEON.
Key constraints: Apple M1–M3 lack SVE support entirely; M4 adds SVE2. Graviton3 has SVE but not SVE2, while Graviton4 has both. The skill helps you detect hardware capabilities, choose appropriate fallbacks, and avoid illegal-instruction traps.
What it helps with
- write vector loops that scale to hardware vector width at runtime
- handle loop tails with predicates instead of scalar epilogue code
- port fixed-width NEON loops to length-agnostic SVE
- enable auto-vectorization with SVE2 compiler flags and pragmas
- debug SVE register state and predicate values in GDB
Example prompts for the agent
- Build a masked load-store loop with
svld1_f32()andsvcntw()for dynamic stride - Port a NEON multiply-add to SVE predicates and test on Graviton hardware
- Compile with
-march=armv9-a+sve2and interpret vectorization remarks from GCC
How to install arm-sve
1Skills CLI (Vercel)
npx skills add mohitmishra786/low-level-dev-skills --skill arm-sve -a claude-code2Manually: put the files in place
~/.claude/skills/arm-sve/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/arm-sve/
1Skills CLI (Vercel)
npx skills add mohitmishra786/low-level-dev-skills --skill arm-sve -a codex2Manually: put the files in place
.agents/skills/arm-sve/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add mohitmishra786/low-level-dev-skills --skill arm-sve -a cursor2Manually: put the files in place
.cursor/skills/arm-sve/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install mohitmishra786/low-level-dev-skills skills/platform/arm-sve2Manually: put the files in place
.github/skills/arm-sve/SKILL.md1Skills CLI (Vercel)
npx skills add mohitmishra786/low-level-dev-skills --skill arm-sve -a gemini-cli2Platform CLI
gemini skills install https://github.com/mohitmishra786/low-level-dev-skills --path skills/platform/arm-sveManually: put the files in place
.devin/skills/arm-sve/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add mohitmishra786/low-level-dev-skills --skill arm-sve -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about arm-sve
How do I install arm-sve in Claude Code?
Run npx skills add mohitmishra786/low-level-dev-skills --skill arm-sve -a claude-code, then find the skill at ~/.claude/skills/arm-sve/SKILL.md.
What does the arm-sve skill cover?
Vector-length agnostic SIMD on ARM servers: intrinsics like svld1_f32(), predicate registers, runtime vector count, compiler flags, platform differences, and GDB debugging of SVE state.
Is SVE available on Apple M1–M3?
No. M1–M3 support NEON only (128-bit vectors). SVE2 was introduced in M4. Graviton3 has SVE without SVE2; Graviton4 has both SVE and SVE2.
Source text
SKILL.md · MIT
---
name: arm-sve
description: 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.
---
# ARM SVE
## Purpose
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.
## When to Use
- Writing high-performance SIMD on AArch64 servers (AWS Graviton3/4)
- Porting fixed-width NEON code to length-agnostic SVE
- Using predicate masks for loop tails instead of separate cleanup loops
- Auto-vectorizing with GCC/Clang `-march=armv9-a+sve2`
- Debugging SVE register state in GDB on hardware with SVE support
- Exploiting SVE2 dot product and crypto extensions
## Workflow
### 1. SVE vs NEON
| | 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 |
### 2. Predicate and VLA concepts
```
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.
### 3. SVE intrinsics example
```c
#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));
}
```
```bash
gcc -march=armv9-a+sve2 -O3 -o saxpy saxpy.c
```
### 4. Key intrinsics
| 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 |
### 5. Loop tail handling
```c
// 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`.
### 6. Compiler auto-vectorization
```bash
# 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
```
```c
#pragma omp simd // may use SVE when available
for (int i = 0; i < n; i++)
c[i] = a[i] + b[i];
```
### 7. Platform differences
| 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) |
```bash
# 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
```
### 8. SVE2 extras
SVE2 adds integer dot product, crypto, and bitwise operations:
```c
#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.
### 9. GDB debugging
```bash
gcc -g -march=armv9-a+sve2 -o saxpy saxpy.c
gdb ./saxpy
```
```gdb
(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.
### 10. NEON → SVE2 migration
```
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
```
```bash
# QEMU SVE emulation
qemu-aarch64 -cpu max ./saxpy
```
## Common Problems
| 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 |
## Related Skills
- `skills/low-level-programming/assembly-arm` — AArch64 assembly and NEON
- `skills/low-level-programming/simd-intrinsics` — general SIMD concepts
- `skills/platform/apple-silicon` — Apple M-series specifics
- `skills/compilers/gcc` — `-march` flags
- `skills/compilers/clang` — vectorization remarks
- `skills/low-level-programming/cpu-cache-opt` — memory layout for SIMD
© mohitmishra786 · MIT · mohitmishra786/low-level-dev-skills