EECE476: Computer Architecture Lecture 17: Pipelining Data Hazards: Forwarding & Stalls Chapter 6.4, 6.5 The University of British ColumbiaEECE 476© 2005.

Slides:



Advertisements
Similar presentations
Morgan Kaufmann Publishers The Processor
Advertisements

COMP381 by M. Hamdi 1 (Recap) Pipeline Hazards. COMP381 by M. Hamdi 2 I n s t r. O r d e r add r1,r2,r3 sub r4,r1,r3 and r6,r1,r7 or r8,r1,r9 xor r10,r1,r11.
1 Pipelining Part 2 CS Data Hazards Data hazards occur when the pipeline changes the order of read/write accesses to operands that differs from.
COMP25212 Further Pipeline Issues. Cray 1 COMP25212 Designed in 1976 Cost $8,800,000 8MB Main Memory Max performance 160 MFLOPS Weight 5.5 Tons Power.
Pipeline Computer Organization II 1 Hazards Situations that prevent starting the next instruction in the next cycle Structural hazards – A required resource.
Intro to Computer Org. Pipelining, Part 2 – Data hazards + Stalls.
Lecture Objectives: 1)Define pipelining 2)Calculate the speedup achieved by pipelining for a given number of instructions. 3)Define how pipelining improves.
Forwarding and Hazards MemberRole William ElliottTeam Leader Jessica Tyler ShulerWiki Specialist Tyler KimseyLead Engineer Cameron CarrollEngineer Danielle.
Instruction-Level Parallelism (ILP)
1 A few words about the quiz Closed book, but you may bring in a page of handwritten notes. –You need to know what the “core” MIPS instructions do. –I.
EECE476: Computer Architecture Lecture 18: Pipelining Control Hazards Chapter 6.6 The University of British ColumbiaEECE 476© 2005 Guy Lemieux.
EECE476: Computer Architecture Lecture 15: Basic Pipelining Datapath & Control Logic Chapter 6.1, 6.2, 6.3 The University of British ColumbiaEECE 476©
MIPS Pipeline Default behaviour and pipeline organization The University of British ColumbiaEECE 476© 2005 Guy Lemieux.
Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University Pipeline Hazards See: P&H Chapter 4.7.
Pipeline Hazards Hakim Weatherspoon CS 3410, Spring 2011 Computer Science Cornell University See P&H Appendix 4.7.
Instructor: Senior Lecturer SOE Dan Garcia CS 61C: Great Ideas in Computer Architecture Pipelining Hazards 1.
ECE 445 – Computer Organization
Part 2 - Data Hazards and Forwarding 3/24/04++
Mary Jane Irwin ( ) [Adapted from Computer Organization and Design,
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
1  2004 Morgan Kaufmann Publishers Chapter Six. 2  2004 Morgan Kaufmann Publishers Pipelining The laundry analogy.
Pipelining Andreas Klappenecker CPSC321 Computer Architecture.
EECE476: Computer Architecture Lecture 19: Pipelining Reducing Control Hazard Penalty Chapter 6.6 The University of British ColumbiaEECE 476© 2005 Guy.
Computer ArchitectureFall 2007 © October 24nd, 2007 Majd F. Sakr CS-447– Computer Architecture.
L17 – Pipeline Issues 1 Comp 411 – Fall /1308 CPU Pipelining Issues Finishing up Chapter 6 This pipe stuff makes my head hurt! What have you been.
CSCE 212 Quiz 9 – 3/30/11 1.What is the clock cycle time based on for single-cycle and for pipelining? 2.What two actions can be done to resolve data hazards?
Pipelined Datapath and Control (Lecture #15) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer.
Lecture 28: Chapter 4 Today’s topic –Data Hazards –Forwarding 1.
Computer Architecture - A Pipelined Datapath A Pipelined Datapath  Resisters are used to save data between stages. 1/14.
ENGS 116 Lecture 51 Pipelining and Hazards Vincent H. Berk September 30, 2005 Reading for today: Chapter A.1 – A.3, article: Patterson&Ditzel Reading for.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 17 - Pipelined.
1 Stalls and flushes  So far, we have discussed data hazards that can occur in pipelined CPUs if some instructions depend upon others that are still executing.
Lecture 15: Pipelining and Hazards CS 2011 Fall 2014, Dr. Rozier.
Chapter 2 Summary Classification of architectures Features that are relatively independent of instruction sets “Different” Processors –DSP and media processors.
Pipelined Datapath and Control
Chapter 4 CSF 2009 The processor: Pipelining. Performance Issues Longest delay determines clock period – Critical path: load instruction – Instruction.
Comp Sci pipelining 1 Ch. 13 Pipelining. Comp Sci pipelining 2 Pipelining.
CSE 340 Computer Architecture Summer 2014 Basic MIPS Pipelining Review.
CS.305 Computer Architecture Enhancing Performance with Pipelining Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from.
CMPE 421 Parallel Computer Architecture
1 Designing a Pipelined Processor In this Chapter, we will study 1. Pipelined datapath 2. Pipelined control 3. Data Hazards 4. Forwarding 5. Branch Hazards.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
EECE 476: Computer Architecture Slide Set #5: Implementing Pipelining Tor Aamodt Slide background: Die photo of the MIPS R2000 (first commercial MIPS microprocessor)
CMPE 421 Parallel Computer Architecture Part 2: Hardware Solution: Forwarding.
CS 1104 Help Session IV Five Issues in Pipelining Colin Tan, S
1  1998 Morgan Kaufmann Publishers Chapter Six. 2  1998 Morgan Kaufmann Publishers Pipelining Improve perfomance by increasing instruction throughput.
Instructor: Senior Lecturer SOE Dan Garcia CS 61C: Great Ideas in Computer Architecture Pipelining Hazards 1.
CSE431 L06 Basic MIPS Pipelining.1Irwin, PSU, 2005 MIPS Pipeline Datapath Modifications  What do we need to add/modify in our MIPS datapath? l State registers.
Lecture 9. MIPS Processor Design – Pipelined Processor Design #1 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System.
L17 – Pipeline Issues 1 Comp 411 – Fall /23/09 CPU Pipelining Issues Read Chapter This pipe stuff makes my head hurt! What have you been.
CSCE 212 Chapter 6 Enhancing Performance with Pipelining Instructor: Jason D. Bakos.
ECE/CS 552: Pipeline Hazards © Prof. Mikko Lipasti Lecture notes based in part on slides created by Mark Hill, David Wood, Guri Sohi, John Shen and Jim.
Pipelining Chapter 6.
CSCI206 - Computer Organization & Programming
Single Clock Datapath With Control
Pipeline Implementation (4.6)
Morgan Kaufmann Publishers The Processor
Pipelining review.
Pipelining Chapter 6.
Pipelining in more detail
CSCI206 - Computer Organization & Programming
CSCI206 - Computer Organization & Programming
Pipeline control unit (highly abstracted)
The Processor Lecture 3.6: Control Hazards
Pipeline control unit (highly abstracted)
Pipeline Control unit (highly abstracted)
Pipelining Chapter 6.
Pipelining Chapter 6.
Guest Lecturer: Justin Hsia
Problem ??: (?? marks) Consider executing the following code on the MIPS pipelined datapath: add $t5, $t6, $t8 add $t9, $t5, $t4 lw $t3, 100($t9) sub $t2,
Presentation transcript:

EECE476: Computer Architecture Lecture 17: Pipelining Data Hazards: Forwarding & Stalls Chapter 6.4, 6.5 The University of British ColumbiaEECE 476© 2005 Guy Lemieux

2 Implementing Forwarding Basic pipeline data flow, no forwarding

3 Implementing Forwarding Basic pipelined data flow, with forwarding D.Rs D.Rt D.Rd D.Rt SgnExt(Imm16) X.RdM.Rd W.Rd

4 Forwarding Example Read after Write Hazard Same instruction sequence as before SUB $2, $1,$3 <- writes $2 AND $12,$2,$5 <- reads $2 OR $13, $6,$2 <- reads $2 ADD $14, $2,$2 <- reads $2 (twice!) SW $15,10($2) <- reads $2 Let’s see the pipeline details

5 Forwarding Details D.Rs = 1 D.Rt = 3 D.Rd = 2 D.Rt = 3 X.RdM.Rd W.Rd SUB $2,$1,$3 [$1] [$3]

6 Forwarding Details D.Rs = 2 D.Rt = 5 D.Rd = 12 D.Rt = 5 X.Rd = 2M.Rd W.Rd AND $12,$2,$5 [$2] [$5] SUB $2,$1,$3 [$1] [$3]

7 Forwarding Details – from X D.Rs = 6 D.Rt = 2 D.Rd = 13 D.Rt = 2 X.Rd = 12M.Rd = 2 W.Rd AND $12,$2,$5 [$2] [$5] SUB $2,$1,$3 M.Out = SUB.Result OR $13,$6,$2 [M.Out]

8 Forwarding Details – from M D.Rs = 2 D.Rt = 2 D.Rd = 14 D.Rt = 2 X.Rd = 13M.Rd = 12 W.Rd = 2 AND $12,$2,$5 [$6] [W.Out] SUB $2,$1,$3 M.Out = AND.Result OR $13,$6,$2 [$6] ADD $14,$2,$2 2 W.Out = SUB.Result What value is here?

9 Forwarding Details – from W D.Rs = 2 D.Rt = 2 D.Rd = 14 D.Rt = 2 X.Rd = 13M.Rd = 12 W.Rd = 2 AND $12,$2,$5 [$6] [W.Out] SUB $2,$1,$3 M.Out = AND.Result OR $13,$6,$2 [$6] ADD $14,$2,$2 2 W.Out = SUB.Result Book assumes RegisterFile “writes before it reads”, ie: it forwards WB result auto- magically (we must make our clocked NIOS register file do this!)

10 Forwarding Details D.Rs = 2 D.Rt =15 D.Rd = ? D.Rt =15 X.Rd = 14M.Rd = 13 W.Rd = 12 OR $13,$6,$2 [SUB.Result] AND $12,$2,$5 M.Out = OR.Result ADD $14,$2,$ SW $15,10($2) 12 W.Out = AND.Result What value is here?

11 New Rules on Forwarding Arrows – Forwarding from W to X Forwarding from X or M to X still OK –Please draw arrows according to rules in previous lecture Forwarding from W to X no longer necessary –NO RED ARROWS from W to X –Assume W to REGFILE occurs before the read needed by D –This effectively accomplishes the forwarding from W to X –Example: the ADD $14,$2,$2 case just shown

12 New Forwarding Observations –RED arrows indicate forwarding –Arrow always starts at X, M, or W stage This is the source of the newer data Source is always the direct output of the pipeline register –Arrow always ends at X stage This is the destination of the forwarded data Destination must choose the forwarded source: X, M, or W –Arrow always spans ONLY 1 clock cycle in time From cycle i to cycle i+1 –Arrow may span 1, 2, or 3 instructions (stages of pipeline)  New: assume REGFILE does W before R RED: shows changes from lecture 16

13 Forwarding Again Read after Write Hazard LW $2, 10($1) <- writes $2 AND $12,$2,$5 <- reads $2 OR $13, $6,$2 <- reads $2 ADD $14, $2,$2 <- reads $2 (twice!) SW $15,10($2) <- reads $2 Difference from previous example –Prev. example, value of was $2 ready after “X” stage –This example, value of $2 is ready after “M” stage Let’s see what must happen to operate correctly!

14 Forwarding with “lw” Example: Clock cycle 1 1LW $2,10($1)IDXMW AND $12,$2,$5IDXMW OR $13,$6,$2IDXMW ADD $14,$2,$2IDXMW SW $15,10($2)IDXMW IDXMW IDXMW IDXMW IDXMW IDXMW W M X D I

15 Forwarding with “lw” Clock cycle 2 1LW $2,10($1)IDXMW 2AND $12,$2,$5IDXMW OR $13,$6,$2IDXMW ADD $14,$2,$2IDXMW SW $15,10($2)IDXMW IDXMW IDXMW IDXMW IDXMW IDXMW W M X D I

16 Forwarding with “lw” Clock cycle 3 can’t forward, wait for M! 1LW $2,10($1)IDXMW 2AND $12,$2,$5IDXMW 3OR $13,$6,$2IDXMW ADD $14,$2,$2IDXMW SW $15,10($2)IDXMW IDXMW IDXMW IDXMW IDXMW IDXMW W M X D I

17 Forwarding with “lw” Clock cycle 4 insert “bubble” in X, forward M 1LW $2,10($1)IDXMW 2?IDXMW 3AND $12,$2,$5IDDXMW 4OR $13,$6,$2IIDXMW ADD $14,$2,$2IDXMW SW $15,10($2)IDXMW IDXMW IDXMW IDXMW IDXMW W M ? D I

18 Forwarding with “lw” Clock cycle 5 forward W (automagic by RegFile) 1LW $2,10($1)IDXMW 2?ID??W 3AND $12,$2,$5IDDXMW 4OR $13,$6,$2IIDXMW 5ADD $14,$2,$2IDXMW SW $15,10($2)IDXMW IDXMW IDXMW IDXMW IDXMW W ? X D I

19 Forwarding with “lw” Clock cycle 6 1LW $2,10($1)IDXMW 2?ID??W 3AND $12,$2,$5IDDXMW 4OR $13,$6,$2IIDXMW 5ADD $14,$2,$2IDXMW 6SW $15,10($2)IDXMW IDXMW IDXMW IDXMW IDXMW ? M X D I

20 Forwarding with “lw” Clock cycle 7 (forwarding shown by arrows) 1LW $2,10($1)IDXMW 2ID??? 3AND $12,$2,$5IDDXMW 4OR $13,$6,$2IIDXMW 5ADD $14,$2,$2IDXMW 6SW $15,10($2)IDXMW 7IDXMW IDXMW IDXMW IDXMW W M X D I

21 Summary: Forwarding with “lw” Called “delayed load” or “load-use delay” or “load delay slot” –Impossible to get result after “X” –Must wait for M stage –May need to wait >1 cycle in deep pipelines –Causes a Data Hazard which cannot be resolved with forwarding Hardware solutions (our textbook MIPS does this!) –Formally, pipeline stall, sometimes interlock. Informally: bubble –Need to detect dependence: “Hazard Detection Unit” –Some CPUs do not do this (eg, very very early MIPS) –Software help: To reduce performance loss, don’t place dependent instruction (RAW) right after “lw” Lazy solution (don’t do this!) –No Hazard Detection Unit –Require software help (eg, insert NOP) –Sometimes called a “feature” –Not considered a “good” solution anymore

22 Hazard Detection Unit

23 Control Hazards Next lecture !