Pipelining. CSC Friday, November 6, 2015

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

Full Datapath. Chapter 4 The Processor 2

Processor (II) - pipelining. Hwansoo Han

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

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

Chapter 4. Instruction Execution. Introduction. CPU Overview. Multiplexers. Chapter 4 The Processor 1. The Processor.

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

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

Chapter 4. The Processor

LECTURE 3: THE PROCESSOR

Chapter 4. The Processor

ECE260: Fundamentals of Computer Engineering

COMPUTER ORGANIZATION AND DESIGN

Full Datapath. Chapter 4 The Processor 2

COMPUTER ORGANIZATION AND DESI

CSEE 3827: Fundamentals of Computer Systems

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

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

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

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

1 Hazards COMP2611 Fall 2015 Pipelined Processor

4. The Processor Computer Architecture COMP SCI 2GA3 / SFWR ENG 2GA3. Emil Sekerinski, McMaster University, Fall Term 2015/16

COMPUTER ORGANIZATION AND DESIGN

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

ECE 154A Introduction to. Fall 2012

Chapter 4 (Part II) Sequential Laundry

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

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

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

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

COMPUTER ORGANIZATION AND DESIGN

Chapter 4. The Processor

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

Chapter 4. The Processor

EIE/ENE 334 Microprocessors

Chapter 4. The Processor

CSCI 402: Computer Architectures. Fengguang Song Department of Computer & Information Science IUPUI. Today s Content

COMP2611: Computer Organization. The Pipelined Processor

Thomas Polzer Institut für Technische Informatik

COMPUTER ORGANIZATION AND DESIGN. The Hardware/Software Interface. Chapter 4. The Processor: A Based on P&H

Chapter 4. The Processor

4.1 Introduction 4.3 Datapath 4.4 Control 4.5 Pipeline overview 4.6 Pipeline control * 4.7 Data hazard & forwarding * 4.

Full Datapath. CSCI 402: Computer Architectures. The Processor (2) 3/21/19. Fengguang Song Department of Computer & Information Science IUPUI

5 th Edition. The Processor We will examine two MIPS implementations A simplified version A more realistic pipelined version

CS 61C: Great Ideas in Computer Architecture. Lecture 13: Pipelining. Krste Asanović & Randy Katz

The Processor: Instruction-Level Parallelism

CENG 3531 Computer Architecture Spring a. T / F A processor can have different CPIs for different programs.

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

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

Computer Architecture Review. Jo, Heeseung

Advanced d Instruction Level Parallelism. Computer Systems Laboratory Sungkyunkwan University

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

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

Processor (IV) - advanced ILP. Hwansoo Han

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

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

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

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

Instr. execution impl. view

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

Pipelined Processor Design

ELE 655 Microprocessor System Design

Pipelined Processor Design

COSC 6385 Computer Architecture - Pipelining

ECE154A Introduction to Computer Architecture. Homework 4 solution

Chapter 4. The Processor

ECEC 355: Pipelining

Real Processors. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University

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

The Processor: Datapath and Control. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Processor (I) - datapath & control. Hwansoo Han

Computer Organization and Structure

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

Lecture 15: Pipelining. Spring 2018 Jason Tang

Final Exam Fall 2007

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

Pipeline Review. Review

Advanced Instruction-Level Parallelism

Lecture 2: Processor and Pipelining 1

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

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

Basic Pipelining Concepts

CS 230 Practice Final Exam & Actual Take-home Question. Part I: Assembly and Machine Languages (22 pts)

Instruction Pipelining

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

Chapter 4. The Processor Designing the datapath

Instruction Pipelining

Chapter 4. The Processor. Jiang Jiang

Pipelined Datapath. Reading. Sections Practice Problems: 1, 3, 8, 12 (2) Lecture notes from MKP, H. H. Lee and S.

CS 2506 Computer Organization II Test 2

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

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

Pipelining and Exploiting Instruction-Level Parallelism (ILP)

Instruction Level Parallelism. Appendix C and Chapter 3, HP5e

Chapter 4. The Processor. Instruction count Determined by ISA and compiler. We will examine two MIPS implementations

Static, multiple-issue (superscaler) pipelines

CSE Lecture 13/14 In Class Handout For all of these problems: HAS NOT CANNOT Add Add Add must wait until $5 written by previous add;

Photo David Wright STEVEN R. BAGLEY PIPELINES AND ILP

These actions may use different parts of the CPU. Pipelining is when the parts run simultaneously on different instructions.

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

Transcription:

Pipelining CSC 211.01 Friday, November 6, 2015

Performance Issues Longest delay determines clock period Critical path: load instruction Instruction memory register file ALU data memory register file Not feasible to vary period for different instructions Violates design principle Making the common case fast We will improve performance by pipelining Chapter 4 The Processor 30

Pipelining Analogy 4.5 An Overview of Pipelining Chapter 4 The Processor 31

MIPS Pipeline Five stages, one step per stage 1. IF: Instruction fetch from memory 2. ID: Instruction decode & register read 3. EX: Execute operation or calculate address 4. MEM: Access memory operand 5. WB: Write result back to register Chapter 4 The Processor 32

