CS 252 Graduate Computer Architecture Lecture 13: Multithreading Krste Asanovic Electrical Engineering and Computer Sciences University of California,

Slides:



Advertisements
Similar presentations
Multithreaded Processors
Advertisements

Computer Organization and Architecture
Multithreading Processors and Static Optimization Review Adapted from Bhuyan, Patterson, Eggers, probably others.
Computer Structure 2014 – Out-Of-Order Execution 1 Computer Structure Out-Of-Order Execution Lihu Rappoport and Adi Yoaz.
CSE 490/590, Spring 2011 CSE 490/590 Computer Architecture Cache III Steve Ko Computer Sciences and Engineering University at Buffalo.
Multithreading processors Adapted from Bhuyan, Patterson, Eggers, probably others.
Microprocessor Microarchitecture Multithreading Lynn Choi School of Electrical Engineering.
CS 7810 Lecture 16 Simultaneous Multithreading: Maximizing On-Chip Parallelism D.M. Tullsen, S.J. Eggers, H.M. Levy Proceedings of ISCA-22 June 1995.
CSE 490/590, Spring 2011 CSE 490/590 Computer Architecture Multithreading II Steve Ko Computer Sciences and Engineering University at Buffalo.
CS 203A Computer Architecture Lecture 10: Multimedia and Multithreading Instructor: L.N. Bhuyan.
1 COMP 206: Computer Architecture and Implementation Montek Singh Mon, Dec 5, 2005 Topic: Intro to Multiprocessors and Thread-Level Parallelism.
1 Lecture 11: SMT and Caching Basics Today: SMT, cache access basics (Sections 3.5, 5.1)
April 6, 2010CS152, Spring 2010 CS 152 Computer Architecture and Engineering Lecture 18: Multithreading Krste Asanovic Electrical Engineering and Computer.
1 Lecture 11: ILP Innovations and SMT Today: out-of-order example, ILP innovations, SMT (Sections 3.5 and supplementary notes)
CS 152 Computer Architecture and Engineering Lecture 18: Multithreading Krste Asanovic Electrical Engineering and Computer Sciences University of California,
CS 162 Computer Architecture Lecture 10: Multithreading Instructor: L.N. Bhuyan Adopted from Internet.
Multithreading and Dataflow Architectures CPSC 321 Andreas Klappenecker.
Chapter 17 Parallel Processing.
CSE 490/590, Spring 2011 CSE 490/590 Computer Architecture Multithreading I Steve Ko Computer Sciences and Engineering University at Buffalo.
1 Lecture 12: ILP Innovations and SMT Today: ILP innovations, SMT, cache basics (Sections 3.5 and supplementary notes)
Simultaneous Multithreading: Multiplying Alpha Performance Dr. Joel Emer Principal Member Technical Staff Alpha Development Group Compaq.
1 Lecture 10: ILP Innovations Today: ILP innovations and SMT (Section 3.5)
Simultaneous Multithreading:Maximising On-Chip Parallelism Dean Tullsen, Susan Eggers, Henry Levy Department of Computer Science, University of Washington,Seattle.
March 16, 2011CS152, Spring 2011 CS 152 Computer Architecture and Engineering Lecture 14: Multithreading Krste Asanovic Electrical Engineering and Computer.
CS 152 Computer Architecture and Engineering Lecture 23: Putting it all together: Intel Nehalem Krste Asanovic Electrical Engineering and Computer Sciences.
CPE 731 Advanced Computer Architecture Thread Level Parallelism Dr. Gheith Abandah Adapted from the slides of Prof. David Patterson, University of California,
CPE 631: Multithreading: Thread-Level Parallelism Within a Processor Electrical and Computer Engineering University of Alabama in Huntsville Aleksandar.
Lecture 11 Multithreaded Architectures Graduate Computer Architecture Fall 2005 Shih-Hao Hung Dept. of Computer Science and Information Engineering National.
POLITECNICO DI MILANO Parallelism in wonderland: are you ready to see how deep the rabbit hole goes? Multithreaded and multicore processors Marco D. Santambrogio:
© Krste Asanovic, 2015CS252, Spring 2015, Lecture 13 CS252 Graduate Computer Architecture Fall 2015 Lecture 13: Multithreading Krste Asanovic
Hyper-Threading Technology Architecture and Microarchitecture
Pipelining and Parallelism Mark Staveley
Thread Level Parallelism Since ILP has inherent limitations, can we exploit multithreading? –a thread is defined as a separate process with its own instructions.
Processor Level Parallelism. Improving the Pipeline Pipelined processor – Ideal speedup = num stages – Branches / conflicts mean limited returns after.
On-chip Parallelism Alvin R. Lebeck CPS 221 Week 13, Lecture 2.
Computer Architecture: Multithreading (I) Prof. Onur Mutlu Carnegie Mellon University.
CENG331 Computer Organization Multithreading
1 Lecture: SMT, Cache Hierarchies Topics: SMT processors, cache access basics and innovations (Sections B.1-B.3, 2.1)
Advanced Computer Architecture pg 1 Embedded Computer Architecture 5SAI0 Chip Multi-Processors (ch 8) Henk Corporaal
Computer Structure 2015 – Intel ® Core TM μArch 1 Computer Structure Multi-Threading Lihu Rappoport and Adi Yoaz.
On-chip Parallelism Alvin R. Lebeck CPS 220/ECE 252.
CS203 – Advanced Computer Architecture TLP – Multithreaded Architectures.
Ch3. Limits on Instruction-Level Parallelism 1. ILP Limits 2. SMT (Simultaneous Multithreading) ECE562/468 Advanced Computer Architecture Prof. Honggang.
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.
Simultaneous Multithreading CMPE 511 BOĞAZİÇİ UNIVERSITY.
Niagara: A 32-Way Multithreaded Sparc Processor Kongetira, Aingaran, Olukotun Presentation by: Mohamed Abuobaida Mohamed For COE502 : Parallel Processing.
Processor Level Parallelism 1
COSC3330 Computer Architecture Lecture 21. TLP and Multi-core
COMP 740: Computer Architecture and Implementation
Electrical and Computer Engineering
Mehmet Altan Açıkgöz Ercan Saraç
Krste Asanovic Electrical Engineering and Computer Sciences
CPE 731 Advanced Computer Architecture Thread Level Parallelism
Prof. Onur Mutlu Carnegie Mellon University
Simultaneous Multithreading
Simultaneous Multithreading
Computer Structure Multi-Threading
Embedded Computer Architecture 5SAI0 Chip Multi-Processors (ch 8)
/ Computer Architecture and Design
Computer Architecture: Multithreading (I)
Krste Asanovic Electrical Engineering and Computer Sciences
Levels of Parallelism within a Single Processor
CPE 631: Multithreading: Thread-Level Parallelism Within a Processor
/ Computer Architecture and Design
Embedded Computer Architecture 5SAI0 Chip Multi-Processors (ch 8)
CSC3050 – Computer Architecture
Levels of Parallelism within a Single Processor
CS 152 Computer Architecture and Engineering CS252 Graduate Computer Architecture Lecture 14 – Multithreading Krste Asanovic Speaker: David Biancolin.
Presentation transcript:

