SlideShare a Scribd company logo
Pipelining
Presented by
Ajal.A.J
AP/ ECE
Pipelining
 Break instructions into steps
 Work on instructions like in an assembly line
 Allows for more instructions to be executed
in less time
 A n-stage pipeline is n times faster than a non
pipeline processor (in theory)
5
What is Pipelining?
 Like an Automobile Assembly Line for
Instructions
 Each step does a little job of processing the
instruction
 Ideally each step operates in parallel
 Simple Model
 Instruction Fetch
 Instruction Decode
 Instruction Execute
F1 D1 E1
F2 D2 E2
F3 D3 E3
pipeline
 It is technique of decomposing a sequential
process into suboperation, with each
suboperation completed in dedicated segment.
 Pipeline is commonly known as an assembly
line operation.
 It is similar like assembly line of car
manufacturing.
 First station in an assembly line set up a
chasis, next station is installing the engine,
another group of workers fitting the body.
Pipeline Stages
We can divide the execution of an instruction
into the following 5 “classic” stages:
IF: Instruction Fetch
ID: Instruction Decode, register fetch
EX: Execution
MEM: Memory Access
WB: Register write Back
RISC Pipeline Stages
 Fetch instruction
 Decode instruction
 Execute instruction
 Access operand
 Write result
 Note:
Slight variations depending on processor
Without Pipelining
Instr 1
Instr 2
Clock Cycle 1 2 3 4 5 6 7 8 9 10
• Normally, you would perform the fetch, decode,
execute, operate, and write steps of an
instruction and then move on to the next
instruction
With Pipelining
Clock Cycle 1 2 3 4 5 6 7 8 9
Instr 1
Instr 2
Instr 3
Instr 4
Instr 5
• The processor is able to perform each stage simultaneously.
• If the processor is decoding an instruction, it
may also fetch another instruction at the same
time.
Pipeline (cont.)
 Length of pipeline depends on the longest
step
 Thus in RISC, all instructions were made to
be the same length
 Each stage takes 1 clock cycle
 In theory, an instruction should be finished
each clock cycle
Stages of Execution in Pipelined
MIPS
5 stage instruction pipeline
1) I-fetch: Fetch Instruction, Increment PC
2) Decode: Instruction, Read Registers
3) Execute:
Mem-reference: Calculate Address
R-format: Perform ALU Operation
4) Memory:
Load: Read Data from Data Memory
Store: Write Data to Data Memory
5) Write Back: Write Data to Register
Pipelined Execution
Representation
 To simplify pipeline, every instruction takes
same number of steps, called stages
 One clock cycle per stage
IFtch Dcd Exec Mem WB
IFtch Dcd Exec Mem WB
IFtch Dcd Exec Mem WB
IFtch Dcd Exec Mem WB
IFtch Dcd Exec Mem WB
Program Flow
Pipeline Problem
 Problem: An instruction may need to wait for
the result of another instruction
Pipeline Solution :
 Solution: Compiler may recognize which
instructions are dependent or independent of
the current instruction, and rearrange them to
run the independent one first
How to make pipelines faster
 Superpipelining
 Divide the stages of pipelining into more stages
 Ex: Split “fetch instruction” stage into two
stages
Super duper pipelining
Super scalar pipelining
 Run multiple pipelines in parallel
Automated consolidation of data from many
sources,
Dynamic pipeline

Dynamic pipeline: Uses buffers to hold
instruction bits in case a
dependent instruction stalls
Pipelining
Lessons
 Pipelining doesn’t help latency (execution time)
of single task, it helps throughput of entire
workload
 Multiple tasks operating simultaneously using
different resources
 Po te ntialspeedup = Number of pipe stages
 Time to “fill” pipeline and time to “drain” it
reduces speedup
 Pipeline rate limited by slowest pipeline stage
 Unbalanced lengths of pipe stages also reduces
speedup
Performance limitations
 Imbalance among pipe stages
 limits cycle time to slowest stage
 Pipelining overhead
 Pipeline register delay
 Clock skew
 Clock cycle > clock skew + latch overhead
 Hazards
Pipeline Hazards
There are situations, called hazards, that prevent
the next instruction in the instruction stream
from executing during its designated cycle
There are three classes of hazards
Structural hazard
Data hazard
Branch hazard
 Structural Hazards. They arise from resource conflicts when the hardware cannot support all
possible combinations of instructions in simultaneous overlapped execution. 
 Data Hazards. They arise when an instruction depends on the result of a previous instruction
in a way that is exposed by the overlapping of instructions in the pipeline. 
 Control Hazards.They arise from the pipelining of branches and other instructions
