SlideShare a Scribd company logo
1 of 17
Lecture 9: Branch Prediction
Basic idea, saturating counter, BHT,
BTB, return address prediction,
correlating prediction

1
Reducing Branch Penalty
Branch penalty in dynamically scheduled processors:
wasted cycles due to pipeline flushing on mispredicted branches
Reduce branch penalty:

1. Predict branch/jump instructions AND branch
direction (taken or not taken)

2. Predict branch/jump target address (for taken
branches)

3. Speculatively execute instructions along the
predicted path

2
What to Use and What to Predict
Available info:



Current predicted PC
Past branch history
(direction and target)

pred_PC

PC

What to predict:






Conditional branch inst:
branch direction and
target address
Jump inst: target
address
Procedure call/return:
target address

May need instruction predecoded

Predictors

IM

PC & Inst

pred info feedback P

C

3
Mis-prediction Detections and Feedbacks
Detections:
At the end of decoding




Target address known at
decoding, and not match
Flush fetch stage

At commit (most cases)




Wrong branch direction or
target address not match
Flush the whole pipeline

(at EXE: MIPS R10000)

Feedbacks:
Any time a mis-prediction is
detected
At a branch’s commit
(at EXE: called speculative update)

FETCH

predictors

RENAME
REB/ROB
SCHD
EXE
WB
COMMIT
4
Branch Direction Prediction
Predict branch direction: taken or not taken
(T/NT)
taken
Not taken

BNE R1, R2, L1
…
L1: …

Static prediction: compilers decide the direction
Dynamic prediction: hardware decides the
direction using dynamic information
1.
2.
3.
4.
5.

1-bit Branch-Prediction Buffer
2-bit Branch-Prediction Buffer
Correlating Branch Prediction Buffer
Tournament Branch Predictor
and more …

5
Predictor for a Single Branch
General Form
1. Access

2. Predict
Output T/NT

state

PC

3. Feedback T/NT

1-bit prediction

Feedback

T
Predict Taken

NT

1

NT
T

0

Predict Taken

6
Branch History Table of 1-bit Predictor
BHT also Called Branch
Prediction Buffer in
textbook
Can use only one 1-bit
predictor, but accuracy is
low
BHT: use a table of simple
predictors, indexed by bits
from PC
Similar to direct mapped
cache
More entries, more cost,
but less conflicts, higher
accuracy
BHT can contain complex
predictors

K-bit

Branch
address

2k
Prediction
Prediction

7
1-bit BHT Weakness
Example: in a loop, 1-bit BHT will cause
2 mispredictions
Consider a loop of 9 iterations before exit:
for (…){
for (i=0; i<9; i++)
a[i] = a[i] * 2.0;
}
 End of loop case, when it exits instead of looping
as before
 First time through loop on next time through
code, when it predicts exit instead of looping
 Only 80% accuracy even if loop 90% of the time

8
2-bit Saturating Counter
Solution: 2-bit scheme where change prediction only if
get misprediction twice: (Figure 3.7, p. 249)
T
Predict Taken

11

NT
T
T

Predict Not
Taken

01

10

Predict Taken

NT
NT
T

00

Predict Not
Taken

NT

Blue: stop, not taken
Gray: go, taken
Adds hysteresis to decision making process
9
Branch Target Buffer
Branch Target Buffer (BTB): Address of branch index to
get prediction AND branch address (if taken)


Note: must check for branch match now, since can’t use wrong
branch address

Example: BTB combined with BHT
Branch PC

Predicted PC

PC of instruction
FETCH
=?
No: branch not
predicted, proceed normally
(Next PC = PC+4)

Extra
Yes: instruction is prediction state
branch and use
bits
predicted PC as
next PC
10
Return Addresses Prediction
Register indirect branch hard to predict
address



Many callers, one callee
Jump to multiple return addresses from a single
address (no PC-target correlation)

SPEC89 85% such branches for procedure
return
Since stack discipline for procedures, save
return address in small buffer that acts like
a stack: 8 to 16 entries has small miss rate
11
Correlating Branches
Code example showing
the potential

Assemble code

If (d==0)
d=1;
If (d==1)
…

BNEZ R1, L1
DADDIU R1,R0,#1
L1: DADDIU R3,R1,#-1
BNEZ R3, L2
L2:
…

Observation: if BNEZ1 is not taken, then BNEZ2
is taken
12
Correlating Branch Predictor
Idea: taken/not taken of
recently executed
branches is related to
behavior of next branch
(as well as the history of
that branch behavior)
 Then behavior of
recent branches
selects between, say, 2
predictions of next
branch, updating just
that prediction
 (1,1) predictor: 1-bit
global, 1-bit local

Branch address (4 bits)
1-bits per branch
local predictors

Prediction
Prediction

