Pipelining
CS1251
Computer Organization
Carl Hamacher
Department of Information
10/5/2017 Technology 1
Pipelining
I1 I2 I3
F1 E1 F2 E2 F3 E3
Sequential Execution
I1 F1 E1
I2 F2 E2
I3 F3 E3
Pipelined Execution
10/5/2017 Department of Information Technology 2
Hardware Organization
Interstage Buffer
B1
Instruction
Execution
Fetch
Unit
Unit
10/5/2017 Department of Information Technology 3
Four State Pipeline
Fetch (F)
Read the instruction from memory
Decode (D)
Decode the instruction and fetch the source operand(s)
Execute (E)
Perform the operation specified by the instruction
Write (W)
Store the result in the destination location
10/5/2017 Department of Information Technology 4
Four Stage Pipeline
10/5/2017 Department of Information Technology 5
Hardware Organization
10/5/2017 Department of Information Technology 6
Data Hazard
Pipeline stalled
Source or destination operands not available at time
expected in the pipeline
Execution operation taking more than one clock
cycle
10/5/2017 Department of Information Technology 7
Data Hazard
10/5/2017 Department of Information Technology 8
Data Dependency
10/5/2017 Department of Information Technology 9
Operand Forwarding
10/5/2017 Department of Information Technology 10
Operand Forwarding
10/5/2017 Department of Information Technology 11
Handling Data Hazards in SW
Compiler detect data dependencies and deal with them
Insert NOPs
Attempt to reorder instructions to perform useful tasks in
NOP slots
Side effects
Instruction changes contents of a register other than the
named destination
Autoincrement/autodecrement addressing modes
Condition code flags
Give rise to multiple dependencies
Should be minimized
10/5/2017 Department of Information Technology 12
Instruction Hazards
Pipeline stalled
Delay in the availability of an instruction
Cache miss
Branch instructions
10/5/2017 Department of Information Technology 13
Instruction Hazard
10/5/2017 Department of Information Technology 14
Instruction Queue and Prefetch
10/5/2017 Department of Information Technology 15
Branch Penalty
10/5/2017 Department of Information Technology 16
Branch Prediction
Attempt to predict whether or not a particular branch
will be taken
Speculative execution
Continue to execute until outcome of branch evaluated
No processor registers or memory can be updated until
branch outcome is confirmed
10/5/2017 Department of Information Technology 17
Branch Prediction
Static Branch Prediction
Some branch instructions predicted as taken and others
as not taken
End or program loop
Beginning of program loop
Hardware or compiler
Dynamic Branch Prediction
Based on execution history
10/5/2017 Department of Information Technology 18
Structural Hazard
Two instructions require use of a given hardware
resource at the same time
Access to memory
Separate instruction and data caches
Access to register file
Multiple port register file
In general avoided by providing sufficient hardware
resources on the processor chip
10/5/2017 Department of Information Technology 19
Structural Hazard
10/5/2017 Department of Information Technology 20
Summary
Pipelining does not result in individual instructions
being executed faster
Throughput increases
Rate at which instruction execution is completed
Important goal in designing processors is to identify
all hazards that may cause the pipeline to stall
Find ways to minimize their impact
10/5/2017 Department of Information Technology 21
Questions?
10/5/2017 Department of Information Technology 22