SlideShare a Scribd company logo
EC 8552 UNIT III PIPELINE HAZARDS
Mr. C.KARTHIKEYAN ,
ASSISTANT PROFESSOR,
ECE, RMKCET
PIPELINE HAZARDS
The events which leads to Pipeline stall by preventing the next instruction to
execute are known as Hazards.
1.Structural Hazard
2.Data Hazard
3.Control Hazard
Pipelined Data Path with
Control Signals
Structural Hazard
IF ID EX MEM WB
IF ID EX MEM WB
lw $10,20($1)
IF ID EX MEM WB
IF ID EX MEM WB
1 2 3 4 5 6 7 8 9
CLOCK CYCLES
PROGRAM
INSTRUCTIONS
Instruction 1
IF ID EX MEM WB
IF ID EX MEM WB
Instruction 2
Instruction 3
Instruction 4
sub $11,$2,$3
add $12,$3,$4
lw $13,24($1)
add $14,$5,$6
Pipeline Stall
Von Neumann Vs Harvard Architecture
Pipeline Hardware Resources
DATA HAZARD
Data hazards occur when the pipeline get stalled because one step must wait for
another to complete.
Data Dependency
IF ID EX MEM WB
IF ID EX MEM WB
1 2 3 4 5 6 7 8
add $s0, $t0, $t1
sub $t2, $s0, $t3
Types of Data Hazard
There are three situations in which a data hazard can occur
Read After Write (RAW)
a true dependency
Write After Read (WAR)
an anti-dependency
write after write (WAW)
an output dependency
add $s0, $t0, $t1
sub $t2, $s0, $t3
add $s1, $t2, $t1
sub $t2, $s0, $t3
add $s1, $t2, $t1
sub $s1, $s0, $t3
How is to overcome Data Hazard?
1. Forwarding / Bypassing
Forwarding Unit to
overcome pipeline stall
Load-use Data hazard
lw $s0, 20($t1)
sub $t2, $s0, $t3
IF ID EX MEM WB
IF ID EX MEM WB
1 2 3 4 5 6 7 8
2. Pipeline Stall / Bubble
lw $s0, 20($t1)
NOP
sub $t2, $s0, $t3
NOP
3. Re-ordering the code
a = b + e;
c = b + f;
lw $t1, 0($t0)
lw $t2, 4($t0)
add $t3, $t1,$t2
sw $t3, 12($t0)
lw $t4, 8($t0)
add $t5, $t1,$t4
sw $t5, 16($t0)
lw $t1, 0($t0)
lw $t2, 4($t0)
add $t3, $t1,$t2
sw $t3, 12($t0)
lw $t4, 8($t0)
add $t5, $t1,$t4
sw $t5, 16($t0)
lw $t1, 0($t0)
lw $t2, 4($t0)
lw $t4, 8($t0)
add $t3, $t1,$t2
sw $t3, 12($t0)
add $t5, $t1,$t4
sw $t5, 16($t0)
Computer Organization and Design by David A Patterson – Page no. 361
I1: or r1,r2,r3
I2: or r2,r1,r4
I3: or r1,r1,r2
1. Indicate dependences and their type
Comparing I1 & I2
a. RAW on r1 – True Dependency
b. WAR on r2 – Anti - Dependency
Computer Organization and Design by David A Patterson – Page no. 361
I1: or r1,r2,r3
I2: or r2,r1,r4
I3: or r1,r1,r2
1. Indicate dependences and their type
Comparing I1 & I3
a. RAW on r1 – True Dependency
b. WAW on r1 – Output Dependency
Computer Organization and Design by David A Patterson – Page no. 361
I1: or r1,r2,r3
I2: or r2,r1,r4
I3: or r1,r1,r2
1. Indicate dependences and their type
Comparing I2 & I3
a. RAW on r2 – True Dependency
b. WAR on r1 – Anti- Dependency
Computer Organization and Design by David A Patterson – Page no. 361
I1: or r1,r2,r3
I2: or r2,r1,r4
I3: or r1,r1,r2
2. Assume there is no forwarding in this pipelined
processor. Indicate hazards and add NOP instructions
to eliminate them.
or r1,r2,r3
NOP
NOP
or r2,r1,r4
NOP
NOP
NOP
NOP
or r1,r1,r2
IF ID EX MEM WB
IF ID EX MEM WB
1 2 3 4 5 6 7 8 9 10 11
IF ID EX MEM WB
Computer Organization and Design by David A Patterson – Page no. 361
I1: or r1,r2,r3
I2: or r2,r1,r4
I3: or r1,r1,r2
3. Assume there is full forwarding. Indicate hazards and add
NOP instructions to eliminate them.
or r1,r2,r3
or r2,r1,r4
or r1,r1,r2
IF ID EX MEM WB
IF ID EX MEM WB
1 2 3 4 5 6 7
IF ID EX MEM WB
Control Hazard / Branch Hazard
control hazard arising from the need to make a decision based on the results
of one instruction while others are executing
beq $6,$7,7
sub $11,$2,$3
add $12,$3,$4
IF ID EX MEM WB
IF ID EX MEM
1 2 3 4 5 6 7
IF ID EX
Control Hazard / Branch Hazard
control hazard arising from the need to make a decision based on the results
of one instruction while others are executing
A control hazard is when we need to find destination of a branch, and can’t
fetch any new instruction until we know that destination
A branch is either
Taken : PC + 4 + Immediate address * 4
Not Taken : PC + 4
Penalty is 3 Clock Cycle
How to overcome Control Hazard?
1. Stall – Stop loading the instructions until the branch target is available
2. Prediction – Assume whether branch is taken or not and continue
fetching the instructions (Static Branch and Dynamic Branch Prediction)
3. Delayed Branch
Assume Branch is Not Taken
Static Prediction
FLUSH
Reducing the Delay of Branches
sub $11,$2,$3
beq $6,$7,7
add $12,$3,$4
IF ID EX MEM WB
IF ID EX MEM
1 2 3 4 5 6 7
IF ID EX
WB
MEM WB
Complication Factors
1. New forwarding unit is required
2. Data dependency from previous instruction
Dynamic Branch Prediction
Prediction of branches at run time using run time information
1.1-bit Prediction scheme
2.2-bit Prediction scheme
Dynamic Branch Prediction
1-bit Prediction scheme
Branch Prediction Buffer / Branch History Table (BHT)
- A small memory indexed by the lower portion of the address of the branch instruction
Prediction Bit
1 if Branch is taken previously
0 if Branch is not taken previously
Dynamic Branch Prediction
Disadvantage of 1-bit Prediction scheme
Even if a branch is almost taken always, there is a possibility to
predict it incorrectly twice, when the branch is not taken
Dynamic Branch Prediction
2-bit Prediction scheme
The prediction is changed
iff the branch is wrongly
predicted twice
Advanced Prediction Schemes
Correlation Predictor Tournament Predictor
A branch predictor that
combines local behavior of a
particular branch and global
information about the behavior
of some recent number of
executed branches.
A branch predictor with
multiple predictions for each
branch and a selection
mechanism that chooses
which predictor to enable for
a given branch

