Cs 61C L25 pipeline.1 Patterson Spring 99 ©UCB CS61C Introduction to Pipelining Lecture 25 April 28, 1999 Dave Patterson (http.cs.berkeley.edu/~patterson)

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

Chapter 8. Pipelining.
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.
Goal: Describe Pipelining
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.
Chapter Six 1.
Pipelining II (1) Fall 2005 Lecture 19: Pipelining II.
CS61C L29 CPU Design : Pipelining to Improve Performance II (1) Garcia, Fall 2006 © UCB Running away with it  Our #8 football team had a great effort.
CS61C L24 Review Pipeline © UC Regents 1 CS61C - Machine Structures Lecture 24 - Review Pipelined Execution November 29, 2000 David Patterson
Inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 29 – CPU Design : Pipelining to Improve Performance II Designed for the.
CS Computer Architecture 1 CS 430 – Computer Architecture Pipelined Execution - Review William J. Taffe using slides of David Patterson.
Inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 29 – CPU Design : Pipelining to Improve Performance II Cal researcher Marty.
inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 28 – CPU Design : Pipelining to Improve Performance The College Board.
CS61C L29 CPU Design : Pipelining to Improve Performance (1) Garcia, Spring 2007 © UCB Wirelessly recharge batt  Powercast & Philips have developed a.
CS61C L30 CPU Design : Pipelining to Improve Performance II (1) Garcia, Spring 2007 © UCB E-voting bill in congress!  Rep Rush Holt (D-NJ) has a bill.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania Computer Organization Pipelined Processor Design 1.
1  2004 Morgan Kaufmann Publishers Chapter Six. 2  2004 Morgan Kaufmann Publishers Pipelining The laundry analogy.
©UCB CS 162 Computer Architecture Lecture 3: Pipelining Contd. Instructor: L.N. Bhuyan
CS61C L28 CPU Design : Pipelining to Improve Performance I (1) Garcia, Fall 2006 © UCB 100 Msites!  Sometimes it’s nice to stop and reflect. The web was.
Computer ArchitectureFall 2007 © October 22nd, 2007 Majd F. Sakr CS-447– Computer Architecture.
CS61C L21 Pipeline © UC Regents 1 CS61C - Machine Structures Lecture 21 - Introduction to Pipelined Execution November 15, 2000 David Patterson
Pipelining Datapath Adapted from the lecture notes of Dr. John Kubiatowicz (UC Berkeley) and Hank Walker (TAMU)
CS61C L31 Pipelined Execution, part II (1) Garcia, Fall 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
CS430 – Computer Architecture Introduction to Pipelined Execution
CS61C L21 Pipelining I (1) Chae, Summer 2008 © UCB Albert Chae, Instructor inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #21 – Pipelining.
Scott Beamer, Instructor
Pipelining - II Adapted from CS 152C (UC Berkeley) lectures notes of Spring 2002.
CS 61C L30 Introduction to Pipelined Execution (1) Garcia, Fall 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
CS 61C L18 Pipelining I (1) A Carle, Summer 2005 © UCB inst.eecs.berkeley.edu/~cs61c/su05 CS61C : Machine Structures Lecture #18: Pipelining
1  1998 Morgan Kaufmann Publishers Chapter Six Enhancing Performance with Pipelining.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 17 - Pipelined.
CS61C L19 Introduction to Pipelined Execution (1) Garcia, Fall 2005 © UCB Lecturer PSOE, new dad Dan Garcia inst.eecs.berkeley.edu/~cs61c.
CS 61C L38 Pipelined Execution, part II (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
Introduction to Pipelining Rabi Mahapatra Adapted from the lecture notes of Dr. John Kubiatowicz (UC Berkeley)
9.2 Pipelining Suppose we want to perform the combined multiply and add operations with a stream of numbers: A i * B i + C i for i =1,2,3,…,7.
CS1104: Computer Organisation School of Computing National University of Singapore.
Integrated Circuits Costs
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.
ECE 232 L18.Pipeline.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 18 Pipelining.
Chapter 6 Pipelined CPU Design. Spring 2005 ELEC 5200/6200 From Patterson/Hennessey Slides Pipelined operation – laundry analogy Text Fig. 6.1.

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
CS 61C L5.2.2 Pipelining I (1) K. Meinz, Summer 2004 © UCB CS61C : Machine Structures Lecture Pipelining I Kurt Meinz inst.eecs.berkeley.edu/~cs61c.
1  1998 Morgan Kaufmann Publishers Chapter Six. 2  1998 Morgan Kaufmann Publishers Pipelining Improve perfomance by increasing instruction throughput.
Pipelining Example Laundry Example: Three Stages
Instructor: Senior Lecturer SOE Dan Garcia CS 61C: Great Ideas in Computer Architecture Pipelining Hazards 1.
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.
Lecture 9. MIPS Processor Design – Pipelined Processor Design #1 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System.
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.
Chapter Six.
Lecture 18: Pipelining I.
Pipelines An overview of pipelining
Review: Instruction Set Evolution
ECE232: Hardware Organization and Design
Chapter Six.
Chapter Six.
Chapter 8. Pipelining.
Recall: Performance Evaluation
Presentation transcript:

cs 61C L25 pipeline.1 Patterson Spring 99 ©UCB CS61C Introduction to Pipelining Lecture 25 April 28, 1999 Dave Patterson (http.cs.berkeley.edu/~patterson) www-inst.eecs.berkeley.edu/~cs61c/schedule.html

cs 61C L25 pipeline.2 Patterson Spring 99 ©UCB Outline °Review Parameter Passing on Stacks °Pipelining Analogy °Pipelining Instruction Execution °Administrivia, “What’s this Stuff Bad for?” °Hazards to Pipelining °Solutions to Hazards °Advanced Pipelining Concepts by Analogy °Conclusion

cs 61C L25 pipeline.3 Patterson Spring 99 ©UCB Review 1/1 °Every machine has a convention for how arguments are passed. °In MIPS, where do the arguments go if you are passing more than 4 words? Stack! °It is sometimes useful to have a variable number of arguments. The C convention is to use “...” *fmt is used to determine the number of variables and their types.

cs 61C L25 pipeline.4 Patterson Spring 99 ©UCB Pipelining is Natural! Laundry Example °Ann, Brian, Cathy, Dave each have one load of clothes to wash, dry, fold, and put away °Washer takes 30 minutes °Dryer takes 30 minutes °“Folder” takes 30 minutes °“Stasher” takes 30 minutes to put clothes into drawers ABCD

cs 61C L25 pipeline.5 Patterson Spring 99 ©UCB Sequential Laundry °Sequential laundry takes 8 hours for 4 loads 30 TaskOrderTaskOrder B C D A Time 30 6 PM AM

cs 61C L25 pipeline.6 Patterson Spring 99 ©UCB Pipelined Laundry: Start work ASAP °Pipelined laundry takes 3.5 hours for 4 loads! TaskOrderTaskOrder 12 2 AM 6 PM Time B C D A 30

cs 61C L25 pipeline.7 Patterson Spring 99 ©UCB Pipelining Lessons °Pipelining doesn’t help latency of single task, it helps throughput of entire workload °Multiple tasks operating simultaneously using different resources °Potential speedup = Number pipe stages °Time to “fill” pipeline and time to “drain” it reduces speedup: 2.3X v. 4X in this example 6 PM 789 Time B C D A 30 TaskOrderTaskOrder

cs 61C L25 pipeline.8 Patterson Spring 99 ©UCB Pipelining Lessons °Suppose new Washer takes 20 minutes, new Stasher takes 20 minutes. How much faster is pipeline? °Pipeline rate limited by slowest pipeline stage °Unbalanced lengths of pipe stages also reduces speedup 6 PM 789 Time B C D A 30 TaskOrderTaskOrder

cs 61C L25 pipeline.9 Patterson Spring 99 ©UCB Review: Steps in Executing MIPS (Lec. 20) 1) Ifetch: Fetch Instruction, Increment PC 2) Decode Instruction, Read Registers 3) Execute: Mem-ref:Calculate Address Arith-log: Perform Operation Branch:Compare if operands == 4) Memory: Load:Read Data from Memory Store:Write Data to Memory 5) Write Back: Write Data to Register Branch:if operands ==, Change PC

