CS203 – Advanced Computer Architecture Pipelining Review.

Slides:



Advertisements
Similar presentations
1 Pipelining Part 2 CS Data Hazards Data hazards occur when the pipeline changes the order of read/write accesses to operands that differs from.
Advertisements

CMSC 611: Advanced Computer Architecture Pipelining Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted.
1 Lecture 3 Pipeline Contd. (Appendix A) Instructor: L.N. Bhuyan CS 203A Advanced Computer Architecture Some slides are adapted from Roth.
Pipeline Computer Organization II 1 Hazards Situations that prevent starting the next instruction in the next cycle Structural hazards – A required resource.
Lecture Objectives: 1)Define pipelining 2)Calculate the speedup achieved by pipelining for a given number of instructions. 3)Define how pipelining improves.
CMPT 334 Computer Organization
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 Hwanmo Sung CS147 Presentation Professor Sin-Min Lee.
Goal: Describe Pipelining
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 - Hazards.
ECE 445 – Computer Organization
Pipelining II Andreas Klappenecker CPSC321 Computer Architecture.
1  1998 Morgan Kaufmann Publishers Chapter Six Enhancing Performance with Pipelining.
Chapter 12 Pipelining Strategies Performance Hazards.
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.
Chapter Six Enhancing Performance with Pipelining
Pipelining Andreas Klappenecker CPSC321 Computer Architecture.
Pipelined Processor II CPSC 321 Andreas Klappenecker.
EENG449b/Savvides Lec 4.1 1/22/04 January 22, 2004 Prof. Andreas Savvides Spring EENG 449bG/CPSC 439bG Computer.
DLX Instruction Format
Appendix A Pipelining: Basic and Intermediate Concepts
1  1998 Morgan Kaufmann Publishers Chapter Six Enhancing Performance with Pipelining.
ENGS 116 Lecture 51 Pipelining and Hazards Vincent H. Berk September 30, 2005 Reading for today: Chapter A.1 – A.3, article: Patterson&Ditzel Reading for.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 17 - Pipelined.
Lecture 15: Pipelining and Hazards CS 2011 Fall 2014, Dr. Rozier.
1 Pipelining Reconsider the data path we just did Each instruction takes from 3 to 5 clock cycles However, there are parts of hardware that are idle many.
Pipelining. 10/19/ Outline 5 stage pipelining Structural and Data Hazards Forwarding Branch Schemes Exceptions and Interrupts Conclusion.
Memory/Storage Architecture Lab Computer Architecture Pipelining Basics.
1 Appendix A Pipeline implementation Pipeline hazards, detection and forwarding Multiple-cycle operations MIPS R4000 CDA5155 Spring, 2007, Peir / University.
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell CS352H: Computer Systems Architecture Topic 8: MIPS Pipelined.
Computer Organization CS224 Fall 2012 Lesson 28. Pipelining Analogy  Pipelined laundry: overlapping execution l Parallelism improves performance §4.5.
Pipelining (I). Pipelining Example  Laundry Example  Four students have one load of clothes each to wash, dry, fold, and put away  Washer takes 30.
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.
Pipeline Hazards. CS5513 Fall Pipeline Hazards Situations that prevent the next instructions in the instruction stream from executing during its.
CMPE 421 Parallel Computer Architecture
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
CS 1104 Help Session IV Five Issues in Pipelining Colin Tan, S
Chapter 6 Pipelined CPU Design. Spring 2005 ELEC 5200/6200 From Patterson/Hennessey Slides Pipelined operation – laundry analogy Text Fig. 6.1.
Chap 6.1 Computer Architecture Chapter 6 Enhancing Performance with Pipelining.
1  1998 Morgan Kaufmann Publishers Chapter Six. 2  1998 Morgan Kaufmann Publishers Pipelining Improve perfomance by increasing instruction throughput.
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
LECTURE 7 Pipelining. DATAPATH AND CONTROL We started with the single-cycle implementation, in which a single instruction is executed over a single cycle.
11 Pipelining Kosarev Nikolay MIPT Oct, Pipelining Implementation technique whereby multiple instructions are overlapped in execution Each pipeline.
Introduction to Computer Organization Pipelining.
Lecture 9. MIPS Processor Design – Pipelined Processor Design #1 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System.
L17 – Pipeline Issues 1 Comp 411 – Fall /23/09 CPU Pipelining Issues Read Chapter This pipe stuff makes my head hurt! What have you been.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Chapter Six.
Pipelining Chapter 6.
Morgan Kaufmann Publishers
Single Clock Datapath With Control
Pipeline Implementation (4.6)
Appendix A - Pipelining
Chapter 4 The Processor Part 3
Morgan Kaufmann Publishers The Processor
Pipelining Chapter 6.
Pipeline control unit (highly abstracted)
Chapter Six.
Chapter Six.
Instruction Level Parallelism (ILP)
November 5 No exam results today. 9 Classes to go!
Pipeline control unit (highly abstracted)
CS203 – Advanced Computer Architecture
Pipeline Control unit (highly abstracted)
Morgan Kaufmann Publishers The Processor
Presentation transcript:

CS203 – Advanced Computer Architecture Pipelining Review

Pipelining Analogy Laundry steps: Wash Dry Fold Put it away – Closet / Dresser / Neat pile on floor Pipelining Review

Pipelining Analogy Assuming each step take 1 hour, 4 loads would take 16 hours! Pipelining Review

Pipelining Analogy To speed things up, overlap steps 4 loads of laundry now only takes 7 hours! Pipelining Review

k stages pipeline, t time per stage, n jobs Non-pipelined time = n*k*t Pipelined time = (k+n-1)*t Speedup of Pipelining This is an ideal case: No job depends on a previous job All jobs behave exactly the same Not realistic. Pipelining Review

SIMPLE 5 STAGE PIPELINE Pipelining Review

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 Pipelining Review

Pipeline Performance Single-cycle (T c = 800ps) Pipelined (T c = 200ps) Pipelining Review

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

Representation of pipeline Pipelining Review

Pipelining What makes it easy all instructions are the same length just a few instruction formats memory operands appear only in loads and stores What makes it hard? structural hazards: suppose we had only one memory control hazards: need to worry about branch instructions data hazards: an instruction depends on a previous instruction What makes it really hard: exception handling trying to improve performance with out-of-order execution, etc. Pipelining Review

HAZARDS Pipelining Review

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 Pipelining Review

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 Pipelining Review

Structural hazard two memory accesses in cc4, use Harvard architecture separate data and code memories Pipelining Review

DATA HAZARDS Pipelining Review

Data Hazards An instruction depends on completion of data access by a previous instruction add$s0, $t0, $t1 sub$t2, $s0, $t3 Pipelining Review

Types of data hazards Read After Write (RAW), true, or dataflow, dependence i1: add r1, r2, r3 i2: add r4, r1, r5 Write After Read (WAR), anti dependence i1: add r1, r2, r3 i2: add r2, r4, r5 Write After Write (WAW), output dependence i1: add r1, r2, r3 i2: add r1, r4, r5 Pipelining Review

WAR & WAW WAR & WAW are name dependencies Dependence is on the container’s name not on the value contained. Can be eliminated by renaming, static (in software) or dynamic (in hardware) WAW & WAR cannot occur in the 5-stage MIPS pipeline All the writing happens in WB stage, in issue order of instructions IFIDEXWBMEM IFIDEXWBMEM IFIDEXWBMEM Pipelining Review

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 Pipelining Review

Examples of Dependencies Pipelining Review

CONTROL HAZARDS Pipelining Review

Control Hazards Branch problem: branches are resolved in EX stage  2 cycles penalty on taken branches Ideal CPI =1. Assuming 2 cycles for all branches and 32% branch instructions  new CPI = *2 = 1.64 Pipelining Review