CS 252 Graduate Computer Architecture Lecture 13: Multithreading Krste Asanovic Electrical Engineering and Computer Sciences University of California, Berkeley

10/30/ Recap: Directory Coherence Protocols k processors. With each cache-block in memory: k presence-bits, 1 dirty-bit With each cache-block in cache: 1 valid bit, and 1 dirty (owner) bit Scale to larger numbers of processors by replacing snoopy broadcast with point-point messages Requires additional directory storage Usually longer latency than snoopy protocols Often combined with snooping –Snoop within small cluster of processors, use directory between clusters

10/30/ Multithreading Difficult to continue to extract ILP from a single thread Many workloads can make use of thread-level parallelism (TLP) –TLP from multiprogramming (run independent sequential jobs) –TLP from multithreaded applications (run one job faster using parallel threads) Multithreading uses TLP to improve utilization of a single processor

10/30/ Pipeline Hazards Each instruction may depend on the next LW r1, 0(r2) LW r5, 12(r1) ADDI r5, r5, #12 SW 12(r1), r5 FDXMW t0t1t2t3t4t5t6t7t8 FDXMWDDD FDXMWDDDFFF FDDDDFFF t9t10t11t12t13t14 What can be done to cope with this?

10/30/ Multithreading How can we guarantee no dependencies between instructions in a pipeline? -- One way is to interleave execution of instructions from different program threads on same pipeline FDXMW t0t1t2t3t4t5t6t7t8 T1: LW r1, 0(r2) T2: ADD r7, r1, r4 T3: XORI r5, r4, #12 T4: SW 0(r7), r5 T1: LW r5, 12(r1) t9 FDXMW FDXMW FDXMW FDXMW Interleave 4 threads, T1-T4, on non-bypassed 5-stage pipe Prior instruction in a thread always completes write- back before next instruction in same thread reads register file

