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
- Metcalf, Reid & Cohen, Modern Fortran Explained (Oxford University Press). The definitive reference.
Its treatment of
pure/elemental, argument association, and the restrictions on aliasing dummy arguments is the precise statement behind §27.3–27.4. Reach for it when you want the exact rule, not the intuition. Tier 1. - The ISO/IEC 1539-1:2018 Fortran standard. The primary source for the no-aliasing rule — the clause restricting entities associated with dummy arguments, which forbids aliasing a defined (written) argument. Dry, authoritative, and the thing the compiler is actually obeying. Tier 1 (the document); the exact clause number is best confirmed against your copy — Tier 2.
- Milan Curcic, Modern Fortran: Building Efficient Parallel Applications (Manning). Project-driven and performance-aware, in the same spirit as this book; good on writing array code the compiler likes. Tier 1.
Compiler optimization, up close
- The GCC / gfortran manual — "Optimize Options." The authoritative list of what each
-Olevel enables, what-ffast-mathactually permits, and the full-fopt-infofamily 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 (…pdpacked vs…sdscalar instructions) and the effect of-O2→-O3→-march=native. The🧩 Try It Yourselfin §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 addedrestrictis 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
- Open Compiler Explorer now and compile a
c = a + bkernel at-O2and-O3 -march=native. Ten minutes of watchingaddsdbecomevaddpdteaches §27.1 and §27.5 better than any prose. - Skim the gfortran "Optimize Options" page for
-O3,-ffast-math, and-fopt-info-vec— the flags you will actually type. - Read Drepper (or its first few sections) once you have felt a loop-order slowdown yourself; it explains what you measured.
- Keep Metcalf/Reid/Cohen and the standard on the shelf for the exact aliasing and
purerules, and graduate to Hennessy & Patterson and the roofline paper when you start caring about the ceiling, not just the loop.