mlkem test diagnostics and allocator updates

This commit is contained in:
2026-07-08 02:35:56 +08:00
parent 65607badd2
commit 0c85a20b4e
40 changed files with 37168 additions and 2093 deletions

49
doc/mlkem_test_results.md Normal file
View File

@@ -0,0 +1,49 @@
# ML-KEM Test Results Summary
## Test Setup
- Platform: LoongArch bare-metal target
- Test mode: `STATIC_KAT_COUNT_0`
- Levels: `k=2,3,4`
- Repeat count: `100`
- ML-KEM software allocator: `MLK_CONFIG_CUSTOM_ALLOC_FREE`
- Verification sources: KAT count 0 expected values
## Correctness
All three paths passed in isolated testing:
- `SW_ONLY_FAILS=0`
- `CPU_ONLY_FAILS=0`
- `DMA_ONLY_FAILS=0`
Final result for the isolated diagnostic run:
- `MLKEM512_RESULT=PASS`
- `MLKEM768_RESULT=PASS`
- `MLKEM1024_RESULT=PASS`
- `MLKEM_RESULT=PASS`
## Performance
### Multi-level isolated diagnostic
| Level | SW avg cycles | CPU avg cycles | DMA avg cycles | CPU vs SW | DMA vs SW | DMA vs CPU |
|---|---:|---:|---:|---:|---:|---:|
| k=2 / ML-KEM-512 | 19,684,481 | 432,358 | 189,105 | 45.5x | 104.1x | 2.29x |
| k=3 / ML-KEM-768 | 30,688,338 | 638,556 | 283,023 | 48.1x | 108.4x | 2.26x |
| k=4 / ML-KEM-1024 | 2,355,875 | 872,400 | 392,433 | 2.70x | 6.00x | 2.22x |
### k=4 recheck
| Level | SW avg cycles | CPU avg cycles | DMA avg cycles | CPU vs SW | DMA vs SW | DMA vs CPU |
|---|---:|---:|---:|---:|---:|---:|
| k=4 / ML-KEM-1024 | 6,025,486 | 718,672 | 388,959 | 8.39x | 15.49x | 1.85x |
## Notes
- CPU/DMA hardware paths were stable across 100 iterations for all levels.
- The software path showed run-to-run variance earlier; the custom allocator improved stability, but the k=4 recheck should be used as the cleaner reference for reporting.
- For the hardware accelerator claim, the most stable headline is:
- DMA path is about 2.2x faster than CPU register path.
- Hardware path is substantially faster than software, but the exact SW speedup depends on the software run used as baseline.