Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Pipeline: Introduction
Lecturer: Prof. Hong Jiang
Courtesy of Prof. Yifeng Zhu, U of Maine Fall, 2006
CSCE430/830
Pipeline
Pipelining Outline
Introduction
Defining Pipelining Pipelining Instructions
Hazards
Structural hazards Data Hazards Control Hazards
CSCE430/830
Pipeline
What is Pipelining?
A way of speeding up execution of instructions
Key idea:
overlap execution of multiple instructions
CSCE430/830
Pipeline
If we do laundry sequentially...
6 PM
T a s k O r d e r
10
11
12
2 AM
A B C D
30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 Time
CSCE430/830
Pipeline
10
11 Time
12
2 AM
30 30 30 30 30 30 30 A
O r d e r
B
C D
Time Required: 3.5 Hours for 4 Loads
CSCE430/830
Pipeline
10
11 Time
12
2 AM
30 30 30 30 30 30 30 A
O r d e r
B
C D
CSCE430/830
Pipelining doesnt help latency of single task, it helps throughput of entire workload Pipeline rate limited by slowest pipeline stage Multiple tasks operating simultaneously Potential speedup = Number pipe stages Unbalanced lengths of pipe stages reduces speedup Time to fill pipeline and time to drain it reduces speedup Pipeline
1ns
200ps
Pipeline Register
CSCE430/830
200ps
200ps
200ps
200ps
Pipeline
Pipelined: 1 operation finishes every 200ps 200ps 200ps 200ps 200ps 200ps
CSCE430/830
Pipeline
Limitations:
Computations must be divisible into stage size Pipeline registers add overhead
CSCE430/830
Pipeline
Pipelining a Processor
Recall the 5 steps in instruction execution:
1. 2. 3. 4. 5. Instruction Fetch (IF) Instruction Decode and Register Read (ID) Execution operation or calculate address (EX) Memory access (MEM) Write result into register (WB)
CSCE430/830
Pipeline
CSCE430/830
Pipeline
I n s t r.
O r d e r
Ifetch
Reg
DMem
Reg
ALU
Ifetch
Reg
DMem
Reg
ALU
Ifetch
Reg
DMem
Reg
ALU
Ifetch
Reg
DMem
Reg
CSCE430/830
Pipeline
Pipeline example: lw IF
CSCE430/830
Pipeline
Pipeline example: lw ID
CSCE430/830
Pipeline
Pipeline example: lw EX
CSCE430/830
Pipeline
CSCE430/830
Pipeline
Pipeline example: lw WB
CSCE430/830
Pipeline
Non-Pipelined
Instruction Order
lw $1, 100($0)
200
400
ALU
600
MEM
800
REG WR
1000
1200
1400
1600
1800
Time
lw $2, 200($0)
800ps
lw $3, 300($0)
ALU
MEM
800ps
800ps
Pipelined
Instruction Order
lw $1, 100($0)
200
400
ALU
600
MEM ALU
800
REG WR MEM
1000
1200
1400
1600
Time
Instruction Fetch
lw $2, 200($0)
200ps
lw $3, 300($0)
200ps
REG WR
REG RD
ALU
MEM
REG WR
Speedup
Consider the unpipelined processor introduced previously. Assume that it has a 1 ns clock cycle and it uses 4 cycles for ALU operations and branches, and 5 cycles for memory operations, assume that the relative frequencies of these operations are 40%, 20%, and 40%, respectively. Suppose that due to clock skew and setup, pipelining the processor adds 0.2ns of overhead to the clock. Ignoring any latency impact, how much speedup in the instruction execution rate will we gain from a pipeline?
CSCE430/830
Pipeline
CSCE430/830
Pipeline
Pipeline Hazards
Limits to pipelining: Hazards prevent next instruction from executing during its designated clock cycle
Structural hazards: two different instructions use same h/w in same cycle Data hazards: Instruction depends on result of prior instruction still in the pipeline Control hazards: Pipelining of branches & other instructions that change the PC
CSCE430/830
Pipeline
CSCE430/830
Pipeline
Pipelining Outline
Introduction
Defining Pipelining Pipelining Instructions
Hazards
Structural hazards Data Hazards Control Hazards \
CSCE430/830
Pipeline