/
1 Lecture 19: Pipelining 1 Lecture 19: Pipelining

1 Lecture 19: Pipelining - PowerPoint Presentation

Ruggedman
Ruggedman . @Ruggedman
Follow
343 views
Uploaded On 2022-08-01

1 Lecture 19: Pipelining - PPT Presentation

Todays topics Hazards and instruction scheduling Branch prediction Outoforder execution 2 Problem 0 add 1 2 3 add 5 1 4 Without bypassing add 1 2 3 IF DR AL DM RW ID: 932027

branch alu problem add alu branch add problem counter instruction dec pipeline ifd stage bypassing aludm predictor stalls target

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "1 Lecture 19: Pipelining" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

1

Lecture 19: Pipelining

Today’s topics:

Hazards and instruction scheduling

Branch prediction

Out-of-order execution

Slide2

2

Problem 0

add $1, $2, $3

add $5, $1, $4

Without bypassing:

add $1, $2, $3: IF DR AL DM RW

add $5, $1, $4: IF DR

DR DR AL DM RWWith bypassing:add $1, $2, $3: IF DR AL DM RWadd $5, $1, $4: IF DR AL DM RW

Point of Production

Point of Consumption

Slide3

3

Problem 1

add $1, $2, $3

lw $4, 8($1)

IF

D/R

ALU

DM

RW

IF

D/R

ALU

DM

RW

IF

D/R

ALU

DM

RW

IF

D/R

ALU

DM

RW

Slide4

4

Problem 1

add $1, $2, $3

lw $4, 8($1)

IF

D/R

ALU

DM

RW

IF

D/R

ALU

DM

RW

IF

D/R

ALU

DM

RW

IF

D/R

ALU

DM

RW

Slide5

5

Problem 2

IF

D/R

ALU

DM

RW

IFD/R

ALU

DM

RW

IF

D/R

ALU

DM

RW

IF

D/R

ALU

DM

RW

lw $1, 8($2)

lw $4, 8($1)

Slide6

6

Problem 2

IF

D/R

ALU

DM

RW

IFD/R

ALU

DM

RW

IF

D/R

ALU

DM

RW

IF

D/R

ALU

DM

RW

lw $1, 8($2)

lw $4, 8($1)

Slide7

7

Problem 3

IF

D/R

ALU

DM

RW

IFD/R

ALU

DM

RW

IF

D/R

ALU

DM

RW

IF

D/R

ALU

DM

RW

lw $1, 8($2)

sw $1, 8($3)

Slide8

8

Problem 3

IF

D/R

ALU

DM

RW

IFD/R

ALU

DM

RW

IF

D/R

ALU

DM

RW

IF

D/R

ALU

DM

RW

lw $1, 8($2)

sw $1, 8($3)

Slide9

9

Problem 4

IF

Dec

ALU

DM

RW

ALUDM

RW

lw $1, 8($2)

add $4, $1, $3

IF

Dec

RR

A 7 or 9 stage pipeline, RR and RW take an entire stage

Slide10

10

Problem 4

IF

Dec

ALU

DM

RW

ALUDM

RW

lw $1, 8($2)

add $4, $1, $3

IF

Dec

RR

A 7 or 9 stage pipeline, RR and RW take an entire stage

Slide11

11

Problem 4

IF

Dec

ALU

DM

RW

ALUDM

RW

lw $1, 8($2)

add $4, $1, $3

IF

Dec

RR

Without bypassing: 4 stalls

IF:IF:DE:DE:RR:AL:DM:DM:RW

IF: IF :DE:DE:DE:DE: DE :DE:RR:AL:RW

With bypassing: 2 stalls

IF:IF:DE:DE:RR:AL:DM:DM:RW

IF: IF :DE:DE:DE:DE: RR :AL:RW

Slide12

12

Control Hazards

Simple techniques to handle control hazard stalls:

for every branch, introduce a stall cycle (note: every

6

th

instruction is a branch!)

assume the branch is not taken and start fetching the next instruction – if the branch is taken, need hardware to cancel the effect of the wrong-path instruction fetch the next instruction (branch delay slot) and execute it anyway – if the instruction turns out to be on the correct path, useful work was done – if the instruction turns out to be on the wrong path, hopefully program state is not lostmake a smarter guess and fetch instructions from the

expected target

Slide13

13

Branch Delay Slots

Source: H&P textbook

Slide14

14

Pipeline without Branch Predictor

IF (br)

PC

Reg Read

Compare

Br-target

PC + 4

Slide15

15

Pipeline with Branch Predictor

IF (br)

PC

Reg Read

Compare

Br-target

Branch

Predictor

Slide16

16

2-Bit Prediction

For each branch, maintain a 2-bit saturating counter:

if the branch is taken: counter = min(3,counter+1)

if the branch is not taken: counter = max(0,counter-1)

… sound familiar?

If (counter >= 2), predict taken, else predict not taken

The counter attempts to capture the common case for each branch