Pipelining. Principles of pipelining Pipeline hazards Remedies. Pre-soak soak soap wash dry wipe. l Chapter 4.4 and 4.5

Similar documents
Pipelining. Maurizio Palesi

CS 110 Computer Architecture. Pipelining. Guest Lecture: Shu Yin. School of Information Science and Technology SIST

administrivia final hour exam next Wednesday covers assembly language like hw and worksheets

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

Chapter 8. Pipelining

Lecture 15: Pipelining. Spring 2018 Jason Tang

Page 1. Pipelining: Its Natural! Chapter 3. Pipelining. Pipelined Laundry Start work ASAP. Sequential Laundry A B C D. 6 PM Midnight

Module 4c: Pipelining

Lecture 3. Pipelining. Dr. Soner Onder CS 4431 Michigan Technological University 9/23/2009 1

1 Hazards COMP2611 Fall 2015 Pipelined Processor

Modern Computer Architecture

COSC 6385 Computer Architecture - Pipelining

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

Pipelining, Instruction Level Parallelism and Memory in Processors. Advanced Topics ICOM 4215 Computer Architecture and Organization Fall 2010

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

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

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

ECE260: Fundamentals of Computer Engineering

6x86 PROCESSOR Superscalar, Superpipelined, Sixth-generation, x86 Compatible CPU

Outline Marquette University

Lecture 19 Introduction to Pipelining

CPS104 Computer Organization and Programming Lecture 19: Pipelining. Robert Wagner

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

EITF20: Computer Architecture Part2.2.1: Pipeline-1

EITF20: Computer Architecture Part2.2.1: Pipeline-1

Lecture 05: Pipelining: Basic/ Intermediate Concepts and Implementation

Pipeline: Introduction

Instruction Level Parallelism. Appendix C and Chapter 3, HP5e

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

ELE 655 Microprocessor System Design

Appendix A. Overview

Pipelined Processor Design

ECEC 355: Pipelining

Pipelined Processor Design

COMPUTER ORGANIZATION AND DESIGN

CPSC 313, 04w Term 2 Midterm Exam 2 Solutions

Pipeline issues. Pipeline hazard: RaW. Pipeline hazard: RaW. Calcolatori Elettronici e Sistemi Operativi. Hazards. Data hazard.

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

The Pipelined MIPS Processor

ELCT 501: Digital System Design

Pipeline Processors David Rye :: MTRX3700 Pipelining :: Slide 1 of 15

Lecture 9. Pipeline Hazards. Christos Kozyrakis Stanford University

EI338: Computer Systems and Engineering (Computer Architecture & Operating Systems)

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

Orange Coast College. Business Division. Computer Science Department. CS 116- Computer Architecture. Pipelining

ECE154A Introduction to Computer Architecture. Homework 4 solution

CISC 662 Graduate Computer Architecture Lecture 6 - Hazards

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

Pipelining: Hazards Ver. Jan 14, 2014

CS 61C: Great Ideas in Computer Architecture Pipelining and Hazards

ECE473 Computer Architecture and Organization. Pipeline: Control Hazard

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

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

EITF20: Computer Architecture Part2.2.1: Pipeline-1

Basic Pipelining Concepts

CMCS Mohamed Younis CMCS 611, Advanced Computer Architecture 1

Computer Architecture. Lecture 6.1: Fundamentals of

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

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

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

Pipeline Overview. Dr. Jiang Li. Adapted from the slides provided by the authors. Jiang Li, Ph.D. Department of Computer Science

Pipelining: Overview. CPSC 252 Computer Organization Ellen Walker, Hiram College

Ti Parallel Computing PIPELINING. Michał Roziecki, Tomáš Cipr

12.1. CS356 Unit 12. Processor Hardware Organization Pipelining

Structure of Computer Systems

What is Pipelining? RISC remainder (our assumptions)

Instr. execution impl. view

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

Computer Architecture

Processor Architecture

Pipelining. lecture 15. MIPS data path and control 3. Five stages of a MIPS (CPU) instruction. - factory assembly line (Henry Ford years ago)

ECE 505 Computer Architecture

Instruction Pipelining Review

CS356 Unit 12a. Logic Circuits. Combinational Logic Gates BASIC HW. Processor Hardware Organization Pipelining

Pipelining. CSC Friday, November 6, 2015

Superscalar Processors

Pipeline Review. Review

Topics. Lecture 12: Pipelining. Introduction to pipelining. Pipelined datapath. Hazards in pipeline. Performance. Design issues.

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

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

Instruction Level Parallelism

EN164: Design of Computing Systems Topic 06.b: Superscalar Processor Design

Chapter 4. The Processor

Week 11: Assignment Solutions

Course on Advanced Computer Architectures

Thomas Polzer Institut für Technische Informatik

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

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

Practical Malware Analysis

The Big Picture Problem Focus S re r g X r eg A d, M lt2 Sub u, Shi h ft Mac2 M l u t l 1 Mac1 Mac Performance Focus Gate Source Drain BOX

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

Introduction to Pipelining. Silvina Hanono Wachman Computer Science & Artificial Intelligence Lab M.I.T.

Full Datapath. Chapter 4 The Processor 2

Working on the Pipeline

Chapter 4. The Processor

Pipelining: Basic and Intermediate Concepts

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

In embedded systems there is a trade off between performance and power consumption. Using ILP saves power and leads to DECREASING clock frequency.

Chapter 06: Instruction Pipelining and Parallel Processing

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

Transcription:

Pipelining Pre-soak soak soap wash dry wipe Chapter 4.4 and 4.5 Principles of pipelining Pipeline hazards Remedies 1

