Pipeline Data Hazards. Dealing With Data Hazards

Similar documents
ECE260: Fundamentals of Computer Engineering

Chapter Six. Dataı access. Reg. Instructionı. fetch. Dataı. Reg. access. Dataı. Reg. access. Dataı. Instructionı fetch. 2 ns 2 ns 2 ns 2 ns 2 ns

Pipelining. Ideal speedup is number of stages in the pipeline. Do we achieve this? 2. Improve performance by increasing instruction throughput ...

Lecture Topics. Announcements. Today: Data and Control Hazards (P&H ) Next: continued. Exam #1 returned. Milestone #5 (due 2/27)

Processor (II) - pipelining. Hwansoo Han

Chapter 4 (Part II) Sequential Laundry

Full Datapath. Chapter 4 The Processor 2

Designing a Pipelined CPU

Pipelining Analogy. Pipelined laundry: overlapping execution. Parallelism improves performance. Four loads: Non-stop: Speedup = 8/3.5 = 2.3.

Midnight Laundry. IC220 Set #19: Laundry, Co-dependency, and other Hazards of Modern (Architecture) Life. Return to Chapter 4

Chapter 4 The Processor 1. Chapter 4B. The Processor

zhandling Data Hazards The objectives of this module are to discuss how data hazards are handled in general and also in the MIPS architecture.

The Processor (3) Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

ECE473 Computer Architecture and Organization. Pipeline: Data Hazards

Pipeline Hazards. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

MIPS An ISA for Pipelining

Lecture 3: The Processor (Chapter 4 of textbook) Chapter 4.1

Chapter 4. The Processor

Department of Computer and IT Engineering University of Kurdistan. Computer Architecture Pipelining. By: Dr. Alireza Abdollahpouri

Improve performance by increasing instruction throughput

COMPUTER ORGANIZATION AND DESIGN

Lecture 05: Pipelining: Basic/ Intermediate Concepts and Implementation

What do we have so far? Multi-Cycle Datapath (Textbook Version)

14:332:331 Pipelined Datapath

SI232 Set #20: Laundry, Co-dependency, and other Hazards of Modern (Architecture) Life. Chapter 6 ADMIN. Reading for Chapter 6: 6.1,

ECE154A Introduction to Computer Architecture. Homework 4 solution

Instruction fetch. MemRead. IRWrite ALUSrcB = 01. ALUOp = 00. PCWrite. PCSource = 00. ALUSrcB = 00. R-type completion

Designing a Pipelined CPU

COMPUTER ORGANIZATION AND DESIGN

Outline. A pipelined datapath Pipelined control Data hazards and forwarding Data hazards and stalls Branch (control) hazards Exception

CSEE 3827: Fundamentals of Computer Systems

Basic Instruction Timings. Pipelining 1. How long would it take to execute the following sequence of instructions?

Outline Marquette University

ECS 154B Computer Architecture II Spring 2009

Full Datapath. Chapter 4 The Processor 2

COMP2611: Computer Organization. The Pipelined Processor

ELE 655 Microprocessor System Design

Pipelined datapath Staging data. CS2504, Spring'2007 Dimitris Nikolopoulos

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. 5 th. Edition. Chapter 4. The Processor

Chapter 4 The Processor 1. Chapter 4A. The Processor

Data Hazards Compiler Scheduling Pipeline scheduling or instruction scheduling: Compiler generates code to eliminate hazard

ECE260: Fundamentals of Computer Engineering

Enhanced Performance with Pipelining

LECTURE 3: THE PROCESSOR

Virtual memory. Hung-Wei Tseng

Pipelining. CSC Friday, November 6, 2015

What do we have so far? Multi-Cycle Datapath

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

CS 251, Winter 2018, Assignment % of course mark

Pipelining. Pipeline performance

T = I x CPI x C. Both effective CPI and clock cycle C are heavily influenced by CPU design. CPI increased (3-5) bad Shorter cycle good

