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

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

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

Multiprocessor Systems

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

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

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

Computer Systems Architecture

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

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

Computer Systems Architecture

Handout 3 Multiprocessor and thread level parallelism

Chap. 4 Multiprocessors and Thread-Level Parallelism

Parallel Computer Architecture Spring Shared Memory Multiprocessors Memory Coherence

Multiprocessors 1. Outline

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

Multiprocessors & Thread Level Parallelism

EITF20: Computer Architecture Part 5.2.1: IO and MultiProcessor

CS654 Advanced Computer Architecture Lec 14 Directory Based Multiprocessors

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

CMSC 611: Advanced. Distributed & Shared Memory

CMSC 411 Computer Systems Architecture Lecture 21 Multiprocessors 3

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

5008: Computer Architecture

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

Thread- Level Parallelism. ECE 154B Dmitri Strukov

CMSC 611: Advanced Computer Architecture

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

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

Aleksandar Milenkovich 1

MULTIPROCESSORS AND THREAD-LEVEL. B649 Parallel Architectures and Programming

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

Lecture 24: Thread Level Parallelism -- Distributed Shared Memory and Directory-based Coherence Protocol

Multiprocessors and Thread Level Parallelism CS 282 KAUST Spring 2010 Muhamed Mudawar

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

Computer Architecture Lecture 10: Thread Level Parallelism II (Chapter 5) Chih Wei Liu 劉志尉 National Chiao Tung University

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

CSE 502 Graduate Computer Architecture Lec 19 Directory-Based Shared-Memory Multiprocessors & MP Synchronization

Chapter 5. Multiprocessors and Thread-Level Parallelism

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

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

Chapter-4 Multiprocessors and Thread-Level Parallelism

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

COSC4201 Multiprocessors

Chapter 5. Multiprocessors and Thread-Level Parallelism

Chapter 5 Thread-Level Parallelism. Abdullah Muzahid

Shared Memory Architectures. Approaches to Building Parallel Machines

CS 152 Computer Architecture and Engineering. Lecture 19: Directory-Based Cache Protocols

CS252 Spring 2017 Graduate Computer Architecture. Lecture 12: Cache Coherence

ECSE 425 Lecture 30: Directory Coherence

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

Shared Memory SMP and Cache Coherence (cont) Adapted from UCB CS252 S01, Copyright 2001 USB

Chapter 5. Thread-Level Parallelism

MULTIPROCESSORS AND THREAD-LEVEL PARALLELISM (PART 1)

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

CS654 Advanced Computer Architecture. Lec 12 Vector Wrap-up and Multiprocessor Introduction

Shared Symmetric Memory Systems

Shared Memory Architectures. Shared Memory Multiprocessors. Caches and Cache Coherence. Cache Memories. Cache Memories Write Operation

EC 513 Computer Architecture

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

Parallel Computer Architecture Spring Distributed Shared Memory Architectures & Directory-Based Memory Coherence

Cache Coherence. CMU : Parallel Computer Architecture and Programming (Spring 2012)

1. Memory technology & Hierarchy

Scalable Cache Coherence

Caches. Parallel Systems. Caches - Finding blocks - Caches. Parallel Systems. Parallel Systems. Lecture 3 1. Lecture 3 2

Bus-Based Coherent Multiprocessors

10 Parallel Organizations: Multiprocessor / Multicore / Multicomputer Systems

Limitations of parallel processing

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

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

Flynn s Classification

Chapter 6: Multiprocessors and Thread-Level Parallelism

CS 152 Computer Architecture and Engineering. Lecture 19: Synchronization and Sequential Consistency

Interconnect Routing

Computer Science 146. Computer Architecture