Pipeline Performance Assume time for stages is 100ps for register read or write 200ps for other stages Compare pipelined datapath with single-cycle datapath Instr Instr fetch Register read ALU op Memory access Register write Total time lw sw R-format beq Chapter 4 The Processor 33

Pipeline Performance Assume time for stages is 100ps for register read or write 200ps for other stages Compare pipelined datapath with single-cycle datapath Instr Instr fetch Register read ALU op Memory access Register write Total time lw 200ps 100 ps 200ps 200ps 100 ps 800ps sw R-format beq Chapter 4 The Processor 33

Pipeline Performance Assume time for stages is 100ps for register read or write 200ps for other stages Compare pipelined datapath with single-cycle datapath Instr Instr fetch Register read ALU op Memory access Register write Total time lw 200ps 100 ps 200ps 200ps 100 ps 800ps sw 200ps 100 ps 200ps 200ps 700ps R-format beq Chapter 4 The Processor 33

Pipeline Performance Assume time for stages is 100ps for register read or write 200ps for other stages Compare pipelined datapath with single-cycle datapath Instr Instr fetch Register read ALU op Memory access Register write Total time lw 200ps 100 ps 200ps 200ps 100 ps 800ps sw 200ps 100 ps 200ps 200ps 700ps R-format 200ps 100 ps 200ps 100 ps 600ps beq Chapter 4 The Processor 33

Pipeline Performance Assume time for stages is 100ps for register read or write 200ps for other stages Compare pipelined datapath with single-cycle datapath Instr Instr fetch Register read ALU op Memory access Register write Total time lw 200ps 100 ps 200ps 200ps 100 ps 800ps sw 200ps 100 ps 200ps 200ps 700ps R-format 200ps 100 ps 200ps 100 ps 600ps beq 200ps 100 ps 200ps 500ps Chapter 4 The Processor 33

Pipeline Performance Single-cycle (T c = 800ps) Pipelined (T c = 200ps) Chapter 4 The Processor 34

Pipelining and ISA Design MIPS ISA designed for pipelining All instructions are 32-bits Easier to fetch and decode in one cycle c.f. x86: 1- to 17-byte instructions Few and regular instruction formats Can decode and read registers in one step Load/store addressing Can calculate address in 3 rd stage, access memory in 4 th stage Alignment of memory operands Memory access takes only one cycle Chapter 4 The Processor 36

Hazards Situations that prevent starting the next instruction in the next cycle Structure hazards A required resource is busy Data hazard Need to wait for previous instruction to complete its data read/write Control hazard Deciding on control action depends on previous instruction Chapter 4 The Processor 37

Structure Hazards Conflict for use of a resource In MIPS pipeline with a single memory Load/store requires data access Instruction fetch would have to stall for that cycle Would cause a pipeline bubble Hence, pipelined datapaths require separate instruction/data memories Or separate instruction/data caches Chapter 4 The Processor 38

Data Hazards An instruction depends on completion of data access by a previous instruction add $s0, $t0, $t1 sub $t2, $s0, $t3 Chapter 4 The Processor 39

Forwarding (aka Bypassing) Use result when it is computed Don t wait for it to be stored in a register Requires extra connections in the datapath Chapter 4 The Processor 40

Load-Use Data Hazard Can t always avoid stalls by forwarding If value not computed when needed Can t forward backward in time! Chapter 4 The Processor 41

Code Scheduling to Avoid Stalls Reorder code to avoid use of load result in the next instruction C code for A = B + E; C = B + F; stall stall lw lw $t1, 0($t0) $t2, 4($t0) add $t3, $t1, $t2 sw $t3, 12($t0) lw $t4, 8($t0) add $t5, $t1, $t4 sw $t5, 16($t0) 13 cycles lw $t1, 0($t0) lw $t2, 4($t0) lw $t4, 8($t0) add $t3, $t1, $t2 sw $t3, 12($t0) add $t5, $t1, $t4 sw $t5, 16($t0) 11 cycles Chapter 4 The Processor 42

Control Hazards Branch determines flow of control Fetching next instruction depends on branch outcome Pipeline can t always fetch correct instruction Still working on ID stage of branch In MIPS pipeline Need to compare registers and compute target early in the pipeline Add hardware to do it in ID stage Chapter 4 The Processor 43

Stall on Branch Wait until branch outcome determined before fetching next instruction Chapter 4 The Processor 44

Branch Prediction Longer pipelines can t readily determine branch outcome early Stall penalty becomes unacceptable Predict outcome of branch Only stall if prediction is wrong In MIPS pipeline Can predict branches not taken Fetch instruction after branch, with no delay Chapter 4 The Processor 45

MIPS with Predict Not Taken Prediction correct Prediction incorrect Chapter 4 The Processor 46

More-Realistic Branch Prediction Static branch prediction Based on typical branch behavior Example: loop and if-statement branches Predict backward branches taken Predict forward branches not taken Dynamic branch prediction Hardware measures actual branch behavior e.g., record recent history of each branch Assume future behavior will continue the trend When wrong, stall while re-fetching, and update history Chapter 4 The Processor 47

Pipeline Summary The BIG Picture Pipelining improves performance by increasing instruction throughput Executes multiple instructions in parallel Each instruction has the same latency Subject to hazards Structure, data, control Instruction set design affects complexity of pipeline implementation Chapter 4 The Processor 48