Top Banner
1 Principles of Pipeline Principles of Pipeline
36

Principles of Pipeline

Jan 13, 2016

Download

Documents

RonaT

Principles of Pipeline. Outline. General Principles of Pipelining Goal Difficulties Suggested Reading 4.4. Problem of SEQ. Too slow Too many tasks needed to finish in one clock cycle Signals need long time to propagate through all of the stages The clock must run slowly enough - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Principles of Pipeline

1

Principles of PipelinePrinciples of Pipeline

Page 2: Principles of Pipeline

2

Outline

• General Principles of Pipelining– Goal– Difficulties

• Suggested Reading 4.4

Page 3: Principles of Pipeline

3

Problem of SEQ

• Too slow– Too many tasks needed to finish in one clock

cycle– Signals need long time to propagate through all

of the stages– The clock must run slowly enough

• Does not make good use of hardware units– Every unit is active for part of the total clock

cycle

Page 4: Principles of Pipeline

4

Real-World Pipelines: Car Washes

• Idea– Divide process into

independent stages– Move objects through stages

in sequence– At any given times, multiple

objects being processed

Sequential Parallel

Pipelined

Page 5: Principles of Pipeline

5

Computational Example

• System– Computation requires total of 300 picoseconds– Additional 20 picoseconds to save result in

register– Can must have clock cycle of at least 320 ps

Combinationallogic

Reg

300 ps 20 ps

Clock

Delay = 320 psThroughput = 3.12 GOPS

Page 6: Principles of Pipeline

6

3-Way Pipelined Version

• System– Divide combinational logic into 3 blocks of 100 ps each– Can begin new operation as soon as previous one

passes through stage A.• Begin new operation every 120 ps

– Overall latency increases• 360 ps from start to finish

Reg

Clock

Comb.logic

A

Reg

Comb.logic

B

Reg

Comb.logic

C

100 ps 20 ps 100 ps 20 ps 100 ps 20 ps

Delay = 360 psThroughput = 8.33 GOPS

Page 7: Principles of Pipeline

7

Pipeline Diagrams

• Unpipelined

– Cannot start new operation until previous one completes

• 3-Way Pipelined

– Up to 3 operations in process simultaneously

Time

OP1OP2OP3

Time

A B CA B C

A B C

OP1OP2OP3

Page 8: Principles of Pipeline

8

Limitations: Nonuniform Delays

Reg

Clock

Reg

Comb.logic

B

Reg

Comb.logic

C

50 ps

20 ps 150 ps 20 ps 100 ps 20 ps

Delay = 510 psThroughput = 5.88 GOPS

Comb.logic

A

Time

OP1OP2OP3

A B CA B C

A B C

Page 9: Principles of Pipeline

9

Limitations: Nonuniform Delays

• Throughput limited by slowest stage• Other stages sit idle for much of the time• Challenging to partition system into

balanced stages

Page 10: Principles of Pipeline

10

Limitations: Register Overhead

Delay = 420 ps, Throughput = 14.29 GOPS

Clock

Reg

Comb.

logic

50 ps 20 ps

Reg

Comb.

logic

50 ps 20 ps

Reg

Comb.

logic

50 ps 20 ps

Reg

Comb.

logic

50 ps 20 ps

Reg

Comb.

logic

50 ps 20 ps

Reg

Comb.

logic

50 ps 20 ps

Page 11: Principles of Pipeline

11

Limitations: Register Overhead

• As try to deepen pipeline, overhead of loading registers becomes more significant

• Percentage of clock cycle spent loading register:– 1-stage pipeline: 6.25% – 3-stage pipeline: 16.67% – 6-stage pipeline: 28.57%

• High speeds of modern processor designs obtained through very deep pipelining

Page 12: Principles of Pipeline

12

Data Dependencies

• System– Each operation depends on result from preceding one

Clock

Combinationallogic

Reg

Time

OP1OP2OP3

Page 13: Principles of Pipeline

13

Data Hazards

Reg

Clock

Comb.logic

A

Reg

Comb.logic

B

Reg

Comb.logic

C

Time

OP1OP2OP3

A B CA B C

A B COP4 A B C

Page 14: Principles of Pipeline

14

Data Hazards

