SlideShare una empresa de Scribd logo
1 de 18
Pipeline Hazards

1
Pipeline Hazards
• Hazards are situations in pipelining where one
instruction cannot immediately follow another.
• Hazards reduce the ideal speedup gained from
pipelining and are classified into three classes:
– Structural hazards: Arise from hardware resource
conflicts when the available hardware cannot support all
possible combinations of instructions.
– Data hazards: Arise when an instruction depends on the
results of a previous instruction in a way that is exposed
by the overlapping of instructions in the pipeline
– Control hazards: Arise from the pipelining of conditional
branches and other instructions that change the PC

• Can always resolve hazards by waiting
2
Structural Hazards
• In pipelined processors, overlapped instruction
execution requires pipelining of functional units
and duplication of resources to allow all possible
combinations of instructions in the pipeline.
• If a resource conflict arises due to a hardware
resource being required by more than one
instruction in a single cycle, and one or more such
instructions cannot be accommodated, then a
structural hazard has occurred, for example:
– when a machine has only one register file write port
– or when a pipelined machine has a shared single-memory pipeline
for data and instructions.

3
Register File/Structural Hazards
Operation on register set
by 2 different instructions
in the same clock cycle

Time (clock cycles)

Instr 4

Ifetch

DMem

Reg

Ifetch

ALU

Reg

Reg

Reg

Ifetch

Reg

DMem

Reg

DMem

Reg

ALU

Instr 3

Ifetch

DMem

Cycle 6 Cycle 7

ALU

O
r
d
e
r

Instr 2

Reg

ALU

I Load Ifetch
n
s
t Instr 1
r.

ALU

Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5

Reg

Reg

DMem

4
Register File/Structural Hazards
We need 3 stall cycles
In order to solve this hazard

Time (clock cycles)

Instr 3
Instr 4

Reg

Ifetch

Reg

DMem

Reg

ALU

Ifetch

DMem

Cycle 6 Cycle 7

Reg

DMem

3 stalls cycles

Reg

Ifetch

Reg

ALU

O
r
d
e
r

Instr 2

Reg

ALU

I Load Ifetch
n
s
t Instr 1
r.

ALU

Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5

Ifetch

5
Register File/Structural Hazards
Allow writing registers in first ½ of cycle
and reading in 2nd ½ of cycle

Instr 3
Instr 4

Ifetch

DMem

Reg

Ifetch

ALU

Reg

No stalls are required

Reg

Ifetch

Reg

DMem

Reg

DMem

Reg

ALU

O
r
d
e
r

Instr 2

Ifetch

DMem

Cycle 6 Cycle 7

Reg

ALU

I Load Ifetch
n
s
t Instr 1
r.

Reg

ALU

Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5

ALU

Time (clock cycles)

Reg

Reg

DMem

6
1 Memory Port/Structural Hazards

Instruction4

Mem

Reg

Mem

Reg

Mem

Reg

Mem

Reg

Mem

Reg

Mem

Reg

ALU

Instruction3

Reg

Operation on Memory
by 2 different instructions
in the same clock cycle

ALU

Instruction2

Mem

Mem

ALU

Instruction1

Reg

ALU

Load Mem

ALU

Instruction Order

Time (in Cycles)

Reg

Mem

Reg

7
Inserting Bubbles (Stalls)

Stall
Stall
Stall
Instruction3

Reg

Mem

Reg

Reg

Mem

3 stall cycles
with 1-port memory
Reg

Mem

Reg

Bubble Bubble Bubble Bubble Bubble
Bubble Bubble Bubble Bubble Bubble

Bubble Bubble Bubble Bubble Bubb
Mem

Reg

ALU

Instruction2

Mem

Mem

ALU

Instruction1

Reg

ALU

Load Mem

ALU

Time (in Cycles)

8

Mem
2 Memory Port/Structural Hazards
(Read & Write at the same time)

Instruction4

Mem

Reg

Mem

Mem

Reg

Mem

Reg

Mem

Reg

Mem

Reg

ALU

Instruction3

Reg

No stall with 2-memory
ports

Reg

ALU

Instruction2

Mem

Mem

ALU

Instruction1

Reg

ALU

Load Mem