that change the PC.
22
What Makes Pipelining Hard?
Power failing,
Arithmetic overflow,
I/O device request,
OS call,
Page fault
Pipeline Hazards
Structural hazard
Resource conflicts when the hardware cannot support
all possible combination of instructions simultaneously
Data hazard
An instruction depends on the results of a previous
instruction
Branch hazard
Instructions that change the PC
Structural hazard
Some pipeline processors have shared a single-
memory pipeline for data and instructions
M
Single Memory is a Structural
Hazard
Load
Instr 1
Instr 2
Instr 3
Instr 4
ALU
M Reg M Reg
ALU
M Reg M Reg
ALU
M Reg M Reg
ALU
Reg M Reg
ALU
M Reg M Reg
• Can’t read same memory twice in same clock cycle
I
n
s
t
r.
O
r
d
e
r
Time (clock cycles)
Structural hazard
Memory data fetch requires on FI and FO
Fetch
Instruction
(FI)
Fetch
Operand
(FO)
Decode
Instruction
(DI)
Write
Operand
(WO)
Execution
Instruction
(EI)
S3 S4S1 S2 S5
1 2 3 4 98765S1
S2
S5
S3
S4
1 2 3 4 8765
1 2 3 4 765
1 2 3 4 65
1 2 3 4 5
Time
Structural hazard
To solve this hazard, we “stall” the pipeline until the
resource is freed
A stall is commonly called pipeline bubble, since it
floats through the pipeline taking space but carry no
useful work
Structural Hazards limit
performance
 Example: if 1.3 memory accesses per
instruction (30% of instructions execute
loads and stores)
and only one memory access per cycle then
 Average CPI ≥ 1.3
 Otherwise datapath resource is more than
100% utilized
Structural Hazard Solution: Add
more Hardware
Structural hazard
Fetch
Instruction
(FI)
Fetch
Operand
(FO)
Decode
Instruction
(DI)
Write
Operand
(WO)
Execution
Instruction
(EI)
Time
Data hazard
Example:
ADD R1R2+R3
SUB R4R1-R5
AND R6R1 AND R7
OR R8R1 OR R9
XOR R10R1 XOR R11
Data hazard
FO: fetch data value WO: store the executed value
Fetch
Instruction
(FI)
Fetch
Operand
(FO)
Decode
Instruction
(DI)
Write
Operand
(WO)
Execution
Instruction
(EI)
S3 S4S1 S2 S5
Time
Data hazard
Delay load approach inserts a no-operation instruction to
avoid the data conflict
ADD R1R2+R3
No-op
No-op
SUB R4R1-R5
AND R6R1 AND R7
OR R8R1 OR R9
XOR R10R1 XOR R11
Data hazard
Data hazard
It can be further solved by a simple hardware technique called
forwarding (also called bypassing or short-circuiting)
The insight in forwarding is that the result is not really needed by SUB
until the ADD execute completely
If the forwarding hardware detects that the previous ALU operation
has written the register corresponding to a source for the current ALU
operation, control logic selects the results in ALU instead of from
memory
Data hazard
36
Data Hazard Classification
Three types of data hazards
RAW : Read After Write
WAW : Write After Write
WAR : Write After Read
• RAR : Read After Read
– Is this a hazard?
Read After Write (RAW)
A read after write (RAW) data hazard refers to a
situation where an instruction refers to a result that
has not yet been calculated or retrieved.
This can occur because even though an instruction
is executed after a previous instruction, the
previous instruction has not been completely
processed through the pipeline.
example:
i1.  R2  <- R1 + R3
i2. R4 <-  R2 + R3
Write After Read (WAR)
A write after read (WAR) data hazard represents a
problem with concurrent execution.
For example:
i1. R4 <- R1 + R5
i2.  R5 <- R1 + R2
Write After Write (WAW
A write after write (WAW) data hazard may occur in
a concurrent execution environment.
example:
i1.  R2 <- R4 + R7
i2.  R2 <- R1 + R3
We must delay the WB (Write Back) of i2 until the execution of i1
Branch hazards
Branch hazards can cause a greater performance
loss for pipelines
When a branch instruction is executed, it may or
may not change the PC
If a branch changes the PC to its target
address, it is a taken branch Otherwise, it is
untaken
Branch hazards
There are FOUR schemes to handle branch hazards
Freeze scheme
Predict-untaken scheme
Predict-taken scheme
Delayed branch
5-Stage Pipelining
Fetch
Instruction
(FI)
Fetch
Operand
(FO)
Decode
Instruction
(DI)
Write
Operand
(WO)
Execution
Instruction
(EI)
1 2 3 4 98765S1
S2
S5
S3
S4
1 2 3 4 8765
1 2 3 4 765
1 2 3 4 65
1 2 3 4 5
Time
Branch Untaken
(Freeze approach)
The simplest method of dealing with branches is to
redo the fetch following a branch
Fetch
Instruction
(FI)
Fetch
Operand
(FO)
Decode
Instruction
(DI)
Write
Operand
(WO)
Execution
Instruction
(EI)
Branch Taken
(Freeze approach)
The simplest method of dealing with branches is to redo
the fetch following a branch
Fetch
Instruction
(FI)
Fetch
Operand
(FO)
Decode
Instruction
(DI)
Write
Operand
(WO)
Execution
Instruction
(EI)
Branch Taken
(Freeze approach)
The simplest scheme to handle branches is to
freeze the pipeline holding or deleting any
instructions after the branch until the branch
destination is known
The attractiveness of this solution lies primarily
in its simplicity both for hardware and software
Branch Hazards
(Predicted-untaken)
A higher performance, and only slightly more
complex, scheme is to treat every branch as not taken
It is implemented by continuing to fetch instructions as if
the branch were normal instruction
The pipeline looks the same if the branch is not
taken
If the branch is taken, we need to redo the fetch
instruction
Branch Untaken
(Predicted-untaken)
Fetch
Instruction
(FI)
Fetch
Operand
(FO)
Decode
Instruction
(DI)
Write
Operand
(WO)
Execution
Instruction
(EI)
Time
Branch Taken
(Predicted-untaken)
Fetch
Instruction
(FI)
Fetch
Operand
(FO)
Decode
Instruction
(DI)
Write
Operand
(WO)
Execution
Instruction
(EI)
Branch Taken
(Predicted-taken)
An alternative scheme is to treat every branch as
taken
As soon as the branch is decoded and the target
address is computed, we assume the branch to be
taken and begin fetching and executing the
target
Branch Untaken
(Predicted-taken)
Fetch
Instruction
(FI)
Fetch
Operand
(FO)
Decode
Instruction
(DI)
Write
Operand
(WO)
Execution
Instruction
(EI)
Branch taken
(Predicted-taken)
Fetch
Instruction
(FI)
Fetch
Operand
(FO)
Decode
Instruction
(DI)
Write
Operand
(WO)
Execution
Instruction
(EI)
Delayed Branch
A fourth scheme in use in some processors is
called delayed branch
It is done in compiler time. It modifies the
code
The general format is:
branch instruction
Delay slot
branch target if taken
Delayed Branch
Optimal
Delayed
Branch
If the optimal is not
available:
(b) Act like
predict-taken
(in complier way)
(c) Act like
predict-untaken
(in complier way)
Delayed Branch
Delayed Branch is limited by
(1) the restrictions on the instructions that are
scheduled into the delay slots (for example:
another branch cannot be scheduled)
(2) our ability to predict at compile time whether a
branch is likely to be taken or not
Branch Prediction
A pipeline with branch prediction uses some
additional logic to guess the outcome of a conditional
branch instruction before it is executed
Branch Prediction
Various techniques can be used to predict whether a
branch will be taken or not:
Prediction never taken
Prediction always taken
Prediction by opcode
Branch history table
The first three approaches are static: they do not
depend on the execution history up to the time of the
conditional branch instruction. The last approach is
dynamic: they depend on the execution history.
58
Important Pipeline
Characteristics
 Latency
 Time required for an instruction to propagate through
the pipeline
 Based on the Number of Stages * Cycle Time
 Dominant if there are lots of exceptions / hazards, i.e.
we have to constantly be re-filling the pipeline
 Throughput
 The rate at which instructions can start and finish
 Dominant if there are few exceptions and hazards, i.e.
the pipeline stays mostly full
 Note we need an increased memory bandwidth
over the non-pipelined processor
59
Exceptions
 An exception is when the normal execution
order of instructions is changed. This has many
names:
 Interrupt
 Fault
 Exception
 Examples:
 I/O device request
 Invoking OS service
 Page Fault
 Malfunction
 Undefined instruction
 Overflow/Arithmetic Anomaly
 Etc!
Eliminating hazards- Pipeline
bubbling
 Bubbling the pipe line , also known as
a pipe line bre ak or a pipe line stall, is a method
for preventing data, structural, and branch
hazards from occurring. 
 instructions are fetched, control logic
determines whether a hazard could/will occur.
If this is true, then the control logic inserts 
NOPs into the pipeline. Thus, before the next
instruction (which would cause the hazard) is
executed, the previous one will have had
sufficient time to complete and prevent the
No: of NOPs = stages in pipeline
 If the number of NOPs is equal to the number
of stages in the pipeline, the processor has
been cleared of all instructions and can
proceed free from hazards. All forms of stalling
introduce a delay before the processor can
resume execution.

More Related Content

What's hot

Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1) Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1)
Subhasis Dash
 
