Systems Architecture II

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.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania Computer Organization Pipelined Processor Design 1.
1 CSE SUNY New Paltz Chapter Six Enhancing Performance with Pipelining.
Computer Organization Lecture Set – 06 Chapter 6 Huei-Yung Lin.
Appendix A Pipelining: Basic and Intermediate Concepts
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.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 17 - Pipelined.
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
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.
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,
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.
Oct. 18, 2000Machine Organization1 Machine Organization (CS 570) Lecture 4: Pipelining * Jeremy R. Johnson Wed. Oct. 18, 2000 *This lecture was derived.
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell CS352H: Computer Systems Architecture Topic 9: MIPS Pipeline.
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.
LECTURE 9 Pipeline Hazards. PIPELINED DATAPATH AND CONTROL In the previous lecture, we finalized the pipelined datapath for instruction sequences which.
May 22, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 14: A Simple Implementation of MIPS * Jeremy R. Johnson Mon. May 17, 2000.
Pipelining: Implementation CPSC 252 Computer Organization Ellen Walker, Hiram College.
EECS 322 April 10, 2000 EECS 322 Computer Architecture Pipeline Control, Data Hazards and Branch Hazards.
CSE 340 Computer Architecture Spring 2016 Overcoming Data Hazards.
Stalling delays the entire pipeline
Pipelining Chapter 6.
Morgan Kaufmann Publishers The Processor
Systems Architecture I
Single Clock Datapath With Control
Appendix C Pipeline implementation
Morgan Kaufmann Publishers The Processor
ECS 154B Computer Architecture II Spring 2009
CDA 3101 Spring 2016 Introduction to Computer Organization
ECE232: Hardware Organization and Design
Morgan Kaufmann Publishers The Processor
Data Hazards and Stalls
Data Hazards and Stalls
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
Pipelining Chapter 6.
Morgan Kaufmann Publishers Enhancing Performance with Pipelining
Computer Organization CS224
Systems Architecture I (CS ) Lecture 16: Exceptions
Systems Architecture I
CSCI206 - Computer Organization & Programming
Systems Architecture II
Pipelined Control (Simplified)
Systems Architecture I
The Processor Lecture 3.5: Data Hazards
Systems Architecture I
CSC3050 – Computer Architecture
Systems Architecture I (CS ) Lecture 17: Exceptions
Pipelining (II).
Morgan Kaufmann Publishers The Processor
Pipelined Datapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
Systems Architecture I
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.
Presentation transcript:

Systems Architecture II September 4, 1997 Systems Architecture II (CS 282-001) Lecture 5: Dealing with Pipeline Hazards* Jeremy R. Johnson *This lecture was derived from material in the text (Chap. 6). All figures from Computer Organization and Design: The Hardware/Software Approach, Second Edition, by David Patterson and John Hennessy, are copyrighted material (COPYRIGHT 1998 MORGAN KAUFMANN PUBLISHERS, INC. ALL RIGHTS RESERVED). July 2, 2001 Systems Architecture II

Systems Architecture II September 4, 1997 Introduction Objective: In the previous lecture we saw the modifications necessary to the single-cycle implementation of MIPS to support pipelining. However, we ignored the possibility of pipeline hazards. In today’s lecture we show how to deal with pipeline hazards. A pipeline hazard is a situation where the next instruction cannot execute in the following clock cycle Topics Data hazards and forwarding Data hazards and stalls Control (branch) hazards stall and reducing the delay of branches dynamic branch prediction delayed branch Exceptions July 2, 2001 Systems Architecture II

Data Hazards and Forwarding Problem: Instruction depends on the result of a previous instruction still in the pipeline Example sub $2, $1, $3 and $12, $2, $5 or $13, $6, $2 add $14, $2, $2 sw $15, 100($2) July 2, 2001 Systems Architecture II

Timing Diagram with Data Dependencies July 2, 2001 Systems Architecture II

