Lecture 4: Advanced Pipelines. Data hazards, control hazards, multi-cycle in-order pipelines (Appendix A.4-A.10)

Similar documents
Lecture 2: Pipelining Basics. Today: chapter 1 wrap-up, basic pipelining implementation (Sections A.1 - A.4)

Lecture 5: Pipelining Basics

Lecture: Pipeline Wrap-Up and Static ILP

Instruction Level Parallelism. Appendix C and Chapter 3, HP5e

Instruction Level Parallelism. ILP, Loop level Parallelism Dependences, Hazards Speculation, Branch prediction

Instruction Pipelining Review

Minimizing Data hazard Stalls by Forwarding Data Hazard Classification Data Hazards Present in Current MIPS Pipeline

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

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

There are different characteristics for exceptions. They are as follows:

Course on Advanced Computer Architectures

Lecture 7: Pipelining Contd. More pipelining complications: Interrupts and Exceptions

Lecture: Out-of-order Processors. Topics: out-of-order implementations with issue queue, register renaming, and reorder buffer, timing, LSQ

Lecture 9: Dynamic ILP. Topics: out-of-order processors (Sections )

ECE 505 Computer Architecture

Appendix C: Pipelining: Basic and Intermediate Concepts

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

Out of Order Processing

Complications with long instructions. CMSC 411 Computer Systems Architecture Lecture 6 Basic Pipelining 3. How slow is slow?

Computer Systems Architecture I. CSE 560M Lecture 5 Prof. Patrick Crowley

Announcement. ECE475/ECE4420 Computer Architecture L4: Advanced Issues in Pipelining. Edward Suh Computer Systems Laboratory

Lecture 8: Instruction Fetch, ILP Limits. Today: advanced branch prediction, limits of ILP (Sections , )

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

1 Hazards COMP2611 Fall 2015 Pipelined Processor

CMSC 411 Computer Systems Architecture Lecture 6 Basic Pipelining 3. Complications With Long Instructions

Chapter 3. Pipelining. EE511 In-Cheol Park, KAIST

Multiple Instruction Issue. Superscalars

EITF20: Computer Architecture Part2.2.1: Pipeline-1

Lecture 7: Static ILP and branch prediction. Topics: static speculation and branch prediction (Appendix G, Section 2.3)

ECEC 355: Pipelining

Pipelining. Principles of pipelining. Simple pipelining. Structural Hazards. Data Hazards. Control Hazards. Interrupts. Multicycle operations

Pipelining and Exploiting Instruction-Level Parallelism (ILP)

Basic Pipelining Concepts

DLX Unpipelined Implementation

ECE154A Introduction to Computer Architecture. Homework 4 solution

CMCS Mohamed Younis CMCS 611, Advanced Computer Architecture 1

Advanced Parallel Architecture Lessons 5 and 6. Annalisa Massini /2017

Pipelining. CSC Friday, November 6, 2015

Advanced Computer Architecture

Multi-cycle Instructions in the Pipeline (Floating Point)

Instruction-Level Parallelism (ILP)

Overview. Appendix A. Pipelining: Its Natural! Sequential Laundry 6 PM Midnight. Pipelined Laundry: Start work ASAP

LECTURE 10. Pipelining: Advanced ILP

CPE Computer Architecture. Appendix A: Pipelining: Basic and Intermediate Concepts

Appendix A. Overview

COSC4201. Prof. Mokhtar Aboelaze York University

CS252 Prerequisite Quiz. Solutions Fall 2007

EITF20: Computer Architecture Part2.2.1: Pipeline-1

Lecture 8: Branch Prediction, Dynamic ILP. Topics: static speculation and branch prediction (Sections )

Background: Pipelining Basics. Instruction Scheduling. Pipelining Details. Idealized Instruction Data-Path. Last week Register allocation

Lecture: Static ILP. Topics: compiler scheduling, loop unrolling, software pipelining (Sections C.5, 3.2)

What is Pipelining? Time per instruction on unpipelined machine Number of pipe stages

COSC4201 Pipelining. Prof. Mokhtar Aboelaze York University

What is Pipelining? RISC remainder (our assumptions)

Page 1. CISC 662 Graduate Computer Architecture. Lecture 8 - ILP 1. Pipeline CPI. Pipeline CPI (I) Pipeline CPI (II) Michela Taufer

Updated Exercises by Diana Franklin