Computer Organization and Architecture.
Computer Organization and Architecture.Computer Organization and Architecture.
Computer Organization and Architecture.
CS_GDRCST
 
Memory organization (Computer architecture)
Memory organization (Computer architecture)Memory organization (Computer architecture)
Memory organization (Computer architecture)
Sandesh Jonchhe
 
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
COMSATS Institute of Information Technology
 
Signed Addition And Subtraction
Signed Addition And SubtractionSigned Addition And Subtraction
Signed Addition And Subtraction
Keyur Vadodariya
 
Basic MIPS implementation
Basic MIPS implementationBasic MIPS implementation
Basic MIPS implementation
kavitha2009
 
Instruction format
Instruction formatInstruction format
Instruction format
Sanjeev Patel
 
CISC & RISC Architecture
CISC & RISC Architecture CISC & RISC Architecture
CISC & RISC Architecture
Suvendu Kumar Dash
 
Memory Reference Instructions
Memory Reference InstructionsMemory Reference Instructions
Memory Reference Instructions
Rabin BK
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086
saurav kumar
 
Computer architecture input output organization
Computer architecture input output organizationComputer architecture input output organization
Computer architecture input output organization
Mazin Alwaaly
 
Superscalar & superpipeline processor
Superscalar & superpipeline processorSuperscalar & superpipeline processor
Superscalar & superpipeline processorMuhammad Ishaq
 
Memory Organization
Memory OrganizationMemory Organization
Memory Organization
Kamal Acharya
 
Stack organization
Stack organizationStack organization
Stack organization
chauhankapil
 
Interrupts and types of interrupts
Interrupts and types of interruptsInterrupts and types of interrupts
Interrupts and types of interrupts
Muhammad Sheharyar Asif
 
Computer architecture register transfer languages rtl
Computer architecture register transfer languages rtlComputer architecture register transfer languages rtl
Computer architecture register transfer languages rtl
Mazin Alwaaly
 
Timing and control
Timing and controlTiming and control
Timing and control
chauhankapil
 
Input Output Organization
Input Output OrganizationInput Output Organization
Input Output Organization
Kamal Acharya
 
Parallel processing
Parallel processingParallel processing
Parallel processing
rajshreemuthiah
 

What's hot (20)

Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1) Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1)
 
Computer Organization and Architecture.
Computer Organization and Architecture.Computer Organization and Architecture.
Computer Organization and Architecture.
 
Memory organization (Computer architecture)
Memory organization (Computer architecture)Memory organization (Computer architecture)
Memory organization (Computer architecture)
 
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
 
Signed Addition And Subtraction
Signed Addition And SubtractionSigned Addition And Subtraction
Signed Addition And Subtraction
 
Basic MIPS implementation
Basic MIPS implementationBasic MIPS implementation
Basic MIPS implementation
 
Instruction format
Instruction formatInstruction format
Instruction format
 
CISC & RISC Architecture
CISC & RISC Architecture CISC & RISC Architecture
CISC & RISC Architecture
 
Memory Reference Instructions
Memory Reference InstructionsMemory Reference Instructions
Memory Reference Instructions
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086
 
Computer architecture input output organization
Computer architecture input output organizationComputer architecture input output organization
Computer architecture input output organization
 
Superscalar & superpipeline processor
Superscalar & superpipeline processorSuperscalar & superpipeline processor
Superscalar & superpipeline processor
 
Memory Organization
Memory OrganizationMemory Organization
Memory Organization
 
Instruction cycle
Instruction cycleInstruction cycle
Instruction cycle
 
Stack organization
Stack organizationStack organization
Stack organization
 
Interrupts and types of interrupts
Interrupts and types of interruptsInterrupts and types of interrupts
Interrupts and types of interrupts
 
Computer architecture register transfer languages rtl
Computer architecture register transfer languages rtlComputer architecture register transfer languages rtl
Computer architecture register transfer languages rtl
 
Timing and control
Timing and controlTiming and control
Timing and control
 
Input Output Organization
Input Output OrganizationInput Output Organization
Input Output Organization
 
Parallel processing
Parallel processingParallel processing
Parallel processing
 

Similar to Pipeline hazard

Assembly p1
Assembly p1Assembly p1
Assembly p1
raja khizar
 
CPU Pipelining and Hazards - An Introduction
CPU Pipelining and Hazards - An IntroductionCPU Pipelining and Hazards - An Introduction
CPU Pipelining and Hazards - An Introduction
Dilum Bandara
 
Topic2a ss pipelines
Topic2a ss pipelinesTopic2a ss pipelines
Topic2a ss pipelines
turki_09
 
Pipelining
PipeliningPipelining
Pipelining
Shubham Bammi
 
Pipelining in computer architecture
Pipelining in computer architecturePipelining in computer architecture
Pipelining in computer architecture
Ramakrishna Reddy Bijjam
 
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
arasanlethers
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
ssuser87fa0c1
 
L4 speeding-up-execution
L4 speeding-up-executionL4 speeding-up-execution
L4 speeding-up-execution
rsamurti
 
Pipeline and data hazard
Pipeline and data hazardPipeline and data hazard
Pipeline and data hazardWaed Shagareen
 
3 Pipelining
3 Pipelining3 Pipelining
3 Pipelining
fika sweety
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer Architecture
Subhasis Dash
 
Pipeline & Nonpipeline Processor
Pipeline & Nonpipeline ProcessorPipeline & Nonpipeline Processor
Pipeline & Nonpipeline Processor
Smit Shah
 
Instruction Level Parallelism – Compiler Techniques
Instruction Level Parallelism – Compiler TechniquesInstruction Level Parallelism – Compiler Techniques
Instruction Level Parallelism – Compiler Techniques
Dilum Bandara
 
Ct213 processor design_pipelinehazard
Ct213 processor design_pipelinehazardCt213 processor design_pipelinehazard
Ct213 processor design_pipelinehazardrakeshrakesh2020
 
Concept of Pipelining
Concept of PipeliningConcept of Pipelining
Concept of Pipelining
SHAKOOR AB
 
Instruction pipelining
Instruction pipeliningInstruction pipelining
Instruction pipelining
Shoaib Commando
 
Pipelining in Computer System Achitecture
Pipelining in Computer System AchitecturePipelining in Computer System Achitecture
Pipelining in Computer System Achitecture
YashiUpadhyay3
 
pipelining
pipeliningpipelining
pipelining
sudhir saurav
 
Pipelining 16 computers Artitacher pdf
Pipelining   16 computers Artitacher  pdfPipelining   16 computers Artitacher  pdf
Pipelining 16 computers Artitacher pdf
MadhuGupta99385
 

Similar to Pipeline hazard (20)

Assembly p1
Assembly p1Assembly p1
Assembly p1
 