More Related Content

What's hot

Datapath design with control unit
Datapath design with control unitDatapath design with control unit
Datapath design with control unit
babuece
 
MPMC LAB MANUAL EEE
MPMC LAB MANUAL EEEMPMC LAB MANUAL EEE
9. data link layer error correction codes - hamming code
9. data link layer   error correction codes - hamming code9. data link layer   error correction codes - hamming code
9. data link layer error correction codes - hamming code
JAIGANESH SEKAR
 
Pipeline and data hazard
Pipeline and data hazardPipeline and data hazard
Pipeline and data hazardWaed Shagareen
 
IEEE floating point representation
 IEEE floating point representation IEEE floating point representation
IEEE floating point representation
MaskurAlShalSabil
 
8259 a
8259 a8259 a
Booths algorithm for Multiplication
Booths algorithm for MultiplicationBooths algorithm for Multiplication
Booths algorithm for Multiplication
Vikas Yadav
 
Addressing mode & data transfer instruction of 8085
Addressing mode & data transfer instruction of 8085Addressing mode & data transfer instruction of 8085
Addressing mode & data transfer instruction of 8085
Chinmayee samal
 
Pipelining & All Hazards Solution
Pipelining  & All Hazards SolutionPipelining  & All Hazards Solution
Pipelining & All Hazards Solution
.AIR UNIVERSITY ISLAMABAD
 