1-bit global
branch history
(0 = not taken)
13
Correlating Branch Predictor
General form: (m, n)
predictor
 m bits for global
history, n bits for local
history
 Records correlation
between m+1 branches
 Simple implementation:
global history can be
store in a shift
register
 Example: (2,2)
predictor, 2-bit global,
2-bit local

Branch address (4 bits)
2-bits per branch
local predictors

Prediction
Prediction

2-bit global
branch history
(01 = not taken then taken)
14
Accuracy of Different Schemes
(Figure 3.15, p. 206)
Frequencyofof Mispredictions
Frequency
Mispredictions

20%

4096 Entries 2-bit BHT
Unlimited Entries 2-bit BHT
1024 Entries (2,2) BHT

18%
16%
14%
12%

11%

10%
8%
6%

6%

6%

6%

5%

5%
4%

4%
2%

1%

1%
0%

0%
nasa7

matrix300

tomcatv

doducd

4,096 entries: 2-bits per entry

spice

fpppp

gcc

Unlimited entries: 2-bits/entry

espresso

eqntott

1,024 entries (2,2)

15

li
Estimate Branch Penalty
EX: BHT correct rate
is 95%, BTB hit rate
is 95%
Average miss penalty
is 15 cycles
How much is the
branch penalty?
16
Accuracy of Return Address Predictor

17

More Related Content

What's hot

Microcontroladores: introducción a la programación en lenguaje ensamblador AVR
Microcontroladores: introducción a la programación en lenguaje ensamblador AVRMicrocontroladores: introducción a la programación en lenguaje ensamblador AVR
Microcontroladores: introducción a la programación en lenguaje ensamblador AVRSANTIAGO PABLO ALBERTO
 
VTU 4TH SEM CSE MICROPROCESSORS SOLVED PAPERS OF JUNE-2014 & JUNE-2015
VTU 4TH SEM CSE MICROPROCESSORS SOLVED PAPERS OF JUNE-2014 & JUNE-2015VTU 4TH SEM CSE MICROPROCESSORS SOLVED PAPERS OF JUNE-2014 & JUNE-2015
VTU 4TH SEM CSE MICROPROCESSORS SOLVED PAPERS OF JUNE-2014 & JUNE-2015vtunotesbysree
 
Data flow architecture
Data flow architectureData flow architecture
Data flow architectureSourav Routh
 
Flag registers, addressing modes, instruction set
Flag registers, addressing modes, instruction setFlag registers, addressing modes, instruction set
Flag registers, addressing modes, instruction setaviban
 
Data link control & protocol concepts
Data link control & protocol conceptsData link control & protocol concepts
Data link control & protocol conceptsRaji Lakshmi
 
Data Link Control Protocols
Data Link Control ProtocolsData Link Control Protocols
Data Link Control ProtocolsTechiNerd
 
Microprocessorandmicroconrollermcq3 121116120640-phpapp02
Microprocessorandmicroconrollermcq3 121116120640-phpapp02Microprocessorandmicroconrollermcq3 121116120640-phpapp02
Microprocessorandmicroconrollermcq3 121116120640-phpapp02Yazeed Khalid
 
Microcontroller 8051 1
Microcontroller 8051  1Microcontroller 8051  1
Microcontroller 8051 1khan yaseen
 
PAI Unit 3 Multitasking in 80386
PAI Unit 3 Multitasking in 80386PAI Unit 3 Multitasking in 80386
PAI Unit 3 Multitasking in 80386KanchanPatil34
 
Flag registers (assembly language) with types and examples
Flag registers (assembly language) with types and examplesFlag registers (assembly language) with types and examples
Flag registers (assembly language) with types and examplesComputer_ at_home
 
Computer arithmetic in computer architecture
Computer arithmetic in computer architectureComputer arithmetic in computer architecture
Computer arithmetic in computer architectureishapadhy
 

What's hot (20)

Microcontroladores: introducción a la programación en lenguaje ensamblador AVR
Microcontroladores: introducción a la programación en lenguaje ensamblador AVRMicrocontroladores: introducción a la programación en lenguaje ensamblador AVR
Microcontroladores: introducción a la programación en lenguaje ensamblador AVR
 
VTU 4TH SEM CSE MICROPROCESSORS SOLVED PAPERS OF JUNE-2014 & JUNE-2015
VTU 4TH SEM CSE MICROPROCESSORS SOLVED PAPERS OF JUNE-2014 & JUNE-2015VTU 4TH SEM CSE MICROPROCESSORS SOLVED PAPERS OF JUNE-2014 & JUNE-2015
VTU 4TH SEM CSE MICROPROCESSORS SOLVED PAPERS OF JUNE-2014 & JUNE-2015
 
Arm11
Arm11Arm11
Arm11
 
Data flow architecture
Data flow architectureData flow architecture
Data flow architecture
 
