Data Hazards and Stalls

Slides:



Advertisements
Similar presentations
Pipeline Hazards CS365 Lecture 10. D. Barbara Pipeline Hazards CS465 2 Review  Pipelined CPU  Overlapped execution of multiple instructions  Each on.
Advertisements

ECE 445 – Computer Organization
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Pipelined Processor.
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 ( )
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 18 - Pipelined.
Chapter Six Enhancing Performance with Pipelining
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.
Exp. 6 Solving Data Hazards. Where to find ALU Result Instruction memory Data memory 1010 PC ALU Registers Rd Rt 0101 IF/IDID/EXEX/MEMMEM/WB.
Lecture 28: Chapter 4 Today’s topic –Data Hazards –Forwarding 1.
1  1998 Morgan Kaufmann Publishers Chapter Six. 2  1998 Morgan Kaufmann Publishers Pipelining Improve performance by increasing instruction throughput.
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.
Enhancing Performance with Pipelining Slides developed by Rami Abielmona and modified by Miodrag Bolic High-Level Computer Systems Design.
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 Part 2: Hardware Solution: Forwarding.
1 (Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 3 rd Ed., Morgan Kaufmann,
2/15/02CSE Data Hazzards Data Hazards in the Pipelined Implementation.
CSE431 L07 Overcoming Data Hazards.1Irwin, PSU, 2005 CSE 431 Computer Architecture Fall 2005 Lecture 07: Overcoming Data Hazards Mary Jane Irwin (
Computing Systems Pipelining: enhancing performance.
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell CS352H: Computer Systems Architecture Topic 9: MIPS Pipeline.
CSIE30300 Computer Architecture Unit 05: Overcoming Data Hazards Hsin-Chou Chi [Adapted from material by and
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.
Csci 136 Computer Architecture II – Superscalar and Dynamic Pipelining Xiuzhen Cheng
LECTURE 9 Pipeline Hazards. PIPELINED DATAPATH AND CONTROL In the previous lecture, we finalized the pipelined datapath for instruction sequences which.
Pipelining: Implementation CPSC 252 Computer Organization Ellen Walker, Hiram College.
CSE 340 Computer Architecture Spring 2016 Overcoming Data Hazards.
Lecture 9 Pipeline Hazards.
Note how everything goes left to right, except …
Pipelining Chapter 6.
Morgan Kaufmann Publishers The Processor
Appendix C Pipeline implementation
ECS 154B Computer Architecture II Spring 2009
ECS 154B Computer Architecture II Spring 2009
ECE232: Hardware Organization and Design
Morgan Kaufmann Publishers The Processor
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
Morgan Kaufmann Publishers The Processor
CSCI206 - Computer Organization & Programming
Pipelining Chapter 6.
Morgan Kaufmann Publishers Enhancing Performance with Pipelining
Computer Organization CS224
Pipelined Datapath The MIPS Example 2018/11/29
Pipelined Control (Simplified)
The Processor Lecture 3.5: Data Hazards
CSC3050 – Computer Architecture
Pipelining (II).
Morgan Kaufmann Publishers The Processor
Pipelined Datapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
Systems Architecture II
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.
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,
©2003 Craig Zilles (derived from slides by Howard Huang)
Need to stall for one cycle.
Presentation transcript:

Data Hazards and Stalls Data hazards and forwarding Data Hazards and Stalls 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

An Example Assuming that register R2 = 10 initially. And the sub instruction will result in R2 = -20. 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

Pipelined dependencies in a five instruction sequence using simplified datapaths to show the dependencies. Note: only add and sw get the right value R2 = - 20 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

An Example (cont’d) Hazard condition (between sub and and at the indicated stages): EX/MEM.RegisterRd = ID/EX.RegisterRs = $2 General 1a. EX/MEM.RegisterRd = ID/EX.RegisterRs 1b. EX/MEM.RegisterRd = ID/EX.RegisterRt 2a. MEM/WB.RegisterRd = ID/EX.RegisterRs 2b. MEM/WB.RegisterRd = ID/EX.RegisterRt Question: can you identify which of the 4 conditions Here captures the hazards condition between sub and or ? 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

Forwarding/Bypassing ALUinputs can also from pipeline registers Extra multiplexors Hazard detection units 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

The dependencies between the pipeline registers move forward in time, so it is possible to supply the inputs to the ALU needed by the and instruction and or instruction by forwarding the results found in the pipeline registers rather than stall. 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

the ALU and pipeline register before adding forwarding. a. No forwarding the ALU and pipeline register before adding forwarding. 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

Forwarding control and the multiplexors are added b. With forwarding Forwarding control and the multiplexors are added 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

The control values for the forwarding multiplexors. 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

Forwarding Conditions 1. 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 = ID/EX.RegisterRt)) ForwardB = 10 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

and (MEM/WB.RegisterRd =/= 0) Con’d 2. MEM hazard: if(MEM/WB.RegWrite and (MEM/WB.RegisterRd =/= 0) and (MEM/WB.RegisterRd = ID/EX.RegisterRs)) ForwardA = 01 and (MEM/WB.RegisterRd = ID/EX.RegisterRt)) ForwardB = 01 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

Priority in Forwarding Add $1, $1, $2 Add $1, $1, $3 Add $1, $1, $4 …. Note: here both EX and MEM stages may have the exact hazard conditions. What should we do ? 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

Priority in Forwarding If (MEM/WB.RegWrite and (MEM/WB.RegisterRd =/= 0) and (EX/MEM.RegisterRd =/= ID/EX.RegisterRs) and (MEM/WB.RegisterRd = ID/EX.RegisterRs)) Forward A = 01 if (MEM/WB.RegWrite and (EX/MEM.RegisterRd =/= ID/EX.RegisterRt) and (MEM/WB.RegisterRd = ID/EX.RegisterRt)) ForwardB = 01 Note: When both EX and MEM stages may have the exact hazard conditions. 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

The datapath modified to resolve hazards via forwarding. 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

The Snapshots of Our Example Through Forwarding 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

Clock cycles 3 of the instruction sequence. 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

Clock cycles 4 of the instruction sequence. add $9, $4, $2 or $4, $4, $2 and $4, $2, $5 sub $2…… before <1> Clock cycles 4 of the instruction sequence. 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

Clock cycles 5 of the instruction sequence. 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

Clock cycles 6 of the instruction sequence. after <2> after <1> add $9, $4, $2 or $4…… and $4…... Clock cycles 6 of the instruction sequence. 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

Hazards and Stalls 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

A pipelined sequence of instructions. 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

The way stalls are really inserted into the pipeline. 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

Forwarding with Load and Stores The problem The solution 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

A Hazard Detection Unit In the ID stage, the following should be checked by the hazard detection unit, so it can insert the stall between a load and its use. if (ID/EX.MemRead and ((ID/EX.RegisterRt = IF/ID.RegisterRs) or (ID/EX.RegisterRt = IF/ID.RegisterRt)) stall the pipeline 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

Pipelined control overview, showing the two multiplexors for forwarding, the hazard detection unit, and the forwarding unit. 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

“Snapshots” of the running example through the pipeline 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

Clock cycles 2 of the instruction sequence in the example. 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

Clock cycles 3 of the instruction sequence in the example. 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

Clock cycles 4 the instruction sequence in the example. 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

Clock cycles 5 of the instruction sequence in the example. 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

Clock cycles 6 of the instruction sequence in the example. 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

Clock cycles 7 of the instruction sequence in the example. (note the forwarding of r4) 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt

Branch Hazards and Handling Branch hazard handling methods Static Dynamic 2018/11/10 \course\cpeg323-05F\Topic6c-323.ppt