cs 61C L25 pipeline.10 Patterson Spring 99 ©UCB Pipelined Execution Representation °To simplify pipeline, every instruction takes same number of steps °Steps also called pipeline “stages” IFtchDcdExecMemWB IFtchDcdExecMemWB IFtchDcdExecMemWB IFtchDcdExecMemWB IFtchDcdExecMemWB IFtchDcdExecMemWB Program Flow Time

cs 61C L25 pipeline.11 Patterson Spring 99 ©UCB Review: A Datapath for MIPS (Lec. 20) Data Cache PCRegisters ALU Instruction Cache Stage 1Stage 2Stage 3(Stage 4) Stage 5 IFtchDcdExecMemWB °Use data path figure to represent pipeline ALU I$ Reg D$Reg

cs 61C L25 pipeline.12 Patterson Spring 99 ©UCB ALU I$ Reg D$Reg I$ Graphical Pipeline Representation I n s t r. O r d e r Time (clock cycles) Load Add Store Sub Or ALU I$ Reg D$Reg ALU I$ Reg D$Reg ALU Reg D$Reg ALU I$ Reg D$Reg (right half highlight means read, left half write)

cs 61C L25 pipeline.13 Patterson Spring 99 ©UCB Example °Suppose 2 ns for memory access, 2 ns for ALU operation, and 1 ns for register file read or write °Nonpipelined Execution: lw : IF + Read Reg + ALU + Memory + Write Reg = = 8 ns add: IF + Read Reg + ALU + Write Reg = = 6 ns °Pipelined Execution: Max(IF,Read Reg,ALU, Memory,Write Reg) = 2 ns