CPU Pipelining and Hazards - An Introduction
CPU Pipelining and Hazards - An IntroductionCPU Pipelining and Hazards - An Introduction
CPU Pipelining and Hazards - An Introduction
 
Topic2a ss pipelines
Topic2a ss pipelinesTopic2a ss pipelines
Topic2a ss pipelines
 
Pipelining
PipeliningPipelining
Pipelining
 
Pipelining in computer architecture
Pipelining in computer architecturePipelining in computer architecture
Pipelining in computer architecture
 
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
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
L4 speeding-up-execution
L4 speeding-up-executionL4 speeding-up-execution
L4 speeding-up-execution
 
Pipeline and data hazard
Pipeline and data hazardPipeline and data hazard
Pipeline and data hazard
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
3 Pipelining
3 Pipelining3 Pipelining
3 Pipelining
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer Architecture
 
Pipeline & Nonpipeline Processor
Pipeline & Nonpipeline ProcessorPipeline & Nonpipeline Processor
Pipeline & Nonpipeline Processor
 
Instruction Level Parallelism – Compiler Techniques
Instruction Level Parallelism – Compiler TechniquesInstruction Level Parallelism – Compiler Techniques
Instruction Level Parallelism – Compiler Techniques
 
Ct213 processor design_pipelinehazard
Ct213 processor design_pipelinehazardCt213 processor design_pipelinehazard
Ct213 processor design_pipelinehazard
 
Concept of Pipelining
Concept of PipeliningConcept of Pipelining
Concept of Pipelining
 
Instruction pipelining
Instruction pipeliningInstruction pipelining
Instruction pipelining
 
Pipelining in Computer System Achitecture
Pipelining in Computer System AchitecturePipelining in Computer System Achitecture
Pipelining in Computer System Achitecture
 
pipelining
pipeliningpipelining
pipelining
 
Pipelining 16 computers Artitacher pdf
Pipelining   16 computers Artitacher  pdfPipelining   16 computers Artitacher  pdf
Pipelining 16 computers Artitacher pdf
 

More from AJAL A J

KEAM KERALA ENTRANCE EXAM
KEAM KERALA ENTRANCE EXAMKEAM KERALA ENTRANCE EXAM
KEAM KERALA ENTRANCE EXAM
AJAL A J
 
Paleontology Career
Paleontology  CareerPaleontology  Career
Paleontology Career
AJAL A J
 
CHEMISTRY basic concepts of chemistry
CHEMISTRY  basic concepts of chemistryCHEMISTRY  basic concepts of chemistry
CHEMISTRY basic concepts of chemistry
AJAL A J
 
Ecology
EcologyEcology
Ecology
AJAL A J
 
Biogeochemical cycles
Biogeochemical cyclesBiogeochemical cycles
Biogeochemical cycles
AJAL A J
 
ac dc bridges
ac dc bridgesac dc bridges
ac dc bridges
AJAL A J
 
Hays bridge schering bridge wien bridge
Hays bridge  schering bridge  wien bridgeHays bridge  schering bridge  wien bridge
Hays bridge schering bridge wien bridge
AJAL A J
 
App Naming Tip
App Naming TipApp Naming Tip
App Naming Tip
AJAL A J
 
flora and fauna of himachal pradesh and kerala
flora and fauna of himachal pradesh and keralaflora and fauna of himachal pradesh and kerala
flora and fauna of himachal pradesh and kerala
AJAL A J
 
B.Sc Cardiovascular Technology(CVT)
 B.Sc Cardiovascular Technology(CVT)  B.Sc Cardiovascular Technology(CVT)
B.Sc Cardiovascular Technology(CVT)
AJAL A J
 
11 business strategies to make profit
11 business strategies to make profit 11 business strategies to make profit
11 business strategies to make profit
AJAL A J
 
PCOS Polycystic Ovary Syndrome
PCOS  Polycystic Ovary SyndromePCOS  Polycystic Ovary Syndrome
PCOS Polycystic Ovary Syndrome
AJAL A J
 
Courses and Career Options after Class 12 in Humanities
Courses and Career Options after Class 12 in HumanitiesCourses and Career Options after Class 12 in Humanities
Courses and Career Options after Class 12 in Humanities
AJAL A J
 
MANAGEMENT Stories
 MANAGEMENT Stories MANAGEMENT Stories
MANAGEMENT Stories
AJAL A J
 
NEET PREPRATION TIPS AND STRATEGY
NEET PREPRATION TIPS AND STRATEGYNEET PREPRATION TIPS AND STRATEGY
NEET PREPRATION TIPS AND STRATEGY
AJAL A J
 
REVOLUTIONS IN AGRICULTURE
REVOLUTIONS IN AGRICULTUREREVOLUTIONS IN AGRICULTURE
REVOLUTIONS IN AGRICULTURE
AJAL A J
 
NRI QUOTA IN NIT'S
NRI QUOTA IN NIT'S NRI QUOTA IN NIT'S
NRI QUOTA IN NIT'S
AJAL A J
 
Subjects to study if you want to work for a charity
Subjects to study if you want to work for a charitySubjects to study if you want to work for a charity
Subjects to study if you want to work for a charity
AJAL A J
 
IIT JEE A KERALA PERSPECTIVE
IIT JEE A KERALA PERSPECTIVE IIT JEE A KERALA PERSPECTIVE
IIT JEE A KERALA PERSPECTIVE
AJAL A J
 