ALU

Instruction Order

Time (in Cycles)

Reg

Mem

Reg

9
Pipeline Hazards
• Hazards reduce the ideal speedup gained from
pipelining and are classified into three classes:
– Structural hazards: Arise from hardware resource
conflicts when the available hardware cannot support all
possible combinations of instructions.
–

Data hazards:

Arise when an instruction depends on
the results of a previous instruction in a way that is
exposed by the overlapping of instructions in the pipeline

– Control hazards: Arise from the pipelining of conditional
branches and other instructions that change the PC

• Can always resolve hazards by waiting

10
Data Hazard on R1
Time (clock cycles)

and r6,r1,r7
or

r8,r1,r9

xor r10,r1,r11

Ifetch

DMem

Reg

DMem

Ifetch

Reg

DMem

Reg

DMem

Reg

ALU

sub r4,r1,r3

Reg

ALU

Ifetch

ALU

O
r
d
e
r

add r1,r2,r3

WB

ALU

I
n
s
t
r.

MEM

ALU

IF ID/RF EX

Ifetch

Reg

Ifetch

Reg

Reg

Reg

DMem

11

Reg
Data Hazard Classification
•

•

•

•

Given two instructions I, J, with I occurring before J
in an instruction stream:
RAW (read after write): A true data dependence
J tried to read a source before I writes to it, so J
incorrectly gets the old value.
WAW (write after write): A name dependence
J tries to write an operand before it is written by I
The writes end up being performed in the wrong
order.
WAR (write after read): A name dependence
J tries to write to a destination before it is read by I,
so I incorrectly gets the new value.
RAR (read after read): Not a hazard.
12
I (Write)

Data Hazard Classification
I (Read)

Shared
Operand

J (Read)

Shared
Operand

J (Write)

Read after Write (RAW)

Write after Read (WAR)

I (Write)

I (Read)
Shared
Operand

Shared
Operand

J (Write)
Write after Write (WAW)

J (Read)
Read after Read (RAR) not a hazard
13
Data Hazards Present in Current MIPS Pipeline

• Read after Write (RAW) Hazards: Possible?

– Caused by a “Dependence” (in compiler nomenclature). This
hazard results from an actual need for communication.
– Yes possible, when an instruction requires an operand generated by
a preceding instruction with distance less than four.

I: add r1,r2,r3
J: sub r4,r1,r3
Inst i
Inst j

1

2
1

3

4

2
3
Read
read the old data.

Write
5
4

5

– Resolved by:
• Forwarding or Stalling.

14
Data Hazards Present in Current MIPS Pipeline
– Write After Read (WAR) – not possible
Error if InstrJ tries to write operand before InstrI reads
it
I: sub r4,r1,r3
J: add r1,r2,r3
K: mul r6,r1,r7
Inst i
Inst j

1

Read
2
1

Always read the correct data.
3

4

5

2

3

4

Write
5

– Called an “anti-dependence” by compiler writers.
This results from reuse of the name “r1”.

15
Data Hazards Present in Current MIPS
Pipeline
– Write After Write (WAW) - not possible
– Error if InstrJ tries to write operand before InstrI writes it.

I: sub r1,r4,r3
J: add r1,r2,r3
K: mul r6,r1,r7
Inst i
Inst j

1

2

3

4

Write
5

1

2

3

4

5
Write

– Called an “output dependence” by compiler writers
This also results from the reuse of name “r1”.
16
Data Hazards
• Solutions for Data Hazards
– Stalling
– Forwarding:
• connect new value directly to next stage

– Reordering

17
Minimizing Data Hazard Stalls by
Forwarding

• Forwarding is a hardware-based technique (also called register
bypassing or short-circuiting) used to eliminate or minimize data
hazard stalls.
• Using forwarding hardware, the result of an instruction is copied
directly from where it is produced (ALU, memory read port etc.), to
where subsequent instructions need it (ALU, input register, memory
write port etc.)
Zero?

Data
Memory

M/W Buffer

MUX

A/M Buffer

MUX

D/A Buffer

ALU

18

Más contenido relacionado

La actualidad más candente

