DOC PREVIEW
Berkeley COMPSCI 152 - Lecture 19 Finish speculation

This preview shows page 1-2 out of 6 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

11/06/01 ©UCB Fall, 2001CS152 / Kubiatowicz Lec19.1CS152Computer Architecture and EngineeringLecture 19Finish speculation(Branch Prediction)November 7th, 2001John Kubiatowicz (http.cs.berkeley.edu/~kubitron)lecture slides: http://www-inst.eecs.berkeley.edu/~cs152/11/07/01 ©UCB Fall, 2001CS152 / Kubiatowicz Lec19.2Review: Tomasulo Organization)3 DGGHUV)3 DGGHUV$GG$GG$GG)3 PXOWLSOLHUV)3 PXOWLSOLHUV0XOW0XOW)URP 0HP)3 5HJLVWHUV5HVHUYDWLRQ 6WDWLRQV&RPPRQ 'DWD %XV &'%7R 0HP)3 2S4XHXH/RDG %XIIHUV6WRUH %XIIHUV/RDG/RDG/RDG/RDG/RDG/RDG11/07/01 ©UCB Fall, 2001CS152 / Kubiatowicz Lec19.3Review: Tomasulo Architecture° Reservations stations: renaming to larger set of registers + buffering source operands• Prevents registers as bottleneck• Avoids WAR, WAW hazards of Scoreboard• Allows loop unrolling in HW° Not limited to basic blocks (integer units gets ahead, beyond branches)° Dynamic Scheduling:• Scoreboarding/Tomasulo• In-order issue, out-of-order execution, out-of-ordercommit° Branch prediction/speculation• Regularities in program execution permit prediction of branch directions and data values• Necessary for wide superscalar issue11/07/01 ©UCB Fall, 2001CS152 / Kubiatowicz Lec19.4° Prediction has become essential to getting good performance from scalar instruction streams.° We will discuss predicting branches. However, architects are now predicting everything: data dependencies, actual data, and results of groups of instructions:• At what point does computation become a probabilistic operation + verification?• We are pretty close with control hazards already…° Why does prediction work?• Underlying algorithm has regularities.• Data that is being operated on has regularities.• Instruction sequence has redundancies that are artifacts of way that humans/compilers think about problems.° Prediction  Compressible information streams?Recall: Prediction: Branches, Dependencies, Data11/07/01 ©UCB Fall, 2001CS152 / Kubiatowicz Lec19.5Review: Independent “Fetch” unitInstruction Fetchwith Branch PredictionOut-Of-OrderExecutionUnitCorrectness FeedbackOn Branch ResultsStream of InstructionsTo Execute° Instruction fetch decoupled from execution° Often issue logic (+ rename) included with Fetch11/07/01 ©UCB Fall, 2001CS152 / Kubiatowicz Lec19.6Review: Branches must be resolved quickly° In our loop-unrolling example, we relied on the fact that branches were under control of “fast” integer unit in order to get overlap! Loop: LD F0 0 R1MULTD F4 F0 F2SD F4 0 R1SUBI R1 R1 #8BNEZ R1 Loop° What happens if branch depends on result of multd??• We completely lose all of our advantages!• Need to be able to “predict” branch outcome.• If we were to predict that branch was taken, this would be right most of the time. ° Problem much worse for superscalar machines!11/07/01 ©UCB Fall, 2001CS152 / Kubiatowicz Lec19.7Dynamic Branch Prediction° Prediction could be “Static” (at compile time) or “Dynamic” (at runtime)• For our example, if we were to statically predict “taken”, we would only be wrong once each pass through loop° Is dynamic branch prediction better than static branch prediction?• Seems to be. Still some debate to this effect• Today, lots of hardware being devoted to dynamic branch predictors.° Does branch prediction make sense for 5-stage, in-order pipeline? What about 8-stage pipeline?• Perhaps: eliminate branch delay slots• Then predict branches11/07/01 ©UCB Fall, 2001CS152 / Kubiatowicz Lec19.8° Address of branch index to get prediction AND branch address (if taken)• Must check for branch match now, since can’t use wrong branch address• Grab predicted PC from table since may take several cycles to compute° Update predicted PC when branch is actually resolved° Return instruction addresses predicted with stack%UDQFK 3& 3UHGLFWHG 3& "3& RI LQVWUXFWLRQ)(7&+3UHGLFW WDNHQ RU XQWDNHQSimple dynamic prediction: Branch Target Buffer (BTB)11/07/01 ©UCB Fall, 2001CS152 / Kubiatowicz Lec19.9Branch History Table° BHT is a table of “Predictors”• Usually 2-bit, saturating counters• Indexed by PC address of Branch – without tags° In Fetch state of branch:• BTB identifies branch• Predictor from BHT used to make prediction° When branch completes• Update corresponding PredictorPredictor 0Predictor 7Predictor 1Branch PC11/07/01 ©UCB Fall, 2001CS152 / Kubiatowicz Lec19.10Dynamic Branch Prediction° Branch History Table: Lower bits of PC address prediction table• Branch Target Buffer (BTB): identify branches and hold taken addresses- Trick: identify branch before fetching instruction!• Branch History Table makes prediction- Simplest possibility – could be something much more complicated.• No address check: Can be good, can be bad….° Simple 1-bit BHT: keep last direction of branch° Problem: in a loop, 1-bit BHT will cause twomispredictions (avg is 9 iteratios 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° Performance = ƒ(accuracy, cost of misprediction)• Misprediction  Flush Reorder Buffer11/07/01 ©UCB Fall, 2001CS152 / Kubiatowicz Lec19.11° Solution: 2-bit scheme where change prediction only if get misprediction twice: (Figure 4.13, p. 264)° Red: stop, not taken° Green: go, taken° Adds hysteresis to decision making processDynamic Branch PredictionTTNTNTPredict TakenPredict Not TakenPredict TakenPredict Not TakenTNTTNT11/07/01 ©UCB Fall, 2001CS152 / Kubiatowicz Lec19.12BHT Accuracy° Mispredict because either:• Wrong guess for that branch• Got branch history of wrong branch when index the table° 4096 entry table programs vary from 1%misprediction (nasa7, tomcatv) to 18% (eqntott), with spice at 9% and gcc at 12%° 4096 about as good as infinite table(in Alpha 211164)11/07/01 ©UCB Fall, 2001CS152 / Kubiatowicz Lec19.13Correlating Branches° Hypothesis: behavior of recently executed branches affects prediction of current branch° Two possibilities; Current branch depends on:• Last m most recently executed branches anywhere in programProduces a “GA” (for “global address”) in the Yeh and Patt classification (e.g. GAg)• Last m most recent outcomes of same branch.Produces a “PA” (for “per address”) in same classification (e.g. PAg)° Idea: record m most


View Full Document

Berkeley COMPSCI 152 - Lecture 19 Finish speculation

Documents in this Course
Quiz 5

Quiz 5

9 pages

Memory

Memory

29 pages

Quiz 5

Quiz 5

15 pages

Memory

Memory

29 pages

Memory

Memory

35 pages

Memory

Memory

15 pages

Quiz

Quiz

6 pages

Midterm 1

Midterm 1

20 pages

Quiz

Quiz

12 pages

Memory

Memory

33 pages

Quiz

Quiz

6 pages

Homework

Homework

19 pages

Quiz

Quiz

5 pages

Memory

Memory

15 pages

Load more
Download Lecture 19 Finish speculation
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 19 Finish speculation and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 19 Finish speculation 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?