Pipeline Data Hazards Warning, warning, warning! Read 4.8 Peer Instruction Lecture Materials for Computer Architecture by Dr. Leo Porter is licensed under.

Slides:



Advertisements
Similar presentations
Morgan Kaufmann Publishers The Processor
Advertisements

Pipeline Summary Try to put everything together for pipelines Before going onto caches. Peer Instruction Lecture Materials for Computer Architecture by.
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.
Breaking up is hard to do….
Intro to Computer Org. Pipelining, Part 2 – Data hazards + Stalls.
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 ( )
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.
Chapter Six Enhancing Performance with Pipelining
Lec 9: Pipelining Kavita Bala CS 3410, Fall 2008 Computer Science Cornell University.
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.
Lecture 15: Pipelining and Hazards CS 2011 Fall 2014, Dr. Rozier.
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.
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.
CSE 340 Computer Architecture Summer 2014 Basic MIPS Pipelining Review.
Basic Pipelining & MIPS Pipelining Chapter 6 [Computer Organization and Design, © 2007 Patterson (UCB) & Hennessy (Stanford), & Slides Adapted from: Mary.
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.
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,
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 (
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.
1  1998 Morgan Kaufmann Publishers Chapter Six. 2  1998 Morgan Kaufmann Publishers Pipelining Improve perfomance by increasing instruction throughput.
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.
Advanced Pipelining 7.1 – 7.5. Peer Instruction Lecture Materials for Computer Architecture by Dr. Leo Porter is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
Pipelining: Implementation CPSC 252 Computer Organization Ellen Walker, Hiram College.
CSE 340 Computer Architecture Spring 2016 Overcoming Data Hazards.
Note how everything goes left to right, except …
Single Clock Datapath With Control
ECS 154B Computer Architecture II Spring 2009
ECS 154B Computer Architecture II Spring 2009
ECE232: Hardware Organization and Design
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
Csci 136 Computer Architecture II – Data Hazard, Forwarding, Stall
Computer Organization CS224
Pipelining in more detail
Data Hazards Data Hazard
Pipelined Control (Simplified)
The Processor Lecture 3.6: Control Hazards
The Processor Lecture 3.5: Data Hazards
Designing a Pipelined CPU
Pipelining (II).
Morgan Kaufmann Publishers The Processor
Introduction to Computer Organization and Architecture
Systems Architecture II
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:

Pipeline Data Hazards Warning, warning, warning! Read 4.8 Peer Instruction Lecture Materials for Computer Architecture by Dr. Leo Porter is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Dr. Leo Porter Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License

Pipelining Key Points Pipeline processors aim at improving instruction throughput. Control signals are generated by combinational logic and passed with the instruction ET=IC*CPI*CT

Dealing With Data Hazards In Software – In Hardware – Data Hazards are caused by instruction dependences. For example, the add is data-dependent on the subtract: subi $5, $4, #45 add $8, $5, $2 Data Hazards are caused by instruction dependences. For example, the add is data-dependent on the subtract: subi $5, $4, #45 add $8, $5, $2 nops/independent insts Pipeline stalls Forwarding

Pipeline Stalls To insure proper pipeline execution in light of register dependences, we must: –detect the hazard –stall the pipeline

Detecting the Hazard IMReg ALU DMReg IMReg ALU DM IMReg ALU DMRegIMReg ALU DMRegIMReg ALU DMReg CC1CC2CC3CC4CC5CC6CC7CC8 6 types of data hazards –two reg reads * 3 reg writes Draw arrows from 3 previous instructions Jump ahead two slides To show the comparison logic

Once you detect the hazard in ID – what must you do to insert the nop and “stall”? 1.Flush all instructions in the pipeline (set control signals to 0). 2.Set all control signals going to ID/EX register to zero. 3.Set PCWrite to zero. 4.Set IF/ID register write to zero. Stalling the pipeline SelectionChanges A1, 3, 4 B1, 2, 3 C2, 3, 4 D1 ENone of the above

The Pipeline Show comparison logic, go back 1 slide, then show how to stall

What else can we do other than just stalling? Registers ID/EX ALU EX/MEMMEM/WB Data Memory 0101 IMReg ALU DMRegIMReg ALU DMReg add $2, $3, $4 add $5, $3, $2 Show how the value is already available

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) Point out source registers being pass along Show how the logic applies.

Data Forwarding The Previous Data Path handles two types of data hazards –EX hazard –MEM hazard We assume the register file handles the third (WB hazard) –“Register File forwarding” –If the register file is asked to read and write the same register in the same cycle, we assume that the reg file allows the write data to be forwarded to the output –We’re still going to call that forwarding. Point out that although the book talks about writing on the neg edge and always reading, this isn’t accurate for today. Today – forwarding in the regfile is explicit.

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) Draw the arrows for the add, or, and add instructions.

