Pipeline hazard

AJAL A J
AJAL A JASST PROF at FISAT em FISAT
Pipeline hazard
Pipeline hazard
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 hazard
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.
1 de 61

Recomendados

pipelining por
pipeliningpipelining
pipeliningSiddique Ibrahim
83K visualizações78 slides
Computer architecture pipelining por
Computer architecture pipeliningComputer architecture pipelining
Computer architecture pipeliningMazin Alwaaly
17K visualizações38 slides
Instruction pipeline: Computer Architecture por
Instruction pipeline: Computer ArchitectureInstruction pipeline: Computer Architecture
Instruction pipeline: Computer ArchitectureMd. Saidur Rahman Kohinoor
56.9K visualizações21 slides
Pipeline hazards in computer Architecture ppt por
Pipeline hazards in computer Architecture pptPipeline hazards in computer Architecture ppt
Pipeline hazards in computer Architecture pptmali yogesh kumar
20.9K visualizações94 slides
Flynns classification por
Flynns classificationFlynns classification
Flynns classificationYasir Khan
82.5K visualizações10 slides
CISC & RISC Architecture por
CISC & RISC Architecture CISC & RISC Architecture
CISC & RISC Architecture Suvendu Kumar Dash
27.6K visualizações42 slides

Mais conteúdo relacionado

Mais procurados

Cache memory por
Cache memoryCache memory
Cache memoryAnuj Modi
55.2K visualizações18 slides
Instruction pipelining por
Instruction pipeliningInstruction pipelining
Instruction pipeliningTech_MX
55K visualizações32 slides
Pipelining por
PipeliningPipelining
Pipeliningsarith divakar
2.3K visualizações31 slides
Interfacing memory with 8086 microprocessor por
Interfacing memory with 8086 microprocessorInterfacing memory with 8086 microprocessor
Interfacing memory with 8086 microprocessorVikas Gupta
116.9K visualizações29 slides
Computer Organization and Architecture. por
Computer Organization and Architecture.Computer Organization and Architecture.
Computer Organization and Architecture.CS_GDRCST
22.8K visualizações48 slides
VLIW Processors por
VLIW ProcessorsVLIW Processors
VLIW ProcessorsSudhanshu Janwadkar
44.7K visualizações20 slides

Mais procurados(20)

Cache memory por Anuj Modi
Cache memoryCache memory
Cache memory
Anuj Modi55.2K visualizações
Instruction pipelining por Tech_MX
Instruction pipeliningInstruction pipelining
Instruction pipelining
Tech_MX55K visualizações
Pipelining por sarith divakar
PipeliningPipelining
Pipelining
sarith divakar2.3K visualizações
Interfacing memory with 8086 microprocessor por Vikas Gupta
Interfacing memory with 8086 microprocessorInterfacing memory with 8086 microprocessor
Interfacing memory with 8086 microprocessor
Vikas Gupta116.9K visualizações
Computer Organization and Architecture. por CS_GDRCST
Computer Organization and Architecture.Computer Organization and Architecture.
Computer Organization and Architecture.
CS_GDRCST22.8K visualizações
VLIW Processors por Sudhanshu Janwadkar
VLIW ProcessorsVLIW Processors
VLIW Processors
Sudhanshu Janwadkar44.7K visualizações
Control Unit Design por Vinit Raut
Control Unit DesignControl Unit Design
Control Unit Design
Vinit Raut14K visualizações
Computer architecture and organization por Tushar B Kute
Computer architecture and organizationComputer architecture and organization
Computer architecture and organization
Tushar B Kute28.2K visualizações
Computer instructions por Anuj Modi
Computer instructionsComputer instructions
Computer instructions
Anuj Modi31.6K visualizações
Micro program example por rajshreemuthiah
Micro program exampleMicro program example
Micro program example
rajshreemuthiah16K visualizações
Parallel processing por rajshreemuthiah
Parallel processingParallel processing
Parallel processing
rajshreemuthiah8.3K visualizações
Microprogrammed Control Unit por PreethiSureshkumar1
Microprogrammed Control UnitMicroprogrammed Control Unit
Microprogrammed Control Unit
PreethiSureshkumar119.4K visualizações
Computer architecture virtual memory por Mazin Alwaaly
Computer architecture virtual memoryComputer architecture virtual memory
Computer architecture virtual memory
Mazin Alwaaly11.3K visualizações
Superscalar & superpipeline processor por Muhammad Ishaq
Superscalar & superpipeline processorSuperscalar & superpipeline processor
Superscalar & superpipeline processor
Muhammad Ishaq78.3K visualizações
Multi Head, Multi Tape Turing Machine por Radhakrishnan Chinnusamy
Multi Head, Multi Tape Turing MachineMulti Head, Multi Tape Turing Machine
Multi Head, Multi Tape Turing Machine
Radhakrishnan Chinnusamy12.4K visualizações
Microprogram Control por Anuj Modi
Microprogram Control Microprogram Control
Microprogram Control
Anuj Modi54.2K visualizações
Parallel processing por Syed Zaid Irshad
Parallel processingParallel processing
Parallel processing
Syed Zaid Irshad1.8K visualizações
Computer Organisation & Architecture (chapter 1) por Subhasis Dash
Computer Organisation & Architecture (chapter 1) Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1)
Subhasis Dash2.3K visualizações
Demand paging por Trinity Dwarka
Demand pagingDemand paging
Demand paging
Trinity Dwarka22.8K visualizações

