Pipelining

Datapath

Hazards

e.g. miss in I-cache (2 extra cycles) Hazard example

Data Hazards

e.g.

ADD r2, r0, r1

ADD r3, r2, #1

data hazard example

e.g.

ADD r2, r0, r1

ADD r3, r2, #1

data hazard example 1

Data Forwarding

data forwarding

Asel = { PC + 4, A, Z } Bsel = { B, offset, Z }

e.g.

data forwarding example

Load Hazard

e.g.

load hazard example 1

e.g.

load hazard example 2

Control Hazards

e.g.

control hazard example

Branch Delay Slot

e.g.

branch delay slot

Speculative Execution

Speculative execution

1 bit predictor

1 bit predictor

2 bit

2 bit predictor

e.g.

on BNT miss, guess LNT

i = 0; do { ... i++; } while (i < 3); // B1

B1 prediction

Structural Hazards

e.g. cache too small => less hit rate

e.g. unified L1 => cannot fetch and ld/st in same cycle

Performance

e.g.

Performance example

CPI = 1.0 + B + L = 1.0 + 0.15 x 0.2 x 2 + 0.2 x 0.4 x 1 = 1.14

if n 1 = n 2 and r 1 = r 2 , S = CPI 1 / CPI 2

See previous chapter See next chapter