01 / Overview
An empirical high-performance computing study investigating hardware cache hierarchy utilization, loop reordering, cache tiling (blocking), and OpenMP parallelization on dense matrix multiplication compute kernels.
02 / The Problem
Naive matrix multiplication (ijk order) exhibits disastrous cache eviction behavior due to column-wise stride access in the second matrix, causing continuous L1/L2 cache misses that bottleneck CPU execution on modern architectures.
03 / My Solution & Architecture
Implemented 6 distinct C11 compute kernels compiled with GCC -O3 -fopenmp -march=native and 64-byte aligned memory allocation (posix_memalign). Python tooling detects CPU cache topology (L1d, L2, L3 cache sizes) and orchestrates repeated benchmark trials with warmups, median filtering, and numerical error bounds checking.
Key Engineering Decisions & Trade-Offs
Converting column-strided memory reads into continuous row-wise reads allows the hardware prefetcher to load contiguous cache lines, yielding an immediate ~12.6x speedup before any multithreading.
Aligning matrix data buffers with CPU 64-byte cache lines prevents split-line access penalties and sets up optimal conditions for SIMD vector registers.
Blocking submatrices to dimensions that fit within the 32KB/48KB L1 data cache ensures zero cache line evictions during inner dot products.
04 / Technologies Used
Every technology in this stack was chosen for direct architectural fitness, verifiable benchmarking ability, and clean maintainability in a production or research setting.
05 / How It Works & Interactive Visualizer
Here is a breakdown of how the system functions in practice:
- Six C11 compute kernels spanning naive, loop-reordered, tiled, and parallel OpenMP algorithms.
- Automated Python benchmark harness recording execution times, GFLOPS, and variance.
- Numerical verification suite with 81 test matrices ensuring mathematical precision (ε < 10⁻⁹).
- Multi-core scalability analysis with OpenMP collapse(2) eliminating outer loop thread starvation.
Interactive Technical Visualizer
06 / Results & Verified Findings
- ~12.6x speedup achieved purely through loop reordering (ikj over ijk) due to continuous sequential memory access.
- Identified optimal cache tile sizes of 64 and 128 elements, matching CPU L1d cache boundaries.
- OpenMP collapse(2) achieved 46.8 GFLOPS peak throughput on large matrix dimensions (N=2048).
07 / What I Learned & Direct Contributions
Key engineering responsibilities and lessons gained during this project:
- Wrote optimized C11 kernels implementing naive ijk, loop-reordered ikj, cache-blocked (tiled), and OpenMP collapse(2) parallelization.
- Engineered automated Python benchmarking orchestrator to measure GFLOPS and CPU execution time across matrix dimensions from 256 to 2048.
- Built comprehensive 81-test validation suite verifying mathematical correctness against double precision error thresholds (ε < 1e-9).
- Authored in-depth hardware architectural analysis report correlating cache sizes with empirical GFLOPS curves.
08 / Future Improvements
Benchmarked on x86_64 CPU architectures with OpenMP; AVX-512 vector intrinsic specialization is planned for future iterations.