Cau 1 - Correlated predictors - Control Hazards The nub of...

Info icon This preview shows pages 1–5. Sign up to view the full content.

1 Spring 2006 CSE 471 - Dynamic Branch Prediction 1 Control Hazards The nub of the problem: ° In what pipeline stage does the processor fetch the next instruction? ° If that instruction is a conditional branch, when does the processor know whether the conditional branch is taken (execute code at the target address) or not taken (execute the sequential code)? ° What is the difference in cycles between them? The cost of stalling until you know whether to branch ° number of cycles in between * branch frequency = the contribution to CPI due to branches Predict the branch outcome to avoid stalling Spring 2006 CSE 471 - Dynamic Branch Prediction 2 Branch Prediction Branch prediction: ° Resolve a branch hazard by predicting which path will be taken ° Proceed under that assumption ° Flush the wrong-path instructions from the pipeline & fetch the right path if wrong Performance improvement depends on: ° whether the prediction is correct (here±s most of the innovation) ° how soon you can check the prediction
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

2 Spring 2006 CSE 471 - Dynamic Branch Prediction 3 Branch Prediction Dynamic branch prediction: ° the prediction changes as program behavior changes ° branch prediction implemented in hardware for a runtime check ° common algorithm based on branch history ° predict the branch taken if branched the last time ° predict the branch not-taken if didn±t branch the last time Alternative: static branch prediction ° compiler-determined prediction ° fixed for the life of the program ° an algorithm? Spring 2006 CSE 471 - Dynamic Branch Prediction 4 Branch Prediction Buffer Branch prediction buffer ° small memory indexed by the lower bits of the address of a branch instruction during the fetch stage ° contains a prediction (which path the last branch to index to this BPB location took) ° do what the prediction says to do ° if the prediction is taken & it is correct ° only incur a one-cycle penalty why? ° if the prediction is not taken & it is correct ° incur no penalty why? ° if the prediction is incorrect ° change the prediction ° also flush the pipeline why? ° penalty is the same as if there were no branch prediction why?
Image of page 2
3 Spring 2006 CSE 471 - Dynamic Branch Prediction 5 Two-bit Prediction A single prediction bit does not work well with loops ° mispredicts the first & last iterations of a nested loop Two-bit branch prediction for loops ° Algorithm: have to be wrong twice before the prediction is changed Spring 2006 CSE 471 - Dynamic Branch Prediction 6 Two-bit Prediction Works well when branches predominantly go in one direction ° Why? A second check is made to make sure that a short & temporary change of direction does not change the prediction away from the dominant direction What pattern is bad for two-bit branch prediction?
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

4 Spring 2006 CSE 471 - Dynamic Branch Prediction 7 Two-bit Prediction Often implemented as a table (a prediction buffer) of 2-bit saturating counters ° increase on a taken branch ° decrease on a not-taken branch, not less than 0 ° most significant bit is the prediction
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.
  • Fall '13
  • Branch predictor, Dynamic branch

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern