two-level adaptive dynamic branch prediction jeroen lichtenauer

23
Two-Level Adaptive Dynamic Two-Level Adaptive Dynamic Branch Branch Prediction Prediction Jeroen Lichtenauer Jeroen Lichtenauer

Post on 20-Dec-2015

217 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

Two-Level Adaptive Dynamic Two-Level Adaptive Dynamic

Branch PredictionBranch Prediction

Jeroen LichtenauerJeroen Lichtenauer

Page 2: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

ContentsContents• The problem to be solvedThe problem to be solved

• Solutions OverviewSolutions Overview

• Prediction counterPrediction counter

• Two-Level Adaptive Branch Two-Level Adaptive Branch PredictionPrediction

• SummarySummary

• ConclusionConclusion

• Related WorkRelated Work

Page 3: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

LiteratureLiterature

• A Comparison of Dynamic Branch A Comparison of Dynamic Branch Predictors that use Two Levels of Branch Predictors that use Two Levels of Branch History.History.Tse-Yu Yeh and Yale N. Patt.Tse-Yu Yeh and Yale N. Patt.Department of Electrical Engineering and Computer Science.Department of Electrical Engineering and Computer Science.The University of Michigan, 1993The University of Michigan, 1993

Also important:Also important:

• Target Prediction for Indirect JumpsTarget Prediction for Indirect JumpsPo-Yung Chang, Eric Hao and Yale N. Patt.Po-Yung Chang, Eric Hao and Yale N. Patt.Department of Electrical Engineering and Computer Science.Department of Electrical Engineering and Computer Science.The University of Michigan, 1997The University of Michigan, 1997

Page 4: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

ProblemProblem• Increase in issue rateIncrease in issue rate

• Increase in pipeline depthIncrease in pipeline depth

• More speculative executionMore speculative execution

• More penalty for misprediction of branchesMore penalty for misprediction of branches

Successful Branch Prediction becomes Successful Branch Prediction becomes more and more important for reducing more and more important for reducing execution time!!execution time!!

Page 5: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

Solutions overviewSolutions overview• Static predictionStatic prediction

– During compilationDuring compilation

• Dynamic predictionDynamic prediction– Hardware, for instance using branch Hardware, for instance using branch

historyhistory

• A combination A combination – Compiler Synthesized Dynamic Branch Compiler Synthesized Dynamic Branch

PredictionPrediction

Page 6: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

Prediction CounterPrediction Counter

• Increase 1 if branch takenIncrease 1 if branch taken

• Decrease 1 if branch not takenDecrease 1 if branch not taken

• Predict taken if counter value larger Predict taken if counter value larger than half of the rangethan half of the range

2 bit counter:2 bit counter:

00 & 01 = Predict not taken00 & 01 = Predict not taken10 & 11 = Predict taken10 & 11 = Predict taken

Page 7: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

Two-Level Adaptive Two-Level Adaptive Branch PredictionBranch Prediction

• First level, execution history First level, execution history register(s):register(s):History of the last History of the last kk branches encountered. branches encountered.

• Second level, pattern history table(s): Second level, pattern history table(s): kk refers to a place in the pattern history refers to a place in the pattern history table that contains the prediction based on table that contains the prediction based on the outcome of the branches at the last the outcome of the branches at the last jj occurences of occurences of kk,,Predictor is for instance a Predictor is for instance a prediction counterprediction counter..

Page 8: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

1st Level 1st Level Branch History Register or Table (BHR or Branch History Register or Table (BHR or

BHT)BHT)

• GGlobal lobal History of all branches kept in a single History of all branches kept in a single register of length register of length kk..

• PPer-addresser-addressTable that contains a history register of Table that contains a history register of length length kk for each branch. for each branch.

• Per Per SSetetTable that contains a history register of Table that contains a history register of length length kk for each set of branches. for each set of branches.

Page 9: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

2nd level2nd levelPattern History Table (PHT)Pattern History Table (PHT)

• gglobal lobal Table with a prediction for all possible Table with a prediction for all possible values of values of kk..

• pper-addresser-addressTable with a prediction for all possible Table with a prediction for all possible values of values of kk for each branch address. for each branch address.

• Per Per ssetetTable with a prediction for all possible Table with a prediction for all possible values of values of kk for each branch set. for each branch set.

Page 10: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

The 9 Variations of 2-Level Adaptive Branch The 9 Variations of 2-Level Adaptive Branch predictionprediction

Page 11: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

The 9 Variations of 2-Level Adaptive Branch The 9 Variations of 2-Level Adaptive Branch predictionprediction

