CMSC 611: Advanced Computer Architecture

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.
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 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.
Appendix A Pipelining: Basic and Intermediate Concepts
Computer ArchitectureFall 2008 © October 6th, 2008 Majd F. Sakr CS-447– Computer Architecture.
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.
B 0000 Pipelining ENGR xD52 Eric VanWyk Fall
EEL5708 Lotzi Bölöni EEL 5708 High Performance Computer Architecture Pipelining.
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.

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
CMSC 611: Advanced Computer Architecture Pipelining Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted.
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.
Advanced Computer Architecture CS 704 Advanced Computer Architecture Lecture 10 Computer Hardware Design (Pipeline Datapath and Control Design) Prof. Dr.
Lecture 18: Pipelining I.
Computer Organization
Pipelines An overview of pipelining
Review: Instruction Set Evolution
ECE232: Hardware Organization and Design
Pipelining Lessons 6 PM T a s k O r d e B C D A 30
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
Serial versus Pipelined Execution
CS-447– Computer Architecture Lecture 14 Pipelining (2)
Pipelining Lessons 6 PM T a s k O r d e B C D A 30
Pipelining Basic concept of assembly line
The Processor Lecture 3.4: Pipelining Datapath and Control
An Introduction to pipelining
Chapter 8. Pipelining.
Pipelining Basic concept of assembly line
Pipelining Basic concept of assembly line
Pipelining Appendix A and Chapter 3.
CMCS Computer Architecture Lecture 20 Pipelined Datapath and Control April 11, CMSC411.htm Mohamed.
A relevant question Assuming you’ve got: One washer (takes 30 minutes)
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 6 PM 7 8 9 10 11 Midnight 30 40 20 30 40 20 30 40 Time 30 40 20 30 40 20 30 40 20 30 40 20 T a s k O r d e A B C D 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? Slide: Dave Patterson

Pipelined Laundry 6 PM 7 8 9 10 11 Midnight 30 40 20 A B C D Time T a s k O r d e A B C D Pipelining means start work as soon as possible Pipelined laundry takes 3.5 hours for 4 loads Slide: Dave Patterson

Pipelining Lessons 6 PM 7 8 9 30 40 20 A B C D 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 30 40 20 T a s k O r d e A B C D Slide: Dave Patterson

MIPS Instruction Set RISC architecture: ALU operations only on registers Memory is affected only by load and store Instructions follow very few formats and typically are of the same size op rs rt rd shamt funct 6 11 16 21 26 31 6 bits 5 bits op rs rt immediate 16 21 26 31 6 bits 16 bits 5 bits op target address 26 31 6 bits 26 bits

Single Cycle Execution

Single Cycle Execution

Single Cycle Execution

Single Cycle Execution

Single Cycle Execution

Single Cycle Execution

Single Cycle Execution

Single Cycle Execution

Single Cycle Execution

Single Cycle Execution

Single Cycle Execution

Multi-Cycle Execution

Multi-Cycle Implementation of MIPS Instruction fetch cycle (IF) IR  Mem[PC]; NPC  PC + 4 Instruction decode/register fetch cycle (ID) A  Regs[IR6..10]; B  Regs[IR11..15]; Imm  ((IR16)16 ##IR16..31) 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[IR16..20]  ALUOutput; Reg-Imm ALU: Regs[IR11..15]  ALUOutput; Load: Regs[IR11..15]  LMD;

Single Cycle Cycle time long enough for longest instruction Clk Load Store Waste Cycle time long enough for longest instruction Shorter instructions waste time No overlap Here are the timing diagrams showing the differences between the single cycle, multiple cycle, and pipeline implementations. For example, in the pipeline implementation, we can finish executing the Load, Store, and R-type instruction sequence in seven cycles. In the multiple clock cycle implementation, however, we cannot start executing the store until Cycle 6 because we must wait for the load instruction to complete. Similarly, we cannot start the execution of the R-type instruction until the store instruction has completed its execution in Cycle 9. In the Single Cycle implementation, the cycle time is set to accommodate the longest instruction, the Load instruction. Consequently, the cycle time for the Single Cycle implementation can be five times longer than the multiple cycle implementation. But may be more importantly, since the cycle time has to be long enough for the load instruction, it is too long for the store instruction so the last part of the cycle here is wasted. +2 = 77 min. (X:57) Figure: Dave Patterson

Multiple Cycle Cycle time long enough for longest stage Clk Load Store R-type Ifetch Reg Exec Mem Wr Ifetch Reg Exec Mem Ifetch Cycle time long enough for longest stage Shorter stages waste time Shorter instructions can take fewer cycles No overlap Here are the timing diagrams showing the differences between the single cycle, multiple cycle, and pipeline implementations. For example, in the pipeline implementation, we can finish executing the Load, Store, and R-type instruction sequence in seven cycles. In the multiple clock cycle implementation, however, we cannot start executing the store until Cycle 6 because we must wait for the load instruction to complete. Similarly, we cannot start the execution of the R-type instruction until the store instruction has completed its execution in Cycle 9. In the Single Cycle implementation, the cycle time is set to accommodate the longest instruction, the Load instruction. Consequently, the cycle time for the Single Cycle implementation can be five times longer than the multiple cycle implementation. But may be more importantly, since the cycle time has to be long enough for the load instruction, it is too long for the store instruction so the last part of the cycle here is wasted. +2 = 77 min. (X:57) Figure: Dave Patterson

Stages of Instruction Execution Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Ifetch Reg/Dec Exec Mem WB Load 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 As shown here, each of these five steps will take one clock cycle to complete. And in pipeline terminology, each step is referred to as one stage of the pipeline. +1 = 8 min. (X:48) Slide: Dave Patterson

Pipeline Cycle time long enough for longest stage Clk Load Ifetch Reg Exec Mem Wr Store Ifetch Reg Exec Mem Wr R-type Ifetch Reg Exec Mem Wr Cycle time long enough for longest stage Shorter stages waste time No additional benefit from shorter instructions Overlap instruction execution Here are the timing diagrams showing the differences between the single cycle, multiple cycle, and pipeline implementations. For example, in the pipeline implementation, we can finish executing the Load, Store, and R-type instruction sequence in seven cycles. In the multiple clock cycle implementation, however, we cannot start executing the store until Cycle 6 because we must wait for the load instruction to complete. Similarly, we cannot start the execution of the R-type instruction until the store instruction has completed its execution in Cycle 9. In the Single Cycle implementation, the cycle time is set to accommodate the longest instruction, the Load instruction. Consequently, the cycle time for the Single Cycle implementation can be five times longer than the multiple cycle implementation. But may be more importantly, since the cycle time has to be long enough for the load instruction, it is too long for the store instruction so the last part of the cycle here is wasted. +2 = 77 min. (X:57) Figure: Dave Patterson

Multi-Cycle Execution

Pipeline

Instruction Pipelining Start handling next instruction while the current instruction is in progress Feasible when different devices at different stages IFetch Dec Exec Mem WB Program Flow Time Pipelining improves performance by increasing instruction throughput

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

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

Pipeline Datapath Data Stationary 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) Data Stationary

Pipeline Stage Interface

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

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

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

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

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

Stalls & Pipeline Performance Assuming all pipeline stages are balanced