CS 3410, Spring 2014 Computer Science Cornell University See P&H Chapter: 4.10, 1.7, 1.8, 5.10, 6.

Slides:



Advertisements
Similar presentations
Chapter 4 The Processor. Chapter 4 — The Processor — 2 The Main Control Unit Control signals derived from instruction 0rsrtrdshamtfunct 31:265:025:2120:1615:1110:6.
Advertisements

ENGS 116 Lecture 101 ILP: Software Approaches Vincent H. Berk October 12 th Reading for today: , 4.1 Reading for Friday: 4.2 – 4.6 Homework #2:
CPE 731 Advanced Computer Architecture ILP: Part V – Multiple Issue Dr. Gheith Abandah Adapted from the slides of Prof. David Patterson, University of.
Advanced Pipelining Optimally Scheduling Code Optimally Programming Code Scheduling for Superscalars (6.9) Exceptions (5.6, 6.8)
Pipeline Optimization
1 Advanced Computer Architecture Limits to ILP Lecture 3.
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.
Chapter 4 The Processor CprE 381 Computer Organization and Assembly Level Programming, Fall 2013 Zhao Zhang Iowa State University Revised from original.
CPE432 Chapter 4C.1Dr. W. Abu-Sufah, UJ Chapter 4C: The Processor, Part C Read Section 4.10 Parallelism and Advanced Instruction-Level Parallelism Adapted.
10/24/05 ELEC62001 Kasi L.K. Anbumony Department of Electrical and Computer Engineering Auburn University Auburn, AL Superscalar Processors.
Instruction Level Parallelism Chapter 4: CS465. Instruction-Level Parallelism (ILP) Pipelining: executing multiple instructions in parallel To increase.
Chapter 4 CSF 2009 The processor: Instruction-Level Parallelism.
Real Processors Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University.
1 xkcd/619. Multicore & Parallel Processing Guest Lecture: Kevin Walsh CS 3410, Spring 2011 Computer Science Cornell University.
3.13. Fallacies and Pitfalls Fallacy: Processors with lower CPIs will always be faster Fallacy: Processors with faster clock rates will always be faster.
Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University Multicore & Parallel Processing P&H Chapter ,
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 19 - Pipelined.
Pipelining III Andreas Klappenecker CPSC321 Computer Architecture.
1  2004 Morgan Kaufmann Publishers Chapter Six. 2  2004 Morgan Kaufmann Publishers Pipelining The laundry analogy.
1 Chapter Six - 2nd Half Pipelined Processor Forwarding, Hazards, Branching EE3055 Web:
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania Computer Organization Pipelined Processor Design 3.
EECS 470 Superscalar Architectures and the Pentium 4 Lecture 12.
CS 300 – Lecture 24 Intro to Computer Architecture / Assembly Language The LAST Lecture!
Multicore and Parallel Processing Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University P & H Chapter ,
Multicore and Parallel Processing Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University P & H Chapter ,
Multicore and Parallel Processing Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University P & H Chapter ,
Fall 2014, Nov ELEC / Lecture 12 1 ELEC / Computer Architecture and Design Fall 2014 Instruction-Level Parallelism.
Multiple Issue Processors: Superscalar and VLIW
Comp Sci pipelining 1 Ch. 13 Pipelining. Comp Sci pipelining 2 Pipelining.
Instruction Level Parallelism Pipeline with data forwarding and accelerated branch Loop Unrolling Multiple Issue -- Multiple functional Units Static vs.
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.
CS 3410, Spring 2014 Computer Science Cornell University See P&H Chapter: 4.10, 1.7, 1.8, 5.10, 6.4, 2.11.
CS 61C: Great Ideas in Computer Architecture (Machine Structures) Lecture 32: Pipeline Parallelism 3 Instructor: Dan Garcia inst.eecs.Berkeley.edu/~cs61c.
Processor Level Parallelism. Improving the Pipeline Pipelined processor – Ideal speedup = num stages – Branches / conflicts mean limited returns after.
Chapter 6 Pipelined CPU Design. Spring 2005 ELEC 5200/6200 From Patterson/Hennessey Slides Pipelined operation – laundry analogy Text Fig. 6.1.
12/26/20151 Pipeline Architecture since 1985  Last time, we completed the 5-stage pipeline MIPS. —Processors like this were first shipped around 1985.
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
Computer Organization CS224 Fall 2012 Lesson 52. Introduction  Goal: connecting multiple computers to get higher performance l Multiprocessors l Scalability,
Lecture 9. MIPS Processor Design – Pipelined Processor Design #1 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System.
LECTURE 10 Pipelining: Advanced ILP. EXCEPTIONS An exception, or interrupt, is an event other than regular transfers of control (branches, jumps, calls,
Csci 136 Computer Architecture II – Superscalar and Dynamic Pipelining Xiuzhen Cheng
Advanced Pipelining 7.1 – 7.5. Peer Instruction Lecture Materials for Computer Architecture by Dr. Leo Porter is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
CS 3410, Spring 2014 Computer Science Cornell University See P&H Chapter: 4.10, 1.7, 1.8, 5.10, 6.4, 2.11.
Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University P & H Chapter 4.10, 1.7, 1.8, 5.10, 6.
Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University P & H Chapter 4.10, 1.7, 1.8, 5.10, 6.
Use of Pipelining to Achieve CPI < 1
Chapter Six.
CS 352H: Computer Systems Architecture
XU, Qiang 徐強 [Adapted from UC Berkeley’s D. Patterson’s and
Pipeline Architecture since 1985
Single Clock Datapath With Control
Pipeline Implementation (4.6)
Morgan Kaufmann Publishers
/ Computer Architecture and Design
ECE232: Hardware Organization and Design
Pipelining: Advanced ILP
Chapter 4 The Processor Part 6
Morgan Kaufmann Publishers The Processor
CS314 Computer Organization Fall 2016
Computer Architecture
Chapter Six.
Chapter Six.
Vishwani D. Agrawal James J. Danaher Professor
CSC3050 – Computer Architecture
Parallelism, Multicore, and Synchronization
Guest Lecturer: Justin Hsia
CS314 Computer Organization Fall 2017
Presentation transcript:

CS 3410, Spring 2014 Computer Science Cornell University See P&H Chapter: 4.10, 1.7, 1.8, 5.10, 6

Next five weeks Week 11 (Apr 15): Proj3 release, Lab3 due Wed, HW2 due Sat Week 12 (Apr 22): Lab4 release and Proj3 due Fri Week 13 (Apr 29): Proj4 release, Lab4 due Tue, Prelim2 Week 14 (May 6): Proj3 tournament Mon, Proj4 design doc due Final Project for class Week 15 (May 13): Proj4 due Wed

Many ways to improve performance Instruction Level Parallelism Multicore Performance in multicore Next 2 lectures: synchronization Next lecture: GPU

We have looked at Pipelining To speed up: Deeper pipelining Make the clock run faster Parallelism Not a luxury, a necessity

Pipelining: execute multiple instructions in parallel Q: How to get more instruction level parallelism? A: Deeper pipeline –E.g. 250MHz 1-stage; 500Mhz 2-stage; 1GHz 4-stage; 4GHz 16-stage Pipeline depth limited by… –max clock speed –min unit of work (less work per stage  shorter clock cycle) –dependencies, hazards / forwarding logic

Pipelining: execute multiple instructions in parallel Q: How to get more instruction level parallelism? A: Multiple issue pipeline –Start multiple instructions per clock cycle in duplicate stages ALU/Br LW/SW

Static multiple issue aka Very Long Instruction Word Decisions made by compiler Dynamic multiple issue Decisions made on the fly Cost: More execute hardware Reading/writing register files: more ports

a.k.a. Very Long Instruction Word (VLIW) Compiler groups instructions to be issued together Packages them into “issue slots” Q: How does HW detect and resolve hazards? A: It doesn’t  Simple HW, assumes compiler avoids hazards Example: Static Dual-Issue 32-bit MIPS Instructions come in pairs (64-bit aligned) –One ALU/branch instruction (or nop) –One load/store instruction (or nop)

Two-issue packets One ALU/branch instruction One load/store instruction 64-bit aligned –ALU/branch, then load/store –Pad an unused instruction with nop Delay slot: 2 instructions (1 cycle) AddressInstruction typePipeline Stages nALU/branchIFIDEXMEMWBWB n + 4Load/storeIFIDEXMEMWBWB n + 8ALU/branchIFIDEXMEMMEM WB n + 12Load/storeIFIDEXMEMMEM WB n + 16ALU/branchIFIDEXEX MEMWB n + 20Load/storeIFIDEXEX MEMWB

Loop: lw $t0, 0($s1) # $t0=array element addu $t0, $t0, $s2 # add scalar in $s2 sw $t0, 0($s1) # store result addi $s1, $s1,–4 # decrement pointer bne $s1, $zero, Loop # branch $s1!=0 Schedule this for dual-issue MIPS Loop: lw $t0, 0($s1) # $t0=array element addu $t0, $t0, $s2 # add scalar in $s2 sw $t0, 0($s1) # store result addi $s1, $s1,–4 # decrement pointer bne $s1, $zero, Loop # branch $s1!=0 ALU/branchLoad/storecycle Loop:

Reorder instructions To fill the issue slot with useful work Complicated: exceptions may occur

Move instructions to fill in nops Need to track hazards and dependencies Loop unrolling

Loop: lw $t0, 0($s1) # $t0=array element addu $t0, $t0, $s2 # add scalar in $s2 sw $t0, 0($s1) # store result addi $s1, $s1,–4 # decrement pointer bne $s1, $zero, Loop # branch $s1!=0 Schedule this for dual-issue MIPS Loop: lw $t0, 0($s1) # $t0=array element addu $t0, $t0, $s2 # add scalar in $s2 sw $t0, 0($s1) # store result addi $s1, $s1,–4 # decrement pointer bne $s1, $zero, Loop # branch $s1!=0 ALU/branchLoad/storecycle Loop:noplw $t0, 0($s1)1 addi $s1, $s1,–4nop2 addu $t0, $t0, $s2nop3 bne $s1, $zero, Loopsw $t0, 4($s1)4 5 instructions/4 cycles = IPC = cycles/5 instructions = CPI = 0.8

Compiler scheduling for dual-issue MIPS… Loop: lw $t0, 0($s1) # $t0 = A[i] lw $t1, 4($s1)# $t1 = A[i+1] addu $t0, $t0, $s2 # add $s2 addu $t1, $t1, $s2 # add $s2 sw $t0, 0($s1) # store A[i] sw $t1, 4($s1) # store A[i+1] addi $s1, $s1, +8 # increment pointer bne $s1, $s3, Loop# continue if $s1!=end ALU/branch slotLoad/store slotcycle Loop:noplw $t0, 0($s1)1 noplw $t1, 4($s1)2 addu $t0, $t0, $s2nop3 addu $t1, $t1, $s2sw $t0, 0($s1)4 addi $s1, $s1, +8 sw $t1, 4($s1)5 bne $s1, $s3, Loopnop6 8 cycles 6 cycles = CPI = 0.75 delay slot

Compiler scheduling for dual-issue MIPS… Loop: lw $t0, 0($s1) # $t0 = A[i] lw $t1, 4($s1)# $t1 = A[i+1] addu $t0, $t0, $s2 # add $s2 addu $t1, $t1, $s2 # add $s2 sw $t0, 0($s1) # store A[i] sw $t1, 4($s1) # store A[i+1] addi $s1, $s1, +8 # increment pointer bne $s1, $s3, Loop# continue if $s1!=end ALU/branch slotLoad/store slotcycle Loop:noplw $t0, 0($s1)1 addi $s1, $s1, +8 lw $t1, 4($s1)2 addu $t0, $t0, $s2nop3 addu $t1, $t1, $s2sw $t0, -8($s1)4 bne $s1, $s3, Loop sw $t1, -4($s1)5 8 cycles 5 cycles = CPI = 0.625

Compiler scheduling for dual-issue MIPS… lw $t0, 0($s1) # load A addi $t0, $t0, +1# increment A sw $t0, 0($s1)# store A lw $t0, 0($s2) # load B addi $t0, $t0, +1# increment B sw $t0, 0($s2)# store B ALU/branch slotLoad/store slotcycle noplw $t0, 0($s1)1 nopnop2 addi $t0, $t0, +1nop3 nopsw $t0, 0($s1)4 noplw $t0, 0($s2)5 nopnop6 addi $t0, $t0, +1nop7 nopsw $t0, 0($s2)8

Compiler scheduling for dual-issue MIPS… lw $t0, 0($s1) # load A addi $t0, $t0, +1# increment A sw $t0, 0($s1)# store A lw $t1, 0($s2) # load B addi $t1, $t1, +1# increment B sw $t1, 0($s2)# store B ALU/branch slotLoad/store slotcycle noplw $t0, 0($s1)1 nopnop2 addi $t0, $t0, +1nop3 nopsw $t0, 0($s1)4 noplw $t1, 0($s2)5 nopnop6 addi $t1, $t1, +1nop7 nopsw $t1, 0($s2)8

Compiler scheduling for dual-issue MIPS… lw $t0, 0($s1) # load A addi $t0, $t0, +1# increment A sw $t0, 0($s1)# store A lw $t1, 0($s2) # load B addi $t1, $t1, +1# increment B sw $t1, 0($s2)# store B ALU/branch slotLoad/store slotcycle noplw $t0, 0($s1)1 noplw $t1, 0($s2) 2 addi $t0, $t0, +1nop3 addi $t1, $t1, +1 sw $t0, 0($s1)4 nopsw $t1, 0($s2) 5 Problem: What if $s1 and $s2 are equal (aliasing)? Won’t work

a.k.a. SuperScalar Processor CPU examines instruction stream and chooses multiple instructions to issue each cycle Compiler can help by reordering instructions…. … but CPU is responsible for resolving hazards

a.k.a. SuperScalar Processor Speculation/Out-of-order Execution Execute instructions as early as possible Aggressive register renaming Guess results of branches, loads, etc. Roll back if guesses were wrong Don’t commit results until all previous insts. are retired

To handle unpredictable stalls Like cache misses Hides details of pipeline from applications Abstraction

Q: Does multiple issue / ILP work? A: Kind of… but not as much as we’d like Limiting factors? Programs dependencies Hard to detect dependencies  be conservative –e.g. Pointer Aliasing: A[0] += 1; B[0] *= 2; Hard to expose parallelism –Can only issue a few instructions ahead of PC Structural limits –Memory delays and limited bandwidth Hard to keep pipelines full

Pentium Atom P4 Itanium 2 K8 K10 Dual-core Itanium 2

Q: Does multiple issue / ILP cost much? A: Yes. Dynamic issue & speculation requires power  Multiple simpler cores may be better?

How to improve System Performance? Instruction Level Parallelism (ILP) Multicore –Increase clock frequency vs multicore Beware of Amdahls Law Next time: Concurrency, programming, and synchronization

Q: How to improve system performance?  Increase CPU clock rate?  But I/O speeds are limited Disk, Memory, Networks, etc. Recall: Amdahl’s Law Solution: Parallelism

Moore’s law A law about transistors Smaller means more transistors per die And smaller means faster too But: need to worry about power too…

Power = capacitance * voltage 2 * frequency approx. capacitance * voltage 3 Reducing voltage helps (a lot) Better cooling helps The power wall We can’t reduce voltage further - leakage We can’t remove more heat

Hot Plate Rocket Nozzle Nuclear Reactor Surface of Sun Xeon 180nm 32nm

AMD Barcelona Quad-Core: 4 processor cores

Intel Nehalem Hex-Core

If tasks have a serial part and a parallel part… Example: step 1: divide input data into n pieces step 2: do work on each piece step 3: combine all results Recall: Amdahl’s Law As number of cores increases … time to execute parallel part? time to execute serial part? Serial part eventually dominates goes to zero Remains the same

affected execution time amount of improvement + execution time unaffected Execution time after improvement =

Example: multiply accounts for 80s out of 100s How much improvement do we need in the multiply performance to get 5× overall improvement? 20 = 80/n + 20 Improving an aspect of a computer and expecting a proportional improvement in overall performance –Can’t be done!

Workload: sum of 10 scalars, and 10 × 10 matrix sum Speed up from 10 to 100 processors? Single processor: Time = ( ) × t add 10 processors Time = 100/10 × t add + 10 × t add = 20 × t add Speedup = 110/20 = processors Time = 100/100 × t add + 10 × t add = 11 × t add Speedup = 110/11 = 10 Assumes load can be balanced across processors

What if matrix size is 100 × 100? Single processor: Time = ( ) × t add 10 processors Time = 10 × t add /10 × t add = 1010 × t add Speedup = 10010/1010 = processors Time = 10 × t add /100 × t add = 110 × t add Speedup = 10010/110 = 91 Assuming load balanced

Strong scaling vs. weak scaling Strong scaling: scales with same problem size Weak scaling: scales with increased problem size