CSC 631: High-Performance Computer Architecture

Similar documents
Fall 2011 Prof. Hyesoon Kim. Thanks to Prof. Loh & Prof. Prvulovic

Multiprocessors 1. Outline

Chap. 4 Multiprocessors and Thread-Level Parallelism

COSC4201 Multiprocessors

COSC4201. Multiprocessors and Thread Level Parallelism. Prof. Mokhtar Aboelaze York University

Computer Architecture Spring 2016

Suggested Readings! What makes a memory system coherent?! Lecture 27" Cache Coherency! ! Readings! ! Program order!! Sequential writes!! Causality!

CSE502: Computer Architecture CSE 502: Computer Architecture

Computer Systems Architecture

Computer Systems Architecture

Parallel Computers. CPE 631 Session 20: Multiprocessors. Flynn s Tahonomy (1972) Why Multiprocessors?

Multiprocessors and Thread-Level Parallelism. Department of Electrical & Electronics Engineering, Amrita School of Engineering

Computer and Information Sciences College / Computer Science Department CS 207 D. Computer Architecture. Lecture 9: Multiprocessors

Multiprocessors & Thread Level Parallelism

Handout 3 Multiprocessor and thread level parallelism

Parallel Computer Architecture Spring Shared Memory Multiprocessors Memory Coherence

COSC 6385 Computer Architecture - Thread Level Parallelism (I)

COEN-4730 Computer Architecture Lecture 08 Thread Level Parallelism and Coherence

Multiprocessors - Flynn s Taxonomy (1966)

Lecture 24: Virtual Memory, Multiprocessors

Chapter 5 Thread-Level Parallelism. Abdullah Muzahid

THREAD LEVEL PARALLELISM

Computer parallelism Flynn s categories

10 Parallel Organizations: Multiprocessor / Multicore / Multicomputer Systems

Aleksandar Milenkovich 1

Lecture 28 Introduction to Parallel Processing and some Architectural Ramifications. Flynn s Taxonomy. Multiprocessing.

Chapter 5. Thread-Level Parallelism

Multiple Issue and Static Scheduling. Multiple Issue. MSc Informatics Eng. Beyond Instruction-Level Parallelism

CS 590: High Performance Computing. Parallel Computer Architectures. Lab 1 Starts Today. Already posted on Canvas (under Assignment) Let s look at it

Spring 2010 Prof. Hyesoon Kim. Thanks to Prof. Loh & Prof. Prvulovic

Aleksandar Milenkovic, Electrical and Computer Engineering University of Alabama in Huntsville

Multiprocessors. Flynn Taxonomy. Classifying Multiprocessors. why would you want a multiprocessor? more is better? Cache Cache Cache.

Lecture 29 Review" CPU time: the best metric" Be sure you understand CC, clock period" Common (and good) performance metrics"

Lecture 24: Board Notes: Cache Coherency

Serial. Parallel. CIT 668: System Architecture 2/14/2011. Topics. Serial and Parallel Computation. Parallel Computing

COSC 6385 Computer Architecture - Multi Processor Systems

Parallel Architecture. Hwansoo Han

EITF20: Computer Architecture Part 5.2.1: IO and MultiProcessor

MULTIPROCESSORS AND THREAD-LEVEL. B649 Parallel Architectures and Programming

MULTIPROCESSORS AND THREAD-LEVEL PARALLELISM. B649 Parallel Architectures and Programming

Computer and Information Sciences College / Computer Science Department CS 207 D. Computer Architecture. Lecture 9: Multiprocessors

Computer Architecture. A Quantitative Approach, Fifth Edition. Chapter 5. Multiprocessors and Thread-Level Parallelism

Lecture 30: Multiprocessors Flynn Categories, Large vs. Small Scale, Cache Coherency Professor Randy H. Katz Computer Science 252 Spring 1996

Module 18: "TLP on Chip: HT/SMT and CMP" Lecture 39: "Simultaneous Multithreading and Chip-multiprocessing" TLP on Chip: HT/SMT and CMP SMT

Non-uniform memory access machine or (NUMA) is a system where the memory access time to any region of memory is not the same for all processors.