Interrupts of microprocessor 8085
Interrupts of microprocessor  8085Interrupts of microprocessor  8085
Interrupts of microprocessor 8085
mujeebkhanelectronic
 
Square of an Input Number - Digital Logic Design | Lecture 5
Square of an Input Number - Digital Logic Design | Lecture 5Square of an Input Number - Digital Logic Design | Lecture 5
Square of an Input Number - Digital Logic Design | Lecture 5
JalpaMaheshwari1
 
Ec8791 lpc2148 pwm
Ec8791 lpc2148 pwmEc8791 lpc2148 pwm
Ec8791 lpc2148 pwm
RajalakshmiSermadurai
 
Sequential Version / Version 1 Unsigned Multiplication Algorithm
Sequential Version / Version 1 Unsigned Multiplication AlgorithmSequential Version / Version 1 Unsigned Multiplication Algorithm
Sequential Version / Version 1 Unsigned Multiplication Algorithm
babuece
 
8086 Microprocessor Pipeline Architecture.pptx
8086 Microprocessor Pipeline Architecture.pptx8086 Microprocessor Pipeline Architecture.pptx
8086 Microprocessor Pipeline Architecture.pptx
Green University of Bangladesh
 
Maharastra EXTC NetSim Experiment Manual
Maharastra EXTC  NetSim Experiment  ManualMaharastra EXTC  NetSim Experiment  Manual
Maharastra EXTC NetSim Experiment Manual
Dr Praveen Jain
 
Interrupts
InterruptsInterrupts
Interrupts
deval patel
 
Carry look ahead adder
Carry look ahead adderCarry look ahead adder
Carry look ahead adder
dragonpradeep
 

What's hot (20)

Datapath design with control unit
Datapath design with control unitDatapath design with control unit
Datapath design with control unit
 
MPMC LAB MANUAL EEE
MPMC LAB MANUAL EEEMPMC LAB MANUAL EEE
MPMC LAB MANUAL EEE
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
9. data link layer error correction codes - hamming code
9. data link layer   error correction codes - hamming code9. data link layer   error correction codes - hamming code
9. data link layer error correction codes - hamming code
 
Pipeline and data hazard
Pipeline and data hazardPipeline and data hazard
Pipeline and data hazard
 
IEEE floating point representation
 IEEE floating point representation IEEE floating point representation
IEEE floating point representation
 
8259 a
8259 a8259 a
8259 a
 
Chapter 5 b
Chapter 5  bChapter 5  b
Chapter 5 b
 
Booths algorithm for Multiplication
Booths algorithm for MultiplicationBooths algorithm for Multiplication
Booths algorithm for Multiplication
 
Addressing mode & data transfer instruction of 8085
Addressing mode & data transfer instruction of 8085Addressing mode & data transfer instruction of 8085
Addressing mode & data transfer instruction of 8085
 
Pipelining & All Hazards Solution
Pipelining  & All Hazards SolutionPipelining  & All Hazards Solution
Pipelining & All Hazards Solution
 
Interrupts of microprocessor 8085
Interrupts of microprocessor  8085Interrupts of microprocessor  8085
Interrupts of microprocessor 8085
 
Square of an Input Number - Digital Logic Design | Lecture 5
Square of an Input Number - Digital Logic Design | Lecture 5Square of an Input Number - Digital Logic Design | Lecture 5
Square of an Input Number - Digital Logic Design | Lecture 5
 
Ec8791 lpc2148 pwm
Ec8791 lpc2148 pwmEc8791 lpc2148 pwm
Ec8791 lpc2148 pwm
 
Sequential Version / Version 1 Unsigned Multiplication Algorithm
Sequential Version / Version 1 Unsigned Multiplication AlgorithmSequential Version / Version 1 Unsigned Multiplication Algorithm
Sequential Version / Version 1 Unsigned Multiplication Algorithm
 