Intel Hex Format
Intel Hex FormatIntel Hex Format
Intel Hex Format
 
Intel IA 64
Intel IA 64Intel IA 64
Intel IA 64
 
Flag registers, addressing modes, instruction set
Flag registers, addressing modes, instruction setFlag registers, addressing modes, instruction set
Flag registers, addressing modes, instruction set
 
Computer System Architecture
Computer System ArchitectureComputer System Architecture
Computer System Architecture
 
Data link control & protocol concepts
Data link control & protocol conceptsData link control & protocol concepts
Data link control & protocol concepts
 
viva q&a for mp lab
viva q&a for mp labviva q&a for mp lab
viva q&a for mp lab
 
Sayeh extension(v23)
Sayeh extension(v23)Sayeh extension(v23)
Sayeh extension(v23)
 
Unit 5
Unit 5Unit 5
Unit 5
 
Data Link Control Protocols
Data Link Control ProtocolsData Link Control Protocols
Data Link Control Protocols
 
Microprocessorandmicroconrollermcq3 121116120640-phpapp02
Microprocessorandmicroconrollermcq3 121116120640-phpapp02Microprocessorandmicroconrollermcq3 121116120640-phpapp02
Microprocessorandmicroconrollermcq3 121116120640-phpapp02
 
Microcontroller 8051 1
Microcontroller 8051  1Microcontroller 8051  1
Microcontroller 8051 1
 
PAI Unit 3 Multitasking in 80386
PAI Unit 3 Multitasking in 80386PAI Unit 3 Multitasking in 80386
PAI Unit 3 Multitasking in 80386
 
register
registerregister
register
 
Delay routine
Delay routineDelay routine
Delay routine
 
Flag registers (assembly language) with types and examples
Flag registers (assembly language) with types and examplesFlag registers (assembly language) with types and examples
Flag registers (assembly language) with types and examples
 
Computer arithmetic in computer architecture
Computer arithmetic in computer architectureComputer arithmetic in computer architecture
Computer arithmetic in computer architecture
 

Viewers also liked

Comp architecture : branch prediction
Comp architecture : branch predictionComp architecture : branch prediction
Comp architecture : branch predictionrinnocente
 
Instruction Level Parallelism (ILP) Limitations
Instruction Level Parallelism (ILP) LimitationsInstruction Level Parallelism (ILP) Limitations
Instruction Level Parallelism (ILP) LimitationsJose Pinilla
 
Intel CPU Manufacturing Process
Intel CPU Manufacturing ProcessIntel CPU Manufacturing Process
Intel CPU Manufacturing ProcessA B Shinde
 
Pipelining and ILP (Instruction Level Parallelism)
Pipelining and ILP (Instruction Level Parallelism) Pipelining and ILP (Instruction Level Parallelism)
Pipelining and ILP (Instruction Level Parallelism) A B Shinde
 
Lec12 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- P6, Netbur...
Lec12 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- P6, Netbur...Lec12 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- P6, Netbur...
Lec12 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- P6, Netbur...Hsien-Hsin Sean Lee, Ph.D.
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsLinkedIn
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerLuminary Labs
 

Viewers also liked (7)

Comp architecture : branch prediction
Comp architecture : branch predictionComp architecture : branch prediction
Comp architecture : branch prediction
 
Instruction Level Parallelism (ILP) Limitations
Instruction Level Parallelism (ILP) LimitationsInstruction Level Parallelism (ILP) Limitations
Instruction Level Parallelism (ILP) Limitations
 
Intel CPU Manufacturing Process
Intel CPU Manufacturing ProcessIntel CPU Manufacturing Process
Intel CPU Manufacturing Process
 
Pipelining and ILP (Instruction Level Parallelism)
Pipelining and ILP (Instruction Level Parallelism) Pipelining and ILP (Instruction Level Parallelism)
Pipelining and ILP (Instruction Level Parallelism)
 
Lec12 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- P6, Netbur...
Lec12 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- P6, Netbur...Lec12 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- P6, Netbur...
Lec12 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- P6, Netbur...
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
 

Similar to Like 2014214

Lec5 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Branch Pred...
Lec5 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Branch Pred...Lec5 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Branch Pred...
Lec5 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Branch Pred...Hsien-Hsin Sean Lee, Ph.D.
 
Computer network (16)
Computer network (16)Computer network (16)
Computer network (16)NYversity
 
24 15055 current steering ijeecs 1570310518(edit)
24 15055 current steering ijeecs  1570310518(edit)24 15055 current steering ijeecs  1570310518(edit)
24 15055 current steering ijeecs 1570310518(edit)nooriasukmaningtyas
 