RISC (reduced instruction set computer)
RISC (reduced instruction set computer)RISC (reduced instruction set computer)
RISC (reduced instruction set computer)LokmanArman
 
CS304PC:Computer Organization and Architecture Session 8 Address Sequencing.pptx
CS304PC:Computer Organization and Architecture Session 8 Address Sequencing.pptxCS304PC:Computer Organization and Architecture Session 8 Address Sequencing.pptx
CS304PC:Computer Organization and Architecture Session 8 Address Sequencing.pptxAsst.prof M.Gokilavani
 
Computer architecture multi core processor
Computer architecture multi core processorComputer architecture multi core processor
Computer architecture multi core processorMazin Alwaaly
 
Csc1401 lecture05 - cache memory
Csc1401   lecture05 - cache memoryCsc1401   lecture05 - cache memory
Csc1401 lecture05 - cache memoryIIUM
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithmsPiyush Rochwani
 
Pipelining of Processors Computer Architecture
Pipelining of  Processors Computer ArchitecturePipelining of  Processors Computer Architecture
Pipelining of Processors Computer ArchitectureHaris456
 
UVM Ral model usage
UVM Ral model usageUVM Ral model usage
UVM Ral model usageParth Pandya
 
Dealing with exceptions Computer Architecture part 2
Dealing with exceptions Computer Architecture part 2Dealing with exceptions Computer Architecture part 2
Dealing with exceptions Computer Architecture part 2Gaditek
 
Virtual memory
Virtual memoryVirtual memory
Virtual memoryAnuj Modi
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithmssangrampatil81
 
Pipelining and vector processing
Pipelining and vector processingPipelining and vector processing
Pipelining and vector processingKamal Acharya
 
Unix Memory Management - Operating Systems
Unix Memory Management - Operating SystemsUnix Memory Management - Operating Systems
Unix Memory Management - Operating SystemsDrishti Bhalla
 

La actualidad más candente (20)

RISC (reduced instruction set computer)
RISC (reduced instruction set computer)RISC (reduced instruction set computer)
RISC (reduced instruction set computer)
 
CS304PC:Computer Organization and Architecture Session 8 Address Sequencing.pptx
CS304PC:Computer Organization and Architecture Session 8 Address Sequencing.pptxCS304PC:Computer Organization and Architecture Session 8 Address Sequencing.pptx
CS304PC:Computer Organization and Architecture Session 8 Address Sequencing.pptx
 
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 multi core processor
Computer architecture multi core processorComputer architecture multi core processor
Computer architecture multi core processor
 
Pipelining & All Hazards Solution
Pipelining  & All Hazards SolutionPipelining  & All Hazards Solution
Pipelining & All Hazards Solution
 
Csc1401 lecture05 - cache memory
Csc1401   lecture05 - cache memoryCsc1401   lecture05 - cache memory
Csc1401 lecture05 - cache memory
 
Pipelining slides
Pipelining slides Pipelining slides
Pipelining slides
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
 
Cache memory
Cache  memoryCache  memory
Cache memory
 
Pipelining of Processors Computer Architecture
Pipelining of  Processors Computer ArchitecturePipelining of  Processors Computer Architecture
Pipelining of Processors Computer Architecture
 
Cache coherence ppt
Cache coherence pptCache coherence ppt
Cache coherence ppt
 
3 Pipelining
3 Pipelining3 Pipelining
3 Pipelining
 
UVM Ral model usage
UVM Ral model usageUVM Ral model usage
UVM Ral model usage
 
Superscalar Processor
Superscalar ProcessorSuperscalar Processor
Superscalar Processor
 
Dealing with exceptions Computer Architecture part 2
Dealing with exceptions Computer Architecture part 2Dealing with exceptions Computer Architecture part 2
Dealing with exceptions Computer Architecture part 2
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
 
Pipelining and vector processing
Pipelining and vector processingPipelining and vector processing
Pipelining and vector processing
 
Unix Memory Management - Operating Systems
Unix Memory Management - Operating SystemsUnix Memory Management - Operating Systems
Unix Memory Management - Operating Systems
 
Multiprocessor system
Multiprocessor system Multiprocessor system
Multiprocessor system
 

Destacado

