05+-+Branches - CS 4290/6290 Branch Pre diction and Ins...

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

View Full Document Right Arrow Icon
CS 4290/6290 Branch Prediction and Instruction Delivery
Background image of page 1

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

View Full DocumentRight Arrow Icon
Want to execute several instructions per cycle? Fetch and decode several instructions per cycle Then find a way to execute them Problem? Branches are very frequent! Approx. 20% of all instructions Can not wait until we know where it goes Long pipelines • Branch outcome known after B cycles • No scheduling past the branch until outcome known Superscalars (e.g., 4-way) Branch every cycle or so! One cycle of work, then stall for ~B cycles? CS 4290/6290 – Spring 2009 – Prof. Milos Prvulovic 2
Background image of page 2
Predict Branches And predict them well! Fetch, decode, etc. on the predicted path Option 1: No execute until branch resovled Option 2: Execute anyway (speculation) Recover from mispredictions Restart fetch from correct path CS 4290/6290 – Spring 2009 – Prof. Milos Prvulovic 3
Background image of page 3

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

View Full DocumentRight Arrow Icon
Need to know two things Whether the branch is taken or not (direction) The target address if it is taken (target) Direct jumps, Function calls Direction known (always taken), target easy to compute Conditional Branches (typically PC-relative) Direction difficult to predict, target easy to compute Indirect jumps, function returns Direction known (always taken), target difficult CS 4290/6290 – Spring 2009 – Prof. Milos Prvulovic 4
Background image of page 4
Needed for conditional branches Most branches are of this type Many, many kinds of predictors for this Static: fixed rule, or compiler annotation (e.g. “BEQL” is “branch if equal likely”) Dynamic: hardware prediction Dynamic prediction usually history-based Example: predict direction is the same as the last time this branch was executed CS 4290/6290 – Spring 2009 – Prof. Milos Prvulovic 5
Background image of page 5

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

View Full DocumentRight Arrow Icon
Always predict NT easy to implement 30-40% accuracy … not so good Always predict T 60-70% accuracy BTFNT (Backward T, Forward NT) loops usually have a number of iterations, so this is like always predicting that the loop is taken Don’t know target until decode Before then, don’t know if it is a branch! CS 4290/6290 – Spring 2009 – Prof. Milos Prvulovic 6
Background image of page 6
CS 4290/6290 – Spring 2009 – Prof. Milos Prvulovic K bits of branch instruction address Index Branch history table of 2^K entries, 1 bit per entry Use this entry to predict this branch: 0: predict not taken 1: predict taken When branch direction resolved, go back into the table and update entry: 0 if not taken, 1 if taken Note: we know this before we even fetch the instruction 7
Background image of page 7

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

View Full DocumentRight Arrow Icon
CS 4290/6290 – Spring 2009 – Prof. Milos Prvulovic
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.

This note was uploaded on 04/12/2010 for the course CS 6290 taught by Professor Staff during the Spring '08 term at Georgia Institute of Technology.

Page1 / 33

05+-+Branches - CS 4290/6290 Branch Pre diction and Ins...

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