cs 61C L25 pipeline.14 Patterson Spring 99 ©UCB Administrivia °Project 6 (last): Due Today °Next Readings: 7.5 °11th homework (last): Due Friday 4/30 7PM Exercises 2.6, 2.13, 6.1, 6.3, 6.4

cs 61C L25 pipeline.15 Patterson Spring 99 ©UCB Administrivia: Rest of 61C F4/30Review: Caches/TLB/VM; Section 7.5 M5/3Deadline to correct your grade record W5/5Review: Interrupts / Polling; A.7 F5/761C Summary / Your Cal heritage / HKN Course Evalution (Due: Final 61C Survey in lab; Return) Sun 5/9 Final Review starting 2PM (1 Pimintel) W5/12 Final (5PM 1 Pimintel) Need Alternative Final? Contact

cs 61C L25 pipeline.16 Patterson Spring 99 ©UCB “What’s This Stuff (Potentially) Bad For?” Linking Entertainment to Violence 100s of studies in recent decades have revealed a direct correlation between exposure to media violence--including video games--and increased aggression. "We are reaching that stage of desensitization at which the inflicting of pain and suffering has become a source of entertainment; vicarious pleasure rather than revulsion. We are learning to kill, and we are learning to like it." Like the tobacco industry, “the evidence is there." The 14-year-old boy who opened fire on a prayer group in a Ky. school foyer in 1997 was a video-game expert. He had never fired a pistol before, but in the ensuing melee, he fired 8 shots, hit 8 people, and killed 3. The average law enforcement officer in the United States, at a distance of 7 yards, hits fewer than 1 in 5 shots. Because of freedom of speech is a value that we don't want to compromise, “it really comes down to the people creating these games. That's where the responsibility lies." N.Y. Times, 4/26/99

cs 61C L25 pipeline.17 Patterson Spring 99 ©UCB Pipeline Hazard: Matching socks in later load A depends on D; stall since folder tied up TaskOrderTaskOrder 12 2 AM 6 PM Time B C D A E F bubble 30

