2/15/02CSE 141 - Data Hazzards Data Hazards in the Pipelined Implementation.

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 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.
Pipeline Hazards CS365 Lecture 10. D. Barbara Pipeline Hazards CS465 2 Review  Pipelined CPU  Overlapped execution of multiple instructions  Each on.
ECE 445 – Computer Organization
Part 2 - Data Hazards and Forwarding 3/24/04++
Review: MIPS Pipeline Data and Control Paths
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
©UCB CS 162 Computer Architecture Lecture 3: Pipelining Contd. Instructor: L.N. Bhuyan
Chapter Six Enhancing Performance with Pipelining
1 Stalling  The easiest solution is to stall the pipeline  We could delay the AND instruction by introducing a one-cycle delay into the pipeline, sometimes.
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?
 The actual result $1 - $3 is computed in clock cycle 3, before it’s needed in cycles 4 and 5  We forward that value to later instructions, to prevent.
1 CSE SUNY New Paltz Chapter Six Enhancing Performance with Pipelining.
Computer Organization Lecture Set – 06 Chapter 6 Huei-Yung Lin.
Lecture 28: Chapter 4 Today’s topic –Data Hazards –Forwarding 1.
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.
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.
Abstraction Question General purpose processors have an abstraction layer fixed at the ISA and have little control over the compilers or code run on the.
Pipeline Hazard CT101 – Computing Systems. Content Introduction to pipeline hazard Structural Hazard Data Hazard Control Hazard.
1 Pipelining Reconsider the data path we just did Each instruction takes from 3 to 5 clock cycles However, there are parts of hardware that are idle many.
Pipeline Data Hazards: Detection and Circumvention Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from slides kindly.
Pipelined Datapath and Control
CPE432 Chapter 4B.1Dr. W. Abu-Sufah, UJ Chapter 4B: The Processor, Part B-2 Read Section 4.7 Adapted from Slides by Prof. Mary Jane Irwin, Penn State University.
Chapter 4 CSF 2009 The processor: Pipelining. Performance Issues Longest delay determines clock period – Critical path: load instruction – Instruction.
Chapter 4 The Processor CprE 381 Computer Organization and Assembly Level Programming, Fall 2012 Revised from original slides provided by MKP.
Basic Pipelining & MIPS Pipelining Chapter 6 [Computer Organization and Design, © 2007 Patterson (UCB) & Hennessy (Stanford), & Slides Adapted from: Mary.
CMPE 421 Parallel Computer Architecture
Pipeline Data Hazards Warning, warning, warning! Read 4.8 Peer Instruction Lecture Materials for Computer Architecture by Dr. Leo Porter is licensed under.
CMPE 421 Parallel Computer Architecture Part 2: Hardware Solution: Forwarding.
Winter 2002CSE Topic Branch Hazards in the Pipelined Processor.
1 (Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 3 rd Ed., Morgan Kaufmann,
CSE431 L07 Overcoming Data Hazards.1Irwin, PSU, 2005 CSE 431 Computer Architecture Fall 2005 Lecture 07: Overcoming Data Hazards Mary Jane Irwin (
CSE 141Dean Tullsen Designing a Pipelined CPU. CSE 141Dean Tullsen Quiz next Wednesday (2/20) No class on Monday 2/18 Quiz will be full hour (less time.
CSIE30300 Computer Architecture Unit 05: Overcoming Data Hazards Hsin-Chou Chi [Adapted from material by and
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.
Introduction to Computer Organization Pipelining.
PROCESSOR PIPELINING YASSER MOHAMMAD. SINGLE DATAPATH DESIGN.
CPE432 Chapter 4B.1Dr. W. Abu-Sufah, UJ Chapter 4B: The Processor, Part B-1 Read Sections 4.7 Adapted from Slides by Prof. Mary Jane Irwin, Penn State.
Pipelining: Implementation CPSC 252 Computer Organization Ellen Walker, Hiram College.
CSE 340 Computer Architecture Spring 2016 Overcoming Data Hazards.
Computer Organization
Stalling delays the entire pipeline
Note how everything goes left to right, except …
Single Clock Datapath With Control
Appendix C Pipeline implementation
ECS 154B Computer Architecture II Spring 2009
ECS 154B Computer Architecture II Spring 2009
ECE232: Hardware Organization and Design
Data Hazards and Stalls
Data Hazards and Stalls
Forwarding Now, we’ll introduce some problems that data hazards can cause for our pipelined processor, and show how to handle them with forwarding.
Chapter 4 The Processor Part 3
Review: MIPS Pipeline Data and Control Paths
Morgan Kaufmann Publishers The Processor
Csci 136 Computer Architecture II – Data Hazard, Forwarding, Stall
Pipelining review.
Computer Organization CS224
Pipelining in more detail
Pipelined Control (Simplified)
The Processor Lecture 3.6: Control Hazards
The Processor Lecture 3.5: Data Hazards
Instruction Execution Cycle
Pipelining (II).
Morgan Kaufmann Publishers The Processor
Stalls and flushes Last time, we discussed data hazards that can occur in pipelined CPUs if some instructions depend upon others that are still executing.
©2003 Craig Zilles (derived from slides by Howard Huang)
Need to stall for one cycle.
ELEC / Computer Architecture and Design Spring 2015 Pipeline Control and Performance (Chapter 6) Vishwani D. Agrawal James J. Danaher.
Presentation transcript:

2/15/02CSE Data Hazzards Data Hazards in the Pipelined Implementation

CSE Data Hazzards2 Pipelined Implementation Datapath Instruction Fetch Instruction Decode/ Register Fetch Execute/ Address Calculation Memory AccessWrite Back Note: The IF stage may be labeled “IM” (instruction memory) Mem labeled “DM” (data memory); WB labeled “Reg”

CSE Data Hazzards3 Data Hazards When a result is needed in the pipeline before it is available, a “data hazard” occurs. IMReg ALU DMReg IMReg ALU DM IMReg ALU DMRegIMReg ALU DMRegIMReg ALU DMReg CC1CC2CC3CC4CC5CC6CC7CC8 sub $2, $1, $3 and $12, $2, $5 or $13, $6, $2 add $14, $2, $2 sw $15, 100($2) R2 Available R2 Needed Time: No hazard here Hazards! Value in register hasn’t been updated

CSE Data Hazzards4 Dealing With Data Hazards Transparent register file eliminates one hazard. Use latches rather than flip-flops in Reg file First half-cycle of cycle 5: register 2 loaded Second half-cycle: new value is read into pipeline state IMReg ALU DMRegIMReg ALU DMRegIMReg ALU DMRegIMReg ALU DMReg CC1CC2CC3CC4CC5CC6CC7CC8 sub $2, $1, $3 and $12, $6, $5 or $13, $6, $8 add $14, $2, $2 R2 Available

CSE Data Hazzards5 Three ways to handle remaining Data Hazards In Software –insert independent instructions (or no-ops) In Hardware –insert bubbles (i.e. stall the pipeline) –data forwarding

CSE Data Hazzards6 Dealing with Data Hazards in Software IMReg ALU DMRegIMReg ALU DMRegIMReg ALU DMRegIMReg ALU DMReg CC1CC2CC3CC4CC5CC6CC7CC8 sub $2, $1, $3 nop add $12, $2, $5 nop Insert enough no-ops (or other instructions that don’t use register 2) so that data hazard doesn’t occur,

CSE Data Hazzards7 Where are No-ops needed? sub $2, $1,$3 and $4, $2,$5 or $8, $2,$6 add $9, $4,$2 slt $1, $6,$7

CSE Data Hazzards8 Handling Data Hazards in Hardware Stall the pipeline sub $2, $1, $3 and $12, $2, $5 or $13, $6, $2 add $14, $2, $2 IMReg DMReg IMReg DM IMReg DMReg IMReg DMReg CC1CC2CC3CC4CC5CC6CC7CC8 Bubble

CSE Data Hazzards9 Pipeline Stalls To insure proper pipeline execution in light of register dependences, we must: –Detect the hazard –Stall the pipeline prevent the IF and ID stages from making progress –the ID stage because we can’t go on until the dependent instruction completes correctly –the IF stage because we do not want to lose any instructions. insert“no-ops” into later stages

CSE Data Hazzards10 The Pipeline What comparisons tell us when to stall?

CSE Data Hazzards11 Stalling the Pipeline Prevent the IF and ID stages from proceeding –don’t write the PC (PCWrite = 0) –don’t rewrite IF/ID register (IF/IDWrite = 0) Insert “nops” –set all control signals propagating to EX/MEM/WB to zero

CSE Data Hazzards12 The Pipeline

CSE Data Hazzards13 Reducing Data Hazards Through Forwarding Registers ID/EX ALU EX/MEMMEM/WB Data Memory 0101 IMReg ALU DMRegIMReg ALU DMReg add $2, $3, $4 or $5, $3, $2 We could avoid stalling if we could get the ALU output from “add” to ALU input for the “or”

CSE Data Hazzards14 Reducing Data Hazards Through Forwarding EX Hazard: if (EX/MEM.RegWrite and (EX/MEM.RegisterRd != 0) and (EX/MEM.RegisterRd = ID/EX.RegisterRs)) ForwardA = 10 if (EX/MEM.RegWrite and (EX/MEM.RegisterRd != 0) and (EX/MEM.RegisterRd = ID/EX.RegisterRt)) ForwardB = 10 (similar for the MEM stage)

CSE Data Hazzards15 Data Forwarding Forwarding (just shown) handles two types of data hazards –EX hazard –MEM hazard We’ve already handled the third type (WB) hazard by using a transparent reg file –if the register file is asked to read and write the same register in the same cycle, the reg file allows the write data to be forwarded to the output.

CSE Data Hazzards16 Eliminating Data Hazards via Forwarding IMReg ALU DMReg IMReg ALU DM IMReg ALU DMRegIMReg ALU DMRegIMReg ALU DMReg CC1CC2CC3CC4CC5CC6CC7CC8 sub $2, $1, $3 and $6, $2, $5 or $13, $6, $2 add $14, $2, $2 sw $15, 100($2)

CSE Data Hazzards17 Does Forwarding eliminate all hazards?? IMReg ALU DMReg IMReg ALU DM IMReg ALU DMRegIMReg ALU DMRegIMReg ALU DMReg CC1CC2CC3CC4CC5CC6CC7CC8 lw $2, 10($1) and $12, $2, $5 or $13, $6, $2 add $14, $2, $2 sw $15, 100($2)

CSE Data Hazzards18 NO! You may need to stall after loads IMReg ALU DMReg IMReg ALU DM IMReg ALU DMReg IMReg ALU DMReg CC1CC2CC3CC4CC5CC6CC7CC8 lw $2, 10($1) and $12, $2, $5 or $13, $6, $2 add $14, $2, $2 sw $15, 100($2) IMReg ALU Bubble

CSE Data Hazzards19 Try this one... Show stalls and forwarding for this code add $3, $2, $1 lw $4, 100($3) and $6, $4, $3 sub $7, $6, $2

CSE Data Hazzards20 Data Hazard Key Points Pipelining provides high throughput, but does not handle data dependences easily. Data dependences cause data hazards. Data hazards can be solved by: –software (no-ops) –hardware stalling –hardware forwarding Our processor, and indeed all modern processors, use a combination of forwarding and stalling.