A STUDY OF BRANCH PREDICTION STRATEGIES JAMES E.SMITH Presented By: Prasanth Kanakadandi.

Slides:



Advertisements
Similar presentations
Lecture 8 Dynamic Branch Prediction, Superscalar and VLIW Advanced Computer Architecture COE 501.
Advertisements

Pipelining and Control Hazards Oct
Lecture Objectives: 1)Define branch prediction. 2)Draw a state machine for a 2 bit branch prediction scheme 3)Explain the impact on the compiler of branch.
Pipeline Computer Organization II 1 Hazards Situations that prevent starting the next instruction in the next cycle Structural hazards – A required resource.
COMPSYS 304 Computer Architecture Speculation & Branching Morning visitors - Paradise Bay, Bay of Islands.
Computer Organization and Architecture
Chapter 8. Pipelining. Instruction Hazards Overview Whenever the stream of instructions supplied by the instruction fetch unit is interrupted, the pipeline.
Chapter 12 CPU Structure and Function. CPU Sequence Fetch instructions Interpret instructions Fetch data Process data Write data.
Computer Organization and Architecture
Computer Organization and Architecture
CPE 731 Advanced Computer Architecture ILP: Part II – Branch Prediction Dr. Gheith Abandah Adapted from the slides of Prof. David Patterson, University.
1 Lecture 7: Static ILP, Branch prediction Topics: static ILP wrap-up, bimodal, global, local branch prediction (Sections )
EECC551 - Shaaban #1 lec # 5 Fall Static Conditional Branch Prediction Branch prediction schemes can be classified into static (at compilation.
1 COMP 206: Computer Architecture and Implementation Montek Singh Wed., Oct. 8, 2003 Topic: Instruction-Level Parallelism (Dynamic Branch Prediction)
Perceptron-based Global Confidence Estimation for Value Prediction Master’s Thesis Michael Black June 26, 2003.
1 COMP 206: Computer Architecture and Implementation Montek Singh Mon., Oct. 7, 2002 Topic: Instruction-Level Parallelism (Dynamic Branch Prediction)
Review CPSC 321 Andreas Klappenecker Announcements Tuesday, November 30, midterm exam.
Computer Organization and Architecture The CPU Structure.
EECE476: Computer Architecture Lecture 20: Branch Prediction Chapter extra The University of British ColumbiaEECE 476© 2005 Guy Lemieux.
Chapter 12 Pipelining Strategies Performance Hazards.
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.
Pipelining Fetch instruction Decode instruction Calculate operands (i.e. EAs) Fetch operands Execute instructions Write result Overlap these operations.
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
Chapter 12 CPU Structure and Function. Example Register Organizations.
Computer Architecture Instruction Level Parallelism Dr. Esam Al-Qaralleh.
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)
Review for Midterm 2 CPSC 321 Computer Architecture Andreas Klappenecker.
Dynamic Branch Prediction
EENG449b/Savvides Lec /25/05 March 24, 2005 Prof. Andreas Savvides Spring g449b EENG 449bG/CPSC 439bG.
7/2/ _23 1 Pipelining ECE-445 Computer Organization Dr. Ron Hayne Electrical and Computer Engineering.
Pipelined Datapath and Control (Lecture #15) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer.
EECC551 - Shaaban #1 lec # 5 Fall Static Conditional Branch Prediction Branch prediction schemes can be classified into static and dynamic.
CH12 CPU Structure and Function
5-Stage Pipelining Fetch Instruction (FI) Fetch Operand (FO) Decode Instruction (DI) Write Operand (WO) Execution Instruction (EI) S3S3 S4S4 S1S1 S2S2.
Evaluation of the Gini-index for Studying Branch Prediction Features Veerle Desmet Lieven Eeckhout Koen De Bosschere.
CPU Design and PipeliningCSCI 4717 – Computer Architecture CSCI 4717/5717 Computer Architecture Topic: CPU Operations and Pipelining Reading: Stallings,
Computer Architecture Lecture 26 Fasih ur Rehman.
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.
CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Pipelining Basics.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Winter 2002CSE Topic Branch Hazards in the Pipelined Processor.
Branch Hazards and Static Branch Prediction Techniques
Branch Prediction Prof. Mikko H. Lipasti University of Wisconsin-Madison Lecture notes based on notes by John P. Shen Updated by Mikko Lipasti.
CPU Design and Pipelining – Page 1CSCI 4717 – Computer Architecture CSCI 4717/5717 Computer Architecture Topic: CPU Operations and Pipelining Reading:
Adapted from Computer Organization and Design, Patterson & Hennessy, UCB ECE232: Hardware Organization and Design Part 13: Branch prediction (Chapter 4/6)
Dynamic Branch Prediction
CS203 – Advanced Computer Architecture
Computer Architecture
Dynamic Branch Prediction
So far we have dealt with control hazards in instruction pipelines by:
Dynamic Branch Prediction
Advanced Computer Architecture
So far we have dealt with control hazards in instruction pipelines by:
Lecture 10: Branch Prediction and Instruction Delivery
Computer Architecture
So far we have dealt with control hazards in instruction pipelines by:
Adapted from the slides of Prof
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:
Presentation transcript:

A STUDY OF BRANCH PREDICTION STRATEGIES JAMES E.SMITH Presented By: Prasanth Kanakadandi

INTRODUCTION Break the smooth flow of instruction fetch and instruction execution Cause Delay Delay reduced by branch prediction More delay if prediction is wrong

PROGRAMS USED IN THE STUDY 1. ADVAN: Calculates the solution of three simultaneous partial differential equations 2. SCI2:Performs matrix inversion 3. SINCOS: Converts a series of points from polar to Cartesian coordinates 4. SORTST: Sorts a list of 10,000 integers 5. GIBSON: An artificial program that compiles to instructions that roughly satisfy the so called GIBSON mix 6. TBLLNK: Processes a linked list and contains a variety of conditional branches

BRANCH PREDICTION STRATEGIES Two types: Static Strategies Dynamic Strategies Two approaches: Predict that branches are always taken Predict that branches are never taken

STRATEGY 1 Predict that all branches will be taken Results: Program Prediction Accuracy ADVAN 99.4 GIBSON 65.4 SCI SINCOS 80.2 SORTST 57.4 TBLLNK 61.5

Majority of branches taken Success rates vary Program Sensitivity: The algorithm, the programmer and the compiler have an effect on the number of branches taken

Strategy 2 Predict that a branch will be decided the same way as its last execution If not previously executed, predict that it will be taken Not realizable

RESULTS FOR STRATEGY 2 Program Prediction Accuracy ADVAN 98.9 GIBSON 97.9 SCI SINCOS 76.2 SORTST 81.7 TBLLNK 91.7

STRATEGY 1a Predict that all branches with certain opcodes will be taken; predict that others will not be taken Examine which branches are usually taken Results: Program Prediction Accuracy Strategy 1 ADVAN GIBSON SCI SINCOS SORTST TBLLNK

STRATEGY 3 Predict that all backward branches will be taken; predict that all forward branches will not be taken Loops terminated by backward branches Program Sensitivity is high Disadvantage: Prediction is slower

RESULTS FOR STRATEGY 3 Program Prediction Accuracy ADVAN 81.9 GIBSON 98.0 SCI SINCOS 82.5 TBLLNK 84.9

DYNAMIC PREDICTION STRATEGIES

STRATEGY 4 Maintain a table of the most recently used branch instructions that are not taken If a branch instruction is in the table, predict that it will not be taken. Remove table entries if they are taken, and use LRU replacement to add new entries

RESULTS FOR STRATEGY 4 Program Prediction Accuracy Table Size ADVAN GIBSON SCI SINCOS SORTST TBLLNK

A VARIATION TO STRATEGY 4 Faster predictions Instruction words compared with associative memory Observe whether next word is in sequence or out-of-sequence If out-of-sequence,address of the out- of-sequence word is given

Instruction fetch can begin at that location Prediction made before decomposing instruction word into separate instructions

STRATEGY 5 Maintain a bit for each instruction in the cache. If the instruction is a branch instruction, the bit is used to record if it was taken on its last execution. Branches are predicted to be decided as on their last execution; if a branch has not been executed, it is predicted to be taken

RESULTS FOR STRATEGY 5 Program Prediction Accuracy ADVAN 98.9 GIBSON 97.0 SCI SINCOS 76.1 SORTST 81.7 TBLLNK 91.7

IMPROVED DYNAMIC STRATEGIES Use random access memory instead of associative memory Deal with anomalous decisions more effectively

STRATEGY 6 Hash the branch instruction address to m bits and use this index to address a RAM containing the outcome of the most recent branch instruction indexing the same location. Predict that the branch outcome will be the same.

Default prediction controlled by initializing memory to all 0’s or 1’s Results: Program Prediction Accuracy ADVAN 98.9 GIBSON 97.9 SCI SINCOS 76.2 SORTST 81.7 TBLLNK 91.8

STRATEGY 7 Use strategy 6 with twos compliment counts instead of a single bit. Predict that the branch will be taken if the sign bit is 1. Increment the count when a branch is taken; decrement it when a branch is not taken

RESULTS FOR STRATEGY 7 Program Prediction Accuracy 2 Bit Counter 3 Bit Counter ADVAN GIBSON SCI SINCOS SORTST TBLLNK

HIERARCHICAL PREDICTION Time penalty Need for a level of confidence to be attached to branch prediction

AN EXAMPLE For instruction prefetch, if the prediction is incorrect, delay is 6 cp and if the prediction is correct, delay is 3 cp For instruction prefetch and instruction preissue, no delay if the prediction is correct. If the prediction is incorrect, delay is 12 cp

70 % of the branches can be predicted correctly Half of the branches with 50% accuracy (Set A) Other half of with 90% accuracy (Set B)

Possible Strategies and average delays Prefetch for all branches: (0.3 * 6 cp) + (0.7 * 3 cp) = 3.9 cp Prefetch and preissue for all branches: (0.3 * 12 cp) + (0.7 * 0) = 3.6 cp Prefetch for branches in A and prefetch and preissue for branches in B: 0.5 * [(0.5 * 3 cp) + (0.5 * 6 cp)] * [(0.1 * 12 cp) + (0.9 * 0 )] = 2.85 cp

HIERARCHICAL PREDICTION FOR STRATEGY 7 Strategy 7 provides natural way for implementing hierarchical prediction. If a counter is at its maximum value when a prediction is made, the last prediction must have been that the branch be taken, and it must have been correct. A following similar prediction is likely to be correct High confidence prediction at extreme counter values

RESULTS Program Prediction Accuracy % Prediction % Correct %Correct % Correct at extremes at extremes not at extremes overall ADVAN GIBSON SCI SINCOS SORTST TBLLNK (Results with 3 bit counter and 16-word RAM)

CONCLUSION