CMSC 611: Advanced Computer Architecture Pipelining Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted.

Slides:



Advertisements
Similar presentations
PipelineCSCE430/830 Pipeline: Introduction CSCE430/830 Computer Architecture Lecturer: Prof. Hong Jiang Courtesy of Prof. Yifeng Zhu, U of Maine Fall,
Advertisements

CMSC 611: Advanced Computer Architecture Pipelining Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted.
1 IKI20210 Pengantar Organisasi Komputer Kuliah no. 25: Pipeline 10 Januari 2003 Bobby Nazief Johny Moningka
CMSC 611: Advanced Computer Architecture Pipelining Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted.
Review: Pipelining. Pipelining Laundry Example Ann, Brian, Cathy, Dave each have one load of clothes to wash, dry, and fold Washer takes 30 minutes Dryer.
Pipelining I (1) Fall 2005 Lecture 18: Pipelining I.
Pipelining Hwanmo Sung CS147 Presentation Professor Sin-Min Lee.
Computer Architecture
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.
Mary Jane Irwin ( ) [Adapted from Computer Organization and Design,
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
Computer ArchitectureFall 2007 © October 24nd, 2007 Majd F. Sakr CS-447– Computer Architecture.
Computer ArchitectureFall 2007 © October 22nd, 2007 Majd F. Sakr CS-447– Computer Architecture.
DLX Instruction Format
1 CSE SUNY New Paltz Chapter Six Enhancing Performance with Pipelining.
Pipelining Datapath Adapted from the lecture notes of Dr. John Kubiatowicz (UC Berkeley) and Hank Walker (TAMU)
1 COMP 206: Computer Architecture and Implementation Montek Singh Mon., Sep 9, 2002 Topic: Pipelining Basics.
1 Atanasoff–Berry Computer, built by Professor John Vincent Atanasoff and grad student Clifford Berry in the basement of the physics building at Iowa State.
Pipelining - II Adapted from CS 152C (UC Berkeley) lectures notes of Spring 2002.
Appendix A Pipelining: Basic and Intermediate Concepts
Computer ArchitectureFall 2008 © October 6th, 2008 Majd F. Sakr CS-447– Computer Architecture.
Pipelining - II Rabi Mahapatra Adapted from CS 152C (UC Berkeley) lectures notes of Spring 2002.
Spring W :332:331 Computer Architecture and Assembly Language Spring 2005 Week 11 Introduction to Pipelined Datapath [Adapted from Dave Patterson’s.
Pipelining Basics Assembly line concept An instruction is executed in multiple steps Multiple instructions overlap in execution A step in a pipeline is.
Introduction to Pipelining Rabi Mahapatra Adapted from the lecture notes of Dr. John Kubiatowicz (UC Berkeley)
CS1104: Computer Organisation School of Computing National University of Singapore.
CSC 4250 Computer Architectures September 15, 2006 Appendix A. Pipelining.
COMP381 by M. Hamdi 1 Pipelining Improving Processor Performance with Pipelining.
Pipelining. 10/19/ Outline 5 stage pipelining Structural and Data Hazards Forwarding Branch Schemes Exceptions and Interrupts Conclusion.
B 0000 Pipelining ENGR xD52 Eric VanWyk Fall
EEL5708 Lotzi Bölöni EEL 5708 High Performance Computer Architecture Pipelining.
Appendix A Pipelining: Basic and Intermediate Concept
Pipelining (I). Pipelining Example  Laundry Example  Four students have one load of clothes each to wash, dry, fold, and put away  Washer takes 30.
Analogy: Gotta Do Laundry
CSE 340 Computer Architecture Summer 2014 Basic MIPS Pipelining Review.
CS.305 Computer Architecture Enhancing Performance with Pipelining Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from.
1 Designing a Pipelined Processor In this Chapter, we will study 1. Pipelined datapath 2. Pipelined control 3. Data Hazards 4. Forwarding 5. Branch Hazards.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Electrical and Computer Engineering University of Cyprus LAB3: IMPROVING MIPS PERFORMANCE WITH PIPELINING.
1 Pipelining Part I CS What is Pipelining? Like an Automobile Assembly Line for Instructions –Each step does a little job of processing the instruction.
ECE 232 L18.Pipeline.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 18 Pipelining.
CECS 440 Pipelining.1(c) 2014 – R. W. Allison [slides adapted from D. Patterson slides with additional credits to M.J. Irwin]

Cs 152 L1 3.1 DAP Fa97,  U.CB Pipelining Lessons °Pipelining doesn’t help latency of single task, it helps throughput of entire workload °Multiple tasks.
Chap 6.1 Computer Architecture Chapter 6 Enhancing Performance with Pipelining.
CSIE30300 Computer Architecture Unit 04: Basic MIPS Pipelining Hsin-Chou Chi [Adapted from material by and
Oct. 18, 2000Machine Organization1 Machine Organization (CS 570) Lecture 4: Pipelining * Jeremy R. Johnson Wed. Oct. 18, 2000 *This lecture was derived.
Pipelining Example Laundry Example: Three Stages
Pipelining CS365 Lecture 9. D. Barbara Pipeline CS465 2 Outline  Today’s topic  Pipelining is an implementation technique in which multiple instructions.
CS252/Patterson Lec 1.1 1/17/01 معماري کامپيوتر - درس نهم pipeline برگرفته از درس : Prof. David A. Patterson.
EE524/CptS561 Jose G. Delgado-Frias 1 Processor Basic steps to process an instruction IFID/OFEXMEMWB Instruction Fetch Instruction Decode / Operand Fetch.
Lecture 9. MIPS Processor Design – Pipelined Processor Design #1 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System.
CMSC 611: Advanced Computer Architecture Pipelining Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Advanced Computer Architecture CS 704 Advanced Computer Architecture Lecture 10 Computer Hardware Design (Pipeline Datapath and Control Design) Prof. Dr.
Lecture 18: Pipelining I.
Pipelines An overview of pipelining
Review: Instruction Set Evolution
CMSC 611: Advanced Computer Architecture
ECE232: Hardware Organization and Design
School of Computing and Informatics Arizona State University
Chapter 3: Pipelining 순천향대학교 컴퓨터학부 이 상 정 Adapted from
Chapter 4 The Processor Part 2
CMSC 611: Advanced Computer Architecture
Lecturer: Alan Christopher
CS-447– Computer Architecture Lecture 14 Pipelining (2)
An Introduction to pipelining
Pipelining Appendix A and Chapter 3.
Recall: Performance Evaluation
Presentation transcript:

CMSC 611: Advanced Computer Architecture Pipelining Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted from Hennessy & Patterson / © 2003 Elsevier Science

Sequential Laundry Washer takes 30 min, Dryer takes 40 min, folding takes 20 min Sequential laundry takes 6 hours for 4 loads If they learned pipelining, how long would laundry take? PM Midnight Slide: Dave Patterson Time ABCD TaskOrderTaskOrder 2

Pipelining means start work as soon as possible Pipelined laundry takes 3.5 hours for 4 loads ABCD 6 PM Midnight TaskOrderTaskOrder Time Slide: Dave Patterson Pipelined Laundry 3

Pipelining Lessons Pipelining doesn’t help latency of single task, it helps throughput of entire workload Pipeline rate limited by slowest pipeline stage Multiple tasks operating simultaneously using different resources Potential speedup = Number pipe stages Unbalanced lengths of pipe stages reduces speedup Time to “fill” pipeline and time to “drain” it reduce speedup Stall for Dependencies Time 6 PM 789 Slide: Dave Patterson ABCD TaskOrderTaskOrder

optarget address bits26 bits oprsrtrdshamtfunct bits 5 bits oprsrt immediate bits16 bits5 bits MIPS Instruction Set RISC characterized by the following features that simplify implementation: –All ALU operations apply only on registers –Memory is affected only by load and store –Instructions follow very few formats and typically are of the same size 5

Single-cycle Execution Ê Figure: Dave Patterson 6

Ê Ë Í Î Multi-cycle Execution Ì Figure: Dave Patterson 7

Ê Instruction fetch cycle (IF) IR  Mem[PC]; NPC  PC + 4 Ë Instruction decode/register fetch cycle (ID) A  Regs[IR ]; B  Regs[IR ]; Imm  ((IR 16 ) 16 ##IR ) Ì Execution/effective address cycle (EX) Memory ref: ALUOutput  A + Imm; Reg-Reg ALU: ALUOutput  A func B; Reg-Imm ALU: ALUOutput  A op Imm; Branch: ALUOutput  NPC + Imm; Cond  (A op 0) Í Memory access/branch completion cycle (MEM) Memory ref: LMD  Mem[ALUOutput] or Mem(ALUOutput]  B; Branch: if (cond) PC  ALUOutput; Î Write-back cycle (WB) Reg-Reg ALU: Regs[IR ]  ALUOutput; Reg-Imm ALU: Regs[IR ]  ALUOutput; Load: Regs[IR ]  LMD; Multi-Cycle Implementation of MIPS 8

Single Cycle Cycle time long enough for longest instruction Shorter instructions waste time No overlap Clk LoadStoreWaste Cycle 1Cycle 2 Figure: Dave Patterson 9

Multiple Cycle Figure: Dave Patterson Cycle time long enough for longest stage Shorter stages waste time Shorter instructions can take fewer cycles No overlap Cycle 1 IfetchRegExecMemWr Cycle 2Cycle 3Cycle 4Cycle 5Cycle 6Cycle 7Cycle 8Cycle 9Cycle 10 IfetchRegExecMem LoadStore Ifetch R-type Clk 10

Pipeline Figure: Dave Patterson Cycle time long enough for longest stage Shorter stages waste time No additional benefit from shorter instructions Overlap instruction execution Cycle 1Cycle 2Cycle 3Cycle 4Cycle 5Cycle 6Cycle 7Cycle 8Cycle 9Cycle 10 Clk LoadIfetchRegExecMemWr IfetchRegExecMemWrStore IfetchRegExecMemWrR-type 11

Stages of Instruction Execution The load instruction is the longest All instructions follows at most the following five steps: – Ifetch: Instruction Fetch Fetch the instruction from the Instruction Memory and update PC – Reg/Dec: Registers Fetch and Instruction Decode – Exec: Calculate the memory address – Mem: Read the data from the Data Memory – WB: Write the data back to the register file Cycle 1Cycle 2Cycle 3Cycle 4Cycle 5 IfetchReg/DecExecMemWB Load Slide: Dave Patterson 12

IFetchDecExecMemWB IFetchDecExecMemWB IFetchDecExecMemWB IFetchDecExecMemWB IFetchDecExecMemWB IFetchDecExecMemWB Program Flow Time Pipelining improves performance by increasing instruction throughput Instruction Pipelining Start handling next instruction while the current instruction is in progress Feasible when different devices at different stages 13

Ideal and upper bound for speedup is number of stages in the pipeline Time between first & fourth instructions is 3  2 = 6 ns Time between first & fourth instructions is 3  8 = 24 ns Example of Instruction Pipelining 14

Pipeline Performance Pipeline increases the instruction throughput –not execution time of an individual instruction An individual instruction can be slower: –Additional pipeline control –Imbalance among pipeline stages Suppose we execute 100 instructions: – Single Cycle Machine 45 ns/cycle x 1 CPI x 100 inst = 4500 ns – Multi-cycle Machine 10 ns/cycle x 4.2 CPI (due to inst mix) x 100 inst = 4200 ns – Ideal 5 stages pipelined machine 10 ns/cycle x (1 CPI x 100 inst + 4 cycle drain) = 1040 ns Lose performance due to fill and drain 15

Data Stationary Pipeline Datapath Every stage must be completed in one clock cycle to avoid stalls Values must be latched to ensure correct execution of instructions The PC multiplexer has moved to the IF stage to prevent two instructions from updating the PC simultaneously (in case of branch instruction) 16

Pipeline Stage Interface 17

Pipeline Hazards Cases that affect instruction execution semantics and thus need to be detected and corrected Hazards types –Structural hazard: attempt to use a resource two different ways at same time Single memory for instruction and data –Data hazard: attempt to use item before it is ready Instruction depends on result of prior instruction still in the pipeline –Control hazard: attempt to make a decision before condition is evaluated branch instructions Hazards can always be resolved by waiting 18

Visualizing Pipelining I n s t r. O r d e r Time (clock cycles) Reg ALU DMemIfetch Reg ALU DMemIfetch Reg ALU DMemIfetch Reg ALU DMemIfetch Reg Cycle 1Cycle 2Cycle 3Cycle 4Cycle 6Cycle 7Cycle 5 Slide: David Culler 19

Example: One Memory Port/Structural Hazard I n s t r. O r d e r Time (clock cycles) Load Instr 1 Instr 2 Instr 3 Instr 4 Reg ALU DMem Ifetch Reg ALU DMemIfetch Reg ALU DMemIfetch Reg ALU DMem Ifetch Reg Cycle 1Cycle 2Cycle 3Cycle 4Cycle 6Cycle 7Cycle 5 DMem Structural Hazard Slide: David Culler 20

Resolving Structural Hazards 1.Wait –Must detect the hazard Easier with uniform ISA –Must have mechanism to stall Easier with uniform pipeline organization 2.Throw more hardware at the problem –Use instruction & data cache rather than direct access to memory 21

I n s t r. O r d e r Time (clock cycles) Load Instr 1 Instr 2 Stall Instr 3 Reg ALU DMem Ifetch Reg ALU DMemIfetch Reg ALU DMemIfetch Reg Cycle 1Cycle 2Cycle 3Cycle 4Cycle 6Cycle 7Cycle 5 Reg ALU DMemIfetch Reg Bubble Detecting and Resolving Structural Hazard Slide: David Culler 22

Stalls & Pipeline Performance Assuming all pipeline stages are balanced 23

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 Reg ALU DMemIfetch Reg Data Hazards Time (clock cycles) IFID/RF EX MEM WB Reg ALU DMemIfetch Reg ALU DMemIfetch Reg ALU DMemIfetch Reg Slide: David Culler Reg ALU DMemIfetch Reg 24

I: add r1,r2,r3 J: sub r4,r1,r3 Three Generic Data Hazards Read After Write (RAW) Instr J tries to read operand before Instr I writes it Caused by a “Data Dependence” (in compiler nomenclature). This hazard results from an actual need for communication. Slide: David Culler 25

Write After Read (WAR) Instr J writes operand before Instr I reads it Called an “anti-dependence” in compilers. –This results from reuse of the name “r1”. Can’t happen in MIPS 5 stage pipeline because: – All instructions take 5 stages, and – Reads are always in stage 2, and – Writes are always in stage 5 I: sub r4,r1,r3 J: add r1,r2,r3 K: mul r6,r1,r7 Three Generic Data Hazards Slide: David Culler 26

Write After Write (WAW) Instr J writes operand before Instr I writes it. Called an “output dependence” in compilers –This also results from the reuse of name “r1”. Can’t happen in MIPS 5 stage pipeline: – All instructions take 5 stages, and – Writes are always in stage 5 Do see WAR and WAW in more complicated pipes I: mul r1,r4,r3 J: add r1,r2,r3 K: sub r6,r1,r7 Three Generic Data Hazards Slide: David Culler 27