Systems Architecture II Hazard Detection 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 sub $2, $1, $3 and $12, $2, $5 (1a) or $13, $6, $2 (2b) add $14, $2, $2 (no hazard) sw $15, 100($2) (no hazard) July 2, 2001 Systems Architecture II

Systems Architecture II Forwarding July 2, 2001 Systems Architecture II

Pipelined Datapath with Forwarding July 2, 2001 Systems Architecture II

Control for Hazard Detection and Forwarding EX hazard: if (EX/MEM.RegWrite) and (EX/MEM.RegisterRd  0) and (EX/MEM.RegisterRd = ID/EX.RegisterRs) then ForwardA = 10 MEM hazard: if (MEM/WB.RegWrite) and (MEM/WB.RegisterRd  0) and (EX/MEM.RegisterRd  ID/EX.RegisterRs) and (MEM/WB.RegisterRd = ID/EX.RegisterRs) then ForwardA = 01 July 2, 2001 Systems Architecture II

Datapath with Control for Forwarding July 2, 2001 Systems Architecture II

Systems Architecture II Example 1 July 2, 2001 Systems Architecture II

Systems Architecture II Example 2 July 2, 2001 Systems Architecture II

Systems Architecture II Example 3 July 2, 2001 Systems Architecture II

Systems Architecture II Example 4 July 2, 2001 Systems Architecture II

Data Hazards and Stalls Problem: Sometimes a data dependency can not be resolved with forwarding (e.g. a load dependency) July 2, 2001 Systems Architecture II

Inserting Stalls into the Pipeline If (ID/EX.MemRead and ((ID/EX.RegisterRt = IF/ID.RegisterRs) or (ID/EX.RegisterRt = IF/ID.RegisterRt))) stall the pipeline (insert nop by setting control = 0) July 2, 2001 Systems Architecture II

Datapath with Control for Stalls July 2, 2001 Systems Architecture II

Systems Architecture II Example 1 July 2, 2001 Systems Architecture II

Systems Architecture II Example 2 July 2, 2001 Systems Architecture II

Systems Architecture II Example 3 July 2, 2001 Systems Architecture II

Systems Architecture II Example 4 July 2, 2001 Systems Architecture II

Systems Architecture II Example 5 July 2, 2001 Systems Architecture II

Systems Architecture II Example 6 July 2, 2001 Systems Architecture II

Systems Architecture II Branch Hazards Problem: An instruction must be fetched every cycle yet the decision of whether to branch doesn’t occur until MEM pipeline stage July 2, 2001 Systems Architecture II

Reducing the Delay of Branches Assume branch not taken. Reduce cost if branch taken, which implies fewer instructions need to be flushed. July 2, 2001 Systems Architecture II

Systems Architecture II July 2, 2001 Systems Architecture II

Systems Architecture II July 2, 2001 Systems Architecture II

Systems Architecture II Loop Prediction Try to predict whether or not a branch will be taken Use branch table to keep track if branch was taken previously 2-bit prediction improves prediction rate (e.g. loop) July 2, 2001 Systems Architecture II

Systems Architecture II Branch Delays Branch Delay Always execute instruction after branch Rely on compiler to put safe instruction in branch delay slot July 2, 2001 Systems Architecture II

Systems Architecture II Exceptions Problem: Another control hazard is an exception (e.g. arithmetic overflow). In this case we need to transfer control to an exception handler. Need to flush pipeline. July 2, 2001 Systems Architecture II

Systems Architecture II July 2, 2001 Systems Architecture II

Systems Architecture II July 2, 2001 Systems Architecture II

Performance Improvement Problem: Assume 2ns for memory access, ALU op, and 1ns for register file access. Assume 1/2 load instructions immediately followed by instruction using result. Branch delay for misprediction is 1 cycle and 1/4 of the branches are mispredicted. Assume full clock delay on all jumps. Assume 22% loads, 11% stores, 49% R-format, 16% branches, and 2% jumps. What is the CPI for pipelined implementation? What is the performance gain over the single cycle implementation? What is the performance gain over the multicycle implementation? July 2, 2001 Systems Architecture II