Chapter 5. Multiprocessors and Thread-Level Parallelism

SMD149 - Operating Systems - Multiprocessing

Overview. SMD149 - Operating Systems - Multiprocessing. Multiprocessing architecture. Introduction SISD. Flynn s taxonomy

Multithreaded Processors. Department of Electrical Engineering Stanford University

Computer Science 146. Computer Architecture

Multiprocessors and Thread Level Parallelism Chapter 4, Appendix H CS448. The Greed for Speed

Beyond ILP In Search of More Parallelism

Parallel Processors. The dream of computer architects since 1950s: replicate processors to add performance vs. design a faster processor

3/13/2008 Csci 211 Lecture %/year. Manufacturer/Year. Processors/chip Threads/Processor. Threads/chip 3/13/2008 Csci 211 Lecture 8 4

Introduction to Parallel Computing


Multiprocessor Cache Coherence. Chapter 5. Memory System is Coherent If... From ILP to TLP. Enforcing Cache Coherence. Multiprocessor Types

Multiprocessors and Locking

EN164: Design of Computing Systems Topic 08: Parallel Processor Design (introduction)

Chapter 5. Multiprocessors and Thread-Level Parallelism

Processor Architecture and Interconnect

CSC 631: High-Performance Computer Architecture

Multithreading: Exploiting Thread-Level Parallelism within a Processor

CSCI 4717 Computer Architecture

Online Course Evaluation. What we will do in the last week?

CSE 392/CS 378: High-performance Computing - Principles and Practice

INSTITUTO SUPERIOR TÉCNICO. Architectures for Embedded Computing

CS/COE1541: Intro. to Computer Architecture

Lecture 23: Thread Level Parallelism -- Introduction, SMP and Snooping Cache Coherence Protocol

WHY PARALLEL PROCESSING? (CE-401)

A Multiprocessor system generally means that more than one instruction stream is being executed in parallel.

CMSC Computer Architecture Lecture 12: Multi-Core. Prof. Yanjing Li University of Chicago

Parallelism, Multicore, and Synchronization

Flynn s Classification

Lecture 10: Cache Coherence: Part I. Parallel Computer Architecture and Programming CMU , Spring 2013

Comp. Org II, Spring

Lecture 13: Memory Consistency. + a Course-So-Far Review. Parallel Computer Architecture and Programming CMU , Spring 2013

Parallel Processing & Multicore computers

Shared Symmetric Memory Systems

Issues in Multiprocessors

Organisasi Sistem Komputer

Comp. Org II, Spring

Parallel Computing Platforms. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Computer Architecture Crash course

CMSC Computer Architecture Lecture 15: Memory Consistency and Synchronization. Prof. Yanjing Li University of Chicago

Computer Organization. Chapter 16

Introduction to Multiprocessors (Part II) Cristina Silvano Politecnico di Milano

Chapter 8. Multiprocessors. In-Cheol Park Dept. of EE, KAIST

Parallel Computing Platforms

MULTIPROCESSORS AND THREAD-LEVEL PARALLELISM (PART 1)

Computer Architecture Lecture 27: Multiprocessors. Prof. Onur Mutlu Carnegie Mellon University Spring 2015, 4/6/2015

Cache Coherence and Atomic Operations in Hardware

CS425 Computer Systems Architecture

Lecture 17: Multiprocessors. Topics: multiprocessor intro and taxonomy, symmetric shared-memory multiprocessors (Sections )

Introduction to parallel computers and parallel programming. Introduction to parallel computersand parallel programming p. 1

Chapter-4 Multiprocessors and Thread-Level Parallelism

Multi-core Architectures. Dr. Yingwu Zhu

Chapter 9 Multiprocessors

Lecture 10: Cache Coherence: Part I. Parallel Computer Architecture and Programming CMU /15-618, Spring 2015

Parallel Processing. Computer Architecture. Computer Architecture. Outline. Multiple Processor Organization

Transcription:

CSC 631: High-Performance Computer Architecture Spring 2017 Lecture 11: Multiprocessors CSC 631: High-Performance Computer Architecture 1 Multiprocessing Flynn s Taxonomy of Parallel Machines How many Instruction streams? How many Data streams? SISD: Single I Stream, Single D Stream A uniprocessor SIMD: Single I, Multiple D Streams Each processor works on its own data But all execute the same instrs in lockstep E.g. a vector processor or MMX CSC 631: High-Performance Computer Architecture 2

Flynn s Taxonomy MISD: Multiple I, Single D Stream Not used much Stream processors are closest to MISD MIMD: Multiple I, Multiple D Streams Each processor executes its own instructions and operates on its own data This is your typical off-the-shelf multiprocessor (made using a bunch of normal processors) Includes multi-core processors CSC 631: High-Performance Computer Architecture 3 Multiprocessors Why do we need multiprocessors? Uniprocessor speed keeps improving But there are things that need even more speed Wait for a few years for Moore s law to catch up? Or use multiple processors and do it now? Multiprocessor software problem Most code is sequential (for uniprocessors) MUCH easier to write and debug Correct parallel code very, very difficult to write Efficient and correct is even harder Debugging even more difficult (Heisenbugs) ILP limits reached? CSC 631: High-Performance Computer Architecture 4

MIMD Multiprocessors Centralized Shared Memory Distributed Memory CSC 631: High-Performance Computer Architecture 5 Centralized-Memory Machines Also Symmetric Multiprocessors (SMP) Uniform Memory Access (UMA) All memory locations have similar latencies Data sharing through memory reads/writes P1 can write data to a physical address A, P2 can then read physical address A to get that data Problem: Memory Contention All processor share the one memory Memory bandwidth becomes bottleneck Used only for smaller machines Most often 2,4, or 8 processors CSC 631: High-Performance Computer Architecture 6

Distributed-Memory Machines Two kinds Distributed Shared-Memory (DSM) All processors can address all memory locations Data sharing like in SMP Also called NUMA (non-uniform memory access) Latencies of different memory locations can differ (local access faster than remote access) Message-Passing A processor can directly address only local memory To communicate with other processors, must explicitly send/receive messages Also called multicomputers or clusters Most accesses local, so less memory contention (can scale to well over 1000 processors) CSC 631: High-Performance Computer Architecture 7 Message-Passing Machines A cluster of computers Each with its own processor and memory An interconnect to pass messages between them Producer-Consumer Scenario: P1 produces data D, uses a SEND to send it to P2 The network routes the message to P2 P2 then calls a RECEIVE to get the message Two types of send primitives Synchronous: P1 stops until P2 confirms receipt of message Asynchronous: P1 sends its message and continues Standard libraries for message passing: Most common is MPI Message Passing Interface CSC 631: High-Performance Computer Architecture 8

Communication Performance Metrics for Communication Performance Communication Bandwidth Communication Latency Sender overhead + transfer time + receiver overhead Communication latency hiding Characterizing Applications Communication to Computation Ratio Work done vs. bytes sent over network Example: 146 bytes per 1000 instructions CSC 631: High-Performance Computer Architecture 9 Parallel Performance Serial sections Very difficult to parallelize the entire app Amdahl s law Speedup Overall = (1- F Parallel 1 F ) + Speedup Parallel Parallel Large remote access latency (100s of ns) Overall IPC goes down CPI = CPI Base + RemoteRequestRate RemoteRequestCost Speedup Parallel =1024 F Parallel = 0.5 Speedup Overall =1.998 Speedup Parallel =1024 F Parallel = 0.99 Speedup Overall = 91.2 This cost reduced with CMP/multi-core CPI Base = 0.4 400ns RemoteRequ estcost = = 1200 Cycles RemoteRequ estrate = 0.002 0.33ns/Cycle CPI = 2.8 We need at least 7 processors just to break even! CSC 631: High-Performance Computer Architecture 10

