Skip to content

Commit 4856ef1

Browse files
Add FFTW r5v RVV benchmark page from benchmarks repo.
Documents r5v vs scalar A/B on X60, MEASURE planner wins, and 3–5× planner lever; cross-links from QE, RV2, and homepage. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent b83906c commit 4856ef1

6 files changed

Lines changed: 75 additions & 6 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ Each RISC-V board exposes several compute paths. We benchmark and tune them inde
1313
| Path | What it is | Examples on our boards |
1414
| ---- | ---------- | ---------------------- |
1515
| **Scalar** | Scalar ISA and portable C kernels — the correctness baseline | `rv64gc` on VisionFive 2; `OPENBLAS_CORETYPE=RISCV64_GENERIC`; U74 **4×4 DGEMM** tuning |
16-
| **Vector** | ISA vector extensions (RVV) in shared libs | OpenBLAS `RISCV64_ZVL256B` on SpaceMiT X60 (VLEN=256); `ZVL128B` where VLEN=128; the `gemv_n` bug we fixed |
16+
| **Vector** | ISA vector extensions (RVV) in shared libs | OpenBLAS `RISCV64_ZVL256B` / `ZVL128B` on X60; [FFTW `r5v`](scientific-libs/fftw.html) **1.06–1.60×** vs scalar; the `gemv_n` bug we fixed |
1717
| **Specific** | Silicon-specific custom units beyond RVV | X60 **IME** (`smt.vmadot`) int8 on [RV2](boards/RV2.html) / [F3](boards/F3.html); [ONNX Runtime](apps/onnx.html) int4 via MLAS |
1818
| **GPU** | Discrete or integrated accelerators | On the roadmap — not yet in our RISC-V board benchmarks |
1919

20-
Recent highlights on the Orange Pi RV2 (SpaceMiT X60, RVV): fixing an OpenBLAS `gemv_n` bug restores correctness across [BLAS](scientific-libs/blas.html), [LAPACK](scientific-libs/lapack.html), [ELPA](scientific-libs/elpa.html), [HPL](apps/hpl.html), and [Quantum ESPRESSO](apps/qe.html) — with patched RVV reaching **10.53 GFLOP/s** on Linpack, **1.58×** on a dense eigensolve, and **1.31×** on a 64-atom Si DFT SCF. On the IME path, setting `accuracy_level=4` on ONNX `MatMulNBits` nodes unlocks **9–10×** int4 LLM decode vs the fp32 fallback — see [ONNX Runtime](apps/onnx.html) and [MLAS](scientific-libs/mlas.html).
20+
Recent highlights on the Orange Pi RV2 (SpaceMiT X60, RVV): fixing an OpenBLAS `gemv_n` bug restores correctness across [BLAS](scientific-libs/blas.html), [LAPACK](scientific-libs/lapack.html), [ELPA](scientific-libs/elpa.html), [HPL](apps/hpl.html), and [Quantum ESPRESSO](apps/qe.html) — with patched RVV reaching **10.53 GFLOP/s** on Linpack, **1.58×** on a dense eigensolve, and **1.31×** on a 64-atom Si DFT SCF. [FFTW `r5v`](scientific-libs/fftw.html) beats scalar **1.06–1.60×** under `FFTW_MEASURE`; planner choice alone is worth **3–5×**. On the IME path, setting `accuracy_level=4` on ONNX `MatMulNBits` nodes unlocks **9–10×** int4 LLM decode — see [ONNX Runtime](apps/onnx.html) and [MLAS](scientific-libs/mlas.html).
2121

2222
## Scientific libs
2323

@@ -29,6 +29,7 @@ Library-level probes — performance *and* numerical correctness:
2929
- **[LAPACK](scientific-libs/lapack.html)** — LAPACK path via NumPy `eigvalsh`
3030
- **[ELPA](scientific-libs/elpa.html)** — dense eigensolver (CP2K / VASP class workloads)
3131
- **[MLAS](scientific-libs/mlas.html)** — ONNX Runtime QNBit int4 GEMM; isolated IME kernel rates on X60
32+
- **[FFTW](scientific-libs/fftw.html)** — RVV `r5v` backend A/B vs scalar; planner-aware `tests/bench` on X60
3233

3334
## Apps
3435

_config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ navigation_scientific_libs:
3535
url: /scientific-libs/elpa.html
3636
- title: MLAS
3737
url: /scientific-libs/mlas.html
38+
- title: FFTW
39+
url: /scientific-libs/fftw.html

