CS 152 Computer Architecture and Engineering CS252A Graduate Computer Architecture
Lecture 4 - Pipelining II
Chris FletcherUC Berkeley, Spring 2026
Pipeline Categories
Single-thread processors exploit more instruction-level parallelism (ILP) :
Category Idea
Super-pipelined Slice stages into sub-stages to raise clock frequency
Decoupled Split integer/address work from FP execution via queues
Out-of-order In-order frontend fills an instruction pool; backend issues independent instructions out of order
Superscalar Widen frontend and backend to fetch and execute several instructions per cycle
Deeper Pipelines: MIPS R4000
Caches too slow for one short cycle → split cache access into stages (8 total):
Stage Work
IF Instruction cache fetch, first half
IS Instruction cache fetch, second half (bits ready before the tag check)
RF Register fetch + I-cache tag check (speculate a direct-mapped I$ hit)
EX ALU execution, branch condition
DF Data cache fetch, first half
DS Data cache fetch, second half (data ready at end of DS)
TC Data cache tag check; commit point right after
WB Register writeback
R4000 Branches and Load-Use Delay
Branch: 3-cycle delay (condition known in EX, cycle 4)
1 2 3 4 5 6 7
BEQZ IF IS RF EX DF DS TC
Inst 1 IF IS RF
Inst 2 IF IS
Inst 3 IF
Target IF IS RF
Load-use: 2-cycle delay (data at end of DS, bypassed before TC)
1 2 3 4 5 6 7 8
LD R1 IF IS RF EX DF DS TC WB
Inst 1 IF IS RF EX DF DS TC
Inst 2 IF IS RF EX DF DS
ADDD R2,R1 IF IS RF EX DF
Speculative bypass from DS to EX in cycle 7, before TC confirms the hit; a TC miss stalls/recovers.
Vector-Vector Add Example
for (i = 0; i < N; i++) A[i] = B[i] + C[i];
loop: fld f0, 0(x2) // x2 -> B[i]
fld f1, 0(x3) // x3 -> C[i]
fadd.d f2, f0, f1 // stalls waiting for f1!
fsd f2, 0(x1) // x1 -> A[i]; stalls waiting for f2!
addi x1, x1, 8
addi x2, x2, 8
addi x3, x3, 8
bne x1, x4, loop // x4 = end pointer
Simple Pipeline Scheduling
Move independent pointer bumps into the stall slots
addi x3 and addi x2 between fld f1 and fadd.d
addi x1 between fadd.d and fsd
Store offset becomes -8(x1) because x1 was already bumped
loop: fld f0, 0(x2)
fld f1, 0(x3)
addi x3, x3, 8
addi x2, x2, 8
fadd.d f2, f0, f1
addi x1, x1, 8
fsd f2, -8(x1)
bne x1, x4, loop
Long load/FP latencies quickly run out of independent work in one iteration
Loop Unrolling
loop: fld f0, 0(x2)
fld f1, 0(x3)
fld f10, 8(x2)
fld f11, 8(x3)
addi x3, x3, 16
addi x2, x2, 16
fadd.d f2, f0, f1
fadd.d f12, f10, f11
addi x1, x1, 16
fsd f2, -16(x1)
fsd f12, -8(x1)
bne x1, x4, loop
Two iterations per pass, distinct registers
Halves loop overhead (addi, bne)
Spaces out fld → fadd.d → fsd chains
Limits:
Number of architectural registers
Larger I-cache footprint
Pointer-aliasing analysis (A, B, C don't overlap)
Can't hide unpredictable cache misses
Check Your Understanding
1.
Pipeline delay: on the R4000, why is load-use delay 2 cycles rather than 3 even though TC doesn't finish until cycle 7?
The direct-mapped data cache lets data from DS (cycle 6) bypass speculatively into the consumer's EX in cycle 7, before TC finishes.
2.
Code check: scheduling
addi x1, x1, 8 before the store changed
fsd f2, 0(x1) to
fsd f2, -8(x1). Why?
addi already advanced x1 by 8 bytes, so -8(x1) points back at the current A[i].
CDC 6600 (Seymour Cray, 1964)
Widely regarded as the first supercomputer
Pioneered dynamic hardware scheduling
Keeps 10 parallel, unpipelined functional units busy: FP adder, 2 FP multipliers, divider, integer adder, 2 incrementers, …
10 MHz clock, 32-bank central memory
CDC 6600: A Load/Store Architecture
Three register banks
8 × 60-bit data registers X0–X7
8 × 18-bit address registers A0–A7
8 × 18-bit index registers B0–B7
3-address ALU ops : opcode(6) | i(3) | j(3) | k(3), $R_i \leftarrow R_j\ op\ R_k$
Only 3-bit register fields to check for dependencies; no implicit accumulator/stack
Implicit decoupled loads/stores
Writing A1–A5 starts a load into X1–X5
Writing A6–A7 starts a store from X6–X7
Setting Ar and reading Xr are separate: many memory requests overlap independent work
Successor CDC 7600 pipelined the units, foreshadowing RISC
CDC 6600 Vector Add
Instruction Effect
A0 ← B0 + a0triggers load of X0 (element of a)
A1 ← B0 + b0triggers load of X1 (element of b)
X6 ← X0 + X1FP add
A6 ← B0 + c0triggers store of X6 (element of c)
Address arithmetic and data arithmetic live in separate register files and run independently
Issues in Complex Pipeline Control
Frontend fetch/decode
Instruction pool
dispatch
ALU
Mem
Fadd
Fmul
Fdiv
issue
WB
Structural conflicts at execute: unpipelined units busy for many cycles
Structural conflicts at the WB port when fast and slow units finish together
Out-of-order writes (WAW, WAR) when a fast young op overtakes a slow old one
Imprecise exceptions when younger ops finish before older ones fault
CDC 6600 Scoreboard
Control logic gating entry to and exit from the instruction pool
Dispatch (in order) : enter in program order until the scoreboard is full
Issue (out of order) to a unit only when there is:
No RAW hazard
No WAW hazard (vs. all older executing instructions)
No structural hazard (execution unit or register writeback)
WAR handled at writeback
A younger op writing r1 may start before an older stalled op reads r1
It stalls just before writeback until the older op has read r1
Stalled outputs can pile up and block that unit
More Complex In-Order Pipeline
Pad all short/pipelined units (integer ALU + data mem, FAdd, FMul) to the same latency to W
X1, X2, X3, then the commit point before W
One in, one out per cycle: writeback port never oversubscribed
Exceptions stay in order
Long-latency ops (unpipelined FDiv, cache miss) stall the pipeline
Padding doesn't slow back-to-back integer ops:
Bypass from end of X1 to X1 inputs ; still commit at W
In-Order Superscalar Pipeline
Goal: IPC > 1 without out-of-order hardware
Alpha 21064 (1992), MIPS R5000 (1996)
Fetch 2 instructions per cycle into dual decode
Issue both if one is integer/memory and the other is floating point
4-wide issue (UltraSPARC, Alpha 21164) by duplicating units
Register-file ports and bypass mux wiring grow explosively
Check Your Understanding
1.
Scoreboard rules: which two data hazards block issue from the CDC 6600 scoreboard, and how is WAR handled?
RAW and WAW (plus structural) block issue. WAR ops issue and execute, then stall before writeback until the older reader finishes.
2.
Design check: integer ALU, FAdd, and FMul all wait until X3 to reach W. Why don't consecutive integer instructions stall 2 cycles?
The integer result is bypassed from the end of X1 straight into the next instruction's X1 input, without waiting for W.
Decoupled Execution: The Observation
loop: fld f0, 0(x2) // control/address
fld f1, 0(x3) // control/address
fadd.d f2, f0, f1 // data computation
fsd f2, 0(x1) // address + data
addi x1, x1, 8 // control/address
addi x2, x2, 8 // control/address
addi x3, x3, 8 // control/address
bne x1, x4, loop // control/address
None of the control or address instructions depend on the FP data computation.
Simple Decoupled Machine
Integer pipeline (runs ahead)
F D X M W
µOp Queue
Memory
load addr
Store Address Queue
store addr (loads checked against pending stores)
Load Data Queue
FP pipeline (own pace)
R X1 X2 X3 W
Store Data Queue
pair data + address → memory
The integer side runs several iterations ahead; many writes to f0 can be in flight, ordered by the FIFOs (no WAW/WAR corruption).
Decoupled Machine: Roles
Integer pipeline (F D X M W): runs addi/bne, computes load addresses, checks each against the Store Address Queue , sends loads to memory, pushes FP µops (load writeback, compute, store data read) into the µOp Queue
Memory returns loaded words in order into the Load Data Queue
FP pipeline (R X1 X2 X3 W): pulls µops and load data, computes fadd.d, pushes results into the Store Data Queue to pair with waiting store addresses
Dynamic ALU Scheduling (MC68060)
EA (effective address) → MEM (data cache) → ALU
Built so CISC memory-register ops like add x1, x1, 24(x2) finish in one pass
EA: x2 + 24 · MEM: read M[x2+24] · ALU: add x1
Also hides load-use stalls for RISC code:
Run an op early (EA) when it feeds a load address
Run it late (ALU) when it consumes loaded data
MC68060 Example: Zero Stalls
Instruction 1 2 3 4 5 6
add x1, x1, 24(x2) EA: x2+24 MEM ALU: x1+M
add x3, x1, x6 EA (pass) MEM (pass) ALU: x1+x6
addi x5, x2, 12 EA: x2+12
lw x4, 16(x5) EA: x5+16 MEM
lw x8, 16(x3) EA: x3+16 MEM
x1: ALU (c3) → ALU (c4) · x5: EA (c3) → EA (c4) · x3: ALU (c4) → EA (c5)
A single-ALU 5-stage pipeline would stall on this code
Check Your Understanding
1.
Queue safety: why must every load address from the integer pipeline be checked against the Store Address Queue?
The integer side runs ahead while older store data may still be queued; a matching address must forward or wait, or the load reads stale memory.
2.
Stage assignment: in EA → MEM → ALU, why does
addi x5, x2, 12 (followed by
lw x4, 16(x5)) execute in EA rather than ALU?
Running in EA produces x5 two cycles earlier, so it bypasses straight into the next lw's EA stage with no stall.