liveBook · Manning

Pipeline

As explained in The Coder Cafe

A processor pipeline is an ordered sequence of stages through which instruction processing progresses.

An instruction pipeline lets a CPU work on several instructions at once by assigning successive processing stages to separate units. The goal is higher throughput: once the pipeline is full, one instruction can complete each cycle in the simplified four-stage model. section 8.1.1 section 8.3

Each instruction passes through four stages:

Two instructions

If every stage takes one cycle, processing two instructions from start to finish one after the other takes eight cycles. Separate stage units allow their work to overlap: while one instruction advances, another can use an earlier stage. This improves the rate of completion without making the four stages disappear. section 8.1.1 section 8.3

Keeping the pipeline supplied with instructions is the catch. At a conditional jump, the CPU may not yet know which instruction to fetch next. Branch prediction guesses the outcome to avoid waiting; a wrong guess costs cycles while the pipeline refills. Longer pipelines can make that penalty larger: a 20-stage pipeline needs at least 20 cycles to fill. Another route to speed—raising the clock frequency—also has limits because it increases power use and heat. section 8.3 section 8.2.2 section 8.1.1

How The Coder Cafe covers it

How deep it goes
Works through a simplified four-stage timing model while noting that real CPU microarchitectures can use different pipeline depths.
Examples
Compares two sequential instructions with overlapped stages and uses a 20-stage pipeline to illustrate refill cost.
What it assumes
Introduces fetch, decode, execute, and write from a simplified CPU model rather than assuming knowledge of pipeline stages.
What you can do after
Evaluate/understand why overlapping instructions improves throughput and why conditional branches can waste cycles.
How it connects
Connects instruction pipelining to branch prediction, CPU microarchitecture, clock frequency, and simultaneous multithreading.

Also explained in

Compare how 63 books explain pipeline →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Coder Cafe. The section links point to the parts of the book it draws on.