Similar a Pipeline hazard

Assembly p1 por
Assembly p1Assembly p1
Assembly p1raja khizar
168 visualizações41 slides
Topic2a ss pipelines por
Topic2a ss pipelinesTopic2a ss pipelines
Topic2a ss pipelinesturki_09
948 visualizações54 slides
Pipelining por
PipeliningPipelining
PipeliningShubham Bammi
857 visualizações30 slides
Pipelining in computer architecture por
Pipelining in computer architecturePipelining in computer architecture
Pipelining in computer architectureRamakrishna Reddy Bijjam
1.1K visualizações78 slides
L4 speeding-up-execution por
L4 speeding-up-executionL4 speeding-up-execution
L4 speeding-up-executionrsamurti
737 visualizações8 slides
Pipeline and data hazard por
Pipeline and data hazardPipeline and data hazard
Pipeline and data hazardWaed Shagareen
20.5K visualizações18 slides

Similar a Pipeline hazard(20)

Assembly p1 por raja khizar
Assembly p1Assembly p1
Assembly p1
raja khizar168 visualizações
Topic2a ss pipelines por turki_09
Topic2a ss pipelinesTopic2a ss pipelines
Topic2a ss pipelines
turki_09948 visualizações
Pipelining por Shubham Bammi
PipeliningPipelining
Pipelining
Shubham Bammi857 visualizações
L4 speeding-up-execution por rsamurti
L4 speeding-up-executionL4 speeding-up-execution
L4 speeding-up-execution
rsamurti737 visualizações
Pipeline and data hazard por Waed Shagareen
Pipeline and data hazardPipeline and data hazard
Pipeline and data hazard
Waed Shagareen20.5K visualizações
Chapter 4 por ececourse
Chapter 4Chapter 4
Chapter 4
ececourse2.8K visualizações
3 Pipelining por fika sweety
3 Pipelining3 Pipelining
3 Pipelining
fika sweety4K visualizações
High Performance Computer Architecture por Subhasis Dash
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer Architecture
Subhasis Dash268 visualizações
Pipeline & Nonpipeline Processor por Smit Shah
Pipeline & Nonpipeline ProcessorPipeline & Nonpipeline Processor
Pipeline & Nonpipeline Processor
Smit Shah625 visualizações
Ct213 processor design_pipelinehazard por rakeshrakesh2020
Ct213 processor design_pipelinehazardCt213 processor design_pipelinehazard
Ct213 processor design_pipelinehazard
rakeshrakesh20201.6K visualizações
Concept of Pipelining por SHAKOOR AB
Concept of PipeliningConcept of Pipelining
Concept of Pipelining
SHAKOOR AB7.5K visualizações
Instruction pipelining por Shoaib Commando
Instruction pipeliningInstruction pipelining
Instruction pipelining
Shoaib Commando1.3K visualizações
Pipelining in Computer System Achitecture por YashiUpadhyay3
Pipelining in Computer System AchitecturePipelining in Computer System Achitecture
Pipelining in Computer System Achitecture
YashiUpadhyay3188 visualizações
pipelining por sudhir saurav
pipeliningpipelining
pipelining
sudhir saurav11.3K visualizações
Core pipelining por Ibrahim Hassan
Core pipelining Core pipelining
Core pipelining
Ibrahim Hassan22 visualizações
Arch 1112-6 por Hector Sanjuan
Arch 1112-6Arch 1112-6
Arch 1112-6
Hector Sanjuan581 visualizações
Chapter 3 por Rozase Patel
Chapter 3Chapter 3
Chapter 3
Rozase Patel148 visualizações
Bc0040 por hayerpa
Bc0040Bc0040
Bc0040
hayerpa430 visualizações
Pipelining And Vector Processing por TheInnocentTuber
Pipelining And Vector ProcessingPipelining And Vector Processing
Pipelining And Vector Processing
TheInnocentTuber16 visualizações