cs 61C L25 pipeline.18 Patterson Spring 99 ©UCB Problems for Computers °Limits to pipelining: Hazards prevent next instruction from executing during its designated clock cycle Structural hazards: HW cannot support this combination of instructions (single person to fold and put clothes away) Control hazards: Pipelining of branches & other instructions stall the pipeline until the hazard “bubbles” in the pipeline Data hazards: Instruction depends on result of prior instruction still in the pipeline (missing sock)

cs 61C L25 pipeline.19 Patterson Spring 99 ©UCB $ Single Cache is a Structural Hazard Load Instr 1 Instr 2 Instr 3 Instr 4 ALU $ Reg $ ALU $ Reg $ ALU $ Reg $ ALU Reg $ ALU $ Reg $ Read same memory twice in same clock cycle I n s t r. O r d e r Time (clock cycles)

cs 61C L25 pipeline.20 Patterson Spring 99 ©UCB Structural Hazards limit performance °Example: if 1.3 memory accesses per instruction (30% of instructions executed loads and stores) and only one memory access per cycle then Average CPI ≥ 1.3 Otherwise resource is more than 100% utilized

cs 61C L25 pipeline.21 Patterson Spring 99 ©UCB °Stall: wait until decision is clear Move up decision to 2nd stage by adding hardware to check registers as being read °Impact: 2 clock cycles per branch instruction  slow Control Hazard Solutions Add Beq Load ALU I$ Reg D$Reg ALU I$ Reg D$Reg ALU Reg D$Reg I$ I n s t r. O r d e r Time (clock cycles) bub ble

cs 61C L25 pipeline.22 Patterson Spring 99 ©UCB °Predict: guess one direction, then back up if wrong For example, Predict not taken °Impact: 1 clock per branch instruction if right, 2 if wrong (right ~ 50% of time) °More dynamic scheme: history of 1 branch (~ 90%) Control Hazard Solutions Add Beq Load ALU I$ Reg D$Reg ALU I$ Reg D$Reg I$ ALU Reg D$Reg I n s t r. O r d e r Time (clock cycles)

cs 61C L25 pipeline.23 Patterson Spring 99 ©UCB °Redefine branch behavior (takes place after next instruction) “delayed branch” °Impact: 1 clock cycles per branch instruction if can find instruction to put in “slot” (≈ 50% of time) Control Hazard Solutions Add Beq Misc ALU I$ Reg D$Reg ALU I$ Reg D$Reg I$ ALU Reg D$Reg Load I$ ALU Reg D$Reg I n s t r. O r d e r Time (clock cycles)

cs 61C L25 pipeline.24 Patterson Spring 99 ©UCB Example Nondelayed vs. Delayed Branch add $1,$2,$3 sub $4, $5,$6 beq $1, $4, Exit or $8, $9,$10 xor $10, $1,$11 Nondelayed Branch Exit: add $1,$2,$3 sub $4, $5,$6 beq $1, $4, Exit or $8, $9,$10 xor $10, $1,$11 Delayed Branch Exit:

cs 61C L25 pipeline.25 Patterson Spring 99 ©UCB Data Hazard on Register $1 add $1,$2,$3 sub $4, $1,$3 and $6, $1,$7 or $8, $1,$9 xor $10, $1,$11

cs 61C L25 pipeline.26 Patterson Spring 99 ©UCB Dependencies backwards in time are hazards Data Hazard on $1: add $1,$2,$3 sub $4,$1,$3 and $6,$1,$7 or $8,$1,$9 xor $10,r1,$11 IFID/RFEXMEMWB ALU I$ Reg D$ Reg ALU I$ Reg D$Reg ALU I$ Reg D$Reg I$ ALU Reg D$Reg ALU I$ Reg D$Reg I n s t r. O r d e r Time (clock cycles)

cs 61C L25 pipeline.27 Patterson Spring 99 ©UCB “Forward” result from one stage to another “or” OK if define read/write properly Data Hazard Solution: add $1,$2,$3 sub $4,$1,$3 and $6,$1,$7 or $8,$1,$9 xor $10,r1,$11 IFID/RFEXMEMWB ALU I$ Reg D$ Reg ALU I$ Reg D$Reg ALU I$ Reg D$Reg I$ ALU Reg D$Reg ALU I$ Reg D$Reg I n s t r. O r d e r Time (clock cycles)