FPGA configuration of an alloyed correlated branch predictor used with RISC p...
FPGA configuration of an alloyed correlated branch predictor used with RISC p...FPGA configuration of an alloyed correlated branch predictor used with RISC p...
FPGA configuration of an alloyed correlated branch predictor used with RISC p...IJECEIAES
 
Chapter 1 Digital Systems and Binary Numbers.ppt
Chapter 1 Digital Systems and Binary Numbers.pptChapter 1 Digital Systems and Binary Numbers.ppt
Chapter 1 Digital Systems and Binary Numbers.pptAparnaDas827261
 
Control hazards MIPS pipeline.pptx
Control hazards MIPS pipeline.pptxControl hazards MIPS pipeline.pptx
Control hazards MIPS pipeline.pptxIrfan Anjum
 
SOC-CH3.pptSOC ProcessorsSOC Processors Used in SOC Used in SOC
SOC-CH3.pptSOC ProcessorsSOC Processors Used in SOC Used in SOCSOC-CH3.pptSOC ProcessorsSOC Processors Used in SOC Used in SOC
SOC-CH3.pptSOC ProcessorsSOC Processors Used in SOC Used in SOCSnehaLatha68
 
Subroutine in 8051 microcontroller
Subroutine in 8051 microcontrollerSubroutine in 8051 microcontroller
Subroutine in 8051 microcontrollerbhadresh savani
 
16-bit microprocessors
16-bit microprocessors16-bit microprocessors
16-bit microprocessorsZahra Sadeghi
 
Software-defined IoT: 6TiSCH Centralized Scheduling and Multipath Construction
Software-defined IoT: 6TiSCH Centralized Scheduling and Multipath ConstructionSoftware-defined IoT: 6TiSCH Centralized Scheduling and Multipath Construction
Software-defined IoT: 6TiSCH Centralized Scheduling and Multipath ConstructionHao Jiang
 
Ars msr 1-intradomain
Ars msr 1-intradomainArs msr 1-intradomain
Ars msr 1-intradomainNarcisIlie1
 
2007 Tidc India Profiling
2007 Tidc India Profiling2007 Tidc India Profiling
2007 Tidc India Profilingdanrinkes
 
Image Representation & Descriptors
Image Representation & DescriptorsImage Representation & Descriptors
Image Representation & DescriptorsPundrikPatel
 
Leopard: Lightweight Partitioning and Replication for Dynamic Graphs
Leopard: Lightweight Partitioning and Replication  for Dynamic Graphs Leopard: Lightweight Partitioning and Replication  for Dynamic Graphs
Leopard: Lightweight Partitioning and Replication for Dynamic Graphs Daniel Abadi
 
Mcs 012 computer organisation and assemly language programming- ignou assignm...
Mcs 012 computer organisation and assemly language programming- ignou assignm...Mcs 012 computer organisation and assemly language programming- ignou assignm...
Mcs 012 computer organisation and assemly language programming- ignou assignm...Dr. Loganathan R
 

Similar to Like 2014214 (20)

Lec5 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Branch Pred...
Lec5 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Branch Pred...Lec5 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Branch Pred...
Lec5 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Branch Pred...
 
Computer network (16)
Computer network (16)Computer network (16)
Computer network (16)
 
24 15055 current steering ijeecs 1570310518(edit)
24 15055 current steering ijeecs  1570310518(edit)24 15055 current steering ijeecs  1570310518(edit)
24 15055 current steering ijeecs 1570310518(edit)
 
FPGA configuration of an alloyed correlated branch predictor used with RISC p...
FPGA configuration of an alloyed correlated branch predictor used with RISC p...FPGA configuration of an alloyed correlated branch predictor used with RISC p...
FPGA configuration of an alloyed correlated branch predictor used with RISC p...
 
Chapter 1 Digital Systems and Binary Numbers.ppt
Chapter 1 Digital Systems and Binary Numbers.pptChapter 1 Digital Systems and Binary Numbers.ppt
Chapter 1 Digital Systems and Binary Numbers.ppt
 
Mini Project- Dual Processor Computation
Mini Project- Dual Processor ComputationMini Project- Dual Processor Computation
Mini Project- Dual Processor Computation
 
Switch Control and Time Delay - Keypad
Switch Control and Time Delay - KeypadSwitch Control and Time Delay - Keypad
Switch Control and Time Delay - Keypad
 
Control hazards MIPS pipeline.pptx
Control hazards MIPS pipeline.pptxControl hazards MIPS pipeline.pptx
Control hazards MIPS pipeline.pptx
 
SOC-CH3.pptSOC ProcessorsSOC Processors Used in SOC Used in SOC
SOC-CH3.pptSOC ProcessorsSOC Processors Used in SOC Used in SOCSOC-CH3.pptSOC ProcessorsSOC Processors Used in SOC Used in SOC
SOC-CH3.pptSOC ProcessorsSOC Processors Used in SOC Used in SOC
 