Mais de AJAL A J

KEAM KERALA ENTRANCE EXAM por
KEAM KERALA ENTRANCE EXAMKEAM KERALA ENTRANCE EXAM
KEAM KERALA ENTRANCE EXAMAJAL A J
711 visualizações60 slides
Paleontology Career por
Paleontology  CareerPaleontology  Career
Paleontology CareerAJAL A J
177 visualizações15 slides
CHEMISTRY basic concepts of chemistry por
CHEMISTRY  basic concepts of chemistryCHEMISTRY  basic concepts of chemistry
CHEMISTRY basic concepts of chemistryAJAL A J
4.2K visualizações28 slides
Ecology por
EcologyEcology
EcologyAJAL A J
266 visualizações39 slides
Biogeochemical cycles por
Biogeochemical cyclesBiogeochemical cycles
Biogeochemical cyclesAJAL A J
275 visualizações10 slides
ac dc bridges por
ac dc bridgesac dc bridges
ac dc bridgesAJAL A J
732 visualizações45 slides

Mais de AJAL A J(20)

KEAM KERALA ENTRANCE EXAM por AJAL A J
KEAM KERALA ENTRANCE EXAMKEAM KERALA ENTRANCE EXAM
KEAM KERALA ENTRANCE EXAM
AJAL A J711 visualizações
Paleontology Career por AJAL A J
Paleontology  CareerPaleontology  Career
Paleontology Career
AJAL A J177 visualizações
CHEMISTRY basic concepts of chemistry por AJAL A J
CHEMISTRY  basic concepts of chemistryCHEMISTRY  basic concepts of chemistry
CHEMISTRY basic concepts of chemistry
AJAL A J4.2K visualizações
Ecology por AJAL A J
EcologyEcology
Ecology
AJAL A J266 visualizações
Biogeochemical cycles por AJAL A J
Biogeochemical cyclesBiogeochemical cycles
Biogeochemical cycles
AJAL A J275 visualizações
ac dc bridges por AJAL A J
ac dc bridgesac dc bridges
ac dc bridges
AJAL A J732 visualizações
Hays bridge schering bridge wien bridge por AJAL A J
Hays bridge  schering bridge  wien bridgeHays bridge  schering bridge  wien bridge
Hays bridge schering bridge wien bridge
AJAL A J252 visualizações
App Naming Tip por AJAL A J
App Naming TipApp Naming Tip
App Naming Tip
AJAL A J165 visualizações
flora and fauna of himachal pradesh and kerala por AJAL A J
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 J9.8K visualizações
B.Sc Cardiovascular Technology(CVT) por AJAL A J
 B.Sc Cardiovascular Technology(CVT)  B.Sc Cardiovascular Technology(CVT)
