Lec12 - 1 Pipeline Hazards Fall 2009 These slides are...

Info iconThis preview shows pages 1–7. 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 Document Right Arrow Icon

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: 1 Pipeline: Hazards Fall, 2009 These slides are adapted from notes by Dr. David Patterson (UCB) 2 Data Hazards • Data hazards occur when data is used before it is stored IM Reg IM Reg CC 1 CC 2 CC 3 CC 4 CC 5 CC 6 Time (in clock cycles) sub $2 , $1, $3 Program execution order (in instructions) and $12, $2 , $5 IM Reg DM Reg IM DM Reg IM DM Reg CC 7 CC 8 CC 9 10 10 10 10 10/– 20 – 20 – 20 – 20 – 20 or $13, $6, $2 add $14, $2 , $2 sw $15, 100 ($2) Value of register $2: DM Reg Reg Reg Reg DM The use of the result of the SUB instruction in the next three instructions causes a data hazard, since the register is not written until after those instructions read it. 3 Data Hazards Read After Write (RAW) Instr J tries to read operand before Instr I writes it • Caused by a “ Dependence ” (in compiler nomenclature). This hazard results from an actual need for communication. Execution Order is: Instr I Instr J I: add r1 ,r2,r3 J: sub r4, r1 ,r3 4 Data Hazards Write After Read (WAR ) Instr J tries to write operand before Instr I reads i – Gets wrong operand – Called an “ anti-dependence ” by compiler writers. This results from reuse of the name “ r1 ”. • Can’t happen in MIPS 5 stage pipeline because: Execution Order is: Instr I Instr J I: sub r4, r1 ,r3 J: add r1 ,r2,r3 K: mul r6,r1,r7 – All instructions take 5 stages, and – Reads are always in stage 2, and – Writes are always in stage 5 5 Data Hazards Write After Write (WAW) Instr J tries to write operand before Instr I writes it – Leaves wrong result ( Instr I not Instr J ) • Called an “ output dependence ” by compiler writers This also results from the reuse of name “ r1 ”. • Can’t happen in MIPS 5 stage pipeline because: Execution Order is: Instr I Instr J I: sub r1 ,r4,r3 J: add r1 ,r2,r3 K: mul r6,r1,r7 – All instructions take 5 stages, and – Writes are always in stage 5 • Will see WAR and WAW in later more complicated pipes 6 Data Hazard Detection in MIPS IM Reg IM Reg CC 1 CC 2 CC 3 CC 4 CC 5 CC 6 Time (in clock cycles) sub $2 , $1, $3 Program execution order (in instructions) and $12, $2 , $5 IM Reg DM...
View Full Document

{[ snackBarMessage ]}

Page1 / 34

Lec12 - 1 Pipeline Hazards Fall 2009 These slides are...

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

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