Chapter 2. Modern CPUs

Under the hood, modern CPUs look nothing like their predecessors. While a brand new Opteron processor will run unmodified 8086 binaries from 1987 just fine, what happens inside is so different as to make any comparisson useless.

Within a processor these days are things called 'pipelines', 'paths', 'branch predictors', 'speculative execution units', 'register shufflers', 'dependency analysers' and so on. It is very hard to attain full comprehension of all this machinery, and by the time you have mastered everything, a new CPU will have come along that does 'HypeThreading' and has a 'Flux Capacitor'.

If your are on an Intel-compatible platform, a great resource on how to exactly write your code so that all paths are busy and each pipeline full is Agner Fog's Pentium Optimization Guide.

This document instead tries to explain the basics, perhaps preparing the reader for further specific research use the guide mentioned above.

The goal is to get your code running at speeds attainable without completely rewiring your program, although quite often spectacular gains await those who manage to tickle their CPU just right.