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.

Further Reading: Why Fortran Is Fast

Going deeper on compiler optimization, memory hierarchy, and the aliasing question. Sources are tagged Tier 1 (confident, recommended) and Tier 2 (real and worth seeking; confirm the current edition/URL/exact clause yourself). This chapter's ideas connect to a large literature on computer architecture and compilers; the pointers below are the ones that repay a Fortran programmer's time.

The language and its guarantees

Compiler optimization, up close

  • The GCC / gfortran manual — "Optimize Options." The authoritative list of what each -O level enables, what -ffast-math actually permits, and the full -fopt-info family used in §27.5. If you take one link from this page, take this one. Tier 1.
  • Compiler Explorer — godbolt.org. Select gfortran, paste a kernel, and watch the assembly change with the flags. The fastest way to see vectorization (…pd packed vs …sd scalar instructions) and the effect of -O2-O3-march=native. The 🧩 Try It Yourself in §27.1 is built on it. Tier 1.
  • Agner Fog, optimization manuals (agner.org/optimize). Deep, practical, and free references on how modern x86 CPUs execute code — instruction throughput, vectorization, and the memory behaviour that makes loop order matter. More than you need now; the reference you grow into. Tier 2.

Memory, caches, and why loops have a "grain"

  • Ulrich Drepper, "What Every Programmer Should Know About Memory." A long, widely circulated technical paper on the memory hierarchy — cache lines, associativity, prefetching, and access patterns. It is the rigorous version of §27.2's "the cache line is the unit of memory traffic." Tier 2.
  • Hennessy & Patterson, Computer Architecture: A Quantitative Approach (Morgan Kaufmann). The standard text on the hardware beneath everything in this chapter — caches, pipelines, and the roofline model that formalizes the arithmetic-intensity reasoning of Case Study 2. Tier 1.
  • Williams, Waterman & Patterson, "Roofline: An Insightful Visual Performance Model." The original roofline paper — memory-bound vs compute-bound made into a single picture. Behind the intensity table in Case Study 2 and the performance analysis you will do in Chapter 38. Tier 2.

On aliasing specifically

  • The C99 rationale and any good reference on restrict. Reading why C added restrict is the clearest way to appreciate what Fortran gives you for free; the C committee's discussion frames it exactly as "recovering the optimization Fortran gets from its aliasing rules." Tier 2.

Suggested order

  1. Open Compiler Explorer now and compile a c = a + b kernel at -O2 and -O3 -march=native. Ten minutes of watching addsd become vaddpd teaches §27.1 and §27.5 better than any prose.
  2. Skim the gfortran "Optimize Options" page for -O3, -ffast-math, and -fopt-info-vec — the flags you will actually type.
  3. Read Drepper (or its first few sections) once you have felt a loop-order slowdown yourself; it explains what you measured.
  4. Keep Metcalf/Reid/Cohen and the standard on the shelf for the exact aliasing and pure rules, and graduate to Hennessy & Patterson and the roofline paper when you start caring about the ceiling, not just the loop.