apps/qe.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Benchmark source: [opensolvers/benchmarks/qe](https://github.com/opensolvers/ben
66

77
## Why QE as a probe
88

9-
[`dgemm`](../scientific-libs/dgemm.html) isolates BLAS-3; [HPL](hpl.html) and [ELPA](../scientific-libs/elpa.html) probe single HPC solvers. A full DFT SCF mixes level-3 GEMM (`calbec`, subspace rotation), dense LAPACK diagonalization, latency-bound BLAS-2, MPI, **and a large FFT fraction** — so it shows both whether a buggy vector BLAS breaks a production code, and what fraction of a real run the RVV speedup actually moves.
9+
[`dgemm`](../scientific-libs/dgemm.html) isolates BLAS-3; [HPL](hpl.html) and [ELPA](../scientific-libs/elpa.html) probe single HPC solvers; [FFTW](../scientific-libs/fftw.html) covers the FFT half. A full DFT SCF mixes level-3 GEMM (`calbec`, subspace rotation), dense LAPACK diagonalization, latency-bound BLAS-2, MPI, **and a large FFT fraction** — so it shows both whether a buggy vector BLAS breaks a production code, and what fraction of a real run each backend swap actually moves.
1010

1111
## Correctness — stock RVV `gemv_n` breaks a real DFT SCF
1212

@@ -37,7 +37,7 @@ The stock vector backend aborts in `inverse_s` (overlap-matrix inversion / Lowdi
3737

3838
### Default band count (`nbnd=136`)
3939

40-
**67.6 s → 57.0 s = 1.19×** overall (`calbec` 1.90×, `rdiaghg` 1.53×). BLAS routines speed up ~1.5–2.0×; the FFT half of the run does not move (FlexiBLAS only swaps BLAS), which caps the whole-application number.
40+
**67.6 s → 57.0 s = 1.19×** overall (`calbec` 1.90×, `rdiaghg` 1.53×). BLAS routines speed up ~1.5–2.0×; the FFT half of the run does not move with a FlexiBLAS swap — see [FFTW](../scientific-libs/fftw.html) for RVV FFT tuning on the same hardware (**1.06–1.60×** under `FFTW_MEASURE`, plus **3–5×** from planner choice).
4141

4242
## Where QE sits on the BLAS-dilution spectrum
4343

boards/RV2.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,7 @@ The fix backports the upstream `gemv_n` correction from OpenBLAS ≥ 0.3.31 ([Op
4545
4. Register the new backend with FlexiBLAS and re-run the same `xhpl`.
4646

4747
Full walkthrough: [EESSI/docs#819](https://github.com/EESSI/docs/pull/819)*Chasing a NaN: correct RVV HPL on a RISC-V SpaceMiT X60 via EESSI*.
48+
49+
## FFTW RVV
50+
51+
See [FFTW](../scientific-libs/fftw.html) — FFTW 3.3.10 with the `r5v` RVV backend vs scalar on this board. Under `FFTW_MEASURE`, r5v wins **1.06–1.60×**; `FFTW_ESTIMATE` under-plans large transforms by **3–5×**.

scientific-libs/fftw.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# FFTW
2+
3+
[FFTW](https://www.fftw.org/) 3.3.10 with the **RISC-V Vector (`r5v`) SIMD backend** — a clean A/B against a scalar build of the *same source* with identical compiler and flags. The only variable is `--enable-r5v` (from [rdolbeau's `r5v-test-release-005`](https://github.com/rdolbeau)).
4+
5+
Benchmark source: [opensolvers/benchmarks/fftw](https://github.com/opensolvers/benchmarks/tree/main/fftw)`build-fftw-r5v.sh` and `bench-fftw-ab.sh`.
6+
7+
Relevant to [Quantum ESPRESSO](../apps/qe.html): plane-wave DFT spends a large fraction on FFT (`vloc_psi`, `fftw` timers). A FlexiBLAS swap does not touch FFT — tuning FFTW separately is how that half of the run moves.
8+
9+
## Orange Pi RV2 (SpaceMiT X60, 1 thread)
10+
11+
EESSI `2025.06-001`, GCC 14.3.0, `-O3 -march=rv64imafdcv_zvl256b`. 1D complex-to-complex via FFTW's own `tests/bench`, `-t 1.0`.
12+
13+
### The RVV backend is real
14+
15+
| Build | Library size | RVV instr count | Codelets in plan |
16+
| ----- | -----------: | --------------: | ---------------- |
17+
| **r5v** (`--enable-r5v`) | 11 MB | **224,354** | `n1fv_16_r5v256`, `t3fv_4_r5v256`, … |
18+
| **scalar** (control) | 924 KB | 734 | (none) |
19+
20+
The r5v library emits **~305×** more vector instructions than scalar, and FFTW's planner actually selects `*_r5v256` codelets (confirmed via `bench -v2`).
21+
22+
### Performance — `FFTW_MEASURE` default
23+
24+
Median MFLOPS; higher = faster. Under the **`FFTW_MEASURE`** planner (the default when no `-o` is passed), r5v beats scalar at every size:
25+
26+
| size | estimate r5v / scalar | **MEASURE r5v / scalar** | **r5v speedup** |
27+
| ---: | --------------------: | -----------------------: | --------------: |
28+
| 256 | 2228 / 1388 | **2520 / 1579** | **1.60×** |
29+
| 1024 | 717 / 747 | **1642 / 1265** | **1.30×** |
30+
| 4096 | 303 / 360 | **1283 / 978** | **1.31×** |
31+
| 16384 | 381 / 276 | **964 / 797** | **1.21×** |
32+
| 65536 | 148 / 142 | **797 / 752** | **1.06×** |
33+
| 262144 | 171 / 138 | **717 / 664** | **1.08×** |
34+
35+
Largest gain on cache-resident transforms (**1.60×** @ N=256); tapers to **~1.06×** as transforms become memory-bandwidth-bound (≥64K).
36+
37+
## Planner choice matters more than codelets
38+
39+
The biggest lever on this hardware is **planner choice** — worth **3–5×**, independent of RVV. `FFTW_ESTIMATE` grossly under-plans large transforms:
40+
41+
| size | estimate → MEASURE (r5v) | gain |
42+
| ---: | -----------------------: | ---: |
43+
| 4096 | 303 → 1283 | **4.2×** |
44+
| 16384 | 381 → 964 | **2.5×** |
45+
| 65536 | 148 → 797 | **5.4×** |
46+
| 262144 | 171 → 717 | **4.2×** |
47+
48+
`patient` was within noise of `MEASURE` where it completed, but planning time blows up at large N (>35 min at N=262144). **`FFTW_MEASURE`** (or cached wisdom) is the sweet spot — never `FFTW_ESTIMATE` on the X60/K1.
49+
50+
### Methodology trap
51+
52+
A first pass with `estimate` and `-t 0.3` appeared to show a **2× RVV regression** at N=262144. With honest timing, r5v is faster under both planners (717 vs 664 MFLOPS under MEASURE). Pin the planner and use **≥1 s** timing before trusting any single FFT A/B point.
53+
54+
## Reproduce
55+
56+
```bash
57+
./build-fftw-r5v.sh # needs $HOME/fftw-r5v.tar.gz on the board
58+
./bench-fftw-ab.sh # writes fftw-proper.log
59+
```
60+
61+
**Gotcha (Orange Pi RV2):** `module load GCCcore/14.3.0` does not repath `gcc` — EESSI's compat GCC 13.4.0 keeps winning. Prepend the real GCC 14 bindir explicitly (see `build-fftw-r5v.sh`). On [Banana Pi F3](../boards/F3.html) the plain `module load GCC/14.3.0` repaths correctly.

website.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ Context file for structural and content decisions on [opensolvers.com](https://w
2020
1. **Home**
2121
2. **Boards** — VisionFive 2, OrangePi RV2, BananaPi F3
2222
3. **Apps** — HPL, Quantum ESPRESSO, ONNX Runtime
23-
4. **Scientific libs** — BLAS, DGEMM, NumPy, LAPACK, ELPA, MLAS
23+
4. **Scientific libs** — BLAS, DGEMM, NumPy, LAPACK, ELPA, MLAS, FFTW
2424

2525
Nav config: `_config.yml` (`navigation`, `navigation_boards`, `navigation_apps`, `navigation_scientific_libs`). Rendered in `_includes/header.html`. Cayman theme requires `_layouts/default.html` override to include the header.
2626

2727
## Content sources
2828

2929
| Source | Used for |
3030
|--------|----------|
31-
| [opensolvers/benchmarks](https://github.com/opensolvers/benchmarks) | BLAS (`dgemm/`), HPL (`hpl/`), ELPA (`elpa/`), QE (`qe/`), NumPy/LAPACK (`numpy/`), ONNX/MLAS (`onnx/`) |
31+
| [opensolvers/benchmarks](https://github.com/opensolvers/benchmarks) | BLAS (`dgemm/`), HPL (`hpl/`), ELPA (`elpa/`), QE (`qe/`), NumPy/LAPACK (`numpy/`), ONNX/MLAS (`onnx/`), FFTW RVV (`fftw/`) |
3232
| [EESSI/docs#818](https://github.com/EESSI/docs/pull/818) | VisionFive 2 / U74 OpenBLAS + HPL |
3333
| [EESSI/docs#819](https://github.com/EESSI/docs/pull/819) | Orange Pi RV2 / X60 RVV `gemv_n` fix + HPL |
3434
| [easyconfigs#26436](https://github.com/easybuilders/easybuild-easyconfigs/pull/26436) | U74 OpenBLAS package |
@@ -44,6 +44,7 @@ Nav config: `_config.yml` (`navigation`, `navigation_boards`, `navigation_apps`,
4444

4545
| Date | Decision |
4646
|------|----------|
47+
| 2026-07-17 | Add FFTW `r5v` RVV page from `benchmarks/fftw`; cross-links from QE and RV2 |
4748
| 2026-07-17 | Add MLAS (lib) and ONNX Runtime (app) pages from `benchmarks/onnx` |
4849
| 2026-07-15 | Vector box: add ZVL256B and ZVL128B subtitles |
4950
| 2026-07-15 | Compute-backends diagram: RV64GC / IME subtitles; U74 DGEMM under Scalar |

0 commit comments

Comments
 (0)