8086 Microprocessor Pipeline Architecture.pptx
8086 Microprocessor Pipeline Architecture.pptx8086 Microprocessor Pipeline Architecture.pptx
8086 Microprocessor Pipeline Architecture.pptx
 
Maharastra EXTC NetSim Experiment Manual
Maharastra EXTC  NetSim Experiment  ManualMaharastra EXTC  NetSim Experiment  Manual
Maharastra EXTC NetSim Experiment Manual
 
Interrupts
InterruptsInterrupts
Interrupts
 
Carry look ahead adder
Carry look ahead adderCarry look ahead adder
Carry look ahead adder
 
boolean 8051
boolean 8051boolean 8051
boolean 8051
 

Similar to 4. Pipeline Hazards.pptx

Pipeline hazards | Structural Hazard, Data Hazard & Control Hazard
Pipeline hazards | Structural Hazard, Data Hazard & Control HazardPipeline hazards | Structural Hazard, Data Hazard & Control Hazard
Pipeline hazards | Structural Hazard, Data Hazard & Control Hazard
babuece
 
Latihan soal
Latihan soalLatihan soal
Latihan soal
joko
 
Exercise 4c stp rapid pvst+ question
Exercise 4c   stp rapid pvst+ questionExercise 4c   stp rapid pvst+ question
Exercise 4c stp rapid pvst+ question
sufi1248
 
Implementation of pipelining in datapath
Implementation of pipelining in datapathImplementation of pipelining in datapath
Implementation of pipelining in datapath
babuece
 
Ccnp3 lab 3_1_en (hacer)
Ccnp3 lab 3_1_en (hacer)Ccnp3 lab 3_1_en (hacer)
Ccnp3 lab 3_1_en (hacer)
Omar Herrera
 
L12-Forwarding.ppt
L12-Forwarding.pptL12-Forwarding.ppt
L12-Forwarding.ppt
RevathiSoundiran1
 
"Attacking industrial remote controllers for fun and profit" - Dr. Marco Bald...
"Attacking industrial remote controllers for fun and profit" - Dr. Marco Bald..."Attacking industrial remote controllers for fun and profit" - Dr. Marco Bald...
"Attacking industrial remote controllers for fun and profit" - Dr. Marco Bald...
PROIDEA
 
Cs718min1 2008soln View
Cs718min1 2008soln ViewCs718min1 2008soln View
Cs718min1 2008soln ViewRavi Soni
 
An Efficient Black Hole Attack Securing Mechanism in Ad Hoc On Demand Distanc...
An Efficient Black Hole Attack Securing Mechanism in Ad Hoc On Demand Distanc...An Efficient Black Hole Attack Securing Mechanism in Ad Hoc On Demand Distanc...
An Efficient Black Hole Attack Securing Mechanism in Ad Hoc On Demand Distanc...
MINTUKAN RABHA
 
INSTRUCTION PIPELINING
INSTRUCTION PIPELININGINSTRUCTION PIPELINING
INSTRUCTION PIPELININGrubysistec
 
Incremental Graph Queries for Cypher
Incremental Graph Queries for CypherIncremental Graph Queries for Cypher
Incremental Graph Queries for Cypher
openCypher
 
pipeline and vector processing
pipeline and vector processingpipeline and vector processing
pipeline and vector processing
Acad
 
Hacking Layer 2 - Enthernet Switcher Hacking Countermeasures.
Hacking Layer 2 - Enthernet Switcher Hacking Countermeasures.Hacking Layer 2 - Enthernet Switcher Hacking Countermeasures.
Hacking Layer 2 - Enthernet Switcher Hacking Countermeasures.
Sumutiu Marius
 
Cisco systems hacking layer 2 ethernet switches
Cisco systems   hacking layer 2 ethernet switchesCisco systems   hacking layer 2 ethernet switches
Cisco systems hacking layer 2 ethernet switches
KJ Savaliya
 
Nec ODU.pdf
Nec ODU.pdfNec ODU.pdf
Nec ODU.pdf
ssuser176a50
 
Nec ODU.pdf
Nec ODU.pdfNec ODU.pdf
Nec ODU.pdf
ssuser176a50
 
Nec ODU.pdf
Nec ODU.pdfNec ODU.pdf
Nec ODU.pdf
ssuser176a50
 
