Skip to content

01 — Build & Run the Ladder

Goal: get a feel for the whole project by building and running every optimization level and watching the performance evolve.

Build everything

make

This produces, in build/:

  • matvec0matvec14 — the 15 matrix-vector levels
  • matmat0matmat10 — the portable matrix-matrix levels
  • ref_matmul, ref_matvec — reference drivers

Why only matmat0–10?

matmat/optim11–14 use x86 SSE intrinsics and a sse_compat.h that isn't provided, so they're excluded by default. See Writing a new level for how a portable sse_compat.h would enable them.

Run every level

for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14; do
  printf "matvec%-2s " $i; ./build/matvec$i
done

for i in 0 1 2 3 4 5 6 7 8 9 10; do
  printf "matmat%-2s " $i; ./build/matmat$i
done

Each program allocates random data, times the kernel, and prints something like:

Optimization 8 : Dot product took 0.0012345 seconds GFLOPS : 6.48

What to watch for

  • GFLOPS generally climbs as the kernel matures (unrolling → registers → vectorization → blocking → packing).
  • Some levels dip — those are the "structure-first" steps (e.g. optim6 builds a tile from many dot products before re-fusing). That's expected and instructive.
  • The times and GFLOPS depend heavily on your CPU, cache sizes, and compiler.

Manual build (for one level)

gcc -O2 -I include -o build/matvec5 src/matvec/optim5.c