ARM Matrix Multiplication (NEON Edition)
Описание и применение
Руководство по реализации умножения матриц на ARM с использованием NEON‑ассемблера, показывающее, как вручную оптимизировать код и измерять производительность.
Задача
Implement fast matrix multiplication on ARM CPUs using NEON assembly instead of relying on GPU or high-level libraries.
Результат
Hand‑written NEON assembly slightly outperforms the C compiler but remains a small fraction of the M2’s theoretical peak. SIMD vectorization yields modest gains, highlighting the need for more advanced optimizations (e.g., SME/SVE2).
Рабочий процесс
- Write reference C matrix multiplication
- Compile with -O2 and benchmark
- Translate naive C loops to ARM assembly
- Benchmark assembly version
- Add SIMD vectorization (load 4 B values, broadcast A, use fmadd)
- Benchmark SIMD version
Доказательства
At -O2 this runs at 2.09 Gflops, about 1.9% of our theoretical maximum.
alright we have 1.98 Gflops (or about 1.8% of the theoretical max)... the c compiler is smarter than me.
- Дата записи: 2026-09-21T22:00:28.259Z