Handout 3 Multiprocessor and thread level parallelism

Similar documents
Computer Systems Architecture

Computer Systems Architecture

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

Chap. 4 Multiprocessors and Thread-Level Parallelism

ESE 545 Computer Architecture Symmetric Multiprocessors and Snoopy Cache Coherence Protocols CA SMP and cache coherence

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

Multiprocessors 1. Outline

Chapter Seven. Idea: create powerful computers by connecting many smaller ones

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

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

Multiprocessors & Thread Level Parallelism

CISC 662 Graduate Computer Architecture Lectures 15 and 16 - Multiprocessors and Thread-Level Parallelism

EITF20: Computer Architecture Part 5.2.1: IO and MultiProcessor

Chapter 5. Multiprocessors and Thread-Level Parallelism

Page 1. Instruction-Level Parallelism (ILP) CISC 662 Graduate Computer Architecture Lectures 16 and 17 - Multiprocessors and Thread-Level Parallelism

MULTIPROCESSORS AND THREAD-LEVEL. B649 Parallel Architectures and Programming

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

Parallel Computer Architecture Spring Shared Memory Multiprocessors Memory Coherence

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

Chapter-4 Multiprocessors and Thread-Level Parallelism

Chapter 5. Multiprocessors and Thread-Level Parallelism

Chapter 5. Thread-Level Parallelism

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

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

10 Parallel Organizations: Multiprocessor / Multicore / Multicomputer Systems

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

Chapter 5 Thread-Level Parallelism. Abdullah Muzahid

Shared Symmetric Memory Systems

Outline. EEL 5764 Graduate Computer Architecture. Chapter 4 - Multiprocessors and TLP. Déjà vu all over again?

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

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

EN2910A: Advanced Computer Architecture Topic 05: Coherency of Memory Hierarchy

MULTIPROCESSORS AND THREAD LEVEL PARALLELISM

Aleksandar Milenkovich 1

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.

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

EN2910A: Advanced Computer Architecture Topic 05: Coherency of Memory Hierarchy Prof. Sherief Reda School of Engineering Brown University

Fall 2012 EE 6633: Architecture of Parallel Computers Lecture 4: Shared Address Multiprocessors Acknowledgement: Dave Patterson, UC Berkeley

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

Computer Science 146. Computer Architecture

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

Mul$processor Architecture. CS 5334/4390 Spring 2014 Shirley Moore, Instructor February 4, 2014

Parallel Architecture. Hwansoo Han

EEC 581 Computer Architecture. Lec 11 Synchronization and Memory Consistency Models (4.5 & 4.6)

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

Lecture 24: Virtual Memory, Multiprocessors

Thread- Level Parallelism. ECE 154B Dmitri Strukov

COSC4201 Multiprocessors

??%/year. ! All microprocessor companies switch to MP (2X CPUs / 2 yrs) " Procrastination penalized: 2X sequential perf. / 5 yrs

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

Review: Multiprocessor. CPE 631 Session 21: Multiprocessors (Part 2) Potential HW Coherency Solutions. Bus Snooping Topology

UNIT I (Two Marks Questions & Answers)

Multiprocessors and Locking

EE382 Processor Design. Processor Issues for MP

Overview: Shared Memory Hardware. Shared Address Space Systems. Shared Address Space and Shared Memory Computers. Shared Memory Hardware

Overview: Shared Memory Hardware

THREAD LEVEL PARALLELISM

CS 654 Computer Architecture Summary. Peter Kemper

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

Chapter 9 Multiprocessors

Introduction. Coherency vs Consistency. Lec-11. Multi-Threading Concepts: Coherency, Consistency, and Synchronization

Computer parallelism Flynn s categories

INSTITUTO SUPERIOR TÉCNICO. Architectures for Embedded Computing

COSC 6385 Computer Architecture - Thread Level Parallelism (I)

Computer Architecture

Page 1. Lecture 12: Multiprocessor 2: Snooping Protocol, Directory Protocol, Synchronization, Consistency. Bus Snooping Topology