Lecture 18: Coherence Protocols. Topics: coherence protocols for symmetric and distributed shared-memory multiprocessors (Sections

Multiprocessor Cache Coherency. What is Cache Coherence?

Switch Gear to Memory Consistency

Computer Architecture

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

CSC 631: High-Performance Computer Architecture

COSC 6385 Computer Architecture - Thread Level Parallelism (III)

COSC 6385 Computer Architecture. - Thread Level Parallelism (III)

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

Parallel Architecture. Hwansoo Han

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

Foundations of Computer Systems

Page 1. SMP Review. Multiprocessors. Bus Based Coherence. Bus Based Coherence. Characteristics. Cache coherence. Cache coherence

Cache Coherence in Bus-Based Shared Memory Multiprocessors

Module 5: Performance Issues in Shared Memory and Introduction to Coherence Lecture 10: Introduction to Coherence. The Lecture Contains:

INSTITUTO SUPERIOR TÉCNICO. Architectures for Embedded Computing

Cray XE6 Performance Workshop

CS 152 Computer Architecture and Engineering

CS 152 Computer Architecture and Engineering. Lecture 19: Directory-Based Cache Protocols

CS/ECE 757: Advanced Computer Architecture II (Parallel Computer Architecture) Symmetric Multiprocessors Part 1 (Chapter 5)

Chapter 9 Multiprocessors

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

CSE502: Computer Architecture CSE 502: Computer Architecture

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

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

ECE 669 Parallel Computer Architecture

Transcription:

Outline EEL 5764 Graduate Computer Architecture Chapter 4 - Multiprocessors and TLP Ann Gordon-oss Electrical and Computer Engineering University of Florida MP Motivation ID v. IMD v. MIMD Centralized vs. Distributed Challenges to Parallel Programming Consistency, Coherency, Write erialization noopy Cache Directory-based protocols and examples http://www.ann.ece.ufl.edu/ These slides are provided by: David Patterson Electrical Engineering and Computer ciences, University of California, Berkeley Modifications/additions have been made from the originals 11/7/08 2 Performance (vs. VAX-11/780) Uniprocessor Performance (PECint) - evisited.yet again 000 00 0 From Hennessy and Patterson, Computer Architecture: A Quantitative Approach, 4th edition, 2006! 25%/year 52%/year??%/year 1 1978 1980 1982 1984 1986 1988 1990 1992 1994 1996 1998 2000 2002 2004 2006 VAX : 25%/year 1978 to 1986 IC + x86: 52%/year 1986 to 2002 IC + x86:??%/year 2002 to present 11/7/08 3 3X Déjà vu all over again? today s processors are nearing an impasse as technologies approach the speed of light.. David Mitchell, The Transputer: The Time Is Now (1989) Transputer had bad timing (Uniprocessor performance!) " Procrastination rewarded: 2X seq. perf. / 1.5 years We are dedicating all of our future product development to multicore designs. This is a sea change in computing Paul Otellini, President, Intel (2005) All microprocessor companies switch to MP (2X CPUs / 2 yrs) " Procrastination penalized: 2X sequential perf. / 5 yrs Manufacturer/Year! AMD/ 05! Intel/ 06! IBM/ 04! un/ 05! Processors/chip! 2! 2! 2! 8! Threads/Processor! 1! 2! 2! 4! Threads/chip! 2! 4! 4! 32! 11/7/08 4

Other Factors Pushing Multiprocessors Growth in data-intensive applications! Data bases, file servers,! Inherently parallel - MT can t fully exploit Growing interest in servers, server perf.! Internet Increasing desktop perf. less important (outside of graphics)! Don t need to run Word any faster! But near unbounded performance increase has lead to terrible programming Other Factors Pushing Multiprocessors Lessons learned:!improved understanding in how to use multiprocessors effectively»!especially in servers where significant natural TLP!Advantages in replication rather than unique design»!in uniprocessor, redesign every few years = tremendous &D Or many designs for different customer demands (Celeron vs. Pentium)»!hift efforts to multiprocessor imple add more processors for more performance 11/7/08 5 11/7/08 6 Outline Flynn s Taxonomy M.J. Flynn, "Very High-peed Computers", Proc. of the IEEE, V 54, 1900-1909, Dec. 1966. MP Motivation ID v. IMD v. MIMD Centralized vs. Distributed Challenges to Parallel Programming Consistency, Coherency, Write erialization noopy Cache Directory-based protocols and examples 11/7/08 7 Flynn divided the world into two streams in 1966 = instruction and data ingle Instruction ingle ingle Instruction Multiple Data (ID) Data IMD (Uniprocessor) (single PC: Vector, CM-2) Multiple Instruction ingle Data (MID) (????) Multiple Instruction Multiple Data MIMD (Clusters, MP servers) IMD " Data Level Parallelism MIMD " Thread Level Parallelism MIMD popular because! Flexible: N pgms and 1 multithreaded pgm! Cost-effective: same MPU in desktop & MIMD 11/7/08 8

Outline MP Motivation ID v. IMD v. MIMD Centralized vs. Distributed Challenges to Parallel Programming Consistency, Coherency, Write erialization noopy Cache Directory-based protocols and examples 11/7/08 9 Back to Basics A parallel computer is! a collection of processing elements that cooperate and communicate to solve large problems fast. How do we build a parallel architecture?! Computer Architecture + Communication Architecture 2 classes of multiprocessors WT memory: 1.! Centralized Multiprocessor Take a single design and just keep adding more processors/cores few dozen processor chips (and < 0 cores) in 2006 mall enough to share single, centralized memory But interconnect is becoming a bottleneck.. 2.! Physically Distributed- multiprocessor Can have larger number chips and cores BW demands are met by distributing memory among processors 11/7/08 Centralized vs. Distributed P 1 $ Mem Intel $ Inter connection network Mem P n Centralized All memory is far Logically connected but on different banks cale Mem 11/7/08 11 P 1 $ AMD Mem Inter connection network Distributed Close memory and far memory P n $ Centralized Multiprocessor Also called symmetric multiprocessors (MPs) main memory has a symmetric relationship to all processors All processors see same access time to memory educing interconnect bottleneck Large caches " single memory can satisfy memory demands of small number of processors How big can the design realistically be? cale to a few dozen processors by using a switch and by using many memory banks caling beyond that is technically conceivable but.it becomes less attractive as the number of processors sharing centralized memory increases Longer wires = longer latency Higher load = higher power More contention = bottleneck for shared resource 11/7/08 12

Distributed Multiprocessor Distributed memory is a must have for big designs Pros: Cost-effective way to scale memory bandwidth If most accesses are to local memory educes latency of local memory accesses Cons: Communicating data between processors more complex oftware aware Must change software to take advantage of increased memory BW 2 Models for Communication and Architecture 1.! message-passing multiprocessors Communication occurs by explicitly passing messages among the processors 2.! shared memory multiprocessors Communication occurs through a shared address space (via loads and stores): either UMA (Uniform Access time) for shared address, centralized memory MP NUMA (Non Uniform Access time multiprocessor) for shared address, distributed memory MP More complicated In past, confusion whether sharing means sharing physical memory (ymmetric MP) or sharing address space 11/7/08 13 11/7/08 14 Outline Challenges of Parallel Processing MP Motivation ID v. IMD v. MIMD Centralized vs. Distributed Challenges to Parallel Programming Consistency, Coherency, Write erialization noopy Cache Directory-based protocols and examples First challenge is % of program inherently sequential uppose 80X speedup from 0 processors. What fraction of original program can be sequential? a.! % b.!5% c.! 1% d.!<1% 11/7/08 15 11/7/08 16

Amdahl s Law Answers peedup overall 80! ( = 80 = ( 1" Fraction ) ( 1" Fraction ) ( 1" Fraction ) 79 = 80! Fraction Fraction parallel parallel Fraction + peedup 1 Fractionparallel + 0 Fractionparallel + ) = 1 0 " 0.8! Fraction 79 / 79.2 = 99.75% parallel 11/7/08 17 1 enhanced parallel = parallel parallel parallel Challenges of Parallel Processing econd challenge is long latency to remote memory uppose 32 CPU MP, 2GHz, 200 ns remote memory (400 clock cycles), all local accesses hit memory hierarchy and base CPI is 0.5. What is the performance impact if 0.2% instructions involve remote access? a.! 1.5X b.! 2.0X c.! 2.5X 11/7/08 18 CPI Equation CPI = Base CPI + emote request rate x emote request cost CPI = 0.5 + 0.2% x 400 = 0.5 + 0.8 = 1.3 No communication is 1.3/0.5 or 2.6 faster than 0.2% instructions involve local access Challenges of Parallel Processing 1.! Need new advances in algorithms Application parallelism 2.! New programming languages Hard to program parallel applications 3.! How to deal with long remote latency impact both by architect and by the programmer! For example, reduce frequency of remote accesses either by»! Caching shared data (HW)»! estructuring the data layout to make more accesses local (W) 11/7/08 19 11/7/08 20

Outline MP Motivation ID v. IMD v. MIMD Centralized vs. Distributed Challenges to Parallel Programming Consistency, Coherency, Write erialization noopy Cache Directory-based protocols and examples ymmetric hared- Architectures - UMA From multiple boards on a shared bus to multiple processors inside a single chip Equal access time for all processors to memory via shared bus Each processor will cache both!private data are used by a single processor!hared data are used by multiple processors Advantage of caching shared data! educes latency to shared data, memory bandwidth for shared data, and interconnect bandwidth! But adds cache coherence problem 11/7/08 21 11/7/08 22 Cache Coherence Problem P 1 P 2 P 3 u =? u =? 3 4 $ $ 5 $ u :5 u :5 u = 7 1 u :5 I/O devices 2 Not Just Cache Coherency. Getting single variable values coherent isn t the only issue! Coherency alone doesn t lead to correct program execution Also deals with synchronization of different variables that interact! hared data values not only need to be coherent but order of access to those values must be protected! Processors see different values for u after event 3! With write back caches, depends on which cache flushes first»! Processes accessing main memory may see very stale value! Unacceptable for programming, and its frequent! 11/7/08 23 11/7/08 24

Intuitive Model This process should see value written immediately A = 1; P 1 P 2 /*Assume initial value of A and flag is 0*/ flag = 1; print A; expect memory to respect order between accesses to different locations issued by a given process! to preserve orders among accesses to same location by different processes Coherence is not enough!! pertains only to single location while (flag == 0); /*spin idly*/ Conceptual Mem Picture 11/7/08 25 P 1 P n P eading an address should return the last value L1 0:67 written to that address L2! Easy in uniprocessors 0:35! In multiprocessors, more complicated than just seeing the last value written»! How do you define write Disk 0:34 order between different processes Too vague and simplistic; 2 issues 1.! Coherence defines values returned by a read 2.! Consistency determines when a written value will be returned by a read Coherence defines behavior to same location, Consistency defines behavior to other locations 11/7/08 26 Defining Coherent ystem 1.! Preserve Program Order: A read by processor P to location X that follows a write by P to X, with no writes of X by another processor occurring between the write and the read by P, always returns the value written by P 2.! Coherent view of memory: ead by a processor to location X that follows a write by another processor to X returns the written value if the read and write are sufficiently separated in time (hardware recognition time) and no other writes to X occur between the two accesses 3.! Write serialization: 2 writes to same location by any 2 processors are seen in the same order by all processors! If not, a processor could keep value 1 since saw as last write! For example, if the values 1 and then 2 are written to a location, processors can never read the value of the location as 2 and then later read it as 1 Write Consistency For now assume 1.! A write does not complete (and allow the next write to occur) until all processors have seen the effect of that write 2.! The processor does not change the order of any write with respect to any other memory access " if a processor writes location A followed by location B, any processor that sees the new value of B must also see the new value of A These restrictions allow the processor to reorder reads, but forces the processor to finish writes in program order 11/7/08 27 11/7/08 28

Outline MP Motivation ID v. IMD v. MIMD Centralized vs. Distributed Challenges to Parallel Programming Consistency, Coherency, Write erialization noopy Cache Directory-based protocols and examples Basic chemes for Enforcing Coherence Problem = Program on multiple processors will normally have copies of the same data in several caches ather than trying to avoid sharing in W, MPs use a HW protocol to maintain coherent caches through:! Migration - data can be moved to a local cache and used there in a transparent fashion»! educes both latency to access shared data that is allocated remotely and bandwidth demand on the shared memory! eplication for shared data being simultaneously read, since caches make a copy of data in local cache»! educes both latency of access and contention for read shared data 11/7/08 29 11/7/08 30 2 Classes of Cache Coherence Protocols 1.! nooping 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 Emphasis for now with systems because they are small enough 2.! Directory based haring status of a block of physical memory is kept in just one location, the directory Old method revisited to deal with future larger systems Moving from bus topology to switch topology 11/7/08 31 nooping Cache-Coherence Protocols tate Address Data P 1 $ Mem Bus snoop I/O devices Each processors cache controller snoops all transactions on the shared medium (bus or switch)! Attractive solution with common broadcast bus! Only interested in relevant transaction! 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 Advantages:! Distributed model! Only a slightly more complicated state machine 11/7/08 32! Doesn t cost much WT hw P n $ Cache-memory transaction

: Write-thru Invalidate u :5 1 P 1 u =? 4 $ $ 5 $ u :5 u = 7 P 2 P 3 I/O devices Must invalidate before step 3 Could just broadcast new data value, all caches update to reflect! Write update uses more bandwidth - too much! all recent MPUs use write invalidate 11/7/08 33 u =? 2 3 u :5 u = 7 Architectural Building Blocks - What do we need? Cache block state transition diagram! FM specifying how state of block changes»! invalid, valid, dirty! Logically need FM for each cache block, not how it is implemented but we will envision this scenario Broadcast Medium (e.g., bus)! 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 Also need method to find up-to-date copy of cache block! If write-back, copy may be in anther processors L1 cache 11/7/08 34 How to locate up-to-date copy of data Cache esources for WB nooping Write-through:! eads always get up-to-date copy from memory! Write through simpler if enough memory BW Write-back harder! Most recent copy can be in any cache! Lower memory bandwidth! Most multiprocessors use write-back Can use same snooping mechanism 1.! noop 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 (which is optimized) 11/7/08 36 11/7/08 35 Normal cache tags can be used for snooping Valid bit per block makes invalidation easy eads!misses easy since rely on snooping! Processors respond if they have dirty data from a read miss Writes! Need to know if know whether any other copies of the block are cached»! No other copies " No need to place write on bus for WB»! Other copies " Need to place invalidate on bus

Cache esources for WB nooping Need one extra state bit to track whether a cache block is shared! Write to hared block " Need to place invalidate on bus and mark cache block as exclusive (if an option)! No further invalidations will be sent for that block! This processor called owner of cache block! Owner then changes state from shared to unshared (or exclusive) Protocol - tart imple nooping coherence protocol is usually implemented by incorporating a finite-state controller in each node Logically, think of a separate controller associated with each cache block! That is, snooping operations or cache requests for different blocks can proceed independently In implementations, a single controller allows multiple operations to distinct blocks to proceed in interleaved fashion! that is, one operation may be initiated before another is completed, even through only one cache access or one bus access is allowed at time 11/7/08 37 11/7/08 38 Write-through Invalidate Protocol 2 states per block in each cache! as in uniprocessor! state of a block is a p-vector of states! Hardware state bits associated with blocks that are in the cache! other blocks can be seen as being in invalid (not-present) state in that cache Writes invalidate all other cache copies (write no-alloc)! can have multiple simultaneous readers of block,but write invalidates them Prd / Busd tate Tag Data V I Prd/ -- PrWr / BusWr BusWr / - PrWr / BusWr tate Tag Data Prd: Processor ead P 1 P n PrWr: Processor Write $ $ Busd: Bus ead Bus BusWr: Bus Write Mem I/O devices 11/7/08 39 Is 2-state Protocol Coherent? Processor only observes state of memory system by issuing memory operations! If processor only does ALU operations, doesn t see see state of memory Assume bus transactions and memory operations are atomic and a one-level cache! one bus transaction complete before next one starts! processor waits for memory operation to complete before issuing next! with one-level cache, assume invalidations applied during bus transaction All writes go to bus + atomicity! Writes serialized by order in which they appear on bus (bus order) => invalidations applied to caches in bus order How to insert reads in this order?! Important since processors see writes through reads, so determines whether write serialization is satisfied! But read hits may happen independently and do not appear on bus or enter directly in bus order Let s understand other ordering issues 11/7/08 40

Ordering Write Back noopy Protocol P 0 : P 1 : P 2 : W W Writes establish a partial ordering for the reads Doesn t constrain ordering of reads, though shared-medium (bus) will order read misses too! any order among reads between writes is fine, as long as in program order Look at invalidation protocol with a write-back cache! noops every address on bus! If cache has a dirty copy of requested block, provides that block in response to the read request and aborts the memory access Each memory block is in one state:! Clean in all caches and up-to-date in memory (hared)! O Dirty in exactly one cache (Exclusive)! O Not in any caches Each cache block is in one state (track these):! hared : block can be read! O Exclusive : cache has only copy, its writeable, and dirty! O Invalid : block contains no data (in uniprocessor cache too) ead misses: cause all caches to snoop bus Writes to clean blocks are treated as misses 11/7/08 41 11/7/08 42 Write-Back tate Machine - CPU tate machine for CPU requests for each cache block Cache Block tate CPU Write Place Write Miss on bus CPU read hit CPU write hit Invalid Exclusive (read/write) CPU ead Place read miss on bus CPU read miss Write back block, Place read miss on bus CPU ead hit hared (read/only) CPU ead miss Place read miss on bus CPU Write Place Write Miss on Bus CPU Write Miss Write back cache block 11/7/08 Place write miss on bus 43 Write-Back tate Machine- Bus request tate machine for bus requests for each cache block Invalid Write miss for this block Write Back Block; (abort memory access) Exclusive (read/write) Write miss for this block ead miss for this block Write Back Block; (abort memory access) hared (read/only) 11/7/08 44

Write-back tate Machine - Putting it all Together tate machine for CPU requests for each cache block and for bus requests for each cache block Cache Block tate Write miss for this block Write Back Block; (abort memory access) Write miss for this block Invalid CPU ead Place read miss CPU Write on bus Place Write Miss on bus CPU read miss Write back block, Exclusive (read/write) Place read miss on bus CPU ead hit hared (read/only) CPU ead miss Place read miss on bus CPU Write Place Write Miss on Bus ead miss for this block Write Back Block; (abort memory access) CPU read hit CPU Write Miss CPU write hit Write back cache block 11/7/08 Place write miss on bus 45 P1 P2 Bus step tate Addr Value tate Addr Value Action Proc. Addr Value Addr Value P1: Write to P1: P1: ead ead P2: ead P2: Write 20 to P2: Write 40 to A2 * Assumes and A2 map to same cache block, but!= A2 * Initial cache state is invalid * Assume write allocate 11/7/08 46 P1 P2 Bus step tate Addr Value tate Addr Value Action Proc. Addr Value Addr Value P1: Write to Excl. WrMs P1 P1: P1: ead ead P2: ead P1 P2 Bus step tate Addr Value tate Addr Value Action Proc. Addr Value Addr Value P1: Write to Excl. WrMs P1 P1: P1: ead ead Excl. P2: ead P2: Write 20 to P2: Write 40 to A2 P2: Write 20 to P2: Write 40 to A2 * Assumes and A2 map to same cache block, but!= A2 * Initial cache state is invalid * Assume write allocate * Assumes and A2 map to same cache block, but!= A2 * Initial cache state is invalid * Assume write allocate 11/7/08 47 11/7/08 48

Goes to shared because it is clean step P1 P1:Write Write to to P1:P1: ead ead P2: P2: ead P1 tate Addr Excl. Excl. har. P2 Value tate Addr har. har. Bus Value Action Proc. Addr WrMs P1 dms WrBk dda P2 P1 P2 Value Addr Value P2: P2: Write Write 20 to to P2: A2 P2: Write Write 40 to to A2 * Assumes and A2 map to same cache block, but!= A2 * Initial cache state is invalid * Assume write allocate 11/7/08 * Assumes and A2 map to same cache block, but!= A2 * Initial cache state is invalid * Assume write allocate 49 11/7/08 * Assumes and A2 map to same cache block, but!= A2 * Initial cache state is invalid * Assume write allocate 11/7/08 50 * Assumes and A2 map to same cache block, but!= A2 * Initial cache state is invalid * Assume write allocate 51 11/7/08 52

Implementation Complications Write aces - Who writes first??! Cannot update cache until bus is obtained»! Otherwise, another processor may get bus first, and then write the same cache block!! Two step process:»! Arbitrate for bus»! Place miss on bus and complete operation! If write miss occurs to block while waiting for bus, handle miss (invalidate may be needed) and then restart.! plit transaction bus:»! Bus transaction is not atomic: can have multiple outstanding transactions for a block»! Multiple misses can interleave, allowing two caches to grab block in the Exclusive state»! Must track and prevent multiple misses for one block Must support interventions and invalidations Limitations in ymmetric hared- Multiprocessors and nooping Protocols ingle memory accommodate all CPUs even though there may be multiple memory banks Bus-based!must support both coherence traffic & normal memory traffic!olution:»!multiple buses or interconnection networks (cross bar or small point-to-point) 11/7/08 53 11/7/08 54 Performance of ymmetric hared- Multiprocessors Cache performance is combination of 1.! Uniprocessor cache miss traffic 2.! Traffic caused by communication»! esults in invalidations and subsequent cache misses 4 th C: coherence miss! Joins Compulsory, Capacity, Conflict! How significant are coherence misses? Coherency Misses 1.! True sharing misses Processes must share data for communication or processing Types: Invalidates due to 1 st write to shared block eads by another CPU of modified block in different cache Miss would still occur if block size were 1 word 2.! False sharing misses When a block is invalidated because some word in the block, other than the one being read, is written into Invalidation does not cause a new value to be communicated, but only causes an extra cache miss Block is shared, but no word in block is actually shared " miss would not occur if block size were 1 word Larger block sizes lead to more false sharing misses 11/7/08 55 11/7/08 56

: True v. False haring v. Hit? Assume x1 and x2 in same cache block, different addresses. P1 and P2 both read x1 and x2 before. Time P1 P2 True, False, Hit? Why? 1 Write x1 2 ead x2 3 Write x1 4 Write x2 5 ead x2 True miss; invalidate x1 in P2 False miss; x1 irrelevant to P2 False miss; x1 irrelevant to P2 False miss; x1 irrelevant to P2 True miss; invalidate x2 in P1 MP Performance 4 Processor Commercial Workload: OLTP, Decision upport (Database), earch Engine True and false sharing doesn t change much as cache size increases 11/7/08 57 11/7/08 58 MP Performance 2MB Cache Commercial Workload: OLTP, Decision upport (Database), earch Engine True and false sharing increase as number of CPUs increase. This will become more significant in the future as we move to many more processors cycles per instruction 3 2.5 2 1.5 1 0.5 Instruction Conflict/Capacity Cold False haring True haring Outline Coherence Write Consistency nooping Building Blocks nooping protocols and examples Coherence traffic and Performance on MP Directory-based protocols and examples 0 1 2 4 6 8 Processor count 11/7/08 59 11/7/08 60

A Cache Coherent ystem Must: Provide set of states, state transition diagram, and actions Manage coherence protocol! (0) Determine when to invoke coherence protocol! (a) Find info about state of block in other caches to determine action»! whether need to communicate with other cached copies! (b) Locate the other copies! (c) Communicate with those copies (invalidate/update) (0) is done the same way on all systems! state of the line is maintained in the cache! protocol is invoked if an access fault occurs on the line Different approaches (snoopy and directory based) distinguished by (a) to (c) Bus-based Coherence All of (a), (b), (c) done through broadcast on bus! faulting processor sends out a search! others respond to the search probe and take necessary action Conceptually simple, but broadcast doesn t scale with p! on bus, bus bandwidth doesn t scale! on scalable network, every fault leads to at least p network transactions calable coherence, how do we keep track as the number of processors gets larger! can have same cache states and state transition diagram! different mechanisms to manage protocol - directory based 11/7/08 61 11/7/08 62 calable Approach: Directories 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»! Presence bit keeps track of which processors have it. Use bit vector to save space»! Minimizes traffic, don t just broadcast for each access»! Minimizes processing, not all processors have to check every address! in scalable networks, communication with directory and copies is through network transactions Many alternatives for organizing directory information 11/7/08 63 Basic Operation of Directory P Cache : P Cache Interconnection Network presence bits dirty bit Directory k processors.! ead from main memory by processor i: 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»! If dirty-bit OFF then { read from main memory; turn p[i] ON; }»! if dirty-bit ON then { recall line from dirty proc; 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 {send invalidations to all caches that have the block; turn dirty-bit ON; turn p[i] ON;... } 11/7/08 64

Directory Protocol imilar to noopy Protocol: Three states similar to snoopy! hared:! 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) - presence vector Keep it simple(r):! Writes to non-exclusive data => write miss! Processor blocks until access completes! Assume messages received and acted upon in order sent (not realistic but we will assume) tate Transition Diagram for One Cache Block in Directory Based ystem tates identical to snoopy case; transactions very similar. Transitions caused by read misses, write misses, invalidates, data fetch requests 11/7/08 65 11/7/08 66 CPU -Cache tate Machine tate machine for CPU requests for each memory block Invalid state if in memory Fetch/Invalidate send Data Write Back message to home directory Invalid Exclusive (read/write) Invalidate CPU ead end ead Miss message CPU Write: end Write Miss msg to h.d. CPU ead hit hared (read/only) CPU read miss: end ead Miss CPU Write: end Write Miss message to home directory Fetch: send Data Write Back message to home directory CPU read miss: send Data Write Back message and read miss to home directory CPU read hit CPU write miss: CPU write hit send Data Write Back message 11/7/08 and Write Miss to home directory 67 tate Transition Diagram for Directory ame states & structure as the transition diagram for an individual cache 2 actions: update of directory state & send messages to satisfy requests Tracks all copies of memory block Also indicates an action that updates the sharing set, harers, as well as sending a message 11/7/08 68

Directory tate Machine tate machine for Directory requests for each memory block Uncached state Uncached if in memory Data Write Back: harers = {} (Write back block) Write Miss: send Fetch/Invalidate; harers = {P}; send Data Value eply msg to remote cache ead miss: harers = {P} send Data Value eply Write Miss: harers = {P}; send Data Value eply msg hared (read only) Write Miss: send Invalidate to harers; then harers = {P}; send Data Value eply msg ead miss: send Fetch; harers += {P}; send Data Value eply ead miss: harers += {P}; send Data Value eply Exclusive (read/write) msg to remote cache 11/7/08 (Write back block) 69 step P1: Write to P1: ead P2: ead P2: Write 20 to " P2: Write 40 to A2 Processor 1 Processor 2 Interconnect Directory P1 P2 Bus Directory Memor tateaddr ValuetateAddrValueActionProc. Addr Value Addr tate{procs}value and A2 map to the same cache block but different memory addresses 11/7/08 70 Processor 1 Processor 2 Interconnect Directory P1 P2 Bus Directory Memor step tateaddr ValuetateAddrValueActionProc. Addr Value Addr tate{procs}value P1: Write to WrMs P1 Ex {P1} Excl. Dap P1 0 P1: ead P2: ead Processor 1 Processor 2 Interconnect Directory P1 P2 Bus Directory Memor step tateaddr ValuetateAddrValueActionProc. Addr Value Addr tate{procs}value P1: Write to WrMs P1 Ex {P1} Excl. Dap P1 0 P1: ead Excl. P2: ead P2: Write 20 to " P2: Write 40 to A2 P2: Write 20 to " P2: Write 40 to A2 and A2 map to the same cache block but different memory addresses and A2 map to the same cache block but different memory addresses 11/7/08 71 11/7/08 72

Processor 1 Processor 2 Interconnect Directory P1 P2 Bus Directory Memor step tateaddr ValuetateAddrValueActionProc. Addr Value Addr tate{procs}value P1: Write to WrMs P1 Ex {P1} Excl. Dap P1 0 P1: ead Excl. P2: ead har. dms P2 har. Ftch P1 {P1} har. Dap P2 har. {P1,P2} P2: Write 20 to " P2: Write 40 to A2 Processor 1 Processor 2 Interconnect Directory P1 P2 Bus Directory Memor step tateaddr ValuetateAddrValueActionProc. Addr Value Addr tate{procs}value P1: Write to WrMs P1 Ex {P1} Excl. Dap P1 0 P1: ead Excl. P2: ead har. dms P2 har. Ftch P1 {P1} har. Dap P2 har. {P1,P2} P2: Write 20 to " Excl. 20 WrMs P2 Inv. Inval. P1 Excl. {P2} P2: Write 40 to A2 Write Back and A2 map to the same cache block but different memory addresses and A2 map to the same cache block but different memory addresses 11/7/08 73 11/7/08 74 Processor 1 Processor 2 Interconnect Directory P1 P2 Bus Directory Memor step tateaddr ValuetateAddrValueActionProc. Addr Value Addr tate{procs}value P1: Write to WrMs P1 Ex {P1} Excl. Dap P1 0 P1: ead Excl. P2: ead har. dms P2 har. Ftch P1 {P1} har. Dap P2 har. {P1,P2} P2: Write 20 to " Excl. 20 WrMs P2 Inv. Inval. P1 Excl. {P2} P2: Write 40 to A2 WrMs P2 A2 A2 Excl. {P2} 0 WrBk P2 20 Unca. {} 20 Excl. A2 40 Dap P2 A2 0 A2 Excl. {P2} 0 Implementing a Directory We assume operations atomic, but they are not; reality is much harder; must avoid deadlock when run out of bufffers in network (see Appendix E) Optimizations:! read miss or write miss in Exclusive: send data directly to requestor from owner vs. 1st to memory and then from memory to requestor and A2 map to the same cache block but different memory addresses 11/7/08 75 11/7/08 76

Directory Protocol (1 st ead) Directory Protocol (ead hare) E E ead pa P1: pa /reply Dir ctrl M P1: pa P2: pa /_ /reply Dir ctrl M U U E E E E $ P1 $ P2 /req I ld va -> rd pa I 11/7/08 77 /_ $ P1 /_ $ P2 /req /req I ld va -> rd pa I ld va -> rd pa 11/7/08 78 Directory Protocol (Wr to shared) Directory Protocol (Wr to Ex) E X/invalidate&reply U/_ D E X/invalidate&reply P1: pa EX P2: pa reply xd(pa) /_ U /reply Dir ctrl M Inv ACK P1: pa Inv pa /_ U /reply Dir ctrl M ead_toupdate pa ead_to_update pa Invalidate pa Write_back pa eply xd(pa) W/_ E W/req E E W/req E /_ $ P1 /_ $ P2 Inv/_ /req Inv/_ /req I st va -> wr pa I 11/7/08 79 W/_ E W/req E W/_ E W/req E W/req E W/req E /_ $ P1 /_ $ P2 Inv/_ /req Inv/_ /req I I st va -> wr pa 11/7/08 80