Pipeline and data hazard
Pipeline and data hazardPipeline and data hazard
Pipeline and data hazardWaed Shagareen
 
Instruction pipeline: Computer Architecture
Instruction pipeline: Computer ArchitectureInstruction pipeline: Computer Architecture
Instruction pipeline: Computer ArchitectureInteX Research Lab
 
Measuring instrumentsppt2
Measuring instrumentsppt2Measuring instrumentsppt2
Measuring instrumentsppt2Puneet Raghav
 
Permanent magnet moving iron type instruments
Permanent magnet moving iron type instrumentsPermanent magnet moving iron type instruments
Permanent magnet moving iron type instrumentsyash patel
 
Moving iron (MI) instruments
Moving iron (MI) instrumentsMoving iron (MI) instruments
Moving iron (MI) instrumentsChandan Singh
 
moving iron instrument
 moving iron instrument moving iron instrument
moving iron instrumentezhilsubitham
 
Electrical instruments ppt
Electrical instruments pptElectrical instruments ppt
Electrical instruments pptAmey Waghmare
 
Basic electrical measuring instruments
Basic electrical measuring instrumentsBasic electrical measuring instruments
Basic electrical measuring instrumentsPramod A
 
Hazard communication
Hazard communicationHazard communication
Hazard communicationwcmc
 
verilog_case_study
verilog_case_studyverilog_case_study
verilog_case_studynizhonglian
 
Pipelining
PipeliningPipelining
PipeliningAJAL A J
 
Chapter 4 the processor
Chapter 4 the processorChapter 4 the processor
Chapter 4 the processors9007912
 
Pipelining Coputing
Pipelining CoputingPipelining Coputing
Pipelining Coputingm.assayony
 

Destacado (20)

Pipeline and data hazard
Pipeline and data hazardPipeline and data hazard
Pipeline and data hazard
 
Instruction pipeline: Computer Architecture
Instruction pipeline: Computer ArchitectureInstruction pipeline: Computer Architecture
Instruction pipeline: Computer Architecture
 
pipelining
pipeliningpipelining
pipelining
 
Pipeline
PipelinePipeline
Pipeline
 
pipelining
pipeliningpipelining
pipelining
 
Measuring instrumentsppt2
Measuring instrumentsppt2Measuring instrumentsppt2
Measuring instrumentsppt2
 
Permanent magnet moving iron type instruments
Permanent magnet moving iron type instrumentsPermanent magnet moving iron type instruments
Permanent magnet moving iron type instruments
 
Moving iron (MI) instruments
Moving iron (MI) instrumentsMoving iron (MI) instruments
Moving iron (MI) instruments
 
Instruction pipelining
Instruction pipeliningInstruction pipelining
Instruction pipelining
 
moving iron instrument
 moving iron instrument moving iron instrument
moving iron instrument
 
Electrical instruments ppt
Electrical instruments pptElectrical instruments ppt
Electrical instruments ppt
 
Basic electrical measuring instruments
Basic electrical measuring instrumentsBasic electrical measuring instruments
Basic electrical measuring instruments
 
Pipelining
PipeliningPipelining
Pipelining
 
Comp archch06l01pipeline
Comp archch06l01pipelineComp archch06l01pipeline
Comp archch06l01pipeline
 
Risc
RiscRisc
Risc
 
Hazard communication
Hazard communicationHazard communication
Hazard communication
 
verilog_case_study
verilog_case_studyverilog_case_study
verilog_case_study
 
Pipelining
PipeliningPipelining
Pipelining
 
Chapter 4 the processor
Chapter 4 the processorChapter 4 the processor
Chapter 4 the processor
 
Pipelining Coputing
Pipelining CoputingPipelining Coputing
Pipelining Coputing
 

Similar a Pipelinig hazardous

Pipeline hazards in computer Architecture ppt
Pipeline hazards in computer Architecture pptPipeline hazards in computer Architecture ppt
Pipeline hazards in computer Architecture pptmali yogesh kumar
 
pipehhhhhhhhhhhhhbbbbbbbbblinehazards.ppt
pipehhhhhhhhhhhhhbbbbbbbbblinehazards.pptpipehhhhhhhhhhhhhbbbbbbbbblinehazards.ppt
pipehhhhhhhhhhhhhbbbbbbbbblinehazards.pptAkkiDongre
 