Chapter 2 Part2 C
Chapter 2 Part2 CChapter 2 Part2 C
Chapter 2 Part2 Cececourse
 
pipehhhhhhhhhhhhhbbbbbbbbblinehazards.ppt
pipehhhhhhhhhhhhhbbbbbbbbblinehazards.pptpipehhhhhhhhhhhhhbbbbbbbbblinehazards.ppt
pipehhhhhhhhhhhhhbbbbbbbbblinehazards.ppt
AkkiDongre
 
ICSE2013
ICSE2013ICSE2013
ICSE2013
swy351
 

Similar to 4. Pipeline Hazards.pptx (20)

Pipeline hazards | Structural Hazard, Data Hazard & Control Hazard
Pipeline hazards | Structural Hazard, Data Hazard & Control HazardPipeline hazards | Structural Hazard, Data Hazard & Control Hazard
Pipeline hazards | Structural Hazard, Data Hazard & Control Hazard
 
Latihan soal
Latihan soalLatihan soal
Latihan soal
 
Exercise 4c stp rapid pvst+ question
Exercise 4c   stp rapid pvst+ questionExercise 4c   stp rapid pvst+ question
Exercise 4c stp rapid pvst+ question
 
Implementation of pipelining in datapath
Implementation of pipelining in datapathImplementation of pipelining in datapath
Implementation of pipelining in datapath
 
Ccnp3 lab 3_1_en (hacer)
Ccnp3 lab 3_1_en (hacer)Ccnp3 lab 3_1_en (hacer)
Ccnp3 lab 3_1_en (hacer)
 
L12-Forwarding.ppt
L12-Forwarding.pptL12-Forwarding.ppt
L12-Forwarding.ppt
 
"Attacking industrial remote controllers for fun and profit" - Dr. Marco Bald...
"Attacking industrial remote controllers for fun and profit" - Dr. Marco Bald..."Attacking industrial remote controllers for fun and profit" - Dr. Marco Bald...
"Attacking industrial remote controllers for fun and profit" - Dr. Marco Bald...
 
Cs718min1 2008soln View
Cs718min1 2008soln ViewCs718min1 2008soln View
Cs718min1 2008soln View
 
An Efficient Black Hole Attack Securing Mechanism in Ad Hoc On Demand Distanc...
An Efficient Black Hole Attack Securing Mechanism in Ad Hoc On Demand Distanc...An Efficient Black Hole Attack Securing Mechanism in Ad Hoc On Demand Distanc...
An Efficient Black Hole Attack Securing Mechanism in Ad Hoc On Demand Distanc...
 
INSTRUCTION PIPELINING
INSTRUCTION PIPELININGINSTRUCTION PIPELINING
INSTRUCTION PIPELINING
 
Incremental Graph Queries for Cypher
Incremental Graph Queries for CypherIncremental Graph Queries for Cypher
Incremental Graph Queries for Cypher
 
pipeline and vector processing
pipeline and vector processingpipeline and vector processing
pipeline and vector processing
 
Hacking Layer 2 - Enthernet Switcher Hacking Countermeasures.
Hacking Layer 2 - Enthernet Switcher Hacking Countermeasures.Hacking Layer 2 - Enthernet Switcher Hacking Countermeasures.
Hacking Layer 2 - Enthernet Switcher Hacking Countermeasures.
 
Cisco systems hacking layer 2 ethernet switches
Cisco systems   hacking layer 2 ethernet switchesCisco systems   hacking layer 2 ethernet switches
Cisco systems hacking layer 2 ethernet switches
 
Nec ODU.pdf
Nec ODU.pdfNec ODU.pdf
Nec ODU.pdf
 
Nec ODU.pdf
Nec ODU.pdfNec ODU.pdf
Nec ODU.pdf
 
Nec ODU.pdf
Nec ODU.pdfNec ODU.pdf
Nec ODU.pdf
 
Chapter 2 Part2 C
Chapter 2 Part2 CChapter 2 Part2 C
Chapter 2 Part2 C
 