Lecture 6 MIPS R4000 and Instruction Level Parallelism. Computer Architectures S

CMSC 611: Advanced Computer Architecture

CS152 Computer Architecture and Engineering March 13, 2008 Out of Order Execution and Branch Prediction Assigned March 13 Problem Set #4 Due March 25

Lecture 9: More ILP. Today: limits of ILP, case studies, boosting ILP (Sections )

Predict Not Taken. Revisiting Branch Hazard Solutions. Filling the delay slot (e.g., in the compiler) Delayed Branch

Instruction Frequency CPI. Load-store 55% 5. Arithmetic 30% 4. Branch 15% 4

Floating Point/Multicycle Pipelining in DLX

Page # CISC 662 Graduate Computer Architecture. Lecture 8 - ILP 1. Pipeline CPI. Pipeline CPI (I) Michela Taufer

Pipelining concepts The DLX architecture A simple DLX pipeline Pipeline Hazards and Solution to overcome

Lecture 7. Instruction Scheduling. I. Basic Block Scheduling II. Global Scheduling (for Non-Numeric Code)

Lecture 11: Out-of-order Processors. Topics: more ooo design details, timing, load-store queue

CISC 662 Graduate Computer Architecture Lecture 7 - Multi-cycles. Interrupts and Exceptions. Device Interrupt (Say, arrival of network message)

CISC 662 Graduate Computer Architecture Lecture 7 - Multi-cycles

EE 4683/5683: COMPUTER ARCHITECTURE

Instruction-Level Parallelism and Its Exploitation

Appendix C. Authors: John Hennessy & David Patterson. Copyright 2011, Elsevier Inc. All rights Reserved. 1

Lecture 9: Case Study MIPS R4000 and Introduction to Advanced Pipelining Professor Randy H. Katz Computer Science 252 Spring 1996

Reduction of Data Hazards Stalls with Dynamic Scheduling So far we have dealt with data hazards in instruction pipelines by:

EITF20: Computer Architecture Part2.2.1: Pipeline-1

Lecture 16: Core Design. Today: basics of implementing a correct ooo core: register renaming, commit, LSQ, issue queue

Pipelining concepts The DLX architecture A simple DLX pipeline Pipeline Hazards and Solution to overcome

CS152 Computer Architecture and Engineering. Complex Pipelines

CPE 631 Lecture 09: Instruction Level Parallelism and Its Dynamic Exploitation

CISC 662 Graduate Computer Architecture Lecture 13 - CPI < 1

COSC 6385 Computer Architecture - Pipelining

Handout 2 ILP: Part B

Lecture 5: Instruction Pipelining. Pipeline hazards. Sequential execution of an N-stage task: N Task 2

Recall from Pipelining Review. Lecture 16: Instruction Level Parallelism and Dynamic Execution #1: Ideas to Reduce Stalls

Administrivia. CMSC 411 Computer Systems Architecture Lecture 6. When do MIPS exceptions occur? Review: Exceptions. Answers to HW #1 posted

CMSC411 Fall 2013 Midterm 2 Solutions

Full Datapath. Chapter 4 The Processor 2

Chapter 06: Instruction Pipelining and Parallel Processing

ELE 818 * ADVANCED COMPUTER ARCHITECTURES * MIDTERM TEST *

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

Exploiting ILP with SW Approaches. Aleksandar Milenković, Electrical and Computer Engineering University of Alabama in Huntsville

Pipelining. Maurizio Palesi

Instruction Pipelining

Instruction Pipelining

Pipelining: Issue instructions in every cycle (CPI 1) Compiler scheduling (static scheduling) reduces impact of dependences

Execution/Effective address

Pipelined Processor Design

INSTITUTO SUPERIOR TÉCNICO. Architectures for Embedded Computing

What is ILP? Instruction Level Parallelism. Where do we find ILP? How do we expose ILP?

Pipelining. Principles of pipelining. Simple pipelining. Structural Hazards. Data Hazards. Control Hazards. Interrupts. Multicycle operations

Transcription:

Lecture 4: Advanced Pipelines Data hazards, control hazards, multi-cycle in-order pipelines (Appendix A.4-A.10) 1

Hazards Structural hazards: different instructions in different stages (or the same stage) conflicting for the same resource Data hazards: an instruction cannot continue because it needs a value that has not yet been generated by an earlier instruction Control hazard: fetch cannot continue because it does not know the outcome of an earlier branch special case of a data hazard separate category because they are treated in different ways 2

