# Verification

CMSIS-DSP is Arm's C library that heliaDSP builds from one commit of Ambiq's upstream-tracking fork [AmbiqAI/CMSIS-DSP](https://github.com/AmbiqAI/CMSIS-DSP), the qualified CMSIS-DSP commit. Checks happen in two repositories: the upstream-tracking fork tests each patch it carries against Arm's source, and heliaDSP tests the build integration, the release, and the library built from the qualified CMSIS-DSP commit through it. The executed results for the current version are recorded in [`COMPATIBILITY.md`](https://github.com/AmbiqAI/helia-dsp/blob/4a7b7f054eafd96ae50c12050ad3ef3ec1ebaea1/COMPATIBILITY.md).

Placeholders on this page: `<CMSIS_6>` (a checkout of [ARM-software/CMSIS_6](https://github.com/ARM-software/CMSIS_6) at v6.2.0), `<Cortex_DFP>` (Arm's Cortex device family pack), `<platform.ld>` (the Corstone-300 linker script of Arm's Ethos-U core platform), `<FVP>` (the Corstone-300 simulator package).

## Where each check runs

| Check | Runs | On every pull request | Executes code |
| --- | --- | --- | --- |
| Host qualification tests | Linux x86-64, scalar kernels | Yes | Yes |
| Provider rule: twenty-nine configure cases | Linux host | Yes | Configure only |
| Release tooling: metadata, dependency identity, archive | Linux host, Git checkout | Yes | Yes (host build from the archive) |
| Cortex-M55 build and link | GCC 15.2.Rel1 (`AUTOVECTORIZE=ON` and Helium), ATfE 22.1.0, Armclang 6.24 | Yes | No |
| Corstone-300 simulator | Cortex-M55 model, by hand | No | Yes |
| Apollo510 EVB | Hardware, by hand | No | Yes |
| Regression tests in the upstream-tracking fork | Corstone-300 simulator and host | In the upstream-tracking fork | Yes |

CI cross-compiles Cortex-M55 code and does not run it. The GCC 15.2.Rel1 miscompilation of Arm's Helium FFT (see [Toolchains](https://ambiqai.github.io/helia-dsp/guide/toolchains/)) passed a CI job of this kind, which links without running, in heliaDSP v1.1.0; the simulator and board runs are what detect such a defect.

## Host qualification tests

The tests are in `helia/tests/qualification/` and ship with the release:

- `smoke.c`: `arm_add_f32` and an identity biquad.
- `biquad_df1_test.c`: the f32 direct-form-I biquad against a float64 reference, with the initializer each build requires; the input is processed in blocks of 17, 18, 19 and 13 samples, so every tail branch of the Helium kernel and the state carried between calls are exercised.
- `rfft_fixed_tables_test.c`: every fixed-length Q15 and Q31 real-FFT initializer against the generic one, forward and inverse, compared bit for bit.

From the repository root, with Ninja installed:

```sh
python tools/qualification/build.py --toolchain host
```

Expected ending:

```text
1/3 Test #1: qualification_smoke ...............   Passed    0.00 sec
2/3 Test #2: qualification_biquad_df1 ..........   Passed    0.00 sec
3/3 Test #3: qualification_rfft_fixed_tables ...   Passed    0.00 sec

100% tests passed out of 3
```

The build tree is `.qualification/host/`. For a Cortex-M55 build and link, `--toolchain gcc --cmsis-core <CMSIS_6>/CMSIS/Core` (or `atfe` with `ATFE_ROOT` set, or `armclang`); these link 256-point Q15 and Q31 real-FFT programs and check that only the 256-point coefficient tables were linked.

## Corstone-300 simulator

The Corstone-300 fixed virtual platform is Arm's simulator of a Cortex-M55 system. The same tests built for it run with the Helium kernels:

```sh
python tools/qualification/build.py --toolchain gcc --fvp \
  --cmsis-core <CMSIS_6>/CMSIS/Core --cortex-dfp <Cortex_DFP> \
  --platform-linker <platform.ld> --fvp-root <FVP>
```

Each program's UART output is checked for `PASS: biquad_df1` and `PASS: 36 fixed-point RFFT parity cases`. The linker prints ``section `.data' can't be allocated in segment 1`` for these programs, and they run. This path supports GCC only; the ATfE simulator runs recorded in `COMPATIBILITY.md` were made with a separate script that is not in the tree.

## Apollo510 EVB

The board runs for 2.0.0, recorded in `COMPATIBILITY.md`, executed the fixed-length against generic Q15 and Q31 real-FFT parity test, lengths 32 to 8192, forward and inverse, 54 checks, with GCC 14.2.1 and with ATfE 22.1.0, at 96 MHz. The library for those runs was built from the upstream-tracking fork's own CMake entry with the flags heliaDSP uses, not through heliaDSP's CMake. The direct-form-I biquad test (`helia/tests/qualification/biquad_df1_test.c`, through `arm_biquad_cascade_df1_mve_init_f32`) passed on the board with GCC 14.2.1 and with ATfE 22.1.0, with the library built through heliaDSP's CMake; largest absolute errors 8.3e-07 and 5.6e-07.

Board runs use Ambiq's internal measurement harness: NumPy float64 references, generated test vectors compiled into the firmware, a host runner, and an Apollo510 firmware runner that reports per-test error, cycle counts (from the Cortex-M data watchpoint and trace unit's cycle counter, DWT) and flash footprint as one JSON record per run. The harness is development tooling and is not part of the heliaDSP tree. Distributing references, vectors and a measuring harness with heliaDSP, so that a user can measure on their own board, is an idea for a later release.

## Provider rule and release tooling

`helia/tests/provider/` holds twenty-nine configure-time cases for the one-provider rule (see [Direct CMake](https://ambiqai.github.io/helia-dsp/getting-started/cmake/#a-second-cmsis-dsp-library)): the bundled provider, also with `MATRIXCHECK=ON`, where `ARM_MATH_MATRIX_CHECK` must reach consumers; two consumers of one provider; three verified external providers, the second added with heliaDSP in a scope that sets `AUTOVECTORIZE=ON`, the third with `ARM_MFCC_CFFT_BASED` public; and twenty-three rejected external providers (a modified tree, a private header definition, a private valued definition `ARM_MATH_AUTOVECTORIZE=1`, the same definition on consumers only, `ARM_MATH_AUTOVECTORIZE=0` private, the definition as the two options `-D ARM_MATH_AUTOVECTORIZE`, as `/DARM_MATH_AUTOVECTORIZE`, a `-UARM_MATH_AUTOVECTORIZE` option, the definition on one library source, the definition in the provider scope's `CMAKE_C_FLAGS_RELEASE` under Ninja Multi-Config, a definition under a generator expression, an option mismatch, an added source, a private machine option, an imported library, `ARM_MFCC_CFFT_BASED` private and on consumers only, `ARM_DSP_CUSTOM_CONFIG` with an `arm_dsp_config.h`, and, applied after heliaDSP is added, a private valued definition, an added source and, from a call deferred to the end of the top-level directory, a private `ARM_MFCC_CFFT_BASED`, also under the call ID `off`, and a deferred call that defers itself again while other calls are pending, which the check's deferral limit stops). Each accepted case must produce one `libCMSISDSP.a`; each rejected case must stop with a message naming its cause.

`tests/release/` tests the release tooling. It needs a Git checkout with the submodule initialized:

```sh
python -m unittest discover -s tests/release -v
```

It runs six tests and ends with `OK`. They cover: the release verifier; the dependency identity check, run through both the CMake function and `tools/release/dependency_identity.py` on copies of the dependency (CRLF line endings, a build directory and stray non-source files accepted; an edited `.c`, `.h`, `.cmake`, `CMakeLists.txt` or `Kconfig`, an edit in a CRLF copy, an added `.h`, `.hpp` or upper-case `.C`, a missing `.c`, a `CMakeCache.txt` beside `Source/CMakeLists.txt`, an edited header beside a `CMakeCache.txt` alone in `Include/`, and an added header beside a `CMakeCache.txt` alone in a new directory refused); propagation of targets and header-affecting definitions in four configurations; the provider cases; the list of header-affecting definitions, against the macros that the pinned headers test in preprocessor conditions, each of which must be in the provider check's lists or in the test's list of macros the check does not compare; and the source archive, which is built twice and must be byte-identical, must contain exactly the tracked files of both repositories, and must build the host tests after extraction with a `git` that fails if called.

`tools/release/verify_release.py` additionally checks that the submodule commit, `cmake/HeliaDspPin.cmake`, `PROVENANCE.toml` and `COMPATIBILITY.md` name the same commit, that the build-input digest matches, that the carried-patch list matches the upstream-tracking fork's history, and that the tree contains no symbolic links, no Git LFS pointers, and no file named `arm_*` outside `third_party/CMSIS-DSP`. It also checks that the fork's upstream base is an ancestor of the pinned commit, which needs the submodule's history in the local object store: in a shallow submodule (`git submodule update --depth 1`) it fails with `upstream base is not an ancestor of the pinned commit`, and `git -C third_party/CMSIS-DSP fetch --unshallow` fetches the rest of the history.

## Regression tests in the upstream-tracking fork

Each code patch in the upstream-tracking fork except the two Zephyr build-integration patches, pull requests #12 and #13, carries a regression test under `Testing/Regression/` that passes on the patched source and fails on Arm's. Most run on the Corstone-300 simulator with a memory-protection (MPU) guard placed directly after, or before, the buffer under test, so that an access outside the buffer faults instead of passing silently. At the qualified CMSIS-DSP commit of 2.0.0 the upstream-tracking fork has:

| Test | Checks | Cases |
| --- | --- | --- |
| `mve_matvec_tail.c` | f32 matrix-vector product reads nothing past the matrix | 63 shapes |
| `mve_matvec_tail_fixed.c` | the same for Q7, Q15 and Q31 | 357 shapes |
| `mve_rfft_table_guards.c` | Q15 and Q31 real-FFT kernels read nothing past their coefficient tables | 36 |
| `rfft_fixed_tables_parity.c` | fixed-length and generic Q15/Q31 real-FFT initializers give identical output | 36 |
| `test_cmake_features.py` | header-affecting definitions reach CMake consumers | 8 option combinations |
| `test_c_only_configure.py` | CMSIS-DSP configures with a C compiler only | 4 configurations |
| `mve_fir_f32_state_bound.c` | f32 FIR kernel writes no state past `numTaps + 2*blockSize - 1`, reads within `4*ceil(numTaps/4) + 2*blockSize - 1`, and reads no input past the block | 240 |
| `mve_cfft_q31_guard.c` | Q31 complex FFT accesses nothing below its buffer | 14 |
| `mve_tail_loads_f32.c`, `mve_tail_loads_fixed.c`, `mve_tail_loads_f16.c`, `mve_tail_loads_remainder.c` | f32/u32, fixed-point and f16 vector kernels, the `vld2q` tails of three f16 kernels, and f32 matrix add and subtract read nothing past their inputs | 168, 923, 288, 112 |
| `mve_cfft_overread.c` | f32, Q31, Q15 and f16 complex FFTs read nothing past the in-place buffer | 72 |
| `mve_matvec_tail_f16.c` | the matrix-vector check for f16 | 119 shapes |
| `mve_fir_decimate_f32_state.c` | f32 FIR decimator reads nothing past its state | 900 |
| `mve_fir_decimate_fixed_state.c` | Q15 and Q31 FIR decimators read nothing past their state and input | 1,800 |
| `test_pythonwrapper_commit_hash.py` | `cmsisdsp.commit_hash` names the commit the wrapper was built from | 11 |

The guarded Q31 complex-FFT test of pull request #10 detects the GCC 15.2.Rel1 defect. The five memory-guarded tests of pull requests #1, #2, #6, #9 and #10 pass under ATfE 22.1.0; the patch ledger of the upstream-tracking fork records the tests of #1, #2 and #6 at `-O2` and `-O3` in its Toolchain section, the test of #9 at `-O2` and `-O3` in its row, and all five, without optimization levels, in the row of pull request #28; the ledger rows of pull requests #14 to #16, #18, #19 and #21 to #23 record their tests' ATfE 22.1.0 results. Pull request #28 adds negative controls to the guarded tests: a run with a 32-bit read past the buffer or a NaN output must fail.

## Not verified

- Arm's own CMSIS-DSP test suite is run neither in heliaDSP nor in the upstream-tracking fork. Kernels that no test listed above covers are compiled at the qualified CMSIS-DSP commit and not executed; this includes 64 upstream commits between the base of heliaDSP v1.1.0 and the base of the qualified CMSIS-DSP commit of 2.0.0.
- No Armclang build has been executed.
- No SoC other than Apollo510 has been run. The SoCs listed in `nsx/nsx-module.yaml` are declarations of source compatibility.
- ATfE's own linker and C library have not been part of an executed image; executed ATfE images were linked by GNU `ld` with newlib.
- Board-specific startup and linker integration, energy, and performance are not conditions a release must pass; [Measurements](https://ambiqai.github.io/helia-dsp/guide/measurements/) reports the measurements that exist.

## Next

- [Measurements](https://ambiqai.github.io/helia-dsp/guide/measurements/)
- [Toolchains](https://ambiqai.github.io/helia-dsp/guide/toolchains/)
- [Contributing](https://ambiqai.github.io/helia-dsp/guide/contributing/)