Lecture 9. Pipeline Hazards. Christos Kozyrakis Stanford University

DLX Unpipelined Implementation

Virtual memory. Hung-Wei Tseng

LECTURE 9. Pipeline Hazards

Processor Architecture. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

ECEC 355: Pipelining

RISC Pipeline. Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter 4.6

CENG 3420 Lecture 06: Pipeline

Processor Design Pipelined Processor (II) Hung-Wei Tseng

The Processor. Z. Jerry Shi Department of Computer Science and Engineering University of Connecticut. CSE3666: Introduction to Computer Architecture

Computer Architecture Computer Science & Engineering. Chapter 4. The Processor BK TP.HCM

Determined by ISA and compiler. We will examine two MIPS implementations. A simplified version A more realistic pipelined version

Perfect Student CS 343 Final Exam May 19, 2011 Student ID: 9999 Exam ID: 9636 Instructions Use pencil, if you have one. For multiple choice

Processor Architecture

EE557--FALL 1999 MIDTERM 1. Closed books, closed notes

Chapter 4. The Processor

Pipelining is Hazardous!

EE2011 Computer Organization Lecture 10: Enhancing Performance with Pipelining ~ Pipelined Datapath

CS 251, Winter 2019, Assignment % of course mark

Chapter 4. The Processor

COSC 6385 Computer Architecture - Pipelining

Multi-cycle Datapath (Our Version)

3/12/2014. Single Cycle (Review) CSE 2021: Computer Organization. Single Cycle with Jump. Multi-Cycle Implementation. Why Multi-Cycle?

ECE Exam II - Solutions November 8 th, 2017

EIE/ENE 334 Microprocessors

ECE/CS 552: Pipeline Hazards

Slides for Lecture 15

1 Hazards COMP2611 Fall 2015 Pipelined Processor

CS3350B Computer Architecture Quiz 3 March 15, 2018

CPE 335 Computer Organization. Basic MIPS Pipelining Part I

Design a MIPS Processor (2/2)

The Processor Pipeline. Chapter 4, Patterson and Hennessy, 4ed. Section 5.3, 5.4: J P Hayes.

Instruction word R0 R1 R2 R3 R4 R5 R6 R8 R12 R31

Unresolved data hazards. CS2504, Spring'2007 Dimitris Nikolopoulos

Lecture 4: Review of MIPS. Instruction formats, impl. of control and datapath, pipelined impl.

Chapter 4. The Processor

Pipelined Processor Design

CS 2506 Computer Organization II Test 2

Thomas Polzer Institut für Technische Informatik

Chapter 4. The Processor

MIPS Pipelining. Computer Organization Architectures for Embedded Computing. Wednesday 8 October 14

Computer Architecture Computer Science & Engineering. Chapter 4. The Processor BK TP.HCM

Pipelined Datapath. Reading. Sections Practice Problems: 1, 3, 8, 12

DEE 1053 Computer Organization Lecture 6: Pipelining

Computer Architecture

Parallelism via Multithreaded and Multicore CPUs. Bradley Dutton March 29, 2010 ELEC 6200

Computer and Information Sciences College / Computer Science Department Enhancing Performance with Pipelining

Modern Computer Architecture

University of Jordan Computer Engineering Department CPE439: Computer Design Lab

Transcription:

Pipeline Data Hazards Warning, warning, warning! Dealing With Data Hazards In Software inserting independent instructions In Hardware inserting bubbles (stalling the pipeline) data forwarding Data Data Hazards Hazards are are caused caused by byinstruction dependences. For For example, the the add add is is data-dependent on on the the subtract: subi subi $5, $5, $4, $4, #45 #45 add add $8, $8, $5, $5, $2 $2

