pipelining: data hazards Prof. Eric Rotenberg

Slides:



Advertisements
Similar presentations
ILP: IntroductionCSCE430/830 Instruction-level parallelism: Introduction CSCE430/830 Computer Architecture Lecturer: Prof. Hong Jiang Courtesy of Yifeng.
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.
CS252/Patterson Lec 1.1 1/17/01 Pipelining: Its Natural! Laundry Example Ann, Brian, Cathy, Dave each have one load of clothes to wash, dry, and fold Washer.
Lecture 6: Pipelining MIPS R4000 and More Kai Bu
Instruction-Level Parallelism (ILP)
MIPS Pipelined Datapath
Review: MIPS Pipeline Data and Control Paths
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?
Computer Architecture - A Pipelined Datapath A Pipelined Datapath  Resisters are used to save data between stages. 1/14.
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.
Pipeline Hazard CT101 – Computing Systems. Content Introduction to pipeline hazard Structural Hazard Data Hazard Control Hazard.
Pipelined Datapath and Control
Caltech CS184b Winter DeHon 1 CS184b: Computer Architecture [Single Threaded Architecture: abstractions, quantification, and optimizations] Day5:
CS252/Patterson Lec 1.1 1/17/01 معماري کامپيوتر - درس نهم pipeline برگرفته از درس : Prof. David A. Patterson.
CSIE30300 Computer Architecture Unit 05: Overcoming Data Hazards Hsin-Chou Chi [Adapted from material by and
EE524/CptS561 Jose G. Delgado-Frias 1 Processor Basic steps to process an instruction IFID/OFEXMEMWB Instruction Fetch Instruction Decode / Operand Fetch.
Pipelining: Implementation CPSC 252 Computer Organization Ellen Walker, Hiram College.
Interstage Buffers 1 Computer Organization II © McQuain Pipeline Timing Issues Consider executing: add $t2, $t1, $t0 sub $t3, $t1, $t0 or.
CS 352H: Computer Systems Architecture
Pipeline Timing Issues
CDA3101 Recitation Section 8
Pipelining: Hazards Ver. Jan 14, 2014
Lecture 07: Pipelining Multicycle, MIPS R4000, and More
5 Steps of MIPS Datapath Figure A.2, Page A-8
Single Clock Datapath With Control
Appendix C Pipeline implementation
Microprocessor Microarchitecture Dynamic Pipeline
ECS 154B Computer Architecture II Spring 2009
\course\cpeg323-08F\Topic6b-323
ECE232: Hardware Organization and Design
Chapter 4 The Processor Part 3
Review: MIPS Pipeline Data and Control Paths
Morgan Kaufmann Publishers The Processor
CS 5513 Computer Architecture Pipelining Examples
Lecture 6: Advanced Pipelines
Computer Architecture Lecture 3 – Part 1 11th May, 2006
Pipelining Multicycle, MIPS R4000, and More
Pipelining review.
Current Design.
Computer Organization CS224
Pipelining in more detail
CSC 4250 Computer Architectures
\course\cpeg323-05F\Topic6b-323
Pipeline control unit (highly abstracted)
The Processor Lecture 3.6: Control Hazards
Control unit extension for data hazards
An Introduction to pipelining
Instruction Level Parallelism (ILP)
The Processor Lecture 3.5: Data Hazards
Daxia Ge Friday February 9th, 2007
Instruction Execution Cycle
Overview What are pipeline hazards? Types of hazards
Pipeline control unit (highly abstracted)
CS203 – Advanced Computer Architecture
Instruction-Level Parallelism (ILP)
Designing a Pipelined CPU
Overview Prof. Eric Rotenberg
Pipeline Control unit (highly abstracted)
Pipelining.
Control unit extension for data hazards
Morgan Kaufmann Publishers The Processor
Introduction to Computer Organization and Architecture
Control unit extension for data hazards
CS 3853 Computer Architecture Pipelining Examples
Conceptual execution on a processor which exploits ILP
MIPS Pipelined Datapath
Spring 2019 Prof. Eric Rotenberg
ECE 721, Spring 2019 Prof. Eric Rotenberg.
Need to stall for one cycle.
Pipelining Hazards.
Presentation transcript:

pipelining: data hazards Prof. Eric Rotenberg ECE 463/563 Fall `18 pipelining: data hazards Prof. Eric Rotenberg Fall 2018 ECE 463/563, Microprocessor Architecture, Prof. Eric Rotenberg

ECE 463/563, Microprocessor Architecture, Prof. Eric Rotenberg Data Hazards read-after-write (RAW) hazard add r1, r2, r3 add r4, r1, r5 write-after-read (WAR) hazard add r2, r4, r5 write-after-write (WAW) hazard add r1, r4, r5 Fall 2018 ECE 463/563, Microprocessor Architecture, Prof. Eric Rotenberg

ECE 463/563, Microprocessor Architecture, Prof. Eric Rotenberg RAW Hazard value needed value available value written IF add r1,r2,r3 ID IF add r4,r1,r5 EX ID IF MEM ID IF WB ID IF ID IF EX ID MEM EX WB MEM Fall 2018 ECE 463/563, Microprocessor Architecture, Prof. Eric Rotenberg

Data forwarding (bypasses) IF/ID ID/EX EX/MEM MEM/WB RF NPC MUX D$ A ALU B MUX MUX IMM Fall 2018 ECE 463/563, Microprocessor Architecture, Prof. Eric Rotenberg

Data forwarding (bypasses) IF/ID ID/EX EX/MEM MEM/WB RF NPC MUX D$ A ALU B MUX MUX IMM preliminary: moved this mux to prior stage Fall 2018 ECE 463/563, Microprocessor Architecture, Prof. Eric Rotenberg

Data forwarding (bypasses) IF/ID ID/EX EX/MEM MEM/WB bypass 2 RF bypass 1 NPC MUX MUX D$ A ALU B MUX MUX MUX IMM Fall 2018 ECE 463/563, Microprocessor Architecture, Prof. Eric Rotenberg

Data forwarding (cont.) EX ID IF add r6,r1,r5 byp 1 WB MEM EX ID IF add r8,r1,r5 byp 3 MEM EX ID IF add r7,r1,r5 byp 2 IF add r1,r2,r3 ID IF add r4,r1,r5 WB MEM EX ID WB MEM EX WB MEM WB Fall 2018 ECE 463/563, Microprocessor Architecture, Prof. Eric Rotenberg

Stalls due to RAW hazards With bypasses No stall if producer is ALU type instruction Unavoidable 1-cycle stall if producer is a load instruction (cache hit) AND its dependent instruction is right behind it. This is because the dependent instruction must wait for BYPASS 2 for the load value. Note: If an instruction takes multiple cycles in EX (e.g., complex ALU operation) or multiple cycles in MEM (load/store cache miss), all instructions behind the long-latency instruction stall whether or not they depend on the data. The stall is attributable to a structural hazard caused by the current pipeline design (EX and MEM stages are “blocking” for multi-cycle instructions). EX ID IF value needed MEM ID IF value available byp 2 ID IF add r4,r1,r5 IF lw r1,#0(r2) WB EX ID MEM EX WB MEM Fall 2018 ECE 463/563, Microprocessor Architecture, Prof. Eric Rotenberg

ECE 463/563, Microprocessor Architecture, Prof. Eric Rotenberg WAR and WAW Hazards WAR hazard A: ADD R1, R2, R3 B: ADD R2, R4, R5 Problem if B writes R2 before A reads R2 A will get the wrong value of R2 (that of B) Doesn’t happen in most in-order pipelines (like ours) Happens in out-of-order pipelines A may be stalled and B may be ready to execute out-of-order and write R2 WAW hazard B: ADD R1, R4, R5 Problem if B writes R1 before A writes R1 Later instructions will get the wrong value of R1 (that of A) A may be stalled and B may be ready to execute out-of-order and write R1 first Fall 2018 ECE 463/563, Microprocessor Architecture, Prof. Eric Rotenberg

WAR and WAW Hazards (cont.) Options for handling WAR and WAW hazards Stall the later instruction to defer its register write, OR Register renaming (see next major topic: ILP) Either way, compiler can limit the occurrence of WAR and WAW hazards by limiting the reuse of destination register specifiers among nearby instructions Fall 2018 ECE 463/563, Microprocessor Architecture, Prof. Eric Rotenberg

Types of program dependencies True dependence (pure dependence, flow dependence) ADD R1, R2, R3 ADD R4, R1, R5 Causes RAW hazard if the two instructions are in the pipeline concurrently Anti-dependence ADD R2, R4, R5 Causes WAR hazard if the two instructions are in the pipeline concurrently Output dependence ADD R1, R4, R5 Causes WAW hazard if the two instructions are in the pipeline concurrently Fall 2018 ECE 463/563, Microprocessor Architecture, Prof. Eric Rotenberg

Program dependencies (cont.) A true dependence is called that, because there is truly a data dependency between the two instructions Producer-consumer relationship Second instruction needs the data produced by the first Anti-dependence and output dependence are sometimes clubbed together as false dependence because there isn’t actually a data dependency between the two instructions, just a register conflict Fall 2018 ECE 463/563, Microprocessor Architecture, Prof. Eric Rotenberg