1 / 20

EECS 470

EECS 470. Branch Prediction Lecture 6 Coverage: Chapter 3. Parts of the predictor. Direction Predictor For conditional branches Predicts whether the branch will be taken Examples: Always taken; backwards taken Address Predictor Predicts the target address (use if predicted taken)

lot
Télécharger la présentation

EECS 470

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EECS 470 Branch Prediction Lecture 6 Coverage: Chapter 3

  2. Parts of the predictor • Direction Predictor • For conditional branches • Predicts whether the branch will be taken • Examples: • Always taken; backwards taken • Address Predictor • Predicts the target address (use if predicted taken) • Examples: • BTB; Return Address Stack; Precomputed Branch • Recovery logic Ref: The Precomputed BranchArchitecture

  3. Characteristics of branches • Individual branches differ • Loops tend not to exit • Unoptimized code: not-taken • Optimized code: taken • If-statements: • Tend to be less predictable • Unconditional branches • Still need address prediction

  4. Example gzip: • gzip: loop branch A@ 0x1200098d8 • Executed: 1359575 times • Taken: 1359565 times • Not-taken: 10 times • % time taken: 99% - 100% Easy to predict (direction and address)

  5. Example gzip: • gzip: if branch B@ 0x12000fa04 • Executed: 151409 times • Taken: 71480 times • Not-taken: 79929 times • % time taken: ~49% Easy to predict? (maybe not/ maybe dynamically)

  6. Easy to predict Easy to predict Example: gzip A B 0 100 Direction prediction: always taken Accuracy: ~73 %

  7. Branch Backwards Most backward branches are heavily NOT-TAKEN Forward branches slightly more likely to be TAKEN Ref: The Effects of Predicated Execution on Branch Prediction

  8. NT T Using history • 1-bit history (direction predictor) • Remember the last direction for a branch Branch History Table branchPC How big is the BHT?

  9. Example: gzip A B 0 100 Direction prediction: always taken Accuracy: ~73 % How many times will branch A mispredict? How many times will branch B mispredict?

  10. SN T NT ST Using history • 2-bit history (direction predictor) Branch History Table branchPC How big is the BHT?

  11. Example: gzip A B 0 100 Direction prediction: always taken Accuracy: ~73 % How many times will branch A mispredict? How many times will branch B mispredict?

  12. Using History Patterns ~80 percent of branches are either heavily TAKEN or heavily NOT-TAKEN For the other 20%, we need to look a patterns of reference to see if they are predictable using a more complex predictor Example: gcc has a branch that flips each time T(1) NT(0)10101010101010101010101010101010101010

  13. NT T Local history branchPC Branch History Table Pattern History Table 10101010 What is the prediction for this BHT 10101010? When do I update the tables?

  14. NT T Local history branchPC Branch History Table Pattern History Table 01010101 On the next execution of this branch instruction, the branch history table is 01010101, pointing to a different pattern What is the accuracy of a flip/flop branch 0101010101010…?

  15. Global history Pattern History Table Branch History Register 01110101 if (aa == 2) aa = 0; if (bb == 2) bb = 0; if (aa != bb) { … How can branches interfere with each other?

  16. Must read! Gshare predictor branchPC Pattern History Table Branch History Register xor 01110101 Ref: Combining Branch Predictors

  17. Bimod predictor Global history reg branchPC xor Choice predictor PHT skewed taken PHT skewed Not-taken mux

  18. Hybrid predictors Global/gshare predictor (much more state) Local predictor (e.g. 2-bit) Prediction 1 Prediction 2 Selection table (2-bit state machine) Prediction How do you select which predictor to use? How do you update the various predictor/selector?

  19. Overriding Predictors • Big predictors are slow, but more accurate • Use a single cycle predictor in fetch • Start the multi-cycle predictor • When it completes, compare it to the fast prediction. • If same, do nothing • If different, assume the slow predictor is right and flush pipline. • Advantage: reduced branch penalty for those branches mispredicted by the fast predictor and correctly predicted by the slow predictor

  20. Pipelined Gshare Predictor • How can we get a pipelined global prediction by stage 1? • Start in stage –2 • Don’t have the most recent branch history… • Access multiple entries • E.g. if we are missing last three branches, get 8 histories and pick between them during fetch stage. Ref: Reconsidering Complex Branch Predictors coming soon (to be published Feb 2003)

More Related