One executable, every matrix flavor — your lab bench
You now have enough kernels to build a single command-line tool that lets you benchmark any matrix flavor with any size. Call it matrix_ops. Subcommands:
| Subcommand | Args | What it runs |
|---|---|---|
add / sub / mul / div | <ROWS> <COLS> | Element-wise op (Track 5 with 2-D indexing) |
gemv | <ROWS> <COLS> | BLAS-2: y = A·x |
gemm-naive | <M> <N> <K> | One thread per output element (Lesson 4) |
gemm | <M> <N> <K> | Tiled, with shared memory + register blocking |
Why build this? Because comparing yourself against vendor BLAS (Track 7) requires a stable test rig you trust. Letting the CLI accept dimensions means you can sweep sizes without recompiling.
Real numbers on RTX 4090 (FP32):
| Op | Size | BW or Perf |
|---|---|---|
| add | 4096×4096 | 167 GB/s |
| gemv | 8192×8192 | 216 GB/s |
| gemm-naive | 512³ | 0.41 TF/s |
| gemm-tiled | 2048³ | 3.8 TF/s |
The 9× jump from naive to tiled is exactly what we predicted: each 16 KB shared-memory tile feeds 128× more FMAs before re-hitting DRAM.