Dynamic Hardware Branch Prediction

Slides:



Advertisements
Similar presentations
Instruction-Level Parallelism compiler techniques and branch prediction prepared and Instructed by Shmuel Wimer Eng. Faculty, Bar-Ilan University March.
Advertisements

Lecture 8 Dynamic Branch Prediction, Superscalar and VLIW Advanced Computer Architecture COE 501.
Dynamic Branch Prediction (Sec 4.3) Control dependences become a limiting factor in exploiting ILP So far, we’ve discussed only static branch prediction.
Pipelining and Control Hazards Oct
Computer Organization and Architecture (AT70.01) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor: Dr. Sumanta Guha Slide Sources: Based.
CPE 631: Branch Prediction Electrical and Computer Engineering University of Alabama in Huntsville Aleksandar Milenkovic,
Dynamic Branch Prediction
CPE 731 Advanced Computer Architecture ILP: Part II – Branch Prediction Dr. Gheith Abandah Adapted from the slides of Prof. David Patterson, University.
CPE 631: Branch Prediction Electrical and Computer Engineering University of Alabama in Huntsville Aleksandar Milenkovic,
1 Lecture: Branch Prediction Topics: branch prediction, bimodal/global/local/tournament predictors, branch target buffer (Section 3.3, notes on class webpage)
W04S1 COMP s1 Seminar 4: Branch Prediction Slides due to David A. Patterson, 2001.
EECC551 - Shaaban #1 lec # 5 Spring Reduction of Control Hazards (Branch) Stalls with Dynamic Branch Prediction So far we have dealt with.
EECC551 - Shaaban #1 lec # 5 Fall Static Conditional Branch Prediction Branch prediction schemes can be classified into static (at compilation.
CPSC614 Lec 5.1 Instruction Level Parallelism and Dynamic Execution #4: Based on lectures by Prof. David A. Patterson E. J. Kim.
1 COMP 206: Computer Architecture and Implementation Montek Singh Wed., Oct. 8, 2003 Topic: Instruction-Level Parallelism (Dynamic Branch Prediction)
1 COMP 206: Computer Architecture and Implementation Montek Singh Mon., Oct. 7, 2002 Topic: Instruction-Level Parallelism (Dynamic Branch Prediction)
EECE476: Computer Architecture Lecture 20: Branch Prediction Chapter extra The University of British ColumbiaEECE 476© 2005 Guy Lemieux.
EECC551 - Shaaban #1 lec # 5 Fall Reduction of Control Hazards (Branch) Stalls with Dynamic Branch Prediction So far we have dealt with.
EENG449b/Savvides Lec /17/04 February 17, 2004 Prof. Andreas Savvides Spring EENG 449bG/CPSC 439bG.
1 Lecture 8: Branch Prediction, Dynamic ILP Topics: branch prediction, out-of-order processors (Sections )
EECC551 - Shaaban #1 lec # 7 Fall Hardware Dynamic Branch Prediction Simplest method: –A branch prediction buffer or Branch History Table.
Goal: Reduce the Penalty of Control Hazards
EECC551 - Shaaban #1 lec # 5 Winter Reduction of Control Hazards (Branch) Stalls with Dynamic Branch Prediction So far we have dealt with.
Computer Architecture Instruction Level Parallelism Dr. Esam Al-Qaralleh.
Branch Prediction Dimitris Karteris Rafael Pasvantidιs.
COMP381 by M. Hamdi 1 (Recap) Control Hazards. COMP381 by M. Hamdi 2 Control (Branch) Hazard A: beqz r2, label B: label: P: Problem: The outcome.
1 COMP 740: Computer Architecture and Implementation Montek Singh Thu, Feb 19, 2009 Topic: Instruction-Level Parallelism III (Dynamic Branch Prediction)
CSC 4250 Computer Architectures October 27, 2006 Chapter 3.Instruction-Level Parallelism & Its Dynamic Exploitation.
So far we have dealt with control hazards in instruction pipelines by:
Dynamic Branch Prediction
EENG449b/Savvides Lec /25/05 March 24, 2005 Prof. Andreas Savvides Spring g449b EENG 449bG/CPSC 439bG.
CIS 429/529 Winter 2007 Branch Prediction.1 Branch Prediction, Multiple Issue.
Spring 2003CSE P5481 Control Hazard Review The nub of the problem: In what pipeline stage does the processor fetch the next instruction? If that instruction.
1 Lecture 7: Branch prediction Topics: bimodal, global, local branch prediction (Sections )
EECC551 - Shaaban #1 lec # 5 Fall Static Conditional Branch Prediction Branch prediction schemes can be classified into static and dynamic.
1 Dynamic Branch Prediction. 2 Why do we want to predict branches? MIPS based pipeline – 1 instruction issued per cycle, branch hazard of 1 cycle. –Delayed.
CSCI 6461: Computer Architecture Branch Prediction Instructor: M. Lancaster Corresponding to Hennessey and Patterson Fifth Edition Section 3.3 and Part.
Lecture 4.5 Pipelines – Control Hazards Topics Control Hazards Branch Prediction Misprediction stalls Readings: Appendix C September 2, 2015 CSCE 513 Computer.
CPE 631 Session 17 Branch Prediction Electrical and Computer Engineering University of Alabama in Huntsville.
Adapted from Computer Organization and Design, Patterson & Hennessy, UCB ECE232: Hardware Organization and Design Part 13: Branch prediction (Chapter 4/6)
Dynamic Branch Prediction
Instruction-Level Parallelism and Its Dynamic Exploitation
CS203 – Advanced Computer Architecture
Concepts and Challenges
Dynamic Branch Prediction
COMP 740: Computer Architecture and Implementation
CS 704 Advanced Computer Architecture
Instruction-Level Parallelism (ILP)
Lecture 5 Pipelines – Control Hazards
CMSC 611: Advanced Computer Architecture
So far we have dealt with control hazards in instruction pipelines by:
CPE 631: Branch Prediction
Chapter 3: ILP and Its Exploitation
Dynamic Branch Prediction
Advanced Computer Architecture
Lecture 5 Pipelines – Control Hazards
/ Computer Architecture and Design
So far we have dealt with control hazards in instruction pipelines by:
Lecture 10: Branch Prediction and Instruction Delivery
So far we have dealt with control hazards in instruction pipelines by:
So far we have dealt with control hazards in instruction pipelines by:
Adapted from the slides of Prof
Dynamic Hardware Prediction
So far we have dealt with control hazards in instruction pipelines by:
So far we have dealt with control hazards in instruction pipelines by:
So far we have dealt with control hazards in instruction pipelines by:
So far we have dealt with control hazards in instruction pipelines by:
So far we have dealt with control hazards in instruction pipelines by:
Lecture 7: Branch Prediction, Dynamic ILP
CPE 631 Lecture 12: Branch Prediction
Presentation transcript:

