220 likes | 376 Views
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.
E N D
Software-based and Hardware-based Branch Prediction Strategiesand 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 Y target address Current address > Target address Predicted address Next inst. address target address N Backward taken & forward not taken branch predictor
0 1 …… 1 0 address2 Addressn-1 address1 address n target address2 target address n-1 target address1 target address n …… One bit counter (two bits counter) HASH table current branch address HASH Predicted direction Lookup BTB update Predicted target 2 to 1 MUX Predicted inst. address Next inst. address Compare update New inst. address Branch prediction counter
3. Simulation Model ModeLevel 1 TableLevel 2 Table # of EntriesWidth 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
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
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.