branch-prediction

Computer Architecture, Fifth Edition: A Quantitative Approach (The Morgan Kaufmann Series in Computer Architecture and Design)

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Nov. 9, 2004 Lec.8 1 Lecture 7 Branch Prediction (3.4, 3.5) Instructor: Laxmi Bhuyan
Background image of page 1

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

View Full DocumentRight Arrow Icon
Nov. 9, 2004 Lec.8 2 Instruction status Execution Write Instruction j k Issue complete Result Busy LD F6 34+ R2 x x x Load1 No LD F2 45+ R3 x x Load2 Yes MULTD F0 F2 F4 x SUBD F8 F6 F2 x DIVD F10 F0 F6 x ADDD F6 F8 F2 x Reservation Stations S1 S2 RS for j RS for k Time Name Busy Op Vj Vk Qj Qk A Load1 No Load2 yes Load 45+Regs[R3] 0 Add1 yes SUB Mem[34+Regs[R2]] Load2 0 Add2 yes ADD Add1 Load2 Add3 No 0 Mult1 yes MUL Regs[F4] Load2 0 Mult2 yes DIV Mem[34+Regs[R2]] Mult1 Register result status Field F0 F2 F4 F6 F8 F10 F12 Addre Tomasulo Status pp. 190
Background image of page 2
Nov. 9, 2004 Lec.8 3 Why do we want to predict branches? MIPS based pipeline – 1 instruction issued per cycle, branch hazard of 1 cycle. Delayed branch Modern processor and next generation – multiple instructions issued per cycle, more branch hazard cycles will incur. Cost of branch misfetch goes up Pentium Pro – 3 instructions issued per cycle, 12+ cycle misfetch penalty HUGE penalty for a misfetched path following a branch
Background image of page 3

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

View Full DocumentRight Arrow Icon
Nov. 9, 2004 Lec.8 4 Branch Prediction Easiest (static prediction) Always taken, always not taken Opcode based Displacement based (forward not taken, backward taken) Compiler directed (branch likely, branch not likely) Next easiest 1 bit predictor – remember last taken/not taken per branch Use a branch-prediction buffer or branch-history table with 1 bit entry Use part of the PC (low-order bits) to index buffer/table – Why? Multiple branches may share the same bit Invert the bit if the prediction is wrong Backward branches for loops will be mispredicted twice EX: If a loop branches 9 times in a row and not taken once, what is the prediction accuracy? Ans: Misprediction at the first loop and last loop => 80% prediction accuracy although branch is taken 90% time.
Background image of page 4
Nov. 9, 2004 Lec.8 5 2-bit Branch Prediction Has 4 states instead of 2, allowing for more information about tendencies A prediction must miss twice before it is changed Good for backward branches of loops
Background image of page 5

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

View Full DocumentRight Arrow Icon
Nov. 9, 2004 Lec.8 6 Branch History Table 01 BHT branch PC Has limited size 2 bits by N (e.g. 4K entries) Uses low-order bits of branch PC to choose entry Plot misprediction instead of prediction
Background image of page 6
Nov. 9, 2004 Lec.8 7 Observations Prediction Accuracy ranges from 99% to 82% or a misprediction rate of 1% to 18% Misprediction for integer programs (gcc, espresso, eqntott, li) is substantially higher than FP programs (nasa7, matrix300, tomcatv, doduc, spice, fppp) Branch penalty involves both misprediction rate and branch frequency, and is higher for integer benchmarks Prediction accuracy improves with buffer size, but doesn’t improve beyond 4K entries (Fig. 3.9)
Background image of page 7

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

View Full DocumentRight Arrow Icon
Nov. 9, 2004 Lec.8 8 Correlating or Two-level Predictors Correlating branch predictors also look at other branches for clues. Consider the following example.
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 27

branch-prediction - Lecture 7 Branch Prediction (3.4, 3.5)...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online