B.Sc Cardiovascular Technology(CVT)
AJAL A J706 visualizações
11 business strategies to make profit por AJAL A J
11 business strategies to make profit 11 business strategies to make profit
11 business strategies to make profit
AJAL A J260 visualizações
PCOS Polycystic Ovary Syndrome por AJAL A J
PCOS  Polycystic Ovary SyndromePCOS  Polycystic Ovary Syndrome
PCOS Polycystic Ovary Syndrome
AJAL A J852 visualizações
Courses and Career Options after Class 12 in Humanities por AJAL A J
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 J1.1K visualizações
MANAGEMENT Stories por AJAL A J
 MANAGEMENT Stories MANAGEMENT Stories
MANAGEMENT Stories
AJAL A J133 visualizações
NEET PREPRATION TIPS AND STRATEGY por AJAL A J
NEET PREPRATION TIPS AND STRATEGYNEET PREPRATION TIPS AND STRATEGY
NEET PREPRATION TIPS AND STRATEGY
AJAL A J902 visualizações
REVOLUTIONS IN AGRICULTURE por AJAL A J
REVOLUTIONS IN AGRICULTUREREVOLUTIONS IN AGRICULTURE
REVOLUTIONS IN AGRICULTURE
AJAL A J156 visualizações
NRI QUOTA IN NIT'S por AJAL A J
NRI QUOTA IN NIT'S NRI QUOTA IN NIT'S
NRI QUOTA IN NIT'S
AJAL A J377 visualizações
Subjects to study if you want to work for a charity por AJAL A J
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 J167 visualizações
IIT JEE A KERALA PERSPECTIVE por AJAL A J
IIT JEE A KERALA PERSPECTIVE IIT JEE A KERALA PERSPECTIVE
IIT JEE A KERALA PERSPECTIVE
AJAL A J77 visualizações
Clat 2020 exam COMPLETE DETAILS por AJAL A J
Clat 2020 exam COMPLETE DETAILSClat 2020 exam COMPLETE DETAILS
Clat 2020 exam COMPLETE DETAILS
AJAL A J149 visualizações

Último

fakenews_DBDA_Mar23.pptx por
fakenews_DBDA_Mar23.pptxfakenews_DBDA_Mar23.pptx
fakenews_DBDA_Mar23.pptxdeepmitra8
14 visualizações34 slides
SPICE PARK DEC2023 (6,625 SPICE Models) por
SPICE PARK DEC2023 (6,625 SPICE Models) SPICE PARK DEC2023 (6,625 SPICE Models)
SPICE PARK DEC2023 (6,625 SPICE Models) Tsuyoshi Horigome
24 visualizações218 slides
K8S Roadmap.pdf por
K8S Roadmap.pdfK8S Roadmap.pdf
K8S Roadmap.pdfMaryamTavakkoli2
6 visualizações1 slide
Machine Element II Course outline.pdf por
Machine Element II Course outline.pdfMachine Element II Course outline.pdf
Machine Element II Course outline.pdfodatadese1
9 visualizações2 slides
Searching in Data Structure por
Searching in Data StructureSearching in Data Structure
Searching in Data Structureraghavbirla63
7 visualizações8 slides
Saikat Chakraborty Java Oracle Certificate.pdf por
Saikat Chakraborty Java Oracle Certificate.pdfSaikat Chakraborty Java Oracle Certificate.pdf
Saikat Chakraborty Java Oracle Certificate.pdfSaikatChakraborty787148
15 visualizações1 slide

Último(20)