2-Advanced Computer Architecture Pipelining
2-Advanced Computer Architecture Pipelining2-Advanced Computer Architecture Pipelining
2-Advanced Computer Architecture PipeliningKarla Adamson
 
Pipelining understandingPipelining is running multiple stages of .pdf
Pipelining understandingPipelining is running multiple stages of .pdfPipelining understandingPipelining is running multiple stages of .pdf
Pipelining understandingPipelining is running multiple stages of .pdfarasanlethers
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer ArchitectureSubhasis Dash
 
ARM - Advance RISC Machine
ARM - Advance RISC MachineARM - Advance RISC Machine
ARM - Advance RISC MachineEdutechLearners
 
Synchronization linux
Synchronization linuxSynchronization linux
Synchronization linuxSusant Sahani
 
Embedded system hardware architecture ii
Embedded system hardware architecture iiEmbedded system hardware architecture ii
Embedded system hardware architecture iiGrace Abraham
 
Multithreading computer architecture
 Multithreading computer architecture  Multithreading computer architecture
Multithreading computer architecture Haris456
 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and ArchitectureDhaval Bagal
 
Performance Enhancement with Pipelining
Performance Enhancement with PipeliningPerformance Enhancement with Pipelining
Performance Enhancement with PipeliningAneesh Raveendran
 
CPU Pipelining and Hazards - An Introduction
CPU Pipelining and Hazards - An IntroductionCPU Pipelining and Hazards - An Introduction
CPU Pipelining and Hazards - An IntroductionDilum Bandara
 
OpenPOWER Application Optimization
OpenPOWER Application Optimization OpenPOWER Application Optimization
OpenPOWER Application Optimization Ganesan Narayanasamy
 

Similar a Pipelinig hazardous (20)

Pipeline hazards in computer Architecture ppt
Pipeline hazards in computer Architecture pptPipeline hazards in computer Architecture ppt
Pipeline hazards in computer Architecture ppt
 
pipehhhhhhhhhhhhhbbbbbbbbblinehazards.ppt
pipehhhhhhhhhhhhhbbbbbbbbblinehazards.pptpipehhhhhhhhhhhhhbbbbbbbbblinehazards.ppt
pipehhhhhhhhhhhhhbbbbbbbbblinehazards.ppt
 
2-Advanced Computer Architecture Pipelining
2-Advanced Computer Architecture Pipelining2-Advanced Computer Architecture Pipelining
2-Advanced Computer Architecture Pipelining
 
Assembly p1
Assembly p1Assembly p1
Assembly p1
 
Pipelining understandingPipelining is running multiple stages of .pdf
Pipelining understandingPipelining is running multiple stages of .pdfPipelining understandingPipelining is running multiple stages of .pdf
Pipelining understandingPipelining is running multiple stages of .pdf
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer Architecture
 
Pipelining
PipeliningPipelining
Pipelining
 
arm
armarm
arm
 
ARM - Advance RISC Machine
ARM - Advance RISC MachineARM - Advance RISC Machine
ARM - Advance RISC Machine
 
Synchronization linux
Synchronization linuxSynchronization linux
Synchronization linux
 
Embedded system hardware architecture ii
Embedded system hardware architecture iiEmbedded system hardware architecture ii
Embedded system hardware architecture ii
 
Multithreading computer architecture
 Multithreading computer architecture  Multithreading computer architecture
Multithreading computer architecture
 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and Architecture
 
Performance Enhancement with Pipelining
Performance Enhancement with PipeliningPerformance Enhancement with Pipelining
Performance Enhancement with Pipelining
 
Sayeh extension(v23)
Sayeh extension(v23)Sayeh extension(v23)
Sayeh extension(v23)
 
CPU Pipelining and Hazards - An Introduction
CPU Pipelining and Hazards - An IntroductionCPU Pipelining and Hazards - An Introduction
CPU Pipelining and Hazards - An Introduction
 
Chapter 2 pc
Chapter 2 pcChapter 2 pc
Chapter 2 pc
 
