software-based and hardware-based branch prediction strategies and performance evaluation
DESCRIPTION
Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation. Gang Luo, Hongfei Guo {gangluo, guo}@cs.wisc.edu. Contents. Background Implementation based on SimpleScalar3.0 Simulation Model Simulation Results Conclusion and Future work. 1. Background. - PowerPoint PPT PresentationTRANSCRIPT
Software-based and Hardware-based
Branch Prediction Strategies
and Performance Evaluation
Gang Luo, Hongfei Guo
{gangluo, guo}@cs.wisc.edu
Contents
• Background
• Implementation based on SimpleScalar3.0
• Simulation Model
• Simulation Results
• Conclusion and Future work
1. Background
• Why branch prediction?
• Software-based branch predictors
• Hardware-based branch predictors
Why need branch prediction
• Avoid control hazard
• Predict branch direction and branch address
• Avoid stopping pipeline
• Speedup program execution
Classification of Branch
Prediction Strategies
• Software-based static branch predictors
• Hardware-based dynamic branch predictors
Software-based Strategy
• Always Taken
• Always Not Taken
• Backward Taken, Forward Not Taken
• All branches with certain operation codes Taken, others Not Taken
Hardware-based Strategy
• One-bit counter
• Two-bit counter
• Gag
• Pag
• Pap
• Branch Instruction Table
2. Implementation based on SS3.0
• Backward taken & forward not taken
• one-bit prediction counter
• fix a bug
---- Support command line configuration
current branch address
target address
Current address >
Target address
target address
Next inst. address
Y
N
Predicted address
Backward taken & forward not taken branch predictor
update
Predicted direction
Lookup
HASH
address2 target address2
Addressn-
1
target address n-1
address1 target address1
……
address n target address n
0 1 …… 1 0
current branch address
Predicted target
BTB
2 to 1 MUX
Next inst. address
Predicted inst. address
Compare
New inst. address
update
Branch prediction counter
One bit counter (two bits counter)
HASH table
3. Simulation Model
Mode Level 1 Table Level 2 Table
# of Entries Width of SR # of Entries
• One-bit -- -- 2048
• Bimode -- -- 2048
• GAg 1 11 2048
• PAg 4 11 2048
• PAp 4 7 2048
• BTB 512 Associ. 4 --
Spec95 Benchmarks Used
• Gcc
• Compress
• Li
• M88k
• Perl
4. Simulation Results
• Results of software-based Strategies
• Results of hardware-based Strategies
• Software-based Strategies vs.
hardware-based Strategies
• Explanations
Performance of Software-based Strategies
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
gcc compress li m88k perl
benchmark
perc
enta
ge o
f co
rrec
t br
anch
pre
dict
ion
taken
not taken
back taken
Analysis of Software-based Strategies
• Always Taken is the best one
• Always Not Taken & Backward Taken, Forward Not Taken are equally bad
Explanation
• Backward Taken, Forward Not Taken is mainly pointed at the for loop and while loop statement
• Most branches in the program are inclined to be taken
Performance of Hardware-based Strategies
0.75
0.8
0.85
0.9
0.95
1
gcc compress li m88k perl
benchmark
perc
enta
ge o
f co
rrec
t br
anch
pre
dict
ion
one bit
two bit
Gag
Pag
Pap
Analysis of Hardware-based Strategies
• Two-bit counter and Gag are the best two
• One-bit counter, Pag, and Pap also achieve high prediction accuracy
Explanation
• One-bit counter: intrinsic shortcoming
• Pag: all the branch histories share the same global two-bit counter tables, which leads to confusion
• Pap: too many branch history pattern tables compared to the number of instructions executed, can’t get enough training
Software-based Strategies vs. Hardware-based Strategies
• Hardware-based strategies always achieve high prediction accuracy, greater than 90%
• Most software-based strategies achieve low prediction accuracy, less than 70%
Explanation
• Different data sets will let the programs have different dynamic branch behaviors
• Even for the same data set, the same branch instruction will exhibit different dynamic branch behaviors at different times in the same running
5. Future Work
• Use some AI algorithms to adjust the parameters of the branch prediction strategies, then we can ensure the most proper training time to achieve the highest performance.