Pipelining
Overview
Pipelining is widely used in modern processors.
Pipelining improves system performance in terms
of throughput.
Pipelined organization requires sophisticated
compilation techniques.
What Is Pipelining
• Laundry Example
• Ann, Brian, Cathy, Dave A B C D
each have one load of clothes
to wash, dry, and fold
• Washer takes 30 minutes
• Dryer takes 40 minutes
• “Folder” takes 20 minutes
What Is Pipelining
6 PM 7 8 9 10 11 Midnight
Time
30 40 20 30 40 20 30 40 20 30 40 20
T
a A
s
k
B
O
r
d C
e
r
D
Sequential laundry takes 6 hours for 4 loads
If they learned pipelining, how long would laundry take?
What Is Pipelining
Start work ASAP
6 PM 7 8 9 10 11 Midnight
Time
30 40 40 40 40 20
T
a A
s • Pipelined laundry takes 3.5
k hours for 4 loads
B
O
r
d C
e
r
D
What Is Pipelining Lessons
Pipelining
• Pipelining doesn’t help latency of
6 PM 7 8 9 single task, it helps throughput of
entire workload
Time
• Pipeline rate limited by slowest
T pipeline stage
30 40 40 40 40 20
a • Multiple tasks operating
s simultaneously
k A • Potential speedup = Number of pipe
stages
O
• Unbalanced lengths of pipe stages
r B reduces speedup
d
e • Time to “fill” pipeline and time to
r “drain” it reduces speedup
C
D
Pipelining Lessons [contd…]
30 40 40 40 40 20
Time to “fill” pipeline and time to “drain” it reduces speedup
Use the Idea of Pipelining in a
Computer
Fetch + Execution
T ime
I1 I2 I3
T ime
Clock cycle 1 2 3 4
F E F E F E
1 1 2 2 3 3
Instruction
I1 F1 E1
(a) Sequential execution
I2 F2 E2
Interstage buffer
B1
I3 F3 E3
Instruction
Ex ecution
fetch (c) Pipelined execution
unit
unit
Figure 8.1. Basic idea of instruction pipelining.
(b) Hardware organization
Use the Idea of Pipelining in a Computer
Time
Clock cycle 1 2 3 4 5 6 7
Instruction
I1 F1 D1 E1 W1
Fetch + Decode
+ Execution + Write I2 F2 D2 E2 W2
I3 F3 D3 E3 W3
I4 F4 D4 E4 W4
(a) Instruction execution divided into four steps
Interstage buffers
D : Decode
F : Fetch instruction E: Execute W : Write
instruction and fetch operation results
operands
B1 B2 B3
(b) Hardware organization
Figure 8.2. A 4-stage pipeline.
Pipeline Performance
• Again, pipelining does not result in individual
instructions being executed faster; rather, it is the
throughput that increases.
• Throughput is measured by the rate at which
instruction execution is completed.
• Pipeline stall causes degradation in pipeline
performance.
• We need to identify all hazards that may cause the
pipeline to stall and to find ways to minimize their
impact.