OpenPOWER Application Optimization
OpenPOWER Application Optimization OpenPOWER Application Optimization
OpenPOWER Application Optimization
 
Pipelining
PipeliningPipelining
Pipelining
 
Chap2 slides
Chap2 slidesChap2 slides
Chap2 slides
 

Más de jasscheema

Más de jasscheema (7)

Function
FunctionFunction
Function
 
Btree
BtreeBtree
Btree
 
B+tree
B+treeB+tree
B+tree
 
Multiole acccess
Multiole acccessMultiole acccess
Multiole acccess
 
Scheduling
SchedulingScheduling
Scheduling
 
Mobile number-portability
Mobile number-portabilityMobile number-portability
Mobile number-portability
 
Presentation1
Presentation1Presentation1
Presentation1
 

Último

Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 

Último (20)

Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

Pipelinig hazardous

  • 2. Pipeline Hazards • Hazards are situations in pipelining where one instruction cannot immediately follow another. • Hazards reduce the ideal speedup gained from pipelining and are classified into three classes: – Structural hazards: Arise from hardware resource conflicts when the available hardware cannot support all possible combinations of instructions. – Data hazards: Arise when an instruction depends on the results of a previous instruction in a way that is exposed by the overlapping of instructions in the pipeline – Control hazards: Arise from the pipelining of conditional branches and other instructions that change the PC • Can always resolve hazards by waiting 2
  • 3. Structural Hazards • In pipelined processors, overlapped instruction execution requires pipelining of functional units and duplication of resources to allow all possible combinations of instructions in the pipeline. • If a resource conflict arises due to a hardware resource being required by more than one instruction in a single cycle, and one or more such instructions cannot be accommodated, then a structural hazard has occurred, for example: – when a machine has only one register file write port – or when a pipelined machine has a shared single-memory pipeline for data and instructions. 3
  • 4. Register File/Structural Hazards Operation on register set by 2 different instructions in the same clock cycle Time (clock cycles) Instr 4 Ifetch DMem Reg Ifetch ALU Reg Reg Reg Ifetch Reg DMem Reg DMem Reg ALU Instr 3 Ifetch DMem Cycle 6 Cycle 7 ALU O r d e r Instr 2 Reg ALU I Load Ifetch n s t Instr 1 r. ALU Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Reg Reg DMem 4
  • 5. Register File/Structural Hazards We need 3 stall cycles In order to solve this hazard Time (clock cycles) Instr 3 Instr 4 Reg Ifetch Reg DMem Reg ALU Ifetch DMem Cycle 6 Cycle 7 Reg DMem 3 stalls cycles Reg Ifetch Reg ALU O r d e r Instr 2 Reg ALU I Load Ifetch n s t Instr 1 r. ALU Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Ifetch 5
  • 6. Register File/Structural Hazards Allow writing registers in first ½ of cycle and reading in 2nd ½ of cycle Instr 3 Instr 4 Ifetch DMem Reg Ifetch ALU Reg No stalls are required Reg Ifetch Reg DMem Reg DMem Reg ALU O r d e r Instr 2 Ifetch DMem Cycle 6 Cycle 7 Reg ALU I Load Ifetch n s t Instr 1 r. Reg ALU Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 ALU Time (clock cycles) Reg Reg DMem 6
  • 7. 1 Memory Port/Structural Hazards Instruction4 Mem Reg Mem Reg Mem Reg Mem Reg Mem Reg Mem Reg ALU Instruction3 Reg Operation on Memory by 2 different instructions in the same clock cycle ALU Instruction2 Mem Mem ALU Instruction1 Reg ALU Load Mem ALU Instruction Order Time (in Cycles) Reg Mem Reg 7
  • 8. Inserting Bubbles (Stalls) Stall Stall Stall Instruction3 Reg Mem Reg Reg Mem 3 stall cycles with 1-port memory Reg Mem Reg Bubble Bubble Bubble Bubble Bubble Bubble Bubble Bubble Bubble Bubble Bubble Bubble Bubble Bubble Bubb Mem Reg ALU Instruction2 Mem Mem ALU Instruction1 Reg ALU Load Mem ALU Time (in Cycles) 8 Mem
  • 9. 2 Memory Port/Structural Hazards (Read & Write at the same time) Instruction4 Mem Reg Mem Mem Reg Mem Reg Mem Reg Mem Reg ALU Instruction3 Reg No stall with 2-memory ports Reg ALU Instruction2 Mem Mem ALU Instruction1 Reg ALU Load Mem ALU Instruction Order Time (in Cycles) Reg Mem Reg 9
  • 10. Pipeline Hazards • Hazards reduce the ideal speedup gained from pipelining and are classified into three classes: – Structural hazards: Arise from hardware resource conflicts when the available hardware cannot support all possible combinations of instructions. – Data hazards: Arise when an instruction depends on the results of a previous instruction in a way that is exposed by the overlapping of instructions in the pipeline – Control hazards: Arise from the pipelining of conditional branches and other instructions that change the PC • Can always resolve hazards by waiting 10
  • 11. Data Hazard on R1 Time (clock cycles) and r6,r1,r7 or r8,r1,r9 xor r10,r1,r11 Ifetch DMem Reg DMem Ifetch Reg DMem Reg DMem Reg ALU sub r4,r1,r3 Reg ALU Ifetch ALU O r d e r add r1,r2,r3 WB ALU I n s t r. MEM ALU IF ID/RF EX Ifetch Reg Ifetch Reg Reg Reg DMem 11 Reg
  • 12. Data Hazard Classification • • • • Given two instructions I, J, with I occurring before J in an instruction stream: RAW (read after write): A true data dependence J tried to read a source before I writes to it, so J incorrectly gets the old value. WAW (write after write): A name dependence J tries to write an operand before it is written by I The writes end up being performed in the wrong order. WAR (write after read): A name dependence J tries to write to a destination before it is read by I, so I incorrectly gets the new value. RAR (read after read): Not a hazard. 12
  • 13. I (Write) Data Hazard Classification I (Read) Shared Operand J (Read) Shared Operand J (Write) Read after Write (RAW) Write after Read (WAR) I (Write) I (Read) Shared Operand Shared Operand J (Write) Write after Write (WAW) J (Read) Read after Read (RAR) not a hazard 13
  • 14. Data Hazards Present in Current MIPS Pipeline • Read after Write (RAW) Hazards: Possible? – Caused by a “Dependence” (in compiler nomenclature). This hazard results from an actual need for communication. – Yes possible, when an instruction requires an operand generated by a preceding instruction with distance less than four. I: add r1,r2,r3 J: sub r4,r1,r3 Inst i Inst j 1 2 1 3 4 2 3 Read read the old data. Write 5 4 5 – Resolved by: • Forwarding or Stalling. 14
  • 15. Data Hazards Present in Current MIPS Pipeline – Write After Read (WAR) – not possible Error if InstrJ tries to write operand before InstrI reads it I: sub r4,r1,r3 J: add r1,r2,r3 K: mul r6,r1,r7 Inst i Inst j 1 Read 2 1 Always read the correct data. 3 4 5 2 3 4 Write 5 – Called an “anti-dependence” by compiler writers. This results from reuse of the name “r1”. 15
  • 16. Data Hazards Present in Current MIPS Pipeline – Write After Write (WAW) - not possible – Error if InstrJ tries to write operand before InstrI writes it. I: sub r1,r4,r3 J: add r1,r2,r3 K: mul r6,r1,r7 Inst i Inst j 1 2 3 4 Write 5 1 2 3 4 5 Write – Called an “output dependence” by compiler writers This also results from the reuse of name “r1”. 16
  • 17. Data Hazards • Solutions for Data Hazards – Stalling – Forwarding: • connect new value directly to next stage – Reordering 17
  • 18. Minimizing Data Hazard Stalls by Forwarding • Forwarding is a hardware-based technique (also called register bypassing or short-circuiting) used to eliminate or minimize data hazard stalls. • Using forwarding hardware, the result of an instruction is copied directly from where it is produced (ALU, memory read port etc.), to where subsequent instructions need it (ALU, input register, memory write port etc.) Zero? Data Memory M/W Buffer MUX A/M Buffer MUX D/A Buffer ALU 18

Notas del editor

  1. Please if anyone has additional comments please speak up