Lecture-14-03 02 2025
Lecture-14-03 02 2025
SPECULATION
Motivation
Assumption in dynamic execution: Perfect branch prediction
Instructions fetched & issued but not executed until branch completes
Iter. # Instructions Issues @ Begins EX Mem acc. Write CDB Comment
◦ Key idea
◦ allow instructions to execute out of order
◦ force them to commit in order
◦ prevent any irrevocable action until instructions commits
Reorder Buffer (ROB)
◦Mechanism to handle incorrect predictions
◦ Instructions wait in ROB until they are no longer speculative
◦ Thereafter, they commit (complete/graduate)
◦ Speculative instructions not allowed to change processor state (regs,
mem, etc)
◦ ROB also provides precise exception
Reorder Buffer Structure
◦ Conceptually, ROB is FIFO queue with 4-field entries:
◦ type: instruction type such as arithmetic, load, store, branch
◦ destination: dest. reg. (load, arithmetic) or memory address (store)
◦ ready: flag indicating if instruction has completed execution
◦ value: value computed by instruction
Address Unit
Load
Store buf eliminated, Bufs
function integrated in A
Add3 Mul2
ROB
Reservation Mul1
Add2
Store Stations
Add1
Store addr
Results must be
data Addr
broadcast on CDB with
Memory Unit FP adders ROB entry number FP multipliers
double x[1000], s;
for (i=0; i<1000; i++)
x[i] = x[i]+s;
; R1 = x = &x[0]
; R2 = &x[1000]
; F2 = s
for: L.D F0, 0(R1) ; F0 =x[i]
ADD.D F4, F0, F2 ; F4 = x[i] + s
S.D F4, 0(R1) ; x[i] = F4
DADDI R1, R1, 8 ; R1 += 8 = &x[i+1]
BNE R1, R2, for ; if (R1! = &x[1000]) goto for
Assumptions of the hardware
◦ Dual-issue superscalar
◦ 1 integer functional unit (FU) (used for both ALU and EA
calculations)
◦ Separate FU to evaluate branch conditions
◦ Separate pipeline FP FU
◦ Issue and Write take 1 cc each
◦ Perfect branch prediction
◦ Instructions are fetched and issued but not actually executed until branch
has completed (No Speculation)
Execution latencies: Int ALU: 1 cc Ld/st: 2 cc (EX+MEM) FP add: 3cc
Dual-Issue Dynamic Superscalar without Speculation
Iter. # Instructions Issues @ Begins EX Mem acc. Write CDB