10/30/ CDC 6600 Peripheral Processors (Cray, 1964) First multithreaded hardware 10 “virtual” I/O processors Fixed interleave on simple pipeline Pipeline has 100ns cycle time Each virtual processor executes one instruction every 1000ns Accumulator-based instruction set to reduce processor state

10/30/ Simple Multithreaded Pipeline Have to carry thread select down pipeline to ensure correct state bits read/written at each pipe stage Appears to software (including OS) as multiple, albeit slower, CPUs +1 2 Thread select PC 1 PC 1 PC 1 PC 1 I$ IR GPR1 XY 2 D$

10/30/ Multithreading Costs Each thread requires its own user state – PC – GPRs Also, needs its own system state –virtual memory page table base register –exception handling registers Other costs?

10/30/ Thread Scheduling Policies Fixed interleave (CDC 6600 PPUs, 1964) –each of N threads executes one instruction every N cycles –if thread not ready to go in its slot, insert pipeline bubble Software-controlled interleave (TI ASC PPUs, 1971) –OS allocates S pipeline slots amongst N threads –hardware performs fixed interleave over S slots, executing whichever thread is in that slot Hardware-controlled thread scheduling (HEP, 1982) –hardware keeps track of which threads are ready to go –picks next thread to execute based on hardware priority scheme

10/30/ Denelcor HEP (Burton Smith, 1982) First commercial machine to use hardware threading in main CPU –120 threads per processor –10 MHz clock rate –Up to 8 processors –precursor to Tera MTA (Multithreaded Architecture)

10/30/ Tera MTA ( ) Up to 256 processors Up to 128 active threads per processor Processors and memory modules populate a sparse 3D torus interconnection fabric Flat, shared main memory – No data cache – Sustains one main memory access per cycle per processor GaAs logic in prototype, 260MHz – CMOS version, MTA-2, 50W/processor

10/30/ MTA Architecture Each processor supports 128 active hardware threads – 1 x 128 = 128 stream status word (SSW) registers, – 8 x 128 = 1024 branch-target registers, –32 x 128 = 4096 general-purpose registers Three operations packed into 64-bit instruction (short VLIW) –One memory operation, –One arithmetic operation, plus –One arithmetic or branch operation Thread creation and termination instructions Explicit 3-bit “lookahead” field in instruction gives number of subsequent instructions (0-7) that are independent of this one –c.f. instruction grouping in VLIW –allows fewer threads to fill machine pipeline –used for variable-sized branch delay slots

10/30/ MTA Pipeline A W C W M Inst Fetch Memory Pool Retry Pool Interconnection Network Write Pool W Memory pipeline Issue Pool Every cycle, one VLIW instruction from one active thread is launched into pipeline Instruction pipeline is 21 cycles long Memory operations incur ~150 cycles of latency Assuming a single thread issues one instruction every 21 cycles, and clock rate is 260 MHz… What is single-thread performance?

10/30/ Coarse-Grain Multithreading Tera MTA designed for supercomputing applications with large data sets and low locality –No data cache –Many parallel threads needed to hide large memory latency Other applications are more cache friendly –Few pipeline bubbles when cache getting hits –Just add a few threads to hide occasional cache miss latencies –Swap threads on cache misses

10/30/ MIT Alewife (1990) Modified SPARC chips –register windows hold different thread contexts Up to four threads per node Thread switch on local cache miss

10/30/ IBM PowerPC RS64-IV (2000) Commercial coarse-grain multithreading CPU Based on PowerPC with quad-issue in-order five- stage pipeline Each physical CPU supports two virtual CPUs On L2 cache miss, pipeline is flushed and execution switches to second thread –short pipeline minimizes flush penalty (4 cycles), small compared to memory access latency –flush pipeline to simplify exception handling

10/30/ CS252 Administrivia More practice problems and solutions on multiprocessor caches coming –Although practice problems are not graded, we’ll expect you’ll have worked through them in the second quiz Reminder: office hours –Krste, Monday 1-3pm in 645 Soda –Rose, Tuesday 5-6pm in 751 Soda

10/30/ Simultaneous Multithreading (SMT) for OoO Superscalars Techniques presented so far have all been “vertical” multithreading where each pipeline stage works on one thread at a time SMT uses fine-grain control already present inside an OoO superscalar to allow instructions from multiple threads to enter execution on same clock cycle. Gives better utilization of machine resources.