Branches are resolved in EX stage Ex. Branch Not Taken B = Branch instr.i = instr after Br.j = instr branch to IFIDEXEMEMWB Pipelining Review

Branches are resolved in EX stage Ex. Branch Not Taken B = Branch instr.i = instr after Br.j = instr branch to IFIDEXEMEMWB i B i+1 i B Pipelining Review

Branches are resolved in EX stage Ex. Branch Taken B = Branch instr.i = instr after Br.j = instr branch to IFIDEXEMEMWB Pipelining Review

Branches are resolved in EX stage Ex. Branch Taken B = Branch instr.i = instr after Br.j = instr branch to IFIDEXEMEMWB i B j B Pipelining Review

Control Hazards Branch problem: branches are resolved in EX stage  2 cycles penalty on taken branches Ideal CPI =1. Assuming 2 cycles for all branches and 32% branch instructions  new CPI = *2 = 1.64 Solutions: Reduce branch penalty: change the datapath – new adder needed in ID stage. Fill branch delay slot(s) with useful instruction(s). Predict branch (Taken/Not Taken). Static branch prediction: same prediction for every instance of that branch Dynamic branch prediction: prediction based on path leading to that branch Pipelining Review

Branches are resolved in ID stage Ex. Branch Not Taken B = Branch instr.i = instr after Br.j = instr branch to IFIDEXEMEMWB Pipelining Review

Branches are resolved in ID stage Ex. Branch Not Taken B = Branch instr.i = instr after Br.j = instr branch to IFIDEXEMEMWB i B i+1 i B Pipelining Review

Branches are resolved in ID stage Ex. Branch Taken B = Branch instr.i = instr after Br.j = instr branch to IFIDEXEMEMWB Pipelining Review

Branches are resolved in ID stage Ex. Branch Taken B = Branch instr.i = instr after Br.j = instr branch to IFIDEXEMEMWB i B j B Pipelining Review

Filling branch delay slots Branch delay slot filling move a useful instruction into the slot right after the branch, hoping that its execution is necessary. Limitations: restrictions on which instructions can be rescheduled, compile time prediction of taken or untaken branches; serious impact on program semantics & future architectures. Pipelining Review

Scheduling Branch Delay Slots add $1,$2,$3 if $2=0 then delay slot A. From before branchB. From branch targetC. From fall through add $1,$2,$3 if $1=0 then delay slot add $1,$2,$3 if $1=0 then delay slot sub $4,$5,$6 becomes if $2=0 then add $1,$2,$3 if $1=0 then sub $4,$5,$6 add $1,$2,$3 if $1=0 then sub $4,$5,$6 Pipelining Review

Branch Prediction Predict the outcome of a branch in the IF stage Idea: doing something is better than waiting around doing nothing Gains might outweigh losses Heavily researched area in the last 20 years Fixed branch prediction. applied to all branch instructions indiscriminately. Predict not-taken (47% actually not taken) : continue to fetch instruction without stalling;; do not change any state (no register write); if branch is taken turn the fetched instruction into no-op, restart fetch at target address: 1 cycle penalty. Assumes branch detection at the ID stage. Predict taken (53%): more difficult, must know target before branch is decoded; no advantage in our simple 5-stage pipeline even if we move the branch to ID stage. Pipelining Review

Branch Prediction Static branch prediction. Opcode-based: prediction based on opcode itself and related condition. Examples: MC 88110, PowerPC 601/603. Displacement based prediction: if d = 0 predict not taken. Examples: Alpha (as option), PowerPC 601/603 for regular conditional branches. Compiler-directed prediction: compiler sets or clears a predict bit in the instruction itself. Examples: AT&T 9210 Hobbit, PowerPC 601/603 (predict bit reverses opcode or displacement predictions), HP PA 8000 (as option). Dynamic branch prediction Later in this course; tons of it! Why is it SO important? For what? Pipelining Review