• Result does not feed back around in time for next operation

• Pipelining has changed behavior of system

1 irmovl $50, %eax2 addl %eax , %ebx3 mrmovl 100(%ebx),%edx

Page 15: Principles of Pipeline

15

SEQ+ CPU Implementation

Page 16: Principles of Pipeline

16

Outline

• SEQ+ Implementations

• Suggested Reading 4.5.1

Page 17: Principles of Pipeline

17

SEQ Hardware vs. SEQ+ Hardware

• SEQ Hardware– Stages occur in sequence– One operation in process at a time

• SEQ+ Hardware– Still sequential implementation– Reorder PC stage to put at beginning

Page 18: Principles of Pipeline

18

Page 19: Principles of Pipeline

19

SEQ+ Hardware

• PC Stage– Task is to select PC for current instruction– Based on results computed by previous

instruction

• Processor State– PC is no longer stored in register– But, can determine PC based on other stored

information

Page 20: Principles of Pipeline

20

PC Computation

int pc= [picode == ICALL : pValC;picode == IJXX && pBch : pValC;Picode == IRET : pValM;1 : pValP;

];

Page 21: Principles of Pipeline

21

Naïve Pipelined Implementation

Page 22: Principles of Pipeline

22

Outline

• Naïve PIPE Implementation

• Pipeline Hazards

• Suggested Reading 4.5.2 ~ 4.5.5

Page 23: Principles of Pipeline

23

Page 24: Principles of Pipeline

24

Pipeline Stages

• Fetch– Select current PC– Read instruction– Compute incremented PC

• Decode– Read program registers

• Execute– Operate ALU

• Memory– Read or write data memory

• Write Back– Update register file

Page 25: Principles of Pipeline

25

PIPE- Hardware

• Pipeline registers hold intermediate values from instruction execution

• Forward (Upward) Paths– Values passed from one stage to next– Cannot jump past stages

• e.g., valC passes through decode

Page 26: Principles of Pipeline

26

Page 27: Principles of Pipeline

27

Feedback Paths

• Predicted PC– Guess value of next PC – Branch information

• Jump taken/not-taken• Fall-through or target address

– Return point• Read from memory

• Register updates• To register file write ports

Page 28: Principles of Pipeline

28

Page 29: Principles of Pipeline

29

• Start fetch of new instruction after current one has completed fetch stage– Not enough time to reliably determine next

instruction

• Guess which instruction will follow– Recover if prediction was incorrect

Predicting the PC

Page 30: Principles of Pipeline

30

Predicting the PC

M_valP

Page 31: Principles of Pipeline

31

Our Prediction Strategy

• Instructions that Don’t Transfer Control– Predict next PC to be valP– Always reliable

• Call and Unconditional Jumps– Predict next PC to be valC (destination)– Always reliable

Page 32: Principles of Pipeline

32

Our Prediction Strategy

• Conditional Jumps– Predict next PC to be valC (destination)– Only correct if branch is taken

• Typically right 60% of time• Recovery: M_Cnd and M_valA (valP: next PC)

• Return Instruction– Don’t try to predict

Page 33: Principles of Pipeline

33

Select PC

Int F_predPC = [

f_icode in {IJXX, ICALL} : f_valC;

1: f_valP;

];

Page 34: Principles of Pipeline

34

Recovering from PC Misprediction

• Mispredicted Jump– Will see branch flag once instruction reaches

Memory stage– Can get fall-through PC from valA (valP)

• Return Instruction– Will get return PC when ret reaches write-

back stage

Page 35: Principles of Pipeline

35

Select PC

int f_PC = [

#mispredicted branch. Fetch at incremented PC

M_icode == IJXX && !M_Cnd : M_valA;

#completion of RET instruciton

W_icode == IRET : W_valM;

#default: Use predicted value of PC

1: F_predPC

];

Page 36: Principles of Pipeline

36

Pipeline Demonstration

1 2 3 4 5 6 7 8 9F D E M

WF D E MW

F D E M WF D E M W

F D E M W

Cycle 5

WI1MI2EI3DI4FI5

irmovl $1,%eax #I1irmovl $2,%ecx #I2irmovl $3,%edx #I3irmovl $4,%ebx #I4halt #I5