Module 03 · How Computers Work · Many programs, one machine · about 17 min to read
Continue where you left off ×
Doing many things at once inside one core: out-of-order, SIMD and speculation
The CPU · Open board
The fetch, decode and execute loop drawn as a circle. This lesson crowds that circle: many instructions in flight at once, started in a new order, and one instruction working on many values.
Before you start. The CPU (fetch-decode-execute, the ISA, assembly) showed one core reading instructions in a loop, a pipeline keeping several in progress, and a wrong guess at a jump costing about 18 cycles, measured. The Memory Hierarchy (cache, locality, the memory wall) showed that reading memory is slow compared with arithmetic, which is why a core often waits. Concurrency & the Hardware covered many cores. This lesson stays inside one core.
The idea in 30 seconds
A core starts an instruction when its inputs are ready, not when its turn in the list comes. This is out-of-order execution.
In one small model, the same five instructions took 10 cycles in strict order and 6 cycles out of order.
A branch predictor guesses which way a branch goes, and a two-bit counter changes its guess only after two surprises.
Speculation runs the guessed path early, and a wrong guess throws the work away, about 18 cycles on one measured chip.
SIMD adds many values with one instruction, so 1,024 numbers take 128 steps with 8 lanes instead of 1,024.
A branch inside a loop blocks SIMD, so fast code often replaces a branch with a mask.
Read the story
Lesson 11 of 41 in How Computers Work
The rest of this lesson is part of a plan.
A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year .
See plans Already a member? Sign in
Or start free : a free account opens lessons 2 and 3 of every track.
In this lesson One core, several helpers, and many of them idle Out-of-order execution: do not wait in line behind a slow ticket A branch is a fork the core must choose before it knows Speculation: start the work before you know the guess is right SIMD: one instruction, many values The scheduler model How a real core does this Dependency chains cap out-of-order gains The predictors, run Two ways out of a mispredicted branch SIMD with a mask Edge cases and costs Terms it explains: out-of-order execution, branch, branch predictor, two-bit counter, Speculation, SIMD, lane, retires, ALU, assembly, branch prediction, CISC vs RISC, clock, core, fetch-decode-execute, flags, immediate, IPC, ISA, opcode, operand, out-of-order, PC (program counter), pipelining, register, superscalar.
Review How Computers Work
Mark as read Saved in this browser, and to your account when you sign in.