Forwarding in Action add $1, $12, $3sub $12, $3, $4add $3, $10, $11Memory AccessWrite Back

Forwarding in Action Instruction Fetchadd $1, $12, $3sub $12, $3, $4add $3, $10, $11Write Back

Eliminating Data Hazards via Forwarding?? CC1CC2CC3CC4CC5CC6CC7CC8 lw $2, 10($1) and $12, $2, $5 or $13, $6, $2 add $14, $2, $2 sw $15, 100($2) Do this on our own

How many stalls occur and how many values require hardware forwarding support to avoid stalling for our MIPS 5-stage pipeline. add $3, $2, $1 lw $4, 100($3) and $6, $4, $3 sub $7, $6, $2 add $9, $3, $6 SelectionStallsForwarded values A13 B24 C23 D15 ENone of the above

Datapath Combined Point out this logic now just checks to see if the next instruction reads from mem Seque – we know MIPS – but can we apply these principles to other pipelines

Suppose EX is the longest (in time) pipeline stage. To reduce CT, we split it in half. Given the following pipeline: IF ID EX1 EX2 M WB Assume the input data must be available at the start of EX1 and the output is available after EX2.How many hardware stalls would be required in the following code (assuming hardware forwarding wherever possible)? lw r1, 0(r3) add r2, r1, r3 SelectionNumber of stalls A0 B1 C2 D3 E4

Suppose EX is the longest (in time) pipeline stage. To reduce CT, we split it in half. Given the following pipeline: IF ID EX1 EX2 M WB Assume the input data must be available at the start of EX1 and the output is available after EX2. How How many hardware stalls would be required in the following code (assuming hardware forwarding wherever possible)? add r1, r2, r3 add r4, r1, r3 SelectionNumber of stalls A0 B1 C2 D3 E4

Suppose IF and M are the longest stages. To reduce CT, we split each in half. Given the following pipeline: IF1 IF2 ID EX M1 M2 WB Assume the input data must be available at the start of F1/M11 and the output is available after F2/M2. How many hardware stalls would be required in the following code (assuming hardware forwarding wherever possible)? lw r1, r2, r3 sw r1, 0 (r3) SelectionNumber of stalls A0 B1 C2 D3 E4

As an ISA designer - you have a choice between dealing with these hazards in software or hardware. Which might you choose and why? SelectionHW or SWWhy? (Best answer) ASoftwareCompilers have a large window of instructions available to do reordering to eliminate hazards BSoftwareDetecting data hazards in hardware can be difficult and expensive CHardwareHardware knows at runtime the actual dependencies and can exploit that knowledge for better reordering DHardwareExposing the number of required stalls violates the abstraction between hardware and software ESoftwareFor different reasons than above Dealing with Data Hazards All these are reasonable – but reason D is the driving factor for hardware dealing with hazards (be sure to highlight no single right answer). Highlight a full discussion of this is in graduate architecture, but we’ll touch on it some later

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 (nops) –hardware stalling –hardware forwarding Our processor, and indeed all modern processors, use a combination of forwarding and stalling. ET = IC * CPI * CT