Clat 2020 exam COMPLETE DETAILS
Clat 2020 exam COMPLETE DETAILSClat 2020 exam COMPLETE DETAILS
Clat 2020 exam COMPLETE DETAILS
AJAL A J
 

More from AJAL A J (20)

KEAM KERALA ENTRANCE EXAM
KEAM KERALA ENTRANCE EXAMKEAM KERALA ENTRANCE EXAM
KEAM KERALA ENTRANCE EXAM
 
Paleontology Career
Paleontology  CareerPaleontology  Career
Paleontology Career
 
CHEMISTRY basic concepts of chemistry
CHEMISTRY  basic concepts of chemistryCHEMISTRY  basic concepts of chemistry
CHEMISTRY basic concepts of chemistry
 
Ecology
EcologyEcology
Ecology
 
Biogeochemical cycles
Biogeochemical cyclesBiogeochemical cycles
Biogeochemical cycles
 
ac dc bridges
ac dc bridgesac dc bridges
ac dc bridges
 
Hays bridge schering bridge wien bridge
Hays bridge  schering bridge  wien bridgeHays bridge  schering bridge  wien bridge
Hays bridge schering bridge wien bridge
 
App Naming Tip
App Naming TipApp Naming Tip
App Naming Tip
 
flora and fauna of himachal pradesh and kerala
flora and fauna of himachal pradesh and keralaflora and fauna of himachal pradesh and kerala
flora and fauna of himachal pradesh and kerala
 
B.Sc Cardiovascular Technology(CVT)
 B.Sc Cardiovascular Technology(CVT)  B.Sc Cardiovascular Technology(CVT)
B.Sc Cardiovascular Technology(CVT)
 
11 business strategies to make profit
11 business strategies to make profit 11 business strategies to make profit
11 business strategies to make profit
 
PCOS Polycystic Ovary Syndrome
PCOS  Polycystic Ovary SyndromePCOS  Polycystic Ovary Syndrome
PCOS Polycystic Ovary Syndrome
 
Courses and Career Options after Class 12 in Humanities
Courses and Career Options after Class 12 in HumanitiesCourses and Career Options after Class 12 in Humanities
Courses and Career Options after Class 12 in Humanities
 
MANAGEMENT Stories
 MANAGEMENT Stories MANAGEMENT Stories
MANAGEMENT Stories
 
NEET PREPRATION TIPS AND STRATEGY
NEET PREPRATION TIPS AND STRATEGYNEET PREPRATION TIPS AND STRATEGY
NEET PREPRATION TIPS AND STRATEGY
 
REVOLUTIONS IN AGRICULTURE
REVOLUTIONS IN AGRICULTUREREVOLUTIONS IN AGRICULTURE
REVOLUTIONS IN AGRICULTURE
 
NRI QUOTA IN NIT'S
NRI QUOTA IN NIT'S NRI QUOTA IN NIT'S
NRI QUOTA IN NIT'S
 
Subjects to study if you want to work for a charity
Subjects to study if you want to work for a charitySubjects to study if you want to work for a charity
Subjects to study if you want to work for a charity
 
IIT JEE A KERALA PERSPECTIVE
IIT JEE A KERALA PERSPECTIVE IIT JEE A KERALA PERSPECTIVE
IIT JEE A KERALA PERSPECTIVE
 
Clat 2020 exam COMPLETE DETAILS
Clat 2020 exam COMPLETE DETAILSClat 2020 exam COMPLETE DETAILS
Clat 2020 exam COMPLETE DETAILS
 

Recently uploaded

J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 

Recently uploaded (20)

J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 