pipehhhhhhhhhhhhhbbbbbbbbblinehazards.ppt
pipehhhhhhhhhhhhhbbbbbbbbblinehazards.pptpipehhhhhhhhhhhhhbbbbbbbbblinehazards.ppt
pipehhhhhhhhhhhhhbbbbbbbbblinehazards.ppt
 
ICSE2013
ICSE2013ICSE2013
ICSE2013
 

More from KarthikeyanC53

1. Introduction to Memory.pptx
1. Introduction to Memory.pptx1. Introduction to Memory.pptx
1. Introduction to Memory.pptx
KarthikeyanC53
 
5. Exception.pptx
5. Exception.pptx5. Exception.pptx
5. Exception.pptx
KarthikeyanC53
 
Floating Point Multiplication.pptx
Floating Point Multiplication.pptxFloating Point Multiplication.pptx
Floating Point Multiplication.pptx
KarthikeyanC53
 
Floating Point Represenataion.pptx
Floating Point Represenataion.pptxFloating Point Represenataion.pptx
Floating Point Represenataion.pptx
KarthikeyanC53
 
Refined Version of Division.pptx
Refined Version of Division.pptxRefined Version of Division.pptx
Refined Version of Division.pptx
KarthikeyanC53
 
Version 1 Division.pptx
Version 1 Division.pptxVersion 1 Division.pptx
Version 1 Division.pptx
KarthikeyanC53
 
BOOTH’s ALGORITHM Part 1.pptx
BOOTH’s ALGORITHM Part 1.pptxBOOTH’s ALGORITHM Part 1.pptx
BOOTH’s ALGORITHM Part 1.pptx
KarthikeyanC53
 
2. Addition and Subtraction.pptx
2. Addition and Subtraction.pptx2. Addition and Subtraction.pptx
2. Addition and Subtraction.pptx
KarthikeyanC53
 
1. Introduction to Arithmetic.pptx
1. Introduction to Arithmetic.pptx1. Introduction to Arithmetic.pptx
1. Introduction to Arithmetic.pptx
KarthikeyanC53
 
6.Performance.pptx
6.Performance.pptx6.Performance.pptx
6.Performance.pptx
KarthikeyanC53
 
5. Addressing Modes.pptx
5. Addressing Modes.pptx5. Addressing Modes.pptx
5. Addressing Modes.pptx
KarthikeyanC53
 
4.Instruction Formats.pptx
4.Instruction Formats.pptx4.Instruction Formats.pptx
4.Instruction Formats.pptx
KarthikeyanC53
 
3. Instruction Set.pptx
3. Instruction Set.pptx3. Instruction Set.pptx
3. Instruction Set.pptx
KarthikeyanC53
 
2. Eight Great Ideas.pptx
2. Eight Great Ideas.pptx2. Eight Great Ideas.pptx
2. Eight Great Ideas.pptx
KarthikeyanC53
 
1. Introduction to CAO.pptx
1. Introduction to CAO.pptx1. Introduction to CAO.pptx
1. Introduction to CAO.pptx
KarthikeyanC53
 

More from KarthikeyanC53 (15)

1. Introduction to Memory.pptx
1. Introduction to Memory.pptx1. Introduction to Memory.pptx
1. Introduction to Memory.pptx
 
5. Exception.pptx
5. Exception.pptx5. Exception.pptx
5. Exception.pptx
 
Floating Point Multiplication.pptx
Floating Point Multiplication.pptxFloating Point Multiplication.pptx
Floating Point Multiplication.pptx
 
Floating Point Represenataion.pptx
Floating Point Represenataion.pptxFloating Point Represenataion.pptx
Floating Point Represenataion.pptx
 
Refined Version of Division.pptx
Refined Version of Division.pptxRefined Version of Division.pptx
Refined Version of Division.pptx
 
Version 1 Division.pptx
Version 1 Division.pptxVersion 1 Division.pptx
Version 1 Division.pptx
 
BOOTH’s ALGORITHM Part 1.pptx
BOOTH’s ALGORITHM Part 1.pptxBOOTH’s ALGORITHM Part 1.pptx
BOOTH’s ALGORITHM Part 1.pptx
 
2. Addition and Subtraction.pptx
2. Addition and Subtraction.pptx2. Addition and Subtraction.pptx
2. Addition and Subtraction.pptx
 