cs 61C L25 pipeline.28 Patterson Spring 99 ©UCB Dependencies backwards in time are hazards Can’t solve with forwarding Must stall instruction dependent on loads Forwarding (or Bypassing): What about Loads lw $1,0($2) sub $4,$1,$3 IFID/RFEXMEMWB ALU I$ Reg D$ Reg ALU I$ Reg D$Reg

cs 61C L25 pipeline.29 Patterson Spring 99 ©UCB Must stall (insert bubble in) pipeline Data Hazard Even with Forwarding lw $1, 0($2) sub $4,$1,$6 and $6,$1,$7 or $8,$1,$9 IFID/RFEXMEMWB ALU I$ Reg D$ Reg ALU I$ Reg D$Reg ALU I$ Reg D$Reg I$ ALU Reg D$ Time (clock cycles) bub ble

cs 61C L25 pipeline.30 Patterson Spring 99 ©UCB Try producing fast code for a = b + c; d = e – f; a, b, c, d,e, and f in memory Slow code: lw $2,b lw $3,c add $1,$2,$3 sw $1,a lw $5,e lw $6,f sub $4,$5,$6 sw$4,d Software Scheduling to Avoid Load Hazards Fast code: lw $2,b lw $3,c lw $5,e add $1,$2,$3 lw $6,f sw $1,a sub $4,$5,$6 sw$4,d

cs 61C L25 pipeline.31 Patterson Spring 99 ©UCB Advanced Pipelining Concepts (if time) °“Out-of-order” Execution °“Superscalar” execution °State-of-the-Art Microprocessor

cs 61C L25 pipeline.32 Patterson Spring 99 ©UCB Review Pipeline Hazard: Stall is dependency A depends on D; stall since folder tied up TaskOrderTaskOrder 12 2 AM 6 PM Time B C D A E F bubble 30

cs 61C L25 pipeline.33 Patterson Spring 99 ©UCB Out-of-Order Laundry: Don’t Wait A depends on D; rest continue; need more resources to allow out-of-order TaskOrderTaskOrder 12 2 AM 6 PM Time B C D A 30 E F bubble

cs 61C L25 pipeline.34 Patterson Spring 99 ©UCB Superscalar Laundry: Parallel per stage More resources, HW to match mix of parallel tasks? TaskOrderTaskOrder 12 2 AM 6 PM Time B C D A E F (light clothing) (dark clothing) (very dirty clothing) (light clothing) (dark clothing) (very dirty clothing) 30

cs 61C L25 pipeline.35 Patterson Spring 99 ©UCB Superscalar Laundry: Mismatch Mix Task mix underutilizes extra resources TaskOrderTaskOrder 12 2 AM 6 PM Time 30 (light clothing) (dark clothing) (light clothing) A B D C

cs 61C L25 pipeline.36 Patterson Spring 99 ©UCB State of the Art: Alpha °15 Million transistors °2 64KB caches on chip; 16MB L2 cache off chip °Clock cycle time 600 MHz (Fastest Cray Supercomputer: T nsec) 90 watts per chip! °Superscalar: fetch up to 6 instructions/clock cycle, retires up to 4 instruction/clock cycle °Execution out-of-order

cs 61C L25 pipeline.37 Patterson Spring 99 ©UCB Summary 1/2: Pipelining Introduction °Pipelining is a fundamental concept Multiple steps using distinct resources Exploiting parallelism in instructions °What makes it easy? (MIPS vs. 80x86) All instructions are the same length  simple instruction fetch Just a few instruction formats  read registers before decode instruction Memory operands only in loads and stores  fewer pipeline stages Data aligned  1 memory access / load, store

cs 61C L25 pipeline.38 Patterson Spring 99 ©UCB Summary 2/2: Pipelining Introduction °What makes it hard? °Structural hazards: suppose we had only one cache?  Need more HW resources °Control hazards: need to worry about branch instructions?  Branch prediction, delayed branch °Data hazards: an instruction depends on a previous instruction?  need forwarding, compiler scheduling