L13 - CMU 18-447 S’08 L13-1 © 2008 J. C. Hoe 18-447...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CMU 18-447 S’08 L13-1 © 2008 J. C. Hoe 18-447 Lecture 13: Branch Prediction James C. Hoe Dept of ECE, CMU March 5, 2008 Announcements: Spring break!! HW3 due now Project 2 due after spring break Handouts: CMU 18-447 S’08 L13-2 © 2008 J. C. Hoe IF PC t t 1 t 2 t 3 t 4 t 5 Inst i Inst j Inst k Inst l Inst h IF PC t t 1 t 2 t 3 t 4 t 5 Inst i Inst j Inst k Inst l Inst h ID IF PC+4 first opportunity to decode Inst h should we correct now? IF PC+4 IF PC t t 1 t 2 t 3 t 4 t 5 Inst i Inst j Inst k Inst l Inst h ID ALU ID IF PC+8 Inst h branch condition and target evaluated in ALU IF PC+4 IF PC t t 1 t 2 t 3 t 4 t 5 Inst i Inst j Inst k Inst l Inst h ID ALU ID IF PC+8 ALU ID IF target MEM When a branch resolves- branch target (Inst k ) is¡fetched- all instructions fetched since inst h (so called “wrong-path” instructions) must be flushed Control Speculation: PC+4 Inst h is a branch CMU 18-447 S’08 L13-3 © 2008 J. C. Hoe Performance Impact ¡ correct guess ⇒ no penalty ~86% of the time ¡ incorrect guess ⇒ 2 bubbles ¡ Assume ­ no data hazards ­ 20% control flow instructions ­ 70% of control flow instructions are taken ­ IPC = 1 / [ 1 + (0.20*0.7 ) * 2 ] = = 1 / [ 1 + 0.14 * 2 ] = 1 / 1.28 = 0.78 penalty for a wrong guess probability of a wrong guess Can we reduce either of the two penalty terms? CMU 18-447 S’08 L13-4 © 2008 J. C. Hoe Making a Better Guess ¡ For ALU instructions ­ can’t do better than guessing nextPC=PC+4 ­ still tricky since must guess nextPC before the current instruction is fetched ¡ For Branch/Jump instructions ­ why not always guess in the taken direction since 70% correct ­ again, must guess nextPC before the branch instruction is fetched (but branch target is encoded in the instruction) ⇒ Must make a guess based only on the current fetch PC !!! ⇒ Fortunately,- PC-offset branch/jump target is static- We are allowed to be wrong some of the time CMU 18-447 S’08 L13-5 © 2008 J. C. Hoe Branch Target Buffer (Oracle) ¡ BTB (Oracle) ­ a giant table indexed by PC ­ returns the guess for nextPC ¡ When encountering a PC for the first time, store in BTB ­ PC + 4 if ALU/LD/ST ­ PC+offset if Branch or Jump ­ ?? if JR ¡ Effectively guessing branches are always taken IPC = 1 /...
View Full Document

This note was uploaded on 04/07/2008 for the course ECE 18447 taught by Professor Hoe during the Spring '08 term at Carnegie Mellon.

Page1 / 11

L13 - CMU 18-447 S’08 L13-1 © 2008 J. C. Hoe 18-447...

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

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