Message Passing Pros and Cons Pros Simpler and cheaper hardware Explicit communication makes programmers aware of costly (communication) operations Cons Explicit communication is painful to program Requires manual optimization If you want a variable to be local and accessible via LD/ST, you must declare it as such If other processes need to read or write this variable, you must explicitly code the needed sends and receives to do this CSC 631: High-Performance Computer Architecture 11 Message Passing: A Program Calculating the sum of array elements #define ASIZE 1024 #define NUMPROC 4 Must manually split the array double myarray[asize/numproc]; double mysum=0; for(int i=0;i<asize/numproc;i++) mysum+=myarray[i]; if(mypid=0){ for(int p=1;p<numproc;p++){ int psum; Master processor adds up partial sums and prints the result recv(p,psum); mysum+=psum; } printf( Sum: %lf\n,mysum); }else send(0,mysum); Slave processors send their partial results to master CSC 631: High-Performance Computer Architecture 12

Shared Memory Pros and Cons Pros Communication happens automatically More natural way of programming Easier to write correct programs and gradually optimize them No need to manually distribute data (but can help if you do) Cons Needs more hardware support Easy to write correct, but inefficient programs (remote accesses look the same as local ones) CSC 631: High-Performance Computer Architecture 13 Shared Memory: A Program Calculating the sum of array elements #define ASIZE 1024 #define NUMPROC 4 shared double array[asize]; shared double allsum=0; shared mutex sumlock; double mysum=0; Array is shared Each processor sums up its part of the array for(int i=mypid*asize/numproc;i<(mypid+1)*asize/numproc;i++) mysum+=array[i]; lock(sumlock); allsum+=mysum; unlock(sumlock); Each processor adds its partial sums to the final result if(mypid=0) printf( Sum: %lf\n,allsum); Master processor prints the result CSC 631: High-Performance Computer Architecture 14

Cache Coherence Problem Shared memory easy with no caches P1 writes, P2 can read Only one copy of data exists (in memory) Caches store their own copies of the data Those copies can easily get inconsistent Classic example: adding to a sum P1 loads allsum, adds its mysum, stores new allsum P1 s cache now has dirty data, but memory not updated P2 loads allsum from memory, adds its mysum, stores allsum P2 s cache also has dirty data Eventually P1 and P2 s cached data will go to memory Regardless of write-back order, the final value ends up wrong CSC 631: High-Performance Computer Architecture 15 Cache Coherence Definition A memory system is coherent if 1. A read R from address X on processor P1 returns the value written by the most recent write W to X on P1 if no other processor has written to X between W and R. 2. If P1 writes to X and P2 reads X after a sufficient time, and there are no other writes to X in between, P2 s read returns the value written by P1 s write. 3. Writes to the same location are serialized: two writes to location X are seen in the same order by all processors. CSC 631: High-Performance Computer Architecture 16

Cache Coherence Definition Property 1. preserves program order It says that in the absence of sharing, each processor behaves as a uniprocessor would Property 2. says that any write to an address must eventually be seen by all processors If P1 writes to X and P2 keeps reading X, P2 must eventually see the new value Property 3. preserves causality Suppose X starts at 0. Processor P1 increments X and processor P2 waits until X is 1 and then increments it to 2. Processor P3 must eventually see that X becomes 2. If different processors could see writes in different order, P2 can see P1 s write and do its own write, while P3 first sees the write by P2 and then the write by P1. Now we have two processors that will forever disagree about the value of A. CSC 631: High-Performance Computer Architecture 17 Maintaining Cache Coherence Hardware schemes Shared Caches Trivially enforces coherence Not scalable (L1 cache quickly becomes a bottleneck) Snooping Needs a broadcast network (like a bus) to enforce coherence Each cache that has a block tracks its sharing state on its own Directory Can enforce coherence even with a point-to-point network A block has just one place where its full sharing state is kept CSC 631: High-Performance Computer Architecture 18

Snooping Typically used for bus-based (SMP) multiprocessors Serialization on the bus used to maintain coherence property 3 Two flavors Write-update (write broadcast) A write to shared data is broadcast to update all copies All subsequent reads will return the new written value (property 2) All see the writes in the order of broadcasts One bus == one order seen by all (property 3) Write-invalidate Write to shared data forces invalidation of all other cached copies Subsequent reads miss and fetch new value (property 2) Writes ordered by invalidations on the bus (property 3) CSC 631: High-Performance Computer Architecture 19 Update vs. Invalidate A burst of writes by a processor to one addr Update: each sends an update Invalidate: possibly only the first invalidation is sent Writes to different words of a block Update: update sent for each word Invalidate: possibly only the first invalidation is sent Producer-consumer communication latency Update: producer sends an update, consumer reads new value from its cache Invalidate: producer invalidates consumer s copy, consumer s read misses and has to request the block Which is better depends on application But write-invalidate is simpler and implemented in most MP-capable processors today CSC 631: High-Performance Computer Architecture 20