10/30/ For most apps, most execution units lie idle in an OoO superscalar From: Tullsen, Eggers, and Levy, “Simultaneous Multithreading: Maximizing On-chip Parallelism, ISCA For an 8-way superscalar.

10/30/ Superscalar Machine Efficiency Issue width Time Completely idle cycle (vertical waste) Instruction issue Partially filled cycle, i.e., IPC < 4 (horizontal waste)

10/30/ Vertical Multithreading What is the effect of cycle-by-cycle interleaving? Issue width Time Second thread interleaved cycle-by-cycle Instruction issue Partially filled cycle, i.e., IPC < 4 (horizontal waste)

10/30/ Chip Multiprocessing (CMP) What is the effect of splitting into multiple processors? Issue width Time

10/30/ Ideal Superscalar Multithreading [Tullsen, Eggers, Levy, UW, 1995] Interleave multiple threads to multiple issue slots with no restrictions Issue width Time

10/30/ O-o-O Simultaneous Multithreading [Tullsen, Eggers, Emer, Levy, Stamm, Lo, DEC/UW, 1996] Add multiple contexts and fetch engines and allow instructions fetched from different threads to issue simultaneously Utilize wide out-of-order superscalar processor issue queue to find instructions to issue from multiple threads OOO instruction window already has most of the circuitry required to schedule from multiple threads Any single thread can utilize whole machine

10/30/ Power 4 Single-threaded predecessor to Power 5. 8 execution units in out-of-order engine, each may issue an instruction each cycle.

10/30/ Power 4 Power 5 2 fetch (PC), 2 initial decodes 2 commits (architected register sets)

10/30/ Power 5 data flow... Why only 2 threads?

10/30/ Changes in Power 5 to support SMT Increased associativity of L1 instruction cache and the instruction address translation buffers Added per thread load and store queues Increased size of the L2 (1.92 vs MB) and L3 caches Added separate instruction prefetch and buffering per thread Increased the number of virtual registers from 152 to 240 Increased the size of several issue queues The Power5 core is about 24% larger than the Power4 core because of the addition of SMT support

10/30/ Pentium-4 Hyperthreading (2002) First commercial SMT design (2-way SMT) –Hyperthreading == SMT Logical processors share nearly all resources of the physical processor –Caches, execution units, branch predictors Die area overhead of hyperthreading ~ 5% When one logical processor is stalled, the other can make progress –No logical processor can use all entries in queues when two threads are active Processor running only one active software thread runs at approximately same speed with or without hyperthreading

10/30/ Pentium-4 Hyperthreading Front End [ Intel Technology Journal, Q ] Resource divided between logical CPUs Resource shared between logical CPUs

10/30/ Pentium-4 Hyperthreading Execution Pipeline [ Intel Technology Journal, Q ]

10/30/ SMT adaptation to parallelism type For regions with high thread level parallelism (TLP) entire machine width is shared by all threads Issue width Time Issue width Time For regions with low thread level parallelism (TLP) entire machine width is available for instruction level parallelism (ILP)

10/30/ Initial Performance of SMT Pentium 4 Extreme SMT yields 1.01 speedup for SPECint_rate benchmark and 1.07 for SPECfp_rate –Pentium 4 is dual threaded SMT –SPECRate requires that each SPEC benchmark be run against a vendor-selected number of copies of the same benchmark Running on Pentium 4 each of 26 SPEC benchmarks paired with every other (26 2 runs) speed-ups from 0.90 to 1.58; average was 1.20 Power 5, 8-processor server 1.23 faster for SPECint_rate with SMT, 1.16 faster for SPECfp_rate Power 5 running 2 copies of each app speedup between 0.89 and 1.41 –Most gained some –Fl.Pt. apps had most cache conflicts and least gains

10/30/ Power 5 thread performance... Relative priority of each thread controllable in hardware. For balanced operation, both threads run slower than if they “owned” the machine.

10/30/ Icount Choosing Policy Why does this enhance throughput? Fetch from thread with the least instructions in flight.

10/30/ SMT Fetch Policies (Locks) Problem: Spin looping thread consumes resources Solution: Provide quiescing operation that allows a thread to sleep until a memory location changes loop: ARM r1, 0(r2) BEQ r1, got_it QUIESCE BR loop got_it: Load and start watching 0(r2) Inhibit scheduling of thread until activity observed on 0(r2)

10/30/ Summary: Multithreaded Categories Time (processor cycle) SuperscalarFine-GrainedCoarse-Grained Multiprocessing Simultaneous Multithreading Thread 1 Thread 2 Thread 3 Thread 4 Thread 5 Idle slot