Multiprocessor Systems

Limitations of parallel processing

1. Memory technology & Hierarchy

Lecture 24: Multiprocessing Computer Architecture and Systems Programming ( )

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

Multiprocessors - Flynn s Taxonomy (1966)

Computer Architecture

18-447: Computer Architecture Lecture 30B: Multiprocessors. Prof. Onur Mutlu Carnegie Mellon University Spring 2013, 4/22/2013

MULTIPROCESSORS AND THREAD-LEVEL PARALLELISM (PART 1)

Cache Coherence in Bus-Based Shared Memory Multiprocessors

5008: Computer Architecture

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

CMSC 611: Advanced. Distributed & Shared Memory

Computer Organization. Chapter 16

Organisasi Sistem Komputer

Advanced Topics in Computer Architecture

Comp. Org II, Spring

CSCI 4717 Computer Architecture

Flynn s Classification

Lecture 17: Multiprocessors: Size, Consitency. Review: Networking Summary

NOW Handout Page 1. Recap: Performance Trade-offs. Shared Memory Multiprocessors. Uniprocessor View. Recap (cont) What is a Multiprocessor?

Introduction II. Overview

Computer Architecture

Parallel Processing & Multicore computers

Chapter 18 Parallel Processing

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

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

Parallel Architecture. Sathish Vadhiyar

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

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

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

Processor Architecture and Interconnect

Review. EECS 252 Graduate Computer Architecture. Lec 13 Snooping Cache and Directory Based Multiprocessors. Outline. Challenges of Parallel Processing

CSE502: Computer Architecture CSE 502: Computer Architecture

Transcription:

Handout 3 Multiprocessor and thread level parallelism

Outline Review MP Motivation SISD v SIMD (SIMT) v MIMD Centralized vs Distributed Memory MESI and Directory Cache Coherency Synchronization and Relaxed Program Order Conclusion 2012/10/24 2

Speculation: Register Renaming vs ROB Alternative to ROB is a larger physical set of registers combined with register renaming Extended registers replace function of both ROB and reservation stations Instruction issue maps names of architectural registers to physical register numbers in extended register set On issue, allocates a new unused register for the destination (which avoids WAW and WAR hazards) Speculation recovery easy because a physical register holding an instruction destination does not become the architectural register until the instruction commits Most Out-of-Order processors today use extended registers with renaming 2012/10/24 3

Terminology: Barrel threading Interleaved multi-threading Cycle i+1: an instruction from thread B is issued Cycle i+2: an instruction from thread C is issued The purpose of this type of multithreading is to remove all data dependency stalls from the execution pipeline Since one thread is relatively independent from other threads, there's less chance of one instruction in one pipe stage needing an output from an older instruction in the pipeline Conceptually, it is similar to pre-emptive multi-tasking used in operating systems One can make the analogy that the time-slice given to each active thread is one CPU cycle Terminology This type of multithreading was first called Barrel processing, in which the staves of a barrel represent the pipeline stages and their executing threads Interleaved or Pre-emptive or Fine-grained or timesliced multithreading are more modern terminology 2012/10/24 4

Time (processor cycle) Multithreaded Categories Superscalar Fine-Grained Coarse-Grained Multiprocessing Simultaneous Multithreading Thread 1 Thread 2 2012/10/24 5 Thread 3 Thread 4 Thread 5 Idle slot

Performance (vs VAX-11/780) Uniprocessor Performance (SPECint) 10000 1000 100 10 From Hennessy and Patterson, Computer Architecture: A Quantitative Approach, 4th edition, 2006 25%/year 52%/year??%/year 3X 1 1978 1980 1982 1984 1986 1988 1990 1992 1994 1996 1998 2000 2002 2004 2006 VAX : 25%/year 1978 to 1986 RISC + x86: 52%/year 1986 to 2002 RISC + x86:??%/year 2002 to present 2012/10/24 6

