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.

Slides:



Advertisements
Similar presentations
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.
Advertisements

CMSC 611: Advanced Computer Architecture Pipelining Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted.
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.
Data Dependencies Describes the normal situation that the data that instructions use depend upon the data created by other instructions, or data is stored.
Advanced Pipelining Optimally Scheduling Code Optimally Programming Code Scheduling for Superscalars (6.9) Exceptions (5.6, 6.8)
Pipeline Computer Organization II 1 Hazards Situations that prevent starting the next instruction in the next cycle Structural hazards – A required resource.
Forwarding and Hazards MemberRole William ElliottTeam Leader Jessica Tyler ShulerWiki Specialist Tyler KimseyLead Engineer Cameron CarrollEngineer Danielle.
Chapter 4 The Processor CprE 381 Computer Organization and Assembly Level Programming, Fall 2013 Zhao Zhang Iowa State University Revised from original.
Pipeline Hazards Pipeline hazards These are situations that inhibit that the next instruction can be processed in the next stage of the pipeline. This.
Instruction-Level Parallelism (ILP)
1 IF IDEX MEM L.D F4,0(R2) MUL.D F0, F4, F6 ADD.D F2, F0, F8 L.D F2, 0(R2) WB IF IDM1 MEM WBM2M3M4M5M6M7 stall.
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.
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.
1 Chapter Six - 2nd Half Pipelined Processor Forwarding, Hazards, Branching EE3055 Web:
Computer ArchitectureFall 2007 © October 24nd, 2007 Majd F. Sakr CS-447– Computer Architecture.
Pipeline Exceptions & ControlCSCE430/830 Pipeline: Exceptions & Control CSCE430/830 Computer Architecture Lecturer: Prof. Hong Jiang Courtesy of Yifeng.
EENG449b/Savvides Lec 4.1 1/22/04 January 22, 2004 Prof. Andreas Savvides Spring EENG 449bG/CPSC 439bG Computer.
Control Hazards.1 Review: Datapath with Data Hazard Control Read Address Instruction Memory Add PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr Register.
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.
What are Exception and Interrupts? MIPS terminology Exception: any unexpected change in the internal control flow – Invoking an operating system service.
Lecture 15: Pipelining and Hazards CS 2011 Fall 2014, Dr. Rozier.
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.
Comp Sci pipelining 1 Ch. 13 Pipelining. Comp Sci pipelining 2 Pipelining.
CMPE 421 Parallel Computer Architecture
CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Pipelining Basics.
CS 1104 Help Session IV Five Issues in Pipelining Colin Tan, S
Chapter 6 Pipelined CPU Design. Spring 2005 ELEC 5200/6200 From Patterson/Hennessey Slides Pipelined operation – laundry analogy Text Fig. 6.1.
ECE/CS 552: Pipelining Instructor: Mikko H Lipasti Fall 2010 University of Wisconsin-Madison Lecture notes based on set created by Mark Hill and John P.
Chapter 6: Pipelining Instructor: Mozafar Bag Mohammadi University of Ilam.
1 (Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 3 rd Ed., Morgan Kaufmann,
CSIE30300 Computer Architecture Unit 06: Containing Control Hazards
Lecture 9. MIPS Processor Design – Pipelined Processor Design #1 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System.
PROCESSOR PIPELINING YASSER MOHAMMAD. SINGLE DATAPATH DESIGN.
LECTURE 10 Pipelining: Advanced ILP. EXCEPTIONS An exception, or interrupt, is an event other than regular transfers of control (branches, jumps, calls,
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.
Pipelining: Implementation CPSC 252 Computer Organization Ellen Walker, Hiram College.
CS 352H: Computer Systems Architecture
Exceptions Another form of control hazard Could be caused by…
Computer Organization CS224
CSCI206 - Computer Organization & Programming
ECS 154B Computer Architecture II Spring 2009
\course\cpeg323-08F\Topic6b-323
ECE/CS 552: Single Cycle Datapath
Pipelining: Advanced ILP
Lecture 6: Advanced Pipelines
Pipelining review.
The processor: Pipelining and Branching
ECE/CS 552: Microprogramming and Exceptions
Lecture 8: ILP and Speculation Contd. Chapter 2, Sections 2. 6, 2
Pipelining in more detail
CSCI206 - Computer Organization & Programming
\course\cpeg323-05F\Topic6b-323
Data Hazards Data Hazard
Pipeline control unit (highly abstracted)
The Processor Lecture 3.6: Control Hazards
Control unit extension for data hazards
The Processor Lecture 3.5: Data Hazards
Instruction Execution Cycle
Pipeline control unit (highly abstracted)
Pipeline Control unit (highly abstracted)
Pipelining (II).
Control unit extension for data hazards
CSC3050 – Computer Architecture
ECE/CS 552: Pipelining and Exceptions
Control unit extension for data hazards
Systems Architecture II
Spring 2010 Ilam University
Presentation transcript:

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 Smith

Pipeline Hazards Forecast – Program Dependences – Data Hazards Stalls Forwarding – Control Hazards – Exceptions 2

Sequential Execution Model MIPS ISA requires the appearance of sequential execution – Precise exceptions – True of most general purpose ISAs 3

Program Dependences 4

Program Data Dependences True dependence (RAW) – j cannot execute until i produces its result Anti-dependence (WAR) – j cannot write its result until i has read its sources Output dependence (WAW) – j cannot write its result until i has written its result 5

Control Dependences Conditional branches – Branch must execute to determine which instruction to fetch next – Instructions following a conditional branch are control dependent on the branch instruction 6

Example (quicksort/MIPS) #for (; (j < high) && (array[j] < array[low]) ; ++j ); #$10 = j #$9 = high #$6 = array #$8 = low bgedone, $10, $9 mul$15, $10, 4 addu$24, $6, $15 lw$25, 0($24) mul$13, $8, 4 addu$14, $6, $13 lw$15, 0($14) bgedone, $25, $15 cont: addu$10, $10, 1... done: addu$11, $11, -1 7

Pipeline Hazards Pipeline hazards – Potential violations of program dependences – Must ensure program dependences are not violated Hazard resolution – Static: compiler/programmer guarantees correctness – Dynamic: hardware performs checks at runtime Pipeline interlock – Hardware mechanism for dynamic hazard resolution – Must detect and enforce dependences at runtime 8

Pipeline Hazards Necessary conditions: – WAR: write stage earlier than read stage Is this possible in IF-RD-EX-MEM-WB ? – WAW: write stage earlier than write stage Is this possible in IF-RD-EX-MEM-WB ? – RAW: read stage earlier than write stage Is this possible in IF-RD-EX-MEM-WB? If conditions not met, no need to resolve Check for both register and memory 9

Pipeline Hazard Analysis Memory hazards – WAR: Yes/No? – WAW: Yes/No? – RAW: Yes/No? Register hazards – WAR: Yes/No? – WAW: Yes/No? – RAW: Yes/No? WAR: write stage earlier than read? WAW: write stage earlier than write? RAW: read stage earlier than write? 10

RAW Hazard Earlier instruction produces a value used by a later instruction: – add $1, $2, $3 – sub $4, $5, $1 Cycle: Instr: addFDXMW subFDXMW 11

RAW Hazard - Stall Detect dependence and stall: – add $1, $2, $3 – sub $4, $5, $1 Cycle: Instr: addFDXMW subFDXMW 12

Control Dependence One instruction affects which executes next – sw $4, 0($5) – bne $2, $3, loop – sub $6, $7, $8 Cycle: Instr: swFDXMW bneFDXMW subFDXMW 13

Control Dependence - Stall Detect dependence and stall – sw $4, 0($5) – bne $2, $3, loop – sub $6, $7, $8 Cycle: Instr: swFDXMW bneFDXMW subFDXMW 14

Pipelined Control Controlled by different instructions Decode instructions and pass the signals down the pipe Control sequencing is embedded in the pipeline – No explicit FSM – Instead, distributed FSM 15

Pipelined Control 16

RAW Hazards Must first detect RAW hazards – Pipeline analysis proves that WAR/WAW don’t occur ID/EX.WriteRegister = IF/ID.ReadRegister1 ID/EX.WriteRegister = IF/ID.ReadRegister2 EX/MEM.WriteRegister = IF/ID.ReadRegister1 EX/MEM.WriteRegister = IF/ID.ReadRegister2 MEM/WB.WriteRegister = IF/ID.ReadRegister1 MEM/WB.WriteRegister = IF/ID.ReadRegister2 17

RAW Hazards Not all hazards because – WriteRegister not used (e.g. sw) – ReadRegister not used (e.g. addi, jump) – Do something only if necessary 18

RAW Hazards Hazard Detection Unit – Several 5-bit comparators Response? Stall pipeline – Instructions in IF and ID stay – IF/ID pipeline latch not updated – Send ‘nop’ down pipeline (called a bubble) – PCWrite, IF/IDWrite, and nop mux 19

RAW Hazard Forwarding A better response – forwarding – Also called bypassing Comparators ensure register is read after it is written Instead of stalling until write occurs – Use mux to select forwarded value rather than register value – Control mux with hazard detection logic 20

Forwarding Paths (ALU instructions) 21

Write before Read RF Register file design – 2-phase clocks common – Write RF on first phase – Read RF on second phase Hence, same cycle: – Write $1 – Read $1 No bypass needed – If read before write or DFF-based, need bypass 22

ALU Forwarding 23

Forwarding Paths (Load instructions) 24

Implementation of Load Forwarding 25

Control Flow Hazards Control flow instructions – branches, jumps, jals, returns – Can’t fetch until branch outcome known – Too late for next IF 26

Control Flow Hazards What to do? – Always stall – Easy to implement – Performs poorly – 1/6 th instructions are branches each branch takes 3 cycles – CPI = x 1/6 = 1.5 (lower bound) 27

Control Flow Hazards Predict branch not taken Send sequential instructions down pipeline Kill instructions later if incorrect Must stop memory accesses and RF writes Late flush of instructions on misprediction – Complex – Global signal (wire delay) 28

Control Flow Hazards Even better but more complex – Predict taken – Predict both (eager execution) – Predict one or the other dynamically Adapt to program branch patterns Lots of chip real estate these days – Core i7, ARM A15 Current research topic – More later, covered in detail in ECE752 29

Control Flow Hazards Another option: delayed branches – Always execute following instruction – “delay slot” (later example on MIPS pipeline) – Put useful instruction there, otherwise ‘nop’ A mistake to cement this into ISA – Just a stopgap (one cycle, one instruction) – Superscalar processors (later) Delay slot just gets in the way 30

Exceptions and Pipelining add $1, $2, $3 overflows A surprise branch – Earlier instructions flow to completion – Kill later instructions – Save PC in EPC, set PC to EX handler, etc. Costs a lot of designer sanity – 554 teams that try this sometimes fail 31

Exceptions Even worse: in one cycle – I/O interrupt – User trap to OS (EX) – Illegal instruction (ID) – Arithmetic overflow – Hardware error – Etc. Interrupt priorities must be supported 32

Pipeline Hazards Program Dependences Data Hazards – Stalls – Forwarding Control Hazards Exceptions 33