Multi-stage process Sequential execution One process begins after previous finishes E.g., six stage process; each stage takes 5 sec Time to complete is 30 sec Throughput = 2/minute Pipelining Begin a stage of the next process as soon as the stage of the previous process is finished Third car in soap, second car in wash, first car in dry Time to complete the wash is? Throughput is = 2

Pipelining for instruction execution Each Instruction has several sub-steps Each instruction has 5 or 6 stages IF, ID, EX, MEM, WB Multiple cycles per instruction Typical cycle time (1 GHz Processor 1 nsec) Average instruction can take 3 to 5 cycles Sequential execution of one instruction after another Too slow Alternatives? 3

Multicycle Multicycle Seq implementation: Cycle: Instr: 1 2 3 4 5 6 7 8 9 10 11 12 13 i IF ID EX M WB i+1 IF ID EX i+2 IF ID EX M i+3 IF i+4 4

Laundry example (Wash, dry, fold, store) T a s k O r d e r A 20 7 8 6 PM 9 Time 30 40 40 40 720 8 30 40 40 20 40 60 7 8 30 40 40 B 25 C D 5 30 D 10 35 5 15

Ideal Pipelining Cycle: 1 2 3 4 5 6 7 8 9 10 11 12 13 Instr: i F D X M W i+1 F D X M W i+2 F D X M W i+3 F D X M W i+4 F D X M W Ideal throughput: 1 instruction/cycle 6

Pipeline hazards Car wash example One stage (soap) may take longer (additional rust proof) Car behind (soak stage) need to idle Pipeline stall Clothes wash example Resource may not be available Washer-dryer combo Resource shared and in use Dried or washed clothes not emptied Cycle taking longer Pipeline stall 7

Pipelining hazards in CPU Hazards: A stage of the instruction cannot execute in the next clock cycle Three types of hazards Structural hazards Two different instructions use the same hardware Resource conflict (e.g., One memory port) Data hazards Two different instructions have a dependency on data Two instructions use the same register/memory Control hazards One instruction s execution affects which instruction is next E.g, jmp Instruction that affects PC (%eip) 8

Structural Hazard MOV 100(%ebp), %eax Instruction Order MOV 200(%ebp), %ebx MOV 300(%ebp), %ecx MOV 400(%ebp), %edx Cant read memory twice in the same cycle 9

Dealing with Structural hazards Stall Block until previous operation completes Decreases throughput or Ins/ cycle Replicate resource Separate memory banks Dual port memory Can read different addresses in the same cycle Need H/W, cost Pipeline the resource Can be used for multi-cycle resource Idle M1 M2 M3 10

Pipeline Data Hazards Data hazards an instruction uses the result of a previous instruction ADD %ecx, %eax or MOV %eax, 100(%ebp) ADD %eax, %edx MOV 100(%ebp), %ebx 11

Data Hazards (RAW) Cycle Instruction Read from %eax Here Write Data to %eax Here ADD %ebx, %eax ADD %eax, %ebx 12

Dealing with data hazards Stalling Hardware detects RWA conflicts and stalls Forwarding connect new value directly to next stage Make data available internally before it is stored 13

Data Hazard -Stalling add %ebx, %eax Instruction Order stall stall stall add %eax, %edx 14

Data Hazards - Forwarding Key idea: connect new value directly to next stage Input to next stage is the new result 0 1 2 3 4 5 6 7 8 add %ebx %eax ID IF ID EX MEM new value of %eax W %eax %ebx sub %eax IF EX MEM R %eax W" %ebx Problem: what about move from memory instructions? 15

Data Hazards - Forwarding Data to be loaded in %eax available only after memory read of location 100 + (%ebp) ID IF ID EX MEM W %eax mov 100(%ebp), %eax STALL new value of %eax sub %eax, %ebx, R IF EX MEM WB %ebx 16

Data hazards; Compiler optimization With loads, data available only after M stage; requires stalls Compiler can reorder instructions Execute instructions out of order to fill in for pipeline stalls mov -8(%ebp), %eax mov -12(%ebp), %edx add %edx, %eax mov %eax, 4(%ebp) mov -16(%ebp) %ecx mov -20(%ebp), %eax sub %ecx, %eax mov %eax, 8(%ebp) mov -8(%ebp), %eax mov -12(%ebp), %edx mov -16(%ebp), %ecx add %edx, %eax mov -20(%ebp), %edx mov %eax, 4(%ebp) sub %edx, %eax mov %eax, 8(%ebp) 17

Other Types of Data Hazards WAW (write after write) variable-length pipeline EX can take 3 cycles later instruction must write after earlier instruction writes WAR (write after read) Variable length pipelines Instructions with late read or memory access later instruction must write after earlier instruction reads F D X 2 3 M W F D X M W F D X 2 3 4 M 2 W F D X M W 18

Pipeline Data Hazards Control hazards the location of an instruction depends on a previous instruction JMP LOOP LOOP: ADD %edx, %eax We cant fetch the next instruction until we know the branch address Branch taken PCß Immediate Branch not taken PC ß PC + 4 19

Control Hazards: Need to know which to fetch Cycle F D W Instruction F D Destination Available Here Need Destination Here W JMP xx... XX: ADD... 20

Control Hazards: Assume branch not taken Cycle F D W JMP Instruction Destination Available Here F D W SUB Need Destination Here F D W ADD Execute SUB, if wrong flush pipeline Flush instruction in F stage introduce NOP JMP xx SUB XX: ADD... 21

Control Hazards: In Some CPUs, address available after EX stage Cycle F D W JMP Destination Available Here Instruction F Need Destination Here D F D W SUB F D W XOR ADD W Execute SUB, and XOR; if wrong flush pipeline Flush instruction in F stage and D stage introduce NOP JMP xx SUB XOR XX: ADD... 22

Summary Pipelining principles Hazards Hazard prevention 23