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
![Page 1: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/1.jpg)
Software-based and Hardware-based
Branch Prediction Strategies
and Performance Evaluation
Gang Luo, Hongfei Guo
{gangluo, guo}@cs.wisc.edu
![Page 2: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/2.jpg)
Contents
• Background
• Implementation based on SimpleScalar3.0
• Simulation Model
• Simulation Results
• Conclusion and Future work
![Page 3: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/3.jpg)
1. Background
• Why branch prediction?
• Software-based branch predictors
• Hardware-based branch predictors
![Page 4: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/4.jpg)
Why need branch prediction
• Avoid control hazard
• Predict branch direction and branch address
• Avoid stopping pipeline
• Speedup program execution
![Page 5: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/5.jpg)
Classification of Branch
Prediction Strategies
• Software-based static branch predictors
• Hardware-based dynamic branch predictors
![Page 6: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/6.jpg)
Software-based Strategy
• Always Taken
• Always Not Taken
• Backward Taken, Forward Not Taken
• All branches with certain operation codes Taken, others Not Taken
![Page 7: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/7.jpg)
Hardware-based Strategy
• One-bit counter
• Two-bit counter
• Gag
• Pag
• Pap
• Branch Instruction Table
![Page 8: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/8.jpg)
2. Implementation based on SS3.0
• Backward taken & forward not taken
• one-bit prediction counter
• fix a bug
---- Support command line configuration
![Page 9: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/9.jpg)
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
![Page 10: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/10.jpg)
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
![Page 11: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/11.jpg)
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 --
![Page 12: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/12.jpg)
Spec95 Benchmarks Used
• Gcc
• Compress
• Li
• M88k
• Perl
![Page 13: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/13.jpg)
4. Simulation Results
• Results of software-based Strategies
• Results of hardware-based Strategies
• Software-based Strategies vs.
hardware-based Strategies
• Explanations
![Page 14: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/14.jpg)
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
![Page 15: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/15.jpg)
Analysis of Software-based Strategies
• Always Taken is the best one
• Always Not Taken & Backward Taken, Forward Not Taken are equally bad
![Page 16: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/16.jpg)
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
![Page 17: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/17.jpg)
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
![Page 18: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/18.jpg)
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
![Page 19: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/19.jpg)
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
![Page 20: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/20.jpg)
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%
![Page 21: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/21.jpg)
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
![Page 22: Software-based and Hardware-based Branch Prediction Strategies and Performance Evaluation](https://reader035.vdocuments.us/reader035/viewer/2022062410/5681596b550346895dc6aae5/html5/thumbnails/22.jpg)
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.