Dealing with Data Hazards in Software CC1 CC2 CC3 CC4 CC5 CC6 CC7 CC8 sub $2, $1, $3 nop nop nop and $12, $2, $5 How Many No-ops? sub $2, $1,$3 and $4, $2,$5 or $8, $2,$6 add $9, $4,$2 slt $1, $6,$7

Are No-ops Really Necessary? sub $2, $1,$3 and $4, $2,$5 or $8, $3,$6 add $9, $2,$8 slt $1, $6,$7 Dealing with Data Hazards in Hardware Part II-Pipeline Stalls CC1 CC2 CC3 CC4 CC5 CC6 CC7 CC8 sub $2, $1, $3 and $12, $2, $5 Bubble Bubble Bubble or $13, $6, $2 add $14, $2, $2 sw $15, 100($2)

Pipeline Stalls CC1 CC2 CC3 CC4 CC5 CC6 CC7 CC8 sub $2, $1, $3 add $12, $3, $5 or $13, $6, $2 Bubble Bubble add $14, $12, $2 sw $14, 100($2) Bubble Bubble Bubble Pipeline Stalls We must: Detect the hazard Stall the pipeline

Knowing When to Stall CC1 CC2 CC3 CC4 CC5 CC6 CC7 CC8 6 types of data hazards two reg reads * 3 reg writes The Pipeline What comparisons tell us when to stall?

Stalling the Pipeline Once we detect a hazard, then we have to be able to stall the pipeline (insert a bubble). Stalling the pipeline is accomplished by (1) preventing the IF and ID stages from making progress the ID stage because it cannot proceed until the dependent instruction completes the IF stage because we do not want to lose any instructions. (2) inserting nops in hardware Stalling the Pipeline Preventing the IF and ID stages from proceeding don t write the PC (PCWrite = 0) don t rewrite IF/ID register (IF/IDWrite = 0) Inserting nops set all control signals propagating to EX/MEM/WB to zero

The Pipeline The Pipeline

Reducing Data Hazards Through Forwarding add $2, $3, $4 add $5, $3, $2 ID/EX EX/MEM MEM/WB isters Data Memory 0 1 Reducing Data Hazards Through Forwarding EX Hazard: if (EX/MEM.Write and (EX/MEM.isterRd!= 0) and (EX/MEM.isterRd = ID/EX.isterRs)) ForwardA = 10 if (EX/MEM.Write and (EX/MEM.isterRd!= 0) and (EX/MEM.isterRd = ID/EX.isterRt )) ForwardB = 10 (similar for the MEM stage)

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) 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 Eliminating Data Hazards via Forwarding CC1 CC2 CC3 CC4 CC5 CC6 CC7 CC8 sub $2, $1, $3 and $6, $2, $5 or $13, $6, $2 add $14, $2, $2 sw $15, 100($2)

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

Forwarding in Action Instruction Fetch Instruction Decode add $1, $12, $3 sub $12, $3, $4 add $3, $10, $11 Eliminating Data Hazards via Forwarding?? CC1 CC2 CC3 CC4 CC5 CC6 CC7 CC8 lw $2, 10($1) and $12, $2, $5 or $13, $6, $2 add $14, $2, $2 sw $15, 100($2)

Eliminating Data Hazards via Forwarding and stalling CC1 CC2 CC3 CC4 CC5 CC6 CC7 CC8 lw $2, 10($1) and $12, $2, $5 Bubble or $13, $6, $2 Bubble add $14, $2, $2 sw $15, 100($2) Try this one... Show stalls and forwarding for this code add $3, $2, $1 lw $4, 100($3) and $6, $4, $3 sub $7, $6, $2

Datapath with Hazard-Detection if (ID/EX.MemRead and ((ID/EX.isterRt = IF/ID.isterRs) or (ID/EX.isterRt = IF/ID.isterRt ))) then stall the pipeline Hazard Detection and $4, $2, $5 lw $2, 20($1)

Hazard Detection and $4, $2, $5 nop (bubble) lw $2, 20($1) 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.