Subroutine in 8051 microcontroller
Subroutine in 8051 microcontrollerSubroutine in 8051 microcontroller
Subroutine in 8051 microcontroller
 
Cs8591 Computer Networks
Cs8591 Computer NetworksCs8591 Computer Networks
Cs8591 Computer Networks
 
Final report
Final reportFinal report
Final report
 
16-bit microprocessors
16-bit microprocessors16-bit microprocessors
16-bit microprocessors
 
Software-defined IoT: 6TiSCH Centralized Scheduling and Multipath Construction
Software-defined IoT: 6TiSCH Centralized Scheduling and Multipath ConstructionSoftware-defined IoT: 6TiSCH Centralized Scheduling and Multipath Construction
Software-defined IoT: 6TiSCH Centralized Scheduling and Multipath Construction
 
Ars msr 1-intradomain
Ars msr 1-intradomainArs msr 1-intradomain
Ars msr 1-intradomain
 
7 eti pres
7 eti pres7 eti pres
7 eti pres
 
2007 Tidc India Profiling
2007 Tidc India Profiling2007 Tidc India Profiling
2007 Tidc India Profiling
 
Image Representation & Descriptors
Image Representation & DescriptorsImage Representation & Descriptors
Image Representation & Descriptors
 
Leopard: Lightweight Partitioning and Replication for Dynamic Graphs
Leopard: Lightweight Partitioning and Replication  for Dynamic Graphs Leopard: Lightweight Partitioning and Replication  for Dynamic Graphs
Leopard: Lightweight Partitioning and Replication for Dynamic Graphs
 
Mcs 012 computer organisation and assemly language programming- ignou assignm...
Mcs 012 computer organisation and assemly language programming- ignou assignm...Mcs 012 computer organisation and assemly language programming- ignou assignm...
Mcs 012 computer organisation and assemly language programming- ignou assignm...
 

Recently uploaded

Genesis 1:7 || Meditate the Scripture daily verse by verse
Genesis 1:7  ||  Meditate the Scripture daily verse by verseGenesis 1:7  ||  Meditate the Scripture daily verse by verse
Genesis 1:7 || Meditate the Scripture daily verse by versemaricelcanoynuay
 
St. John's Church Parish Magazine - May 2024
St. John's Church Parish Magazine - May 2024St. John's Church Parish Magazine - May 2024
St. John's Church Parish Magazine - May 2024Chris Lyne
 
The Revelation Chapter 4 Working Copy.docx
The Revelation Chapter 4 Working Copy.docxThe Revelation Chapter 4 Working Copy.docx
The Revelation Chapter 4 Working Copy.docxFred Gosnell
 
The_Chronological_Life_of_Christ_Part_99_Words_and_Works
The_Chronological_Life_of_Christ_Part_99_Words_and_WorksThe_Chronological_Life_of_Christ_Part_99_Words_and_Works
The_Chronological_Life_of_Christ_Part_99_Words_and_WorksNetwork Bible Fellowship
 
Famous Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in ka...
Famous Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in ka...Famous Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in ka...
Famous Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in ka...baharayali
 
NoHo First Good News online newsletter May 2024
NoHo First Good News online newsletter May 2024NoHo First Good News online newsletter May 2024
NoHo First Good News online newsletter May 2024NoHo FUMC
 
Famous Kala Jadu, Black magic expert in UK and Kala ilam expert in Saudi Arab...
Famous Kala Jadu, Black magic expert in UK and Kala ilam expert in Saudi Arab...Famous Kala Jadu, Black magic expert in UK and Kala ilam expert in Saudi Arab...
Famous Kala Jadu, Black magic expert in UK and Kala ilam expert in Saudi Arab...baharayali
 
Top Kala Jadu, Black magic expert in Faisalabad and Kala ilam specialist in S...
Top Kala Jadu, Black magic expert in Faisalabad and Kala ilam specialist in S...Top Kala Jadu, Black magic expert in Faisalabad and Kala ilam specialist in S...
Top Kala Jadu, Black magic expert in Faisalabad and Kala ilam specialist in S...baharayali
 
Genesis 1:8 || Meditate the Scripture daily verse by verse
Genesis 1:8  ||  Meditate the Scripture daily verse by verseGenesis 1:8  ||  Meditate the Scripture daily verse by verse
Genesis 1:8 || Meditate the Scripture daily verse by versemaricelcanoynuay
 
Top 10 Amil baba list Famous Amil baba In Pakistan Amil baba Kala jadu in Raw...
Top 10 Amil baba list Famous Amil baba In Pakistan Amil baba Kala jadu in Raw...Top 10 Amil baba list Famous Amil baba In Pakistan Amil baba Kala jadu in Raw...
Top 10 Amil baba list Famous Amil baba In Pakistan Amil baba Kala jadu in Raw...Amil Baba Naveed Bangali
 