Page 12: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

The 9 Variations of 2-Level Adaptive Branch The 9 Variations of 2-Level Adaptive Branch predictionprediction

Page 13: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

1 Global Branch History(1 Global Branch History(GGAAss), function of History ), function of History LengthLength

Page 14: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

1 Global Branch History(1 Global Branch History(GGAAss), function of Pattern ), function of Pattern TablesTables

Page 15: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

Per-Address Branch History(Per-Address Branch History(PPAAss) function of History ) function of History lengthlength

Page 16: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

Per-Address Branch History(Per-Address Branch History(PPAAss) function of Pattern ) function of Pattern TablesTables

Page 17: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

Per-Address Branch History(Per-Address Branch History(PPAAss), function of PHTs), function of PHTs

Page 18: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

1 Global Branch History(1 Global Branch History(GGAAss), function of PHTs), function of PHTs

Page 19: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

Per-Set Branch History(Per-Set Branch History(PPAAss), function of PHTs), function of PHTs

Page 20: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

Interpretation of resultsInterpretation of results• Pattern tables(PHTs) always best per-Pattern tables(PHTs) always best per-sset et

(*A(*Ass) or global (*A) or global (*Agg). *A). *App is useless. is useless.

• Global History schemes(Global History schemes(GGAAss) perform ) perform best on integer programs, but only at high best on integer programs, but only at high cost.cost.

• Per-address History schemes (Per-address History schemes (PPAAss) ) perform better on floating point programs, perform better on floating point programs, even at low cost.even at low cost.

• Per-set History schemes (Per-set History schemes (SSAAss) can reach ) can reach best overall performance, but have the best overall performance, but have the highest cost so not cost-effective.highest cost so not cost-effective.

Page 21: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

• Branch prediction is a very important factor Branch prediction is a very important factor in reducing CPI in modern processors that in reducing CPI in modern processors that use extensive pipelining.use extensive pipelining.

• A counter is often used for prediction (2 bit)A counter is often used for prediction (2 bit)

• Two-Level Adaptive Dynamic Branch Two-Level Adaptive Dynamic Branch Prediction ‘learns’ the outcome of branches Prediction ‘learns’ the outcome of branches in different program states.in different program states.

• 9 Variations of 2-L.A.B.P. (9 Variations of 2-L.A.B.P. (GGlobal, lobal, PPer-er-Address and Per-Address and Per-SSet for both levels), but et for both levels), but only 4 useful.only 4 useful.

SummarySummary

Page 22: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

• Two-level Adaptive Branch Prediction is very Two-level Adaptive Branch Prediction is very effective, up to +97% average accuracy.effective, up to +97% average accuracy.

• BHR length has more influence on precision BHR length has more influence on precision then number of PHTs.then number of PHTs.

• Pattern tables(PHTs) always per-Pattern tables(PHTs) always per-sset (*Aet (*Ass) or ) or even just 1 global table (*Aeven just 1 global table (*Agg).).

• At low cost At low cost PPAAss is best , at high cost is best , at high cost GGAAss is is bestbest

ConclusionConclusion

Page 23: Two-Level Adaptive Dynamic Branch Prediction Jeroen Lichtenauer

• Compiler Synthesised Dynamic Branch Compiler Synthesised Dynamic Branch PredictionPredictionScott Mahlke and Balas NatarajanScott Mahlke and Balas NatarajanHewlett-Peckard Laboratories, Palo Alto, 1996Hewlett-Peckard Laboratories, Palo Alto, 1996Uses not only branch history but also other info, for Uses not only branch history but also other info, for instance the contents of the architectural registers.instance the contents of the architectural registers.This does not provide significant better prediction This does not provide significant better prediction results then 2-Level Branch Predictors.results then 2-Level Branch Predictors.

• The Effect of Process Switches on Branch The Effect of Process Switches on Branch Prediction AccuracyPrediction AccuracyT. Kisuki, H. Corporaal and P.M.W. KnijnenburgT. Kisuki, H. Corporaal and P.M.W. KnijnenburgDepartment of Computer Science, Leiden UniversityDepartment of Computer Science, Leiden UniversityDepartment of Electrical Engineering, Delft University of Department of Electrical Engineering, Delft University of TechnologyTechnology19991999The effect of ‘cold starts’ after process switches is only The effect of ‘cold starts’ after process switches is only significant if the process switches occur more than once significant if the process switches occur more than once every 100K clock cycles.every 100K clock cycles.

Related WorkRelated Work