MSI Snoopy Protocol State of block B in cache C can be Invalid: B is not cached in C To read or write, must make a request on the bus Modified: B is dirty in C C has the block, no other cache has the block, and C must update memory when it displaces B Can read or write B without going to the bus Shared: B is clean in C C has the block, other caches have the block, and C need not update memory when it displaces B Can read B without going to bus To write, must send an upgrade request to the bus CSC 631: High-Performance Computer Architecture 21 MSI Snoopy Protocol My RD/WR: My action Someone else Also called modified CSC 631: High-Performance Computer Architecture 22

Cache to Cache transfers Problem P1 has block B in M state P2 wants to read B, puts a RdReq on bus If P1 does nothing, memory will supply the data to P2 What does P1 do? Solution 1: abort/retry P1 cancels P2 s request, issues a write back P2 later retries RdReq and gets data from memory Too slow (two memory latencies to move data from P1 to P2) Solution 2: intervention P1 indicates it will supply the data ( intervention bus signal) Memory sees that, does not supply the data, and waits for P1 s data P1 starts sending the data on the bus, memory is updated P2 snoops the transfer during the write-back and gets the block CSC 631: High-Performance Computer Architecture 23 Cache-To-Cache Transfers Intervention works if some cache has data in M state Nobody else has the correct data, clear who supplies the data What if a cache has requested data in S state There might be others who have it, who should supply the data? Solution 1: let memory supply the data Solution 2: whoever wins arbitration supplies the data Solution 3: A separate state similar to S that indicates there are maybe others who have the block in S state, but if anybody asks for the data we should supply it CSC 631: High-Performance Computer Architecture 24

MSI Protocol Three states: Invalid Shared (clean) Modified (dirty) CSC 631: High-Performance Computer Architecture 25 MESI Protocol New state: exclusive data is clean but I have the only copy (except memory) Benefit: bandwidth reduction CSC 631: High-Performance Computer Architecture 26

Detecting Other Sharers Problem P1 wants to read B, puts a RdReq on bus, receives data How does P1 know whether to cache B in S or E state? Solution: Share bus signal Always low, except when somebody pulls it to high When P2 snoops P1 s request, it pulls Share to high P1 goes to S if Share high, to E if Share low CSC 631: High-Performance Computer Architecture 27 Directory-Based Coherence Typically in distributed shared memory For every local memory block, local directory has an entry Directory entry indicates Who has cached copies of the block In what state do they have the block CSC 631: High-Performance Computer Architecture 28

Basic Directory Scheme Each entry has One dirty bit (1 if there is a dirty cached copy) A presence vector (1 bit for each node) Tells which nodes may have cached copies All misses sent to block s home Directory performs needed coherence actions Eventually, directory responds with data CSC 631: High-Performance Computer Architecture 29 Read Miss Processor P k has a read miss on block B, sends request to home node of the block Directory controller Finds entry for B, checks D bit If D=0 Read memory and send data back, set P[k] If D=1 Request block from processor whose P bit is 1 When block arrives, update memory, clear D bit, send block to P k and set P[k] CSC 631: High-Performance Computer Architecture 30

Directory Operation Network controller connected to each bus A proxy for remote caches and memories Requests for remote addresses forwarded to home, responses from home placed on the bus Requests from home placed on the bus, cache responses sent back to home node Each cache still has its own coherence state Directory is there just to avoid broadcasts and order accesses to each location Simplest scheme: If access A1 to block B still not fully processed by directory when A2 arrives, A2 waits in a queue until A1 is done CSC 631: High-Performance Computer Architecture 31 Shared Memory Performance Another C for cache misses Still have Compulsory, Capacity, Conflict Now have Coherence, too We had it in our cache and it was invalidated Two sources for coherence misses True sharing Different processors access the same data False sharing Different processors access different data, but they happen to be in the same block CSC 631: High-Performance Computer Architecture 32