MEIDUNIDADE COM JESUS PALESTRA ESPIRITA1.pptx
MEIDUNIDADE COM JESUS  PALESTRA ESPIRITA1.pptxMEIDUNIDADE COM JESUS  PALESTRA ESPIRITA1.pptx
MEIDUNIDADE COM JESUS PALESTRA ESPIRITA1.pptxMneasEntidades
 
Verified Amil baba in Pakistan Amil baba in Islamabad Famous Amil baba in Ger...
Verified Amil baba in Pakistan Amil baba in Islamabad Famous Amil baba in Ger...Verified Amil baba in Pakistan Amil baba in Islamabad Famous Amil baba in Ger...
Verified Amil baba in Pakistan Amil baba in Islamabad Famous Amil baba in Ger...Amil Baba Naveed Bangali
 
St John's Church Parish Diary for May 2024
St John's Church Parish Diary for May 2024St John's Church Parish Diary for May 2024
St John's Church Parish Diary for May 2024Chris Lyne
 
+92343-7800299 No.1 Amil baba in Pakistan amil baba in Lahore amil baba in Ka...
+92343-7800299 No.1 Amil baba in Pakistan amil baba in Lahore amil baba in Ka...+92343-7800299 No.1 Amil baba in Pakistan amil baba in Lahore amil baba in Ka...
+92343-7800299 No.1 Amil baba in Pakistan amil baba in Lahore amil baba in Ka...Amil Baba Mangal Maseeh
 
From The Heart v8.pdf xxxxxxxxxxxxxxxxxxx
From The Heart v8.pdf xxxxxxxxxxxxxxxxxxxFrom The Heart v8.pdf xxxxxxxxxxxxxxxxxxx
From The Heart v8.pdf xxxxxxxxxxxxxxxxxxxssuser83613b
 
Top Kala Jadu, Bangali Amil baba in Lahore and Kala jadu specialist in Lahore...
Top Kala Jadu, Bangali Amil baba in Lahore and Kala jadu specialist in Lahore...Top Kala Jadu, Bangali Amil baba in Lahore and Kala jadu specialist in Lahore...
Top Kala Jadu, Bangali Amil baba in Lahore and Kala jadu specialist in Lahore...baharayali
 
Legends of the Light v2.pdf xxxxxxxxxxxxx
Legends of the Light v2.pdf xxxxxxxxxxxxxLegends of the Light v2.pdf xxxxxxxxxxxxx
Legends of the Light v2.pdf xxxxxxxxxxxxxssuser83613b
 
Real Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in kara...
Real Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in kara...Real Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in kara...
Real Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in kara...baharayali
 

Recently uploaded (20)

Genesis 1:7 || Meditate the Scripture daily verse by verse
Genesis 1:7  ||  Meditate the Scripture daily verse by verseGenesis 1:7  ||  Meditate the Scripture daily verse by verse
Genesis 1:7 || Meditate the Scripture daily verse by verse
 
St. John's Church Parish Magazine - May 2024
St. John's Church Parish Magazine - May 2024St. John's Church Parish Magazine - May 2024
St. John's Church Parish Magazine - May 2024
 
The Revelation Chapter 4 Working Copy.docx
The Revelation Chapter 4 Working Copy.docxThe Revelation Chapter 4 Working Copy.docx
The Revelation Chapter 4 Working Copy.docx
 
The_Chronological_Life_of_Christ_Part_99_Words_and_Works
The_Chronological_Life_of_Christ_Part_99_Words_and_WorksThe_Chronological_Life_of_Christ_Part_99_Words_and_Works
The_Chronological_Life_of_Christ_Part_99_Words_and_Works
 
Famous Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in ka...
Famous Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in ka...Famous Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in ka...
Famous Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in ka...
 
NoHo First Good News online newsletter May 2024
NoHo First Good News online newsletter May 2024NoHo First Good News online newsletter May 2024
NoHo First Good News online newsletter May 2024
 
English - The Forgotten Books of Eden.pdf
English - The Forgotten Books of Eden.pdfEnglish - The Forgotten Books of Eden.pdf
English - The Forgotten Books of Eden.pdf
 
Famous Kala Jadu, Black magic expert in UK and Kala ilam expert in Saudi Arab...
Famous Kala Jadu, Black magic expert in UK and Kala ilam expert in Saudi Arab...Famous Kala Jadu, Black magic expert in UK and Kala ilam expert in Saudi Arab...
Famous Kala Jadu, Black magic expert in UK and Kala ilam expert in Saudi Arab...
 
Top Kala Jadu, Black magic expert in Faisalabad and Kala ilam specialist in S...
Top Kala Jadu, Black magic expert in Faisalabad and Kala ilam specialist in S...Top Kala Jadu, Black magic expert in Faisalabad and Kala ilam specialist in S...
Top Kala Jadu, Black magic expert in Faisalabad and Kala ilam specialist in S...
 