fakenews_DBDA_Mar23.pptx por deepmitra8
fakenews_DBDA_Mar23.pptxfakenews_DBDA_Mar23.pptx
fakenews_DBDA_Mar23.pptx
deepmitra814 visualizações
SPICE PARK DEC2023 (6,625 SPICE Models) por Tsuyoshi Horigome
SPICE PARK DEC2023 (6,625 SPICE Models) SPICE PARK DEC2023 (6,625 SPICE Models)
SPICE PARK DEC2023 (6,625 SPICE Models)
Tsuyoshi Horigome24 visualizações
K8S Roadmap.pdf por MaryamTavakkoli2
K8S Roadmap.pdfK8S Roadmap.pdf
K8S Roadmap.pdf
MaryamTavakkoli26 visualizações
Machine Element II Course outline.pdf por odatadese1
Machine Element II Course outline.pdfMachine Element II Course outline.pdf
Machine Element II Course outline.pdf
odatadese19 visualizações
Searching in Data Structure por raghavbirla63
Searching in Data StructureSearching in Data Structure
Searching in Data Structure
raghavbirla637 visualizações
Saikat Chakraborty Java Oracle Certificate.pdf por SaikatChakraborty787148
Saikat Chakraborty Java Oracle Certificate.pdfSaikat Chakraborty Java Oracle Certificate.pdf
Saikat Chakraborty Java Oracle Certificate.pdf
SaikatChakraborty78714815 visualizações
SNMPx por Amatullahbutt
SNMPxSNMPx
SNMPx
Amatullahbutt17 visualizações
DevOps-ITverse-2023-IIT-DU.pptx por Anowar Hossain
DevOps-ITverse-2023-IIT-DU.pptxDevOps-ITverse-2023-IIT-DU.pptx
DevOps-ITverse-2023-IIT-DU.pptx
Anowar Hossain9 visualizações
Introduction to CAD-CAM.pptx por suyogpatil49
Introduction to CAD-CAM.pptxIntroduction to CAD-CAM.pptx
Introduction to CAD-CAM.pptx
suyogpatil495 visualizações
MSA Website Slideshow (16).pdf por msaucla
MSA Website Slideshow (16).pdfMSA Website Slideshow (16).pdf
MSA Website Slideshow (16).pdf
msaucla68 visualizações
MK__Cert.pdf por Hassan Khan
MK__Cert.pdfMK__Cert.pdf
MK__Cert.pdf
Hassan Khan10 visualizações
Investor Presentation por eser sevinç
Investor PresentationInvestor Presentation
Investor Presentation
eser sevinç25 visualizações
2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx por lwang78
2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx
2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx
lwang7853 visualizações
Update 42 models(Diode/General ) in SPICE PARK(DEC2023) por Tsuyoshi Horigome
Update 42 models(Diode/General ) in SPICE PARK(DEC2023)Update 42 models(Diode/General ) in SPICE PARK(DEC2023)
Update 42 models(Diode/General ) in SPICE PARK(DEC2023)
Tsuyoshi Horigome28 visualizações
START Newsletter 3 por Start Project
START Newsletter 3START Newsletter 3
START Newsletter 3
Start Project5 visualizações
_MAKRIADI-FOTEINI_diploma thesis.pptx por fotinimakriadi
_MAKRIADI-FOTEINI_diploma thesis.pptx_MAKRIADI-FOTEINI_diploma thesis.pptx
_MAKRIADI-FOTEINI_diploma thesis.pptx
fotinimakriadi8 visualizações
DevOps to DevSecOps: Enhancing Software Security Throughout The Development L... por Anowar Hossain
DevOps to DevSecOps: Enhancing Software Security Throughout The Development L...DevOps to DevSecOps: Enhancing Software Security Throughout The Development L...
DevOps to DevSecOps: Enhancing Software Security Throughout The Development L...
Anowar Hossain13 visualizações
Codes and Conventions.pptx por IsabellaGraceAnkers
Codes and Conventions.pptxCodes and Conventions.pptx
Codes and Conventions.pptx
IsabellaGraceAnkers8 visualizações

Pipeline hazard

  • 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
  • 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.