Other factors that favor Multiprocessors Growth in data-intensive applications Data bases, file servers, Growing interest in servers, server perf Increasing desktop perf less important Outside of graphics Improved understanding in how to use multiprocessors effectively Especially server where significant natural TLP Advantage of leveraging design investment by replication Rather than unique design 2012/10/24 7

Flynn s Taxonomy MJ Flynn, "Very High-Speed Computers", Proc of the IEEE, V 54, 1900-1909, Dec 1966 Flynn classified by data and control streams in 1966 Single Instruction Single Data (SISD) (Uniprocessor) Multiple Instruction Single Data (MISD) (????) Single Instruction Multiple Data SIMD (single PC: Vector, CM-2) Multiple Instruction Multiple Data MIMD (Clusters, SMP servers) SIMD Data Level Parallelism or SIMT MIMD Thread Level Parallelism MIMD popular because Flexible: N pgms and 1 multithreaded pgm Cost-effective: same MPU in desktop & MIMD 2012/10/24 8

Back to Basics A parallel computer is a collection of processing elements that cooperate and communicate to solve large problems fast Parallel Architecture = Computer Architecture + Communication Architecture 2 classes of multiprocessors WRT memory: 1 Centralized Memory Multiprocessor < few dozen processor chips (and < 100 cores) in 2006 Small enough to share single, centralized memory 2 Physically Distributed-Memory multiprocessor Larger number chips and cores than 1 BW demands Memory distributed among processors 2012/10/24 9

Centralized vs Distributed Memory Scale P 1 P n P 1 P n $ $ Mem $ Mem $ Interconnection network Interconnection network Mem Mem Centralized Memory Distributed Memory 2012/10/24 10

Centralized Memory Multiprocessor Also called symmetric multiprocessors (SMPs) because single main memory has a symmetric relationship to all processors Large caches single memory can satisfy memory demands of small number of processors Can scale to a few dozen processors by using a switch and by using many memory banks Although scaling beyond that is technically conceivable, it becomes less attractive as the number of processors sharing centralized memory increases 2012/10/24 11

Distributed Memory Multiprocessor Pro: Cost-effective way to scale memory bandwidth If most accesses are to local memory Pro: Reduces latency of local memory accesses Con: Communicating data between processors more complex Con: Must change software to take advantage of increased memory BW 2012/10/24 12

2 Models for Communication and Memory Architecture 1 Communication occurs by explicitly passing messages among the processors: message-passing multiprocessors 2 Communication occurs through a shared address space (via loads and stores): shared memory multiprocessors either UMA (Uniform Memory Access time) for shared address, centralized memory MP NUMA (Non Uniform Memory Access time multiprocessor) for shared address, distributed memory MP In past, confusion whether sharing means sharing physical memory (Symmetric MP) or sharing address space 2012/10/24 13

Symmetric Shared-Memory Architectures From multiple boards on a shared bus to multiple processors inside a single chip Caches both Private data are used by a single processor Shared data are used by multiple processors Caching shared data reduces latency to shared data, memory bandwidth for shared data, and interconnect bandwidth cache coherence problem 2012/10/24 14

Example Cache Coherence Problem u :5 P 1 P 2 P 3 u =? u =? $ 4 $ 5 $ u :5 3 u = 7 1 u :5 2 I/O devices Memory Processors see different values for u after event 3 With write back caches, value written back to memory depends on happenstance of which cache flushes or writes back value when» Processes accessing main memory may see very stale value Unacceptable for programming, and it s frequent! 2012/10/24 15

Basic Schemes for Enforcing Coherence Program on multiple processors will normally have copies of the same data in several caches Unlike I/O, where it s rare Rather than trying to avoid sharing in SW, SMPs use a HW protocol to maintain coherent caches Migration and Replication key to performance of shared data Migration - data can be moved to a local cache and used there in a transparent fashion Reduces both latency to access shared data that is allocated remotely and bandwidth demand on the shared memory Replication for shared data being simultaneously read, since caches make a copy of data in local cache Reduces both latency of access and contention for read shared data 2012/10/24 16

