【正文】
? ? ? } For both schemes Actual: N N T T N N T T State: N* N* N* N*T T*N N*T N* N*T Predicted: N N N N T N N N Scheme 1 Scheme 2 T T N T N T N N T* T*N N* N*T T T N T N T N N T* T*N N* N*T 2 1 Copyright 2020 UCB amp。 A. Smith, IEEE Computer, Jan 1984 Copyright 2020 UCB amp。 Man Kaufmann ECE668 .7 Adapted from Patterson, Katz and Culler 169。 Man Kaufmann ECE668 .6 Adapted from Patterson, Katz and Culler 169。 Man Kaufmann ECE668 .5 Adapted from Patterson, Katz and Culler 169。 Man Kaufmann ECE668 .4 Adapted from Patterson, Katz and Culler 169。 Man Kaufmann ECE668 .3 Adapted from Patterson, Katz and Culler 169。 Man Kaufmann ECE668 .2 Adapted from Patterson, Katz and Culler 169。 UCB Csaba Andras Moritz UNIVERSITY OF MASSACHUSETTS Dept. of Electrical amp。 Copyright 2020 UCB amp。 Man Kaufmann ECE668 .1 Adapted from Patterson, Katz and Culler 169。 Computer Engineering Computer Architecture ECE 668 Dynamic Branch Prediction Copyright 2020 UCB amp。 UCB Static Branch Prediction ?Simplest: Predict taken ? average misprediction rate = untaken branch frequency, which for the SPEC programs is 34% ? Unfortunately, the correct prediction rate ranges from not very accurate (41%) to highly accurate (91%) ?Predict on the basis of branch direction? ? choosing backwardgoing branches to be taken (loop) ? forwardgoing branches to be not taken (if) ? SPEC programs, however, most forwardgoing branches are taken = predict taken is better ?Predict branches on the basis of profile information collected from earlier runs ? Misprediction varies from 5% to 22% Copyright 2020 UCB amp。 UCB Eight Branch Prediction Schemes ? 1bit BranchPrediction ? 2bit BranchPrediction ? Correlating Branch Prediction ? Gshare ? Tournament Branch Predictor ? Branch Target Buffer ? Conditionally Executed Instructions ? Return Address Predictors Branch Prediction even more important when N instructions per cycle are issued Amdahl’s Law = relative impact of the control stalls will be larger with the lower potential CPI in an nissue processor Copyright 2020 UCB amp。 UCB Dynamic Branch Prediction ?Performance = ?(accuracy, cost of misprediction) ?Branch History Table (BHT): Lower bits of PC address index table of 1bit values ? Says whether or not branch taken last time ( TTaken, N ) ?No full address check (saves HW, but may be wrong) ?Problem: in a loop, 1bit BHT will cause 2 mispredictions (avg is 9 iterations before exit): ? End of loop case, when it exits instead of looping as before ?First time through loop on next time through code, when it predicts exit instead of looping ?Only % accuracy if 9 iterations per loop on average . . . TTT T N N T TT . . . Copyright 2020 UC