SlideShare a Scribd company logo
1 of 30
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

Computer organisation -morris mano
Computer organisation  -morris manoComputer organisation  -morris mano
Computer organisation -morris manovishnu murthy
 
Bit pair recoding
Bit pair recodingBit pair recoding
Bit pair recodingBasit Ali
 
Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)Piyush Rochwani
 
Advanced Computer Architecture chapter 5 problem solutions
Advanced Computer  Architecture  chapter 5 problem solutionsAdvanced Computer  Architecture  chapter 5 problem solutions
Advanced Computer Architecture chapter 5 problem solutionsJoe Christensen
 
Pipelining
PipeliningPipelining
PipeliningAmin Omi
 
Floating Point Addition.pptx
Floating Point Addition.pptxFloating Point Addition.pptx
Floating Point Addition.pptxKarthikeyanC53
 
Chapter 4 The Processor
Chapter 4 The ProcessorChapter 4 The Processor
Chapter 4 The Processorguest4f73554
 
Datapath Design of Computer Architecture
Datapath Design of Computer ArchitectureDatapath Design of Computer Architecture
Datapath Design of Computer ArchitectureAbu Zaman
 
Computer architecture the pentium architecture
Computer architecture the pentium architectureComputer architecture the pentium architecture
Computer architecture the pentium architectureMazin Alwaaly
 
Microprocessor 8086-lab-mannual
Microprocessor 8086-lab-mannualMicroprocessor 8086-lab-mannual
Microprocessor 8086-lab-mannualyeshwant gadave
 
Set associative mapping
Set associative mappingSet associative mapping
Set associative mappingAshik Khan
 

What's hot (20)

Computer organisation -morris mano
Computer organisation  -morris manoComputer organisation  -morris mano
Computer organisation -morris mano
 
Bit pair recoding
Bit pair recodingBit pair recoding
Bit pair recoding
 
Pipelining in computer architecture
Pipelining in computer architecturePipelining in computer architecture
Pipelining in computer architecture
 
Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)
 
Pipelining
PipeliningPipelining
Pipelining
 
Advanced Computer Architecture chapter 5 problem solutions
Advanced Computer  Architecture  chapter 5 problem solutionsAdvanced Computer  Architecture  chapter 5 problem solutions
Advanced Computer Architecture chapter 5 problem solutions
 
Cache mapping
Cache mappingCache mapping
Cache mapping
 
Pipelining
PipeliningPipelining
Pipelining
 
MEMORY & I/O SYSTEMS
MEMORY & I/O SYSTEMS                          MEMORY & I/O SYSTEMS
MEMORY & I/O SYSTEMS
 
Floating Point Addition.pptx
Floating Point Addition.pptxFloating Point Addition.pptx
Floating Point Addition.pptx
 
Chapter 4 The Processor
Chapter 4 The ProcessorChapter 4 The Processor
Chapter 4 The Processor
 
Chapter 5 c
Chapter 5 cChapter 5 c
Chapter 5 c
 
Control Memory
Control MemoryControl Memory
Control Memory
 
Datapath Design of Computer Architecture
Datapath Design of Computer ArchitectureDatapath Design of Computer Architecture
Datapath Design of Computer Architecture
 
cache memory
 cache memory cache memory
cache memory
 
pipelining
pipeliningpipelining
pipelining
 
Data Hazard and Solution for Data Hazard
Data Hazard and Solution for Data HazardData Hazard and Solution for Data Hazard
Data Hazard and Solution for Data Hazard
 
Computer architecture the pentium architecture
Computer architecture the pentium architectureComputer architecture the pentium architecture
Computer architecture the pentium architecture
 
Microprocessor 8086-lab-mannual
Microprocessor 8086-lab-mannualMicroprocessor 8086-lab-mannual
Microprocessor 8086-lab-mannual
 
Set associative mapping
Set associative mappingSet associative mapping
Set associative mapping
 

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 Hazardbabuece
 
Latihan soal
Latihan soalLatihan soal
Latihan soaljoko
 
Exercise 4c stp rapid pvst+ question
Exercise 4c   stp rapid pvst+ questionExercise 4c   stp rapid pvst+ question
Exercise 4c stp rapid pvst+ questionsufi1248
 
Implementation of pipelining in datapath
Implementation of pipelining in datapathImplementation of pipelining in datapath
Implementation of pipelining in datapathbabuece
 
3. Implementation of Pipelining in Datapath.pptx
3. Implementation of Pipelining in Datapath.pptx3. Implementation of Pipelining in Datapath.pptx
3. Implementation of Pipelining in Datapath.pptxKarthikeyanC53
 
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
 
"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 CypheropenCypher
 
pipeline and vector processing
pipeline and vector processingpipeline and vector processing
pipeline and vector processingAcad
 
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 switchesKJ Savaliya
 
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
 
Chapter 2 Part2 C
Chapter 2 Part2 CChapter 2 Part2 C
Chapter 2 Part2 Cececourse
 
Instruction Level Parallelism – Compiler Techniques
Instruction Level Parallelism – Compiler TechniquesInstruction Level Parallelism – Compiler Techniques
Instruction Level Parallelism – Compiler TechniquesDilum Bandara
 

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
 
3. Implementation of Pipelining in Datapath.pptx
3. Implementation of Pipelining in Datapath.pptx3. Implementation of Pipelining in Datapath.pptx
3. Implementation of Pipelining in Datapath.pptx
 
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
 
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
 
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.
 
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
 
Instruction Level Parallelism – Compiler Techniques
Instruction Level Parallelism – Compiler TechniquesInstruction Level Parallelism – Compiler Techniques
Instruction Level Parallelism – Compiler Techniques
 

More from KarthikeyanC53

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

More from KarthikeyanC53 (16)

1. Introduction to Memory.pptx
1. Introduction to Memory.pptx1. Introduction to Memory.pptx
1. Introduction to Memory.pptx
 
6. ILP.pptx
6. ILP.pptx6. ILP.pptx
6. ILP.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

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 

Recently uploaded (20)

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 

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