Chapter 4 The Processor Part 2

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

Pipelining I (1) Fall 2005 Lecture 18: Pipelining I.
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.
Pipelined Datapath and Control (Lecture #13) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer.
Mary Jane Irwin ( ) [Adapted from Computer Organization and Design,
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
©UCB CS 162 Computer Architecture Lecture 3: Pipelining Contd. Instructor: L.N. Bhuyan
Computer ArchitectureFall 2007 © October 22nd, 2007 Majd F. Sakr CS-447– Computer Architecture.
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.
Computer ArchitectureFall 2008 © October 6th, 2008 Majd F. Sakr CS-447– Computer Architecture.
Introduction to Pipelining Rabi Mahapatra Adapted from the lecture notes of Dr. John Kubiatowicz (UC Berkeley)
B 0000 Pipelining ENGR xD52 Eric VanWyk Fall
Chapter 4 CSF 2009 The processor: Pipelining. Performance Issues Longest delay determines clock period – Critical path: load instruction – Instruction.
Chapter 4 The Processor CprE 381 Computer Organization and Assembly Level Programming, Fall 2012 Revised from original slides provided by MKP.
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.
Computer Organization CS224 Chapter 4 Part b The Processor Spring 2010 With thanks to M.J. Irwin, T. Fountain, D. Patterson, and J. Hennessy for some lecture.
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.
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
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.
CSE431 L06 Basic MIPS Pipelining.1Irwin, PSU, 2005 MIPS Pipeline Datapath Modifications  What do we need to add/modify in our MIPS datapath? l State registers.
Lecture 9. MIPS Processor Design – Pipelined Processor Design #1 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System.
CPE432 Chapter 4B.1Dr. W. Abu-Sufah, UJ Chapter 4B: The Processor, Part B-1 Read Sections 4.7 Adapted from Slides by Prof. Mary Jane Irwin, Penn State.
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.
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
Lecture 18: Pipelining I.
Computer Organization
Pipelines An overview of pipelining
Pipelining concepts, datapath and hazards
Morgan Kaufmann Publishers
Performance of Single-cycle Design
CMSC 611: Advanced Computer Architecture
Morgan Kaufmann Publishers The Processor
Single Clock Datapath With Control
ECE232: Hardware Organization and Design
ECS 154B Computer Architecture II Spring 2009
ECE232: Hardware Organization and Design
Review: MIPS Pipeline Data and Control Paths
Morgan Kaufmann Publishers The Processor
Morgan Kaufmann Publishers The Processor
Single-cycle datapath, slightly rearranged
Morgan Kaufmann Publishers Enhancing Performance with Pipelining
A pipeline diagram Clock cycle lw $t0, 4($sp) IF ID
Lecturer: Alan Christopher
Serial versus Pipelined Execution
CS-447– Computer Architecture Lecture 14 Pipelining (2)
Systems Architecture II
The Processor Lecture 3.4: Pipelining Datapath and Control
An Introduction to pipelining
Pipelining Appendix A and Chapter 3.
Morgan Kaufmann Publishers The Processor
Introduction to Computer Organization and Architecture
A relevant question Assuming you’ve got: One washer (takes 30 minutes)
The Processor: Datapath & Control.
Recall: Performance Evaluation
Pipelined datapath and control
Presentation transcript:

Chapter 4 The Processor Part 2 박능수

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

Overview of Pipeline Pipelining provides a method for executing multiple instructions at the same time. Laundry Example Ann, Brian, Cathy, Dave each have one load of clothes to wash, dry, and fold Washer takes 30 minutes Dryer takes 40 minutes “Folder” takes 20 minutes A B C D

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 Sequential laundry takes 6 hours for 4 loads If they learned pipelining, how long would laundry take?

Pipelined Laundry: Start work ASAP 6 PM 7 8 9 10 11 Midnight Time 30 40 20 T a s k O r d e A B C D Pipelined laundry takes 3.5 hours for 4 loads

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 reduces speedup Stall for Dependences 6 PM 7 8 9 Time 30 40 20 T a s k O r d e A B C D

Pipelining Lessons Five stages, one step per stage IF: Instruction fetch from memory ID: Instruction decode & register read EX: Execute operation or calculate address MEM: Access memory operand WB: Write result back to register

One Way to Break up the Datapath Operations Ifetch: Instruction Fetch Fetch the instruction from the Instruction Memory ID(ID/Reg): Instruction Decode and Registers Fetch Exec: Calculate the memory address Mem: Read the data from the Data Memory Wr: Write the data back to the register file Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Load Ifetch ID/Reg Exec Mem Wr

Pipelined Execution On a processor multiple instructions are in various stages at the same time. Assume each instruction takes five cycles Time IFetch ID Exec Mem WB IFetch ID Exec Mem WB IFetch ID Exec Mem WB IFetch ID Exec Mem WB IFetch ID Exec Mem WB Program Flow IFetch ID Exec Mem WB

Single Cycle, Multiple Cycle, vs. Pipeline Clk Single Cycle Implementation: Load Store Cycle 1 Cycle 2 Waste Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Cycle 9 Cycle 10 Clk Multiple Cycle Implementation: Ifetch ID Exec Mem Wr Load Store R-type Load Ifetch ID Exec Mem Wr Pipeline Implementation: Store R-type

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 800ps sw 700ps R-format 600ps beq 500ps

Ideal speedup is number of stages in the pipeline. Do we achieve this? Pipelining Improve performance by increasing instruction throughput Ideal speedup is number of stages in the pipeline. Do we achieve this?

If all stages are balanced i.e., all take the same time 𝑇𝑖𝑚𝑒 𝑏𝑒𝑡𝑤𝑒𝑒𝑛 𝑖𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛𝑠 𝑝𝑖𝑝𝑒𝑙𝑖𝑛𝑒𝑑 = 𝑇𝑖𝑚𝑒 𝑏𝑒𝑡𝑤𝑒𝑒𝑛 𝑖𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛𝑠 𝑛𝑜𝑛𝑝𝑖𝑝𝑒𝑙𝑖𝑛𝑒𝑑 𝑁𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑠𝑡𝑎𝑔𝑒𝑠 If not balanced, speedup is less Speedup due to increased throughput Latency (time for each instruction) does not decrease

Why Pipeline? Suppose Single Cycle Machine Multicycle Machine 100 instructions are executed The single cycle machine has a cycle time of 45 ns The multicycle and pipeline machines have cycle times of 10 ns The multicycle machine has a CPI of 3.6 Single Cycle Machine 45 ns/cycle x 1 CPI x 100 inst = 4500 ns Multicycle Machine 10 ns/cycle x 3.6 CPI x 100 inst = 3600 ns Ideal pipelined machine 10 ns/cycle x (1 CPI x 100 inst + 4 cycle drain) = 1040 ns Ideal pipelined vs. single cycle speedup 4500 ns / 1040 ns = 4.33 What has not yet been considered?

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 3rd stage, access memory in 4th stage Alignment of memory operands Memory access takes only one cycle

MIPS Pipelined Datapath MEM Right-to-left flow leads to hazards WB

Pipeline registers Need registers between stages To hold information produced in previous cycle

Morgan Kaufmann Publishers 10 November, 2018 Pipeline Operation Cycle-by-cycle flow of instructions through the pipelined datapath “Single-clock-cycle” pipeline diagram Shows pipeline usage in a single cycle Highlight resources used c.f. “multi-clock-cycle” diagram Graph of operation over time We’ll look at “single-clock-cycle” diagrams for load & store Chapter 4 — The Processor

Morgan Kaufmann Publishers 10 November, 2018 IF for Load, Store, … Chapter 4 — The Processor

Morgan Kaufmann Publishers 10 November, 2018 ID for Load, Store, … Chapter 4 — The Processor

Morgan Kaufmann Publishers 10 November, 2018 EX for Load Chapter 4 — The Processor

Morgan Kaufmann Publishers 10 November, 2018 MEM for Load Chapter 4 — The Processor

Morgan Kaufmann Publishers 10 November, 2018 WB for Load Wrong register number Chapter 4 — The Processor

Corrected Datapath for Load Morgan Kaufmann Publishers 10 November, 2018 Corrected Datapath for Load Chapter 4 — The Processor

Morgan Kaufmann Publishers 10 November, 2018 EX for Store Chapter 4 — The Processor

Morgan Kaufmann Publishers 10 November, 2018 MEM for Store Chapter 4 — The Processor

Morgan Kaufmann Publishers 10 November, 2018 WB for Store Chapter 4 — The Processor

Single-Cycle Pipeline Diagram Morgan Kaufmann Publishers 10 November, 2018 Single-Cycle Pipeline Diagram State of pipeline in a given cycle Chapter 4 — The Processor

Multi-Cycle Pipeline Diagram Morgan Kaufmann Publishers 10 November, 2018 Multi-Cycle Pipeline Diagram Form showing resource usage Chapter 4 — The Processor

Multi-Cycle Pipeline Diagram Morgan Kaufmann Publishers 10 November, 2018 Multi-Cycle Pipeline Diagram Traditional form Chapter 4 — The Processor

Graphically Representing Pipelines Can help with answering questions like: how many cycles does it take to execute this code? what is the ALU doing during cycle 4? use this representation to help understand datapaths

Why Pipeline? For Performance! Time (clock cycles) Once the pipeline is full, one instruction is completed every cycle, so CPI = 1 ALU IM Reg DM Inst 0 I n s t r. O r d e ALU IM Reg DM Inst 1 ALU IM Reg DM Inst 2 ALU IM Reg DM Inst 3 ALU IM Reg DM Inst 4 Time to fill the pipeline

MIPS Pipeline Datapath Additions/Mods State registers between each pipeline stage to isolate them IF:IFetch ID:Dec EX:Execute MEM: MemAccess WB: WriteBack Read Address Instruction Memory Add PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr Register File Data 1 Data 2 16 32 ALU Shift left 2 Data IF/ID Sign Extend ID/EX EX/MEM MEM/WB Any info that is needed in a later pipe stage must be passed to that stage via a pipeline register (e.g., need to preserve the destination register address in the pipeline state registers) Note two exceptions to right-to-left flow WB that writes the result back into the register file in the middle of the datapath Selection of the next value of the PC, one input comes from the calculated branch address from the MEM stage Only later instructions in the pipeline can be influenced by these two REVERSE data movements. The first one (WB to ID) leads to data hazards. The second one (MEM to IF) leads to control hazards. All instructions must update some state in the processor – the register file, the memory, or the PC – so separate pipeline registers are redundant to the state that is updated (not needed). PC can be thought of as a pipeline register: the one that feeds the IF stage of the pipeline. Unlike all of the other pipeline registers, the PC is part of the visible architecture state – its content must be saved when an exception occurs (the contents of the other pipe registers are discarded). System Clock

Pipelined Control (Simplified) Morgan Kaufmann Publishers 10 November, 2018 Pipelined Control (Simplified) Chapter 4 — The Processor

Pipeline control We have 5 stages. What needs to be controlled in each stage? Instruction Fetch and PC Increment Instruction Decode / Register Fetch Execution Memory Stage Write Back How would control be handled in an automobile plant? a fancy control center telling everyone what to do? should we use a finite state machine?

Morgan Kaufmann Publishers 10 November, 2018 Pipelined Control Control signals derived from instruction Pass control signals along just like the data implementation Chapter 4 — The Processor

Morgan Kaufmann Publishers 10 November, 2018 Pipelined Control Chapter 4 — The Processor

MIPS Pipeline Data and Control Paths 1 PCSrc ID/EX EX/MEM Control IF/ID Add MEM/WB Branch Add 4 RegWrite Shift left 2 Instruction Memory Read Addr 1 Data Memory Register File Read Data 1 Read Addr 2 MemtoReg Read Address ALUSrc PC Read Data Address 1 Write Addr ALU Read Data 2 Write Data Write Data 1 ALU cntrl How many bits wide is each pipeline register? PC = 32 bits IF/ID = 64 bits ID/EX = 9 + 32x4 + 10 = 147 EX/MEM = 5 + 1 + 32x3 + 5 = 107 MEM/WB = 2 + 32x2 + 5 = 71 MemWrite MemRead Sign Extend 16 32 ALUOp 1 RegDst