Genesis 1:8 || Meditate the Scripture daily verse by verse
Genesis 1:8  ||  Meditate the Scripture daily verse by verseGenesis 1:8  ||  Meditate the Scripture daily verse by verse
Genesis 1:8 || Meditate the Scripture daily verse by verse
 
Top 10 Amil baba list Famous Amil baba In Pakistan Amil baba Kala jadu in Raw...
Top 10 Amil baba list Famous Amil baba In Pakistan Amil baba Kala jadu in Raw...Top 10 Amil baba list Famous Amil baba In Pakistan Amil baba Kala jadu in Raw...
Top 10 Amil baba list Famous Amil baba In Pakistan Amil baba Kala jadu in Raw...
 
MEIDUNIDADE COM JESUS PALESTRA ESPIRITA1.pptx
MEIDUNIDADE COM JESUS  PALESTRA ESPIRITA1.pptxMEIDUNIDADE COM JESUS  PALESTRA ESPIRITA1.pptx
MEIDUNIDADE COM JESUS PALESTRA ESPIRITA1.pptx
 
Verified Amil baba in Pakistan Amil baba in Islamabad Famous Amil baba in Ger...
Verified Amil baba in Pakistan Amil baba in Islamabad Famous Amil baba in Ger...Verified Amil baba in Pakistan Amil baba in Islamabad Famous Amil baba in Ger...
Verified Amil baba in Pakistan Amil baba in Islamabad Famous Amil baba in Ger...
 
St John's Church Parish Diary for May 2024
St John's Church Parish Diary for May 2024St John's Church Parish Diary for May 2024
St John's Church Parish Diary for May 2024
 
+92343-7800299 No.1 Amil baba in Pakistan amil baba in Lahore amil baba in Ka...
+92343-7800299 No.1 Amil baba in Pakistan amil baba in Lahore amil baba in Ka...+92343-7800299 No.1 Amil baba in Pakistan amil baba in Lahore amil baba in Ka...
+92343-7800299 No.1 Amil baba in Pakistan amil baba in Lahore amil baba in Ka...
 
From The Heart v8.pdf xxxxxxxxxxxxxxxxxxx
From The Heart v8.pdf xxxxxxxxxxxxxxxxxxxFrom The Heart v8.pdf xxxxxxxxxxxxxxxxxxx
From The Heart v8.pdf xxxxxxxxxxxxxxxxxxx
 
Famous No -1 amil baba in Hyderabad ! Best No _ Astrologer in Pakistan, UK, A...
Famous No -1 amil baba in Hyderabad ! Best No _ Astrologer in Pakistan, UK, A...Famous No -1 amil baba in Hyderabad ! Best No _ Astrologer in Pakistan, UK, A...
Famous No -1 amil baba in Hyderabad ! Best No _ Astrologer in Pakistan, UK, A...
 
Top Kala Jadu, Bangali Amil baba in Lahore and Kala jadu specialist in Lahore...
Top Kala Jadu, Bangali Amil baba in Lahore and Kala jadu specialist in Lahore...Top Kala Jadu, Bangali Amil baba in Lahore and Kala jadu specialist in Lahore...
Top Kala Jadu, Bangali Amil baba in Lahore and Kala jadu specialist in Lahore...
 
Legends of the Light v2.pdf xxxxxxxxxxxxx
Legends of the Light v2.pdf xxxxxxxxxxxxxLegends of the Light v2.pdf xxxxxxxxxxxxx
Legends of the Light v2.pdf xxxxxxxxxxxxx
 
Real Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in kara...
Real Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in kara...Real Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in kara...
Real Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in kara...
 

