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 30 — Further Reading

The flags in this chapter are documented most authoritatively by the compiler vendors themselves, and understood most deeply through the floating-point theory that -Ofast puts at risk. The list below is deliberately short and practical: the pages you will actually open while tuning a build.

The compiler manuals (primary sources — keep these bookmarked)

  • The GCC manual, "Options That Control Optimization" (gcc.gnu.org/onlinedocs). The definitive reference for -O0-Ofast, -march, -flto, -ffast-math, and every sub-flag they imply. When you need to know exactly what a flag does on your version, this is the source of truth — and the composition of -Ofast and -ffast-math is spelled out here, sub-flag by sub-flag.
  • The GNU Fortran (gfortran) manual (gcc.gnu.org/onlinedocs/gfortran). The Fortran-specific flags — -fcheck=all, -fbacktrace, -ffpe-trap, -fno-protect-parens, -finit-real — and their exact semantics. Read the "Error and Warning Options" and "Code Gen Options" sections.
  • Intel oneAPI Fortran (ifx) Developer Guide and Reference (intel.com). The authority for -xHost, -ipo, -qopt-report, and — crucially — the -fp-model settings and their defaults, which are the single most common source of cross-compiler result differences.
  • NVIDIA HPC SDK documentation (docs.nvidia.com/hpc-sdk). The nvfortran reference: -fast, -Minfo, and the OpenACC/CUDA-Fortran flags you will meet again in Chapter 35.

Floating point — why -Ofast is dangerous (read before you use it)

  • David Goldberg, "What Every Computer Scientist Should Know About Floating-Point Arithmetic," ACM Computing Surveys, 1991. The classic. It explains non-associativity, rounding, and cancellation — precisely the properties -ffast-math trades away. If §30.1's 1.0-becomes-0.0 example unsettled you, this paper is why.
  • The GCC wiki page on floating-point math and -ffast-math (gcc.gnu.org/wiki). A practical companion to Goldberg: what each -ffast-math sub-optimization assumes about your program, and how each can bite.
  • Chapter 20 of this book (Floating Point). The in-house treatment; re-read §20 on machine epsilon and catastrophic cancellation alongside this chapter.

Optimization in depth

  • Agner Fog's optimization manuals and instruction tables (agner.org). Deep, practitioner-grade material on how modern CPUs execute code — SIMD widths, FMA, and why -march=native helps some loops and not others. Tier 2, but among the most respected free resources in the field.
  • Metcalf, Reid & Cohen, Modern Fortran Explained (Oxford University Press). The standard-focused reference; its treatment of iso_fortran_env covers compiler_version() and compiler_options(), the reproducibility tools of §30.4.
  • fortran-lang.org — the community "best practices" and compiler pages, including a maintained comparison of the free and commercial Fortran compilers and their flags.

Tools

  • Compiler Explorer / Godbolt (godbolt.org). Paste a Fortran routine, choose a compiler and flags, and see the assembly — the fastest way to confirm that -O3 -march=native actually vectorized your loop, or that -Ofast reassociated your sum. Indispensable for understanding what a flag really did.
  • fpm (Fortran Package Manager) (fpm.fortran-lang.org). Build profiles (--profile release/debug) that make the two-build discipline of §30.3 automatic and portable across compilers — the practical home for the profile table of Case Study 30.2.

Appendix and cross-references

Suggested order

  1. Skim the GCC "Options That Control Optimization" page — just the -O levels and -Ofast.
  2. Read Goldberg (or re-read Chapter 20) enough to respect -ffast-math before you ever type it.
  3. Try a loop in Godbolt at -O2, -O3, and -O3 -march=native; watch the vectorization appear.
  4. Read the Intel -fp-model section — the one cross-compiler gotcha most likely to bite you.
  5. Keep Appendix C open the next time you build anything.