liveBook · Manning

Pipeline stall

As explained in The Coder Cafe

A pipeline stall is a temporary suspension of instruction-pipeline progress while required information or resources become available.

A pipeline stall is a temporary pause in instruction-pipeline progress. One or more execution units become idle while waiting for information or a resource before continuing. These idle cycles, often called bubbles, reduce the potential throughput of a full pipeline. section 8.1.1

Pipeline stalls matter because:

  • Instruction pipelining overlaps fetch, decode, execute, and write-back stages, aiming to complete one instruction per cycle after the pipeline fills. section 8.1.1 section 8.3
  • A conditional branch can leave the pipeline waiting because the CPU does not yet know which instruction path to fetch. section 8.1.1 section 8.3
  • Branch prediction reduces these stalls by guessing the branch outcome before the condition is evaluated. section 8.3

A conditional branch

Consider an if/else statement. Its pseudo-assembly loads and compares a value, executes BEQ ELSE, and then calls either foo() or bar(). Until the branch outcome is known, fetching the correct next instructions may pause or follow the wrong path, creating wasted cycles. section 8.1.1

...         ; Something before
LOAD R1, a  ; i1: Load a into register R1
CMP R1, #0  ; i2: Compare R1 with 0 (the result is checked in the next instruction)
BEQ ELSE    ; i3: If a == 0, branch to ELSE
CALL foo    ; i4: Call foo() if a == 0
JMP END     ; i5: Skip ELSE section
ELSE:
CALL bar    ; i6: Call bar() if a != 0
END:
            ; Something after
foo:
...         ; Starts from i100
bar:
...         ; Starts from i200

Browse the pseudo-assembly listing for the conditional-branch example. section 8.1.1

How The Coder Cafe covers it

How deep it goes
Defines idle-unit bubbles and traces conditional-branch stalls, while emphasizing branch prediction rather than detailed hardware recovery.
Examples
Uses staged instruction timelines and an if/else branch translated into pseudo-assembly with calls to foo() and bar().
What you can do after
Evaluate/understand how conditional jumps create bubbles and why branch prediction reduces wasted pipeline cycles.
How it connects
Connects instruction pipelining with throughput, conditional branches, branch prediction, CPU microarchitecture, and simultaneous multithreading.

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.