1. Introduction to Arithmetic.pptx
1. Introduction to Arithmetic.pptx1. Introduction to Arithmetic.pptx
1. Introduction to Arithmetic.pptx
 
6.Performance.pptx
6.Performance.pptx6.Performance.pptx
6.Performance.pptx
 
5. Addressing Modes.pptx
5. Addressing Modes.pptx5. Addressing Modes.pptx
5. Addressing Modes.pptx
 
4.Instruction Formats.pptx
4.Instruction Formats.pptx4.Instruction Formats.pptx
4.Instruction Formats.pptx
 
3. Instruction Set.pptx
3. Instruction Set.pptx3. Instruction Set.pptx
3. Instruction Set.pptx
 
2. Eight Great Ideas.pptx
2. Eight Great Ideas.pptx2. Eight Great Ideas.pptx
2. Eight Great Ideas.pptx
 
1. Introduction to CAO.pptx
1. Introduction to CAO.pptx1. Introduction to CAO.pptx
1. Introduction to CAO.pptx
 

Recently uploaded

Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
DhatriParmar
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 

Recently uploaded (20)

Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 

4. Pipeline Hazards.pptx

  • 1. EC 8552 UNIT III PIPELINE HAZARDS Mr. C.KARTHIKEYAN , ASSISTANT PROFESSOR, ECE, RMKCET
  • 2. PIPELINE HAZARDS The events which leads to Pipeline stall by preventing the next instruction to execute are known as Hazards. 1.Structural Hazard 2.Data Hazard 3.Control Hazard
  • 3. Pipelined Data Path with Control Signals
  • 4. Structural Hazard IF ID EX MEM WB IF ID EX MEM WB lw $10,20($1) IF ID EX MEM WB IF ID EX MEM WB 1 2 3 4 5 6 7 8 9 CLOCK CYCLES PROGRAM INSTRUCTIONS Instruction 1 IF ID EX MEM WB IF ID EX MEM WB Instruction 2 Instruction 3 Instruction 4 sub $11,$2,$3 add $12,$3,$4 lw $13,24($1) add $14,$5,$6
  • 6. Von Neumann Vs Harvard Architecture Pipeline Hardware Resources
  • 7. DATA HAZARD Data hazards occur when the pipeline get stalled because one step must wait for another to complete. Data Dependency IF ID EX MEM WB IF ID EX MEM WB 1 2 3 4 5 6 7 8 add $s0, $t0, $t1 sub $t2, $s0, $t3
  • 8. Types of Data Hazard There are three situations in which a data hazard can occur Read After Write (RAW) a true dependency Write After Read (WAR) an anti-dependency write after write (WAW) an output dependency add $s0, $t0, $t1 sub $t2, $s0, $t3 add $s1, $t2, $t1 sub $t2, $s0, $t3 add $s1, $t2, $t1 sub $s1, $s0, $t3
  • 9. How is to overcome Data Hazard? 1. Forwarding / Bypassing
  • 10.
  • 11.
  • 12. Forwarding Unit to overcome pipeline stall
  • 13. Load-use Data hazard lw $s0, 20($t1) sub $t2, $s0, $t3 IF ID EX MEM WB IF ID EX MEM WB 1 2 3 4 5 6 7 8 2. Pipeline Stall / Bubble lw $s0, 20($t1) NOP sub $t2, $s0, $t3 NOP
  • 14. 3. Re-ordering the code a = b + e; c = b + f; lw $t1, 0($t0) lw $t2, 4($t0) add $t3, $t1,$t2 sw $t3, 12($t0) lw $t4, 8($t0) add $t5, $t1,$t4 sw $t5, 16($t0) lw $t1, 0($t0) lw $t2, 4($t0) add $t3, $t1,$t2 sw $t3, 12($t0) lw $t4, 8($t0) add $t5, $t1,$t4 sw $t5, 16($t0) lw $t1, 0($t0) lw $t2, 4($t0) lw $t4, 8($t0) add $t3, $t1,$t2 sw $t3, 12($t0) add $t5, $t1,$t4 sw $t5, 16($t0)
  • 15. Computer Organization and Design by David A Patterson – Page no. 361 I1: or r1,r2,r3 I2: or r2,r1,r4 I3: or r1,r1,r2 1. Indicate dependences and their type Comparing I1 & I2 a. RAW on r1 – True Dependency b. WAR on r2 – Anti - Dependency
  • 16. Computer Organization and Design by David A Patterson – Page no. 361 I1: or r1,r2,r3 I2: or r2,r1,r4 I3: or r1,r1,r2 1. Indicate dependences and their type Comparing I1 & I3 a. RAW on r1 – True Dependency b. WAW on r1 – Output Dependency
  • 17. Computer Organization and Design by David A Patterson – Page no. 361 I1: or r1,r2,r3 I2: or r2,r1,r4 I3: or r1,r1,r2 1. Indicate dependences and their type Comparing I2 & I3 a. RAW on r2 – True Dependency b. WAR on r1 – Anti- Dependency
  • 18. Computer Organization and Design by David A Patterson – Page no. 361 I1: or r1,r2,r3 I2: or r2,r1,r4 I3: or r1,r1,r2 2. Assume there is no forwarding in this pipelined processor. Indicate hazards and add NOP instructions to eliminate them. or r1,r2,r3 NOP NOP or r2,r1,r4 NOP NOP NOP NOP or r1,r1,r2 IF ID EX MEM WB IF ID EX MEM WB 1 2 3 4 5 6 7 8 9 10 11 IF ID EX MEM WB
  • 19. Computer Organization and Design by David A Patterson – Page no. 361 I1: or r1,r2,r3 I2: or r2,r1,r4 I3: or r1,r1,r2 3. Assume there is full forwarding. Indicate hazards and add NOP instructions to eliminate them. or r1,r2,r3 or r2,r1,r4 or r1,r1,r2 IF ID EX MEM WB IF ID EX MEM WB 1 2 3 4 5 6 7 IF ID EX MEM WB
  • 20. Control Hazard / Branch Hazard control hazard arising from the need to make a decision based on the results of one instruction while others are executing beq $6,$7,7 sub $11,$2,$3 add $12,$3,$4 IF ID EX MEM WB IF ID EX MEM 1 2 3 4 5 6 7 IF ID EX
  • 21. Control Hazard / Branch Hazard control hazard arising from the need to make a decision based on the results of one instruction while others are executing A control hazard is when we need to find destination of a branch, and can’t fetch any new instruction until we know that destination A branch is either Taken : PC + 4 + Immediate address * 4 Not Taken : PC + 4
  • 22. Penalty is 3 Clock Cycle
  • 23. How to overcome Control Hazard? 1. Stall – Stop loading the instructions until the branch target is available 2. Prediction – Assume whether branch is taken or not and continue fetching the instructions (Static Branch and Dynamic Branch Prediction) 3. Delayed Branch
  • 24. Assume Branch is Not Taken Static Prediction FLUSH
  • 25. Reducing the Delay of Branches sub $11,$2,$3 beq $6,$7,7 add $12,$3,$4 IF ID EX MEM WB IF ID EX MEM 1 2 3 4 5 6 7 IF ID EX WB MEM WB Complication Factors 1. New forwarding unit is required 2. Data dependency from previous instruction
  • 26. Dynamic Branch Prediction Prediction of branches at run time using run time information 1.1-bit Prediction scheme 2.2-bit Prediction scheme
  • 27. Dynamic Branch Prediction 1-bit Prediction scheme Branch Prediction Buffer / Branch History Table (BHT) - A small memory indexed by the lower portion of the address of the branch instruction Prediction Bit 1 if Branch is taken previously 0 if Branch is not taken previously
  • 28. Dynamic Branch Prediction Disadvantage of 1-bit Prediction scheme Even if a branch is almost taken always, there is a possibility to predict it incorrectly twice, when the branch is not taken
  • 29. Dynamic Branch Prediction 2-bit Prediction scheme The prediction is changed iff the branch is wrongly predicted twice
  • 30. Advanced Prediction Schemes Correlation Predictor Tournament Predictor A branch predictor that combines local behavior of a particular branch and global information about the behavior of some recent number of executed branches. A branch predictor with multiple predictions for each branch and a selection mechanism that chooses which predictor to enable for a given branch