User Visible/Invisible All microarchitecture performance gains up to this point were free in that no user intervention required beyond buying the new processor/system recompilation/rewriting could provide even more benefit, but you get some even if you do nothing Multi-processing pushes the problem of finding the parallelism to above the ISA interface CSC 631: High-Performance Computer Architecture 33 Multi-thread/Multi-core HW Benefits of going parallel Different HW organizations, tradeoffs CSC 631: High-Performance Computer Architecture 34

Workload Benefits runtime 3-wide OOO CPU Task A Task B 4-wide OOO CPU Task A Task B Benefit 3-wide OOO CPU 3-wide OOO CPU Task A Task B 2-wide OOO CPU 2-wide OOO CPU Task A Task B This assumes you have two tasks/programs to execute CSC 631: High-Performance Computer Architecture 35 If Only One Task runtime 3-wide OOO CPU 4-wide OOO CPU Task A Task A Benefit 3-wide OOO CPU 3-wide OOO CPU Task A No benefit over 1 CPU 2-wide OOO CPU 2-wide OOO CPU Task A Performance degradation! Idle CSC 631: High-Performance Computer Architecture 36

(Execution) Latency vs. Bandwidth Desktop processing typically want an application to execute as quickly as possible (minimize latency) Server/Enterprise processing often throughput oriented (maximize bandwidth) latency of individual task less important ex. Amazon processing thousands of requests per minute: it s ok if an individual request takes a few seconds more so long as total number of requests are processed in time CSC 631: High-Performance Computer Architecture 37 Implementing MP Machines One approach: add sockets to your MOBO minimal changes to existing CPUs power delivery, heat removal and I/O not too bad since each chip has own set of pins and cooling CPU 0 CPU 1 CPU 2 CPU 3 Pictures found from google images CSC 631: High-Performance Computer Architecture 38

Chip-Multiprocessing Simple SMP on the same chip Intel Smithfield Block Diagram AMD Dual-Core Athlon FX Pictures found from google images CSC 631: High-Performance Computer Architecture 39 Shared Caches CPU 0 CPU 1 Resources can be shared between CPUs ex. IBM Power 5 L2 cache shared between both CPUs (no need to keep two copies coherent) L3 cache is also shared (only tags are on-chip; data are off-chip) CSC 631: High-Performance Computer Architecture 40

Benefits? Cheaper than mobo-based SMP all/most interface logic integrated on to main chip (fewer total chips, single CPU socket, single interface to main memory) less power than mobo-based SMP as well (communication on-die is more power-efficient than chip-to-chip communication) Performance on-chip communication is faster Efficiency potentially better use of hardware resources than trying to make wider/more OOO single-threaded CPU CSC 631: High-Performance Computer Architecture 41 Performance vs. Power 2x CPUs not necessarily equal to 2x performance 2x CPUs à ½ power for each maybe a little better than ½ if resources can be shared Back-of-the-Envelope calculation: 3.8 GHz CPU at 100W Dual-core: 50W per CPU Benefit of SMP: Full power budget per socket! P µ V 3 : V orig3 /V CMP3 = 100W/50W à V CMP = 0.8 V orig f µ V: f CMP = 3.0GHz CSC 631: High-Performance Computer Architecture 42

Multithreaded Processors Single thread in superscalar execution: dependences cause most of stalls Idea: when one thread stalled, other can go Different granularities of multithreading Coarse MT: can change thread every few cycles Fine MT: can change thread every cycle Simultaneous Multithreading (SMT) Instrs from different threads even in the same cycle AKA Hyperthreading CSC 631: High-Performance Computer Architecture 43 Simultaneous Multi-Threading Uni-Processor: 4-6 wide, lucky if you get 1-2 IPC poor utilization SMP: 2-4 CPUs, but need independent tasks else poor utilization as well SMT: Idea is to use a single large uni-processor as a multi-processor CSC 631: High-Performance Computer Architecture 44