Dynamic Hardware Branch Prediction Goal Allow the processor to resolve the outcome of a branch early, thus preventing control dependences from causing stalls. CSCE 614 Fall 2009

Branch-Prediction Buffer Simplest Branch history table Small memory indexed by the lower portion of the address of the branch instruction 1 bit says whether the branch was taken or not. If the bit turns out to be wrong, the prediction bit is inverted and stored back. CSCE 614 Fall 2009

Example Consider a loop branch whose behavior is taken nine times in a row, then not taken once. What is the prediction accuracy for this branch? Even if a branch is almost always taken, we predict incorrectly twice when it is not taken. CSCE 614 Fall 2009

2-bit Prediction Scheme A prediction must miss twice before it is changed. CSCE 614 Fall 2009

n-bit Saturating Counter Values: 0 ~ 2n-1 When the counter is greater than or equal to one-half of its maximum value, the branch is predicted as taken. Otherwise, not taken. Studies have shown that the 2-bit predictors do almost do well, and thus most systems rely on 2-bit branch predictors. CSCE 614 Fall 2009

4096-entry 2-bit prediction buffer CSCE 614 Fall 2009

CSCE 614 Fall 2009

Correlating Branch Predictor It may be possible to improve the accuracy if we look at the behavior of other branches. DSUBIU R3, R1, #2 BNEZ (b1) R3, L1 DADD R1, R0, R0 L1: DSUBIU R3, R2, #2 BNEZ (b2) R3, L2 DADD R2, R0, R0 L2: DSUBU R3, R1, R2 BEQZ (b3) R3, L3 if (aa == 2) aa = 0; if (bb == 2) bb = 0; if (aa != bb) MIPS code CSCE 614 Fall 2009

Correlating Predictors (Two-Level Predictors) The behavior of b3 is correlated with the behavior of b1 and b2. b1: not taken and b2: not taken => b3: taken Branch predictors that use the behavior of other branches to make a prediction CSCE 614 Fall 2009

Correlating Predictors Two-level predictors BNEZ (b1) R1, L1 DADDIU R1, R0, #1 L1: DADDIU R3, R1, #-1 BNEZ (b2) R3, L2 … L2: if (d == 0) d = 1; if (d == 1) CSCE 614 Fall 2009

initial value of d b1 value of d before b2 b2 1 2 1 2 Assume d = 0, 1, or 2 CSCE 614 Fall 2009

1-bit Predictor (Initialized to NT) b1 predic b1 action new b1 pr b2 predic b2 action new b2 pr 2 CSCE 614 Fall 2009

(1,1) Predictor Every branch has two separate prediction bits. First bit: the prediction if the last branch in the program is not taken. Second bit: the prediction if the last branch in the program is taken. Write the pair of prediction bits together. CSCE 614 Fall 2009

Combinations & Meaning Prediction bits Prediction if not taken Prediction if taken CSCE 614 Fall 2009

(1,1) Predictor d b1 predic b1 action new b1 pr b2 predic b2 action CSCE 614 Fall 2009

(m,n) Predictor Uses the last m branches to choose from 2m branch predictors, each of which is an n-bit predictor. Yields higher prediction rates than 2-bit scheme Requires a trivial amount of additional hardware The global history of the most recent m branches are recorded in an m-bit shift register. CSCE 614 Fall 2009

CSCE 614 Fall 2009

(m,n) Predictor Total number of bits: = 2m x n x #prediction entries selected by the branch address Examples CSCE 614 Fall 2009

CSCE 614 Fall 2009

Tournament Predictors Most popular form of multilevel branch predictors By using multiple predictors (one based on global information, one based on local information, and combining them with a selector), it can select the right predictor for the right branch. Alpha 21264 Uses most sophisticated branch predictor as of 2001. CSCE 614 Fall 2009

Tournament Predictors CSCE 614 Fall 2009

CSCE 614 Fall 2009