Data Hazards 3

Bypassing Some data hazard stalls can be eliminated: bypassing 4

Example add R1, R2, R3 lw R4, 8(R1) 5

Example lw R1, 8(R2) lw R4, 8(R1) 6

Data Dependence Example lw R1, 8(R2) sw R1, 8(R3) 7

Summary For the 5-stage pipeline, bypassing can eliminate delays between the following example pairs of instructions: add/sub R1, R2, R3 add/sub/lw/sw R4, R1, R5 lw R1, 8(R2) sw R1, 4(R3) The following pairs of instructions will have intermediate stalls: lw R1, 8(R2) add/sub/lw R3, R1, R4 or sw R3, 8(R1) fmul F1, F2, F3 fadd F5, F1, F4 8

Control Hazards Simple techniques to handle control hazard stalls: for every branch, introduce a stall cycle (note: every 6 th instruction is a branch!) assume the branch is not taken and start fetching the next instruction if the branch is taken, need hardware to cancel the effect of the wrong-path instruction fetch the next instruction (branch delay slot) and execute it anyway if the instruction turns out to be on the correct path, useful work was done if the instruction turns out to be on the wrong path, hopefully program state is not lost 9

Branch Delay Slots 10

Slowdowns from Stalls Perfect pipelining with no hazards an instruction completes every cycle (total cycles ~ num instructions) speedup = increase in clock speed = num pipeline stages With hazards and stalls, some cycles (= stall time) go by during which no instruction completes, and then the stalled instruction completes Total cycles = number of instructions + stall cycles Slowdown because of stalls = 1/ (1 + stall cycles per instr) 11

Pipeline Implementation Signals for the muxes have to be generated some of this can happen during ID Need look-up tables to identify situations that merit bypassing/stalling the number of inputs to the muxes goes up 12

Detecting Control Signals Situation Example code Action No dependence Dependence requiring stall Dependence overcome by forwarding LD R1, 45(R2) DADD R5, R6, R7 DSUB R8, R6, R7 OR R9, R6, R7 LD R1, 45(R2) DADD R5, R1, R7 DSUB R8, R6, R7 OR R9, R6, R7 LD R1, 45(R2) DADD R5, R6, R7 DSUB R8, R1, R7 OR R9, R6, R7 No hazards Detect use of R1 during ID of DADD and stall Detect use of R1 during ID of DSUB and set mux control signal that accepts result from bypass path Dependence with accesses in order LD R1, 45(R2) DADD R5, R6, R7 DSUB R8, R6, R7 OR R9, R1, R7 No action required 13

Multicycle Instructions Functional unit Latency Initiation interval Integer ALU 1 1 Data memory 2 1 FP add 4 1 FP multiply 7 1 FP divide 25 25 14

Effects of Multicycle Instructions Structural hazards if the unit is not fully pipelined (divider) Frequent RAW hazard stalls Potentially multiple writes to the register file in a cycle WAW hazards because of out-of-order instr completion Imprecise exceptions because of o-o-o instr completion Note: Can also increase the width of the processor: handle multiple instructions at the same time: for example, fetch two instructions, read registers for both, execute both, etc. 15

Precise Exceptions On an exception: must save PC of instruction where program must resume all instructions after that PC that might be in the pipeline must be converted to NOPs (other instructions continue to execute and may raise exceptions of their own) temporary program state not in memory (in other words, registers) has to be stored in memory potential problems if a later instruction has already modified memory or registers A processor that fulfils all the above conditions is said to provide precise exceptions (useful for debugging and of course, correctness) 16

Dealing with these Effects Multiple writes to the register file: increase the number of ports, stall one of the writers during ID, stall one of the writers during WB (the stall will propagate) WAW hazards: detect the hazard during ID and stall the later instruction Imprecise exceptions: buffer the results if they complete early or save more pipeline state so that you can return to exactly the same state that you left at 17

ILP Instruction-level parallelism: overlap among instructions: pipelining or multiple instruction execution What determines the degree of ILP? dependences: property of the program hazards: property of the pipeline 18

Types of Dependences Data dependences: an instr produces a result for another (true dependence, results in RAW hazards in a pipeline) Name dependences: two instrs that use the same names (anti and output dependences, result in WAR and WAW hazards in a pipeline) Control dependences: an instruction s execution depends on the result of a branch re-ordering should preserve exception behavior and dataflow 19

Title Bullet 20