SMT (2) Regular CPU SMT (4 threads) CMP 2x HW Cost Approx 1x HW Cost CSC 631: High-Performance Computer Architecture 45 Overview of SMT Hardware Changes For an N-way (N threads) SMT, we need: Ability to fetch from N threads N sets of registers (including PCs) N rename tables (RATs) N virtual memory spaces But we don t need to replicate the entire OOO execution engine (schedulers, execution units, bypass networks, ROBs, etc.) CSC 631: High-Performance Computer Architecture 46

SMT Fetch Multiplex the Fetch Logic RS PC 0 PC 1 PC 2 I$ fetch Decode, etc. cycle % N Can do simple round-robin between active threads, or favor some over the others based on how much each is stalling relative to the others CSC 631: High-Performance Computer Architecture 47 SMT Rename Thread #1 s R12!= Thread #2 s R12 separate name spaces need to disambiguate Thread 0 Register # RAT 0 Thread-ID PRF concat RAT PRF Thread 1 Register # RAT 1 Register # CSC 631: High-Performance Computer Architecture 48

SMT Issue, Exec, Bypass, No change needed After Renaming Thread 0: Add R1 = R2 + R3 Sub R4 = R1 R5 Xor R3 = R1 ^ R4 Load R2 = 0[R3] Thread 1: Add R1 = R2 + R3 Sub R4 = R1 R5 Xor R3 = R1 ^ R4 Load R2 = 0[R3] Thread 0: Add T12 = T20 + T8 Sub T19 = T12 T16 Xor T14 = T12 ^ T19 Load T23 = 0[T14] Thread 1: Add T17 = T29 + T3 Sub T5 = T17 T2 Xor T31 = T17 ^ T5 Load T25 = 0[T31] Shared RS Entries Sub T5 = T17 T2 Add T12 = T20 + T8 Load T25 = 0[T31] Xor T14 = T12 ^ T19 Load T23 = 0[T14] Sub T19 = T12 T16 Xor T31 = T17 ^ T5 Add T17 = T29 + T3 CSC 631: High-Performance Computer Architecture 49 SMT Cache Each process has own virtual address space TLB must be thread-aware translate (thread-id,virtual page) à physical page Virtual portion of caches must also be threadaware VIVT cache must now be (virtual addr, thread-id)- indexed, (virtual addr, thread-id)-tagged Similar for VIPT cache No changes needed if using PIPT cache (like L2) CSC 631: High-Performance Computer Architecture 50

SMT Commit Register File Management ARF/PRF organization need one ARF per thread Need to maintain interrupts, exceptions, faults on a per-thread basis like OOO needs to appear to outside world that it is in-order, SMT needs to appear as if it is actually N CPUs CSC 631: High-Performance Computer Architecture 51 SMT Performance When it works, it fills idle issue slots with work from other threads; throughput improves But sometimes it can cause performance degradation! Time( ) < Time( ) Finish one task, then do the other Do both at same time using SMT CSC 631: High-Performance Computer Architecture 52

How? Cache thrashing I$ D$ Thread 0 just fits in the Level-1 Caches Context switch to Thread 1 I$ D$ Thread 1 also fits nicely in the caches Executes reasonably quickly due to high cache hit rates L2 I$ D$ Caches were just big enough to hold one thread s data, but not two thread s worth Now both threads have significantly higher cache miss rates CSC 631: High-Performance Computer Architecture 53 This is all combinable Can have a system that supports SMP, CMP and SMT at the same time Take a dual-socket SMP motherboard Insert two chips, each with a dual-core CMP Where each core supports two-way SMT This example provides 8 threads worth of execution, shared on 4 actual cores, split across two physical packages CSC 631: High-Performance Computer Architecture 54

OS Confusion SMT/CMP is supposed to look like multiple CPUs to the software/os Performance worse than if SMT was turned off and used 2-way SMP only 2-way A/B SMT 2-way idle SMT A B idle CPU 0 CPU 1 CPU 2 2 cores (either SMP/CMP) Say OS has two tasks to run idle CPU 3 Schedule tasks to (virtual) CPUs CSC 631: High-Performance Computer Architecture 55