Affiliate disclosure
Book titles on this page link to Amazon. As an Amazon Associate, DataField.Dev earns from qualifying purchases — at no additional cost to you.
Chapter 29 — Further Reading
Optimization is one of those subjects where a handful of the right sources save you years of folklore. These teach the why — memory hierarchies, the roofline, why libraries win — not just a bag of tricks, grouped by what you want from them.
The mental models (memory, caches, the roofline)
- Ulrich Drepper, "What Every Programmer Should Know About Memory" (2007, freely online). The definitive long-form explanation of caches, cache lines, prefetching, and why access pattern dominates numerical performance. Everything in §29.1–29.2 is a corollary of this document; read it once and loop order will never mystify you again. (Tier 1.)
- Samuel Williams, Andrew Waterman, and David Patterson, "Roofline: An Insightful Visual Performance Model for Multicore Architectures," Communications of the ACM 52(4), 2009. The paper that named the roofline model this chapter leans on for the memory- vs compute-bound decision. Short, visual, and immediately practical. (Tier 1.)
- John L. Hennessy and David A. Patterson, Computer Architecture: A Quantitative Approach (Morgan Kaufmann). The standard reference for the hardware underneath — cache hierarchies, SIMD, and pipelines. Consult the memory-hierarchy and data-level-parallelism chapters when you want the full picture. (Tier 1.)
Optimization in practice
- Donald E. Knuth, "Structured Programming with go to Statements," ACM Computing Surveys 6(4), 1974. The source of "premature optimization is the root of all evil" and the "critical 3%." Read the surrounding paragraphs, not just the slogan — Knuth is arguing for optimization in the right place, which is exactly §29.5's thesis. (Tier 1.)
- Milan Curcic, Modern Fortran: Building Efficient Parallel Applications (Manning, 2020). Optimizes
numerical Fortran in the exact modern style of this book — array operations,
do concurrent, and the path from a serial kernel to a parallel one. The best companion for turning §29's techniques into your own solver. (Tier 1.) - Michael Metcalf, John Reid, and Malcolm Cohen, Modern Fortran Explained (Oxford). The authoritative
reference for the precise semantics of
do concurrent, thecontiguousattribute, andpure/elemental— the language features this chapter uses to unlock the optimizer. (Tier 1.)
Why the library wins (BLAS/LAPACK)
- Kazushige Goto and Robert van de Geijn, "Anatomy of High-Performance Matrix Multiplication," ACM
Transactions on Mathematical Software 34(3), 2008. The paper on how a real
dgemmis built — multi-level blocking, packing, and the register microkernel that reaches ~80% of peak. Read it to understand precisely why Case Study 2's hand loop loses. (Tier 1.) - The BLAS and LAPACK documentation (
netlib.org/blas,netlib.org/lapack). The reference definitions behind Chapter 21'sdgemmanddgesv, and the interface every tuned implementation (OpenBLAS, MKL) matches. (Tier 1.) - The OpenBLAS project (
github.com/OpenMathLib/OpenBLAS). A production, open-source tuned BLAS you can actually link against and measure yourself — the concrete answer to "so how fast isdgemm?" (Tier 1.)
Online and tools
- The GCC / gfortran manual (
gcc.gnu.org/onlinedocs) — the reference for-O2/-O3,-march=native, and the-fopt-info-vec/-fopt-info-vec-missedvectorization reports this chapter reads. The full flag treatment is Chapter 30. (Tier 1.) - Compiler Explorer (
godbolt.org) — paste a loop, pick gfortran with-O3 -march=native, and see whether it emittedvfmadd/vmovupd(SIMD) or scalar instructions. The fastest way to confirm a loop vectorized without running anything. (Tier 1.)
Suggested order
- Read Drepper on memory — it makes §29.1–29.2 obvious rather than arbitrary.
- Skim the Roofline paper for the one picture that tells you which optimizations can possibly help.
- Keep Curcic open beside your editor while you optimize the solver's
step. - When you reach Case Study 2's reckoning, read Goto & van de Geijn to see exactly what
dgemmdoes that you should not attempt — then link OpenBLAS and measure the gap for yourself.