Like 2014214

  • 1. Lecture 9: Branch Prediction Basic idea, saturating counter, BHT, BTB, return address prediction, correlating prediction 1
  • 2. Reducing Branch Penalty Branch penalty in dynamically scheduled processors: wasted cycles due to pipeline flushing on mispredicted branches Reduce branch penalty: 1. Predict branch/jump instructions AND branch direction (taken or not taken) 2. Predict branch/jump target address (for taken branches) 3. Speculatively execute instructions along the predicted path 2
  • 3. What to Use and What to Predict Available info:   Current predicted PC Past branch history (direction and target) pred_PC PC What to predict:    Conditional branch inst: branch direction and target address Jump inst: target address Procedure call/return: target address May need instruction predecoded Predictors IM PC & Inst pred info feedback P C 3
  • 4. Mis-prediction Detections and Feedbacks Detections: At the end of decoding   Target address known at decoding, and not match Flush fetch stage At commit (most cases)   Wrong branch direction or target address not match Flush the whole pipeline (at EXE: MIPS R10000) Feedbacks: Any time a mis-prediction is detected At a branch’s commit (at EXE: called speculative update) FETCH predictors RENAME REB/ROB SCHD EXE WB COMMIT 4
  • 5. Branch Direction Prediction Predict branch direction: taken or not taken (T/NT) taken Not taken BNE R1, R2, L1 … L1: … Static prediction: compilers decide the direction Dynamic prediction: hardware decides the direction using dynamic information 1. 2. 3. 4. 5. 1-bit Branch-Prediction Buffer 2-bit Branch-Prediction Buffer Correlating Branch Prediction Buffer Tournament Branch Predictor and more … 5
  • 6. Predictor for a Single Branch General Form 1. Access 2. Predict Output T/NT state PC 3. Feedback T/NT 1-bit prediction Feedback T Predict Taken NT 1 NT T 0 Predict Taken 6
  • 7. Branch History Table of 1-bit Predictor BHT also Called Branch Prediction Buffer in textbook Can use only one 1-bit predictor, but accuracy is low BHT: use a table of simple predictors, indexed by bits from PC Similar to direct mapped cache More entries, more cost, but less conflicts, higher accuracy BHT can contain complex predictors K-bit Branch address 2k Prediction Prediction 7
  • 8. 1-bit BHT Weakness Example: in a loop, 1-bit BHT will cause 2 mispredictions Consider a loop of 9 iterations before exit: for (…){ for (i=0; i<9; i++) a[i] = a[i] * 2.0; }  End of loop case, when it exits instead of looping as before  First time through loop on next time through code, when it predicts exit instead of looping  Only 80% accuracy even if loop 90% of the time 8
  • 9. 2-bit Saturating Counter Solution: 2-bit scheme where change prediction only if get misprediction twice: (Figure 3.7, p. 249) T Predict Taken 11 NT T T Predict Not Taken 01 10 Predict Taken NT NT T 00 Predict Not Taken NT Blue: stop, not taken Gray: go, taken Adds hysteresis to decision making process 9
  • 10. Branch Target Buffer Branch Target Buffer (BTB): Address of branch index to get prediction AND branch address (if taken)  Note: must check for branch match now, since can’t use wrong branch address Example: BTB combined with BHT Branch PC Predicted PC PC of instruction FETCH =? No: branch not predicted, proceed normally (Next PC = PC+4) Extra Yes: instruction is prediction state branch and use bits predicted PC as next PC 10
  • 11. Return Addresses Prediction Register indirect branch hard to predict address   Many callers, one callee Jump to multiple return addresses from a single address (no PC-target correlation) SPEC89 85% such branches for procedure return Since stack discipline for procedures, save return address in small buffer that acts like a stack: 8 to 16 entries has small miss rate 11
  • 12. Correlating Branches Code example showing the potential Assemble code If (d==0) d=1; If (d==1) … BNEZ R1, L1 DADDIU R1,R0,#1 L1: DADDIU R3,R1,#-1 BNEZ R3, L2 L2: … Observation: if BNEZ1 is not taken, then BNEZ2 is taken 12
  • 13. Correlating Branch Predictor Idea: taken/not taken of recently executed branches is related to behavior of next branch (as well as the history of that branch behavior)  Then behavior of recent branches selects between, say, 2 predictions of next branch, updating just that prediction  (1,1) predictor: 1-bit global, 1-bit local Branch address (4 bits) 1-bits per branch local predictors Prediction Prediction 1-bit global branch history (0 = not taken) 13
  • 14. Correlating Branch Predictor General form: (m, n) predictor  m bits for global history, n bits for local history  Records correlation between m+1 branches  Simple implementation: global history can be store in a shift register  Example: (2,2) predictor, 2-bit global, 2-bit local Branch address (4 bits) 2-bits per branch local predictors Prediction Prediction 2-bit global branch history (01 = not taken then taken) 14
  • 15. Accuracy of Different Schemes (Figure 3.15, p. 206) Frequencyofof Mispredictions Frequency Mispredictions 20% 4096 Entries 2-bit BHT Unlimited Entries 2-bit BHT 1024 Entries (2,2) BHT 18% 16% 14% 12% 11% 10% 8% 6% 6% 6% 6% 5% 5% 4% 4% 2% 1% 1% 0% 0% nasa7 matrix300 tomcatv doducd 4,096 entries: 2-bits per entry spice fpppp gcc Unlimited entries: 2-bits/entry espresso eqntott 1,024 entries (2,2) 15 li
  • 16. Estimate Branch Penalty EX: BHT correct rate is 95%, BTB hit rate is 95% Average miss penalty is 15 cycles How much is the branch penalty? 16
  • 17. Accuracy of Return Address Predictor 17

Editor's Notes

  1. This lecture will cover sections 1.1-1.4: introduction, application, technology trends, cost and price.
  2. &lt;number&gt;