Pipeline hazard

  • 1.
  • 2.
  • 4. Pipelining  Break instructions into steps  Work on instructions like in an assembly line  Allows for more instructions to be executed in less time  A n-stage pipeline is n times faster than a non pipeline processor (in theory)
  • 5. 5 What is Pipelining?  Like an Automobile Assembly Line for Instructions  Each step does a little job of processing the instruction  Ideally each step operates in parallel  Simple Model  Instruction Fetch  Instruction Decode  Instruction Execute F1 D1 E1 F2 D2 E2 F3 D3 E3
  • 6. pipeline  It is technique of decomposing a sequential process into suboperation, with each suboperation completed in dedicated segment.  Pipeline is commonly known as an assembly line operation.  It is similar like assembly line of car manufacturing.  First station in an assembly line set up a chasis, next station is installing the engine, another group of workers fitting the body.
  • 7. Pipeline Stages We can divide the execution of an instruction into the following 5 “classic” stages: IF: Instruction Fetch ID: Instruction Decode, register fetch EX: Execution MEM: Memory Access WB: Register write Back
  • 8. RISC Pipeline Stages  Fetch instruction  Decode instruction  Execute instruction  Access operand  Write result  Note: Slight variations depending on processor
  • 9. Without Pipelining Instr 1 Instr 2 Clock Cycle 1 2 3 4 5 6 7 8 9 10 • Normally, you would perform the fetch, decode, execute, operate, and write steps of an instruction and then move on to the next instruction
  • 10. With Pipelining Clock Cycle 1 2 3 4 5 6 7 8 9 Instr 1 Instr 2 Instr 3 Instr 4 Instr 5 • The processor is able to perform each stage simultaneously. • If the processor is decoding an instruction, it may also fetch another instruction at the same time.
  • 11. Pipeline (cont.)  Length of pipeline depends on the longest step  Thus in RISC, all instructions were made to be the same length  Each stage takes 1 clock cycle  In theory, an instruction should be finished each clock cycle
  • 12. Stages of Execution in Pipelined MIPS 5 stage instruction pipeline 1) I-fetch: Fetch Instruction, Increment PC 2) Decode: Instruction, Read Registers 3) Execute: Mem-reference: Calculate Address R-format: Perform ALU Operation 4) Memory: Load: Read Data from Data Memory Store: Write Data to Data Memory 5) Write Back: Write Data to Register
  • 13. Pipelined Execution Representation  To simplify pipeline, every instruction takes same number of steps, called stages  One clock cycle per stage IFtch Dcd Exec Mem WB IFtch Dcd Exec Mem WB IFtch Dcd Exec Mem WB IFtch Dcd Exec Mem WB IFtch Dcd Exec Mem WB Program Flow
  • 14. Pipeline Problem  Problem: An instruction may need to wait for the result of another instruction
  • 15. Pipeline Solution :  Solution: Compiler may recognize which instructions are dependent or independent of the current instruction, and rearrange them to run the independent one first
  • 16. How to make pipelines faster  Superpipelining  Divide the stages of pipelining into more stages  Ex: Split “fetch instruction” stage into two stages Super duper pipelining Super scalar pipelining  Run multiple pipelines in parallel Automated consolidation of data from many sources,
  • 17. Dynamic pipeline  Dynamic pipeline: Uses buffers to hold instruction bits in case a dependent instruction stalls
  • 18. Pipelining Lessons  Pipelining doesn’t help latency (execution time) of single task, it helps throughput of entire workload  Multiple tasks operating simultaneously using different resources  Po te ntialspeedup = Number of pipe stages  Time to “fill” pipeline and time to “drain” it reduces speedup  Pipeline rate limited by slowest pipeline stage  Unbalanced lengths of pipe stages also reduces speedup
  • 19. Performance limitations  Imbalance among pipe stages  limits cycle time to slowest stage  Pipelining overhead  Pipeline register delay  Clock skew  Clock cycle > clock skew + latch overhead  Hazards
  • 20.
  • 21. Pipeline Hazards There are situations, called hazards, that prevent the next instruction in the instruction stream from executing during its designated cycle There are three classes of hazards Structural hazard Data hazard Branch hazard  Structural Hazards. They arise from resource conflicts when the hardware cannot support all possible combinations of instructions in simultaneous overlapped execution.   Data Hazards. They arise when an instruction depends on the result of a previous instruction in a way that is exposed by the overlapping of instructions in the pipeline.   Control Hazards.They arise from the pipelining of branches and other instructions that change the PC.
  • 22. 22 What Makes Pipelining Hard? Power failing, Arithmetic overflow, I/O device request, OS call, Page fault
  • 23. Pipeline Hazards Structural hazard Resource conflicts when the hardware cannot support all possible combination of instructions simultaneously Data hazard An instruction depends on the results of a previous instruction Branch hazard Instructions that change the PC
  • 24. Structural hazard Some pipeline processors have shared a single- memory pipeline for data and instructions
  • 25. M Single Memory is a Structural Hazard Load Instr 1 Instr 2 Instr 3 Instr 4 ALU M Reg M Reg ALU M Reg M Reg ALU M Reg M Reg ALU Reg M Reg ALU M Reg M Reg • Can’t read same memory twice in same clock cycle I n s t r. O r d e r Time (clock cycles)
  • 26. Structural hazard Memory data fetch requires on FI and FO Fetch Instruction (FI) Fetch Operand (FO) Decode Instruction (DI) Write Operand (WO) Execution Instruction (EI) S3 S4S1 S2 S5 1 2 3 4 98765S1 S2 S5 S3 S4 1 2 3 4 8765 1 2 3 4 765 1 2 3 4 65 1 2 3 4 5 Time
  • 27. Structural hazard To solve this hazard, we “stall” the pipeline until the resource is freed A stall is commonly called pipeline bubble, since it floats through the pipeline taking space but carry no useful work
  • 28. Structural Hazards limit performance  Example: if 1.3 memory accesses per instruction (30% of instructions execute loads and stores) and only one memory access per cycle then  Average CPI ≥ 1.3  Otherwise datapath resource is more than 100% utilized Structural Hazard Solution: Add more Hardware
  • 30. Data hazard Example: ADD R1R2+R3 SUB R4R1-R5 AND R6R1 AND R7 OR R8R1 OR R9 XOR R10R1 XOR R11
  • 31. Data hazard FO: fetch data value WO: store the executed value Fetch Instruction (FI) Fetch Operand (FO) Decode Instruction (DI) Write Operand (WO) Execution Instruction (EI) S3 S4S1 S2 S5 Time
  • 32. Data hazard Delay load approach inserts a no-operation instruction to avoid the data conflict ADD R1R2+R3 No-op No-op SUB R4R1-R5 AND R6R1 AND R7 OR R8R1 OR R9 XOR R10R1 XOR R11
  • 34. Data hazard It can be further solved by a simple hardware technique called forwarding (also called bypassing or short-circuiting) The insight in forwarding is that the result is not really needed by SUB until the ADD execute completely If the forwarding hardware detects that the previous ALU operation has written the register corresponding to a source for the current ALU operation, control logic selects the results in ALU instead of from memory
  • 36. 36 Data Hazard Classification Three types of data hazards RAW : Read After Write WAW : Write After Write WAR : Write After Read • RAR : Read After Read – Is this a hazard?
  • 37. Read After Write (RAW) A read after write (RAW) data hazard refers to a situation where an instruction refers to a result that has not yet been calculated or retrieved. This can occur because even though an instruction is executed after a previous instruction, the previous instruction has not been completely processed through the pipeline. example: i1.  R2  <- R1 + R3 i2. R4 <-  R2 + R3
  • 38. Write After Read (WAR) A write after read (WAR) data hazard represents a problem with concurrent execution. For example: i1. R4 <- R1 + R5 i2.  R5 <- R1 + R2
  • 39. Write After Write (WAW A write after write (WAW) data hazard may occur in a concurrent execution environment. example: i1.  R2 <- R4 + R7 i2.  R2 <- R1 + R3 We must delay the WB (Write Back) of i2 until the execution of i1
  • 40. Branch hazards Branch hazards can cause a greater performance loss for pipelines When a branch instruction is executed, it may or may not change the PC If a branch changes the PC to its target address, it is a taken branch Otherwise, it is untaken
  • 41. Branch hazards There are FOUR schemes to handle branch hazards Freeze scheme Predict-untaken scheme Predict-taken scheme Delayed branch
  • 43. Branch Untaken (Freeze approach) The simplest method of dealing with branches is to redo the fetch following a branch Fetch Instruction (FI) Fetch Operand (FO) Decode Instruction (DI) Write Operand (WO) Execution Instruction (EI)
  • 44. Branch Taken (Freeze approach) The simplest method of dealing with branches is to redo the fetch following a branch Fetch Instruction (FI) Fetch Operand (FO) Decode Instruction (DI) Write Operand (WO) Execution Instruction (EI)
  • 45. Branch Taken (Freeze approach) The simplest scheme to handle branches is to freeze the pipeline holding or deleting any instructions after the branch until the branch destination is known The attractiveness of this solution lies primarily in its simplicity both for hardware and software
  • 46. Branch Hazards (Predicted-untaken) A higher performance, and only slightly more complex, scheme is to treat every branch as not taken It is implemented by continuing to fetch instructions as if the branch were normal instruction The pipeline looks the same if the branch is not taken If the branch is taken, we need to redo the fetch instruction
  • 49. Branch Taken (Predicted-taken) An alternative scheme is to treat every branch as taken As soon as the branch is decoded and the target address is computed, we assume the branch to be taken and begin fetching and executing the target
  • 52. Delayed Branch A fourth scheme in use in some processors is called delayed branch It is done in compiler time. It modifies the code The general format is: branch instruction Delay slot branch target if taken
  • 54. Delayed Branch If the optimal is not available: (b) Act like predict-taken (in complier way) (c) Act like predict-untaken (in complier way)
  • 55. Delayed Branch Delayed Branch is limited by (1) the restrictions on the instructions that are scheduled into the delay slots (for example: another branch cannot be scheduled) (2) our ability to predict at compile time whether a branch is likely to be taken or not
  • 56. Branch Prediction A pipeline with branch prediction uses some additional logic to guess the outcome of a conditional branch instruction before it is executed
  • 57. Branch Prediction Various techniques can be used to predict whether a branch will be taken or not: Prediction never taken Prediction always taken Prediction by opcode Branch history table The first three approaches are static: they do not depend on the execution history up to the time of the conditional branch instruction. The last approach is dynamic: they depend on the execution history.
  • 58. 58 Important Pipeline Characteristics  Latency  Time required for an instruction to propagate through the pipeline  Based on the Number of Stages * Cycle Time  Dominant if there are lots of exceptions / hazards, i.e. we have to constantly be re-filling the pipeline  Throughput  The rate at which instructions can start and finish  Dominant if there are few exceptions and hazards, i.e. the pipeline stays mostly full  Note we need an increased memory bandwidth over the non-pipelined processor
  • 59. 59 Exceptions  An exception is when the normal execution order of instructions is changed. This has many names:  Interrupt  Fault  Exception  Examples:  I/O device request  Invoking OS service  Page Fault  Malfunction  Undefined instruction  Overflow/Arithmetic Anomaly  Etc!
  • 60. Eliminating hazards- Pipeline bubbling  Bubbling the pipe line , also known as a pipe line bre ak or a pipe line stall, is a method for preventing data, structural, and branch hazards from occurring.   instructions are fetched, control logic determines whether a hazard could/will occur. If this is true, then the control logic inserts  NOPs into the pipeline. Thus, before the next instruction (which would cause the hazard) is executed, the previous one will have had sufficient time to complete and prevent the
  • 61. No: of NOPs = stages in pipeline  If the number of NOPs is equal to the number of stages in the pipeline, the processor has been cleared of all instructions and can proceed free from hazards. All forms of stalling introduce a delay before the processor can resume execution.