Instruction Pipelining Flashcards
Week 2.4 (24 cards)
what are the basic ideas of instruction pipelining
- split instructions into independent stages
- execute stages concurrently
what are the limiting factors of instruction pipeling
- execution time longer than fetch time
- branches may invalidate fetched operations
what are the 6 steps of a realistic pipeline
- FI = fetch instruction
- DI = decode instruction
- CO = calculate operations
- FO = fetch operands
- EI = execute instructions
- WO = write operands
draw a timing diagram for a simple programme using a realistic pipeline
what are the realistic assumptions that break down the ‘realistic pipeline’
- not all instructions require all 6 pipeline stages
- not all stages can be performed in parallel
- not all stages have equal duration
- interrupts may invalidate the pipeline
- branching may invalidate the pipeline
what are 3 things that can affect pipeline performance
- cycle time
- total pipeline time
- speedup
what is the formula of the cycle time
T = max ti + d = Tm + d
where:
- ti = time delay of ith pipeline stage
- k = number of pipeline stages
- d = delay of a latch
- Tm = maximum stage delay
total pipeline time formula
Tk, n = (k + n - 1).t
where:
- Tk,n = execution time of n instructions in k-stage pipeline
- t = cycle time
- k = number of pipeline stages
- n = number of instructions
speedup formula
Sk = T1,n/Tk,n
= n.k.t/(k + n - 1).t
= n.k/(k + n - 1)
what is the limit of speedup
lim Sk = lim (n.k/k + n - 1) = k
what are pipeline hazards
the pipeline must stall because conditions do not permit continued execution
what are the 3 main pipeline hazards
- resource
- data
- control
what is a resource hazards
2 instructions in the same pipeline need the same resources
- instruction 1 must source operands, so instruction 3 cannot be fetched when there is only one memory
what is a data hazard
2 instructions in the pipepline access the same memory location
what are the 3 data hazards
- RAW - read after write
- WAR - write after read
- WAW - write after write
what is a read after write data hazard
read takes place before preceding write is complete
what is a write after read data hazard
write operation completes before read has taken place
what is a write after write data hazard
2 writes happen in the wrong order
what is a control hazard
wrong branch is taken in the pipeline
what is the most serious data hazard
control - pipeline must be completely flushed
what are some solutions to control hazards
- multiple pipelines for branches
- prefetch branch target
- instruction buffer (loop buffer)
- branch prediction - static or dynamic
- reordering of branches
what are some static approaches of branch prediction
- ‘always taken’
- ‘never taken’
- predict by opcode
what are some dynamic approaches of branch prediction
- ‘taken/not taken’ switch
- branch-history table