Two Classes of Cache Coherence Protocols 1 Directory based Sharing status of a block of physical memory is kept in just one location, the directory 2 Snooping Every cache with a copy of data also has a copy of sharing status of block, but no centralized state is kept All caches are accessible via some broadcast medium (a bus or switch) All cache controllers monitor or snoop on the medium to determine whether or not they have a copy of a block that is requested on a bus or switch access 2012/10/24 17

Snoopy Cache-Coherence Protocols State Address Data P 1 $ Bus snoop P n $ Mem I/O devices Cache-memory transaction Cache Controller snoops all transactions on the shared medium (bus or switch) relevant transaction if for a block it contains take action to ensure coherence» invalidate, update, or supply value depends on state of the block and the protocol Either get exclusive access before write via write invalidate or update all copies on write 2012/10/24 18

Example: Write-thru Invalidate P 1 P 2 P 3 u =? u =? 3 4 $ $ 5 $ u :5 u :5 u = 7 1 u :5 u = 7 2 I/O devices Memory Must invalidate before step 3 Write update uses more broadcast medium BW all recent MPUs use write invalidate 2012/10/24 19

Architectural Building Blocks Cache block state transition diagram FSM specifying how disposition of block changes» invalid, valid, dirty, shared Broadcast Medium Transactions (eg, bus) Fundamental system design abstraction Logically single set of wires connect several devices Protocol: arbitration, command/addr, data Every device observes every transaction Broadcast medium enforces serialization of read or write accesses Write serialization 1 st processor to get medium invalidates others copies Implies cannot complete write until it obtains bus All coherence schemes require serializing accesses to same cache block Also need to find up-to-date copy of cache block 2012/10/24 20

MESI Protocol Each cache line will be associated with one of 4 states Invalid (I); Modified (M); Exclusive (E) or Shared (S) I Snoop hit on write S Snp hit read Write-allocate M E 2012/10/24 CA 2007 21

Locate up-to-date copy of data Write-through: get up-to-date copy from memory Write through simpler if enough memory BW Write-back harder Most recent copy can be in a cache Can use same snooping mechanism 1 Snoop every address placed on the bus 2 If a processor has dirty copy of requested cache block, it provides it in response to a read request and aborts the memory access Complexity from retrieving cache block from a processor cache, which can take longer than retrieving it from memory Write-back needs lower memory bandwidth Support larger numbers of faster processors Most multiprocessors use write-back 2012/10/24 CA 2007 22

Cache behavior in response to bus Every bus transaction must check the cacheaddress tags could potentially interfere with processor cache accesses A way to reduce interference is to duplicate tags One set for caches access, one set for bus accesses Another way to reduce interference is to use L2 tags Since L2 less heavily used than L1 Every entry in L1 cache must be present in the L2 cache, called the inclusion property If Snoop gets a hit in L2 cache, then it must arbitrate for the L1 cache to update the state and possibly retrieve the data, which usually requires a stall of the processor 2012/10/24 23

Scalable Approach: Directory Every memory block has associated directory information keeps track of copies of cached blocks and their states on a miss, find directory entry, look it up, and communicate only with the nodes that have copies if necessary in scalable networks, communication with directory and copies is through network transactions Many alternatives for organizing directory information 2012/10/24 24

Directory Protocol Similar to Snoopy Protocol: Three states Shared: 1 processors have data, memory up-to-date Uncached (no processor has it; not valid in any cache) Exclusive: 1 processor (owner) has data; memory out-of-date In addition to cache state, must track which processors have data when in the shared state (usually bit vector, 1 if processor has copy) 2012/10/24 25

Scalable Approach: Directory P P Cache Cache Interconnection Network 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 M emory Directory presence bits dirty bit Read from main memory by processor i: If dirty-bit OFF then { read from main memory; turn p[i] ON; } if dirty-bit ON then { recall line from dirty proc (cache state to shared); update memory; turn dirty-bit OFF; turn p[i] ON; supply recalled data to i;} Write to main memory by processor i: If dirty-bit OFF then { supply data to i; send invalidations to all caches that have the block; turn dirty-bit ON; turn p[i] ON; } 2012/10/24 26

Understanding Program Order Initially X = 2 P1 r0=read(x) r0=r0+1 Write(r0,X) P2 r1=read(x) r1=r1+1 Write(r1,X) Possible execution sequences: P1:r0=Read(X) P2:r1=Read(X) P2:r1=Read(X), r1=2 P2:r1=r1+1, r1 = 3 P1:r0=r0+1,3=2+1 P2:Write(r1,X) P1:Write(r0,X) P1:r0=Read(X), r0 = 3 P2:r1=r1+1, r1=2+1 =3 P1:r0=r0+1, r0 = 3+1=4 P2:Write(r1,X) P1:Write(r0,X) x=3 in memory x=4 in memory P1: r0 = R(x) P1: r0 = r0+1 P1: W(r0, x) P2: r1=r(x) P2: r1 = r1 +1 P2: W(r1, x) X = 4 in memory Data race: there is a variable modified by more than one process in a way such that the results depend on who gets there first Non-mutual exclusive access to shared item X results in different outcome- Data race

Lock(L): L is a Lock at an address Two threads access one shared variable Acquire L Release L Thread 0 Thread 1 Lock(L) X = X + 1; Unlock(L) Lock(L) X = X + 1; Unlock(L) R(X) ADD W(X) 2012/10/24 28

Synchronization through a barrier Thread 0 Thread 1 X = X +1; Barrier X = X +1; 2012/10/24 29

Synchronization Why synchronization? Processors communicate through shared variables Hardware supports for synchronization Instruction that performs read-modify-write in an atomic way Example instructions 0 : lock unclaimed, 1: taken Test and set Fetch-and-increment Exchange Enter critical session (Shared resource) Test and set the lock to 1 Release the lock, reset to 0

Spin lock A spin lock whose address is in R1 R2 = 1, write 1 to Mem[R1], read Mem[R1] back to R2 (done before the write) Problem Spin lock ties up the processor Spin lock does not scale In cache coherence multiprocessor, a write of getting the lock, will generate a write miss (each processor wants to get the lock executing exch) This may cause huge traffic in the interconnection

Spin on Local Copy Read it first This causes the copy to reside in the local cache (shared state)

Coherency vs Consistency A consistent memory means that the entire address space as seen by a program (that may be running as multiple processes on a single processor or on multiple processors) will be consistent What does consistent mean? All processes/processor will see the entire memory containing the same values at all times You see what I see Coherency is related to reads/writes of a single data item Cache coherence only requires a locally (ie per-location) consistent view If every single data item is coherent, then the memory is consistent

Relaxing Program Orders Divide memory operations into data operations and synchronization operations - Synchronization operations act like a fence: - All data operations before synch in program order must complete before synch is executed - All data operations after synch in program order must wait for synch to complete - Synchs are performed in program order - Implementation of fence: processor has counter that is incremented when data op is issued, and decremented when data op is completed

Relaxed Consistency Model Release consistency R/R, R/W, W/R, W/W Can be OOO = A (This is a read) B= (This is a write) Acquire (S) SA->W SA-> R C= = D Release (S) E = F= W->SR R->SR SA->SR

And in Conclusion End of uniprocessors speedup => Multiprocessors Parallelism challenges: % parallalizable, long latency to remote memory Centralized vs distributed memory Small MP vs lower latency, larger BW for Larger MP Message Passing vs Shared Address Uniform access time vs Non-uniform access time Snooping cache over shared medium for smaller MP by invalidating other cached copies on write Sharing cached data Coherence (values returned by a read), Consistency (when a written value will be returned by a read) Shared medium serializes writes Write consistency