Shared Memory Multiprocessors

Similar documents
Cache Coherence: Part 1

Cache Coherence in Bus-Based Shared Memory Multiprocessors

L7 Shared Memory Multiprocessors. Shared Memory Multiprocessors

Processor Architecture

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

Parallel Computer Architecture Lecture 5: Cache Coherence. Chris Craik (TA) Carnegie Mellon University

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

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

Switch Gear to Memory Consistency

NOW Handout Page 1. Recap. Protocol Design Space of Snooping Cache Coherent Multiprocessors. Sequential Consistency.

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

Lecture 11: Snooping Cache Coherence: Part II. CMU : Parallel Computer Architecture and Programming (Spring 2012)

Module 10: "Design of Shared Memory Multiprocessors" Lecture 20: "Performance of Coherence Protocols" MOESI protocol.

Computer Architecture

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

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

Snooping coherence protocols (cont.)

Shared Memory Architectures. Approaches to Building Parallel Machines

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

Lecture 9 Outline. Lower-Level Protocol Choices. MESI (4-state) Invalidation Protocol. MESI: Processor-Initiated Transactions

Recall: Sequential Consistency. CS 258 Parallel Computer Architecture Lecture 15. Sequential Consistency and Snoopy Protocols

Cache Coherence. (Architectural Supports for Efficient Shared Memory) Mainak Chaudhuri

4 Chip Multiprocessors (I) Chip Multiprocessors (ACS MPhil) Robert Mullins

Multicore Workshop. Cache Coherency. Mark Bull David Henty. EPCC, University of Edinburgh

Bus-Based Coherent Multiprocessors

Advanced OpenMP. Lecture 3: Cache Coherency

Lecture-22 (Cache Coherence Protocols) CS422-Spring

Snooping-Based Cache Coherence

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

Approaches to Building Parallel Machines. Shared Memory Architectures. Example Cache Coherence Problem. Shared Cache Architectures

Snooping coherence protocols (cont.)

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

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

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

Lecture 24: Multiprocessing Computer Architecture and Systems Programming ( )

Lecture 3: Snooping Protocols. Topics: snooping-based cache coherence implementations

Alewife Messaging. Sharing of Network Interface. Alewife User-level event mechanism. CS252 Graduate Computer Architecture.

Cray XE6 Performance Workshop

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

Scalable Cache Coherence. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

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

Memory Hierarchy in a Multiprocessor

Scalable Cache Coherence

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

Cache Coherence. Silvina Hanono Wachman Computer Science & Artificial Intelligence Lab M.I.T.

CS315A Midterm Solutions

Portland State University ECE 588/688. Cache Coherence Protocols

Multiprocessors & Thread Level Parallelism

Cache Coherence. Silvina Hanono Wachman Computer Science & Artificial Intelligence Lab M.I.T.

Chapter 5. Multiprocessors and Thread-Level Parallelism

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

ECE PP used in class for assessing cache coherence protocols

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

MULTIPROCESSORS AND THREAD-LEVEL. B649 Parallel Architectures and Programming

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

Overview: Shared Memory Hardware

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

EC 513 Computer Architecture

CSE502: Computer Architecture CSE 502: Computer Architecture

Lecture 20: Multi-Cache Designs. Spring 2018 Jason Tang

12 Cache-Organization 1

Cache Coherence. Todd C. Mowry CS 740 November 10, Topics. The Cache Coherence Problem Snoopy Protocols Directory Protocols

1. Memory technology & Hierarchy

Incoherent each cache copy behaves as an individual copy, instead of as the same memory location.

Foundations of Computer Systems

CSC 631: High-Performance Computer Architecture

Multiprocessors 1. Outline

Multiprocessor Cache Coherency. What is Cache Coherence?

Flynn s Classification

Shared Memory Multiprocessors

Computer Architecture

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

Computer Systems Architecture

10 Parallel Organizations: Multiprocessor / Multicore / Multicomputer Systems

Scalable Cache Coherence

Lecture 7: Implementing Cache Coherence. Topics: implementation details

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

Chapter 5. Multiprocessors and Thread-Level Parallelism

Basic Architecture of SMP. Shared Memory Multiprocessors. Cache Coherency -- The Problem. Cache Coherency, The Goal.

Fall 2015 :: CSE 610 Parallel Computer Architectures. Cache Coherence. Nima Honarmand

ECE7660 Parallel Computer Architecture. Shared Memory Multiprocessors

Computer Architecture and Engineering CS152 Quiz #5 April 27th, 2016 Professor George Michelogiannakis Name: <ANSWER KEY>

ECE 485/585 Microprocessor System Design

Aleksandar Milenkovich 1

Parallel Arch. Review

Portland State University ECE 588/688. Directory-Based Cache Coherence Protocols

Chapter 5 Thread-Level Parallelism. Abdullah Muzahid

Cache Coherence and Atomic Operations in Hardware

Page 1. Cache Coherence

Multiprocessors II: CC-NUMA DSM. CC-NUMA for Large Systems

Handout 3 Multiprocessor and thread level parallelism

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

A three-state update protocol

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

EE382 Processor Design. Processor Issues for MP

Lecture 10: Cache Coherence. Parallel Computer Architecture and Programming CMU / 清华 大学, Summer 2017

Chapter 5. Thread-Level Parallelism

The Cache-Coherence Problem

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

Physical Design of Snoop-Based Cache Coherence on Multiprocessors

Transcription:

Parallel Computing Shared Memory Multiprocessors Hwansoo Han

Cache Coherence Problem P 0 P 1 P 2 cache load r1 (100) load r1 (100) r1 =? r1 =? 4 cache 5 cache store b (100) 3 100: a 100: a 1 Memory 2 I/O devices 100: a 2

Coherent Memory System: Intuition Reading a location should return latest value written by any process Easy in uniprocessors Except for I/O (DMA) Coherence between I/O devices and processors But infrequent: SW solutions work Uncacheable operations, flush pages, pass I/O data through caches Coherence problem is more pervasive and performance critical in multiprocessors Much higher impact on hardware design 3

Problems with the Intuition The meaning of last value should be well-defined In sequential case: last is defined in terms of program order, not time Program order: order of operations in machine code In parallel case: Program order defined within a process (thread), but orders across processes should be defined to make sense Meaningful semantics on parallel case Involve both cache coherence and memory consistency model 4

Coherence and Consistency Cache coherence Multiple local caches should work as if they are unified one Read should get the value of the last write to any local cache Memory consistency Sequential consistency: execution should be the same result as if... Some serial order among operations from multiple processors Program order among operarions in each individual processor Weak consistency: needed for better performance Written values are available after exit of critical section (synchronization) <Proc 1> A = 1 B = 1 <Proc 2> x = B y = A (x,y) = (0,0), (0,1), (1,1) : possible values But (1,0) is impossible in sequential consistency * All values are initialized to zeros * Assume all statements are atomic 5

Cache Coherence Solutions Software based: Often used in clusters of workstations or PCs (e.g. Treadmarks ) Extend virtual memory system to perform more work on page faults Send messages to remote machines if necessary Hardware based: two most common variations exist Snoopy schemes Rely on broadcast to observe all coherence traffic Well suited for buses and small-sized systems (e.g. SGI Challenge) Directory schemes Uses centralized information to avoid broadcast Scales well to large numbers of processors (e.g. SGI Origin 2000) 6

Shared Caches Processors share a single cache Essentially eliminating the problem Useful for very small machines Problems are limited cache bandwidth and cache interference Benefits are fine-grain sharing and prefetch effects P 0 P 1 shared cache Memory Intel Quad Core i7 7

Snoopy Cache Coherence Schemes Basic idea All coherence-related activities are broadcast to all processors E.g. on a global bus Each processor (or its representative) monitors (a.k.a. snoops ) these actions and reacts to any which are relevant to the current contents of its cache If another processor wishes to write to a line, you may need to invalidate (i.e. discard) the copy in your own cache If another processor whishes to read a line for which you have a dirty copy, you may need to apply Most common approach in multiprocessors SGI Challenge, SUN Enterprise, multiprocessor PCs, etc. 8

Implementing a Snoopy Protocol Cache controller now receives inputs from both: Requests from processor, bus requests/response from snooper React on inputs by ignoring or taking actions Update states, respond with data, generate new bus transactions Protocol is a distributed algorithm Cooperating state machines Set of states, state transition diagram, actions Granularity of coherence is typically a cache block Same as that of allocation in cache and transfer to/from cache 9

Coherence with Write-through Caches P 0 P n cache Bus snoop cache cache-memory transaction Memory I/O devices Key extensions to uniprocessors Snooping, invalidating/updating caches No new states or bus transactions in this case Invalidation- vs. update-based protocols Write propagation Invalid state causes miss on later access Memory is up-to-date via write-through 10

Write-through State Transition Two states per block, as in uniprocessor State of a block can be independently collected to build cache state State bits associated with only blocks in the cache Other blocks regarded as being in invalid (not-present) state Write will invalidate all other caches, not local one Can have multiple simultaneous readers, but write invalidates them PrRd/- BusWr/- Write-Thru, no-allocate-on-miss Invalidation Protocol V I PrWr/BusWr PrWr/BusWr PrRd/BusRd Processor-initiated transactions Bus snooper-initiated transactions 11

Problem with Write-Through High bandwidth requirements Every write from every processor goes to shared bus and memory E.g., a 3GHz, 1CPI processor, 15% of instructions are 8 byte stores Each processor generates 450M stores or 3.6GB data per second 5GB/s bus can support only 1 processor without saturating Write-through especially unpopular for SMPs Write-back caches absorb most writes as cache hits Write hits do not go on bus But need to ensure write propagation and serialization Need more sophisticated protocols: large design space exists 12

Write-Back Snoopy Protocols No need to change processor, main memory, cache Extend cache controller and exploit bus (provides serialization) Dirty state now also indicates exclusive ownership Exclusive: only cache with a valid copy (main memory may be so, too) Owner: responsible for supplying block upon a request for it Design space Invalidation- vs. Updated-based protocols Set of states 13

Write-Back, Invalidate-Based Protocol Exclusive state means Can modify without notifying anyone else i.e. no bus transaction Must first get block in exclusive state before writing into it Even if already in valid state, need transaction (as if write miss) Store to non-dirty block Generates a read-exclusive bus transaction Tell others about impending write, obtain exclusive ownership Makes the write visible, (notify write is performed to other processors) May be actually observed later (by other processors via read misses) Write hit made visible, when block updated in writer s cache Only one RdX can succeed at a time for a block serialized by bus Read and Read-exclusive (RdX) bus transactions drive coherence actions 14

Write-Back, Update-Based Protocol A write operation updates values in other caches Update bus transaction new transaction Advantages Other processors don t miss on next access reduced latency In invalidation protocols, they would miss and cause more transactions Single bus transaction to update several caches can save bandwidth Also, only the word written is transferred, not whole block Disadvantages Multiple writes by the same processor cause multiple update transactions In invalidation, first write gets exclusive ownership, other writes are performed locally Detailed tradeoffs are more complex 15

Invalidate vs. Update Basic question of program behavior Is a block (written by one) read by others before it is rewritten? Yes:, P0Wr, P1Rd, P0Wr, No:, P0Wr, P0Wr, P1Rd, Invalidation Yes: readers will take a miss No: multiple writes without additional traffic Update Yes: readers will not miss, if they had a copy previously Single bus transaction to update all copies in other caches No: multiple useless updates, even to dead copies Need to look at program behavior and hardware complexity Invalidation protocols much more popular Some systems provide both, or even hybrid 16

MSI Write-back Invalidation Protocol States Invalid (I) Shared (S) one or more Dirty or Modified (M) one copy Processor events PrRd read from load instruction PrWr write from store instruction Bus transactions BusRd asks for copy with no intent to modify BusRdX ask for copy with intent to modify BusWr (Flush) updates memory Actions Update state, perform bus transaction, flush value onto bus 17

State Transition Diagram PrRd/- PrWr/- Write-Back, Invalidation Protocol M PrWr/BusRdX BusRd/Flush PrWr/BusRdX S BusRdX/Flush PrRd/BusRd PrRd/- BusRd/- BusRdX/- Write to shared block Already have latest data; can use upgrade (BusUpgr) instead of BusRdx(S M) I Replacement changes state of two blocks: outgoing and incoming 18

Satisfying Coherence Write propagation is clear Write serialization All writes that appear on the bus (BusRdX) ordered by the bus Write performed in writer s cache before it handles other transactions ordered in the same way even w.r.t. writer Reads that appear on the bus ordered w.r.t. these Writes that don t appear on the bus Writes in M state from the same processor, P Reads by all processors see writes in the same order Read by P itself will see them in this order Read by other processors will generate BusRd and the snooper in P will respond with Flush. Thus, the others will see the content 19

Lower-Level Protocol Choices BusRd observed in M state What transition should be made? Depends on expectations of access patterns S: assuming that I ll read it again soon, rather than other will write Good for mostly read again What about migratory data Read-write operations from me, another, the third,... I state is better don t have to be invalidated from other s write Synapse transitioned to I state Sequent Symmetry and MIT Alewife use adaptive protocols Choices can affect performance of memory system 20

MESI Invalidation Protocol Problem with MSI protocol Read-and-modify requires 2 bus transactions even if not shared data BusRd (I S) followed by BusRdX or BusUpgr (S M) E.g. sequential programs will not share data even on multiprocessors E.g. parallel programs also have many private data not to share Add exclusive state Allows to write locally without bus transaction, but not modified 4 States Invalid Exclusive (or exclusive-clean) only this cache has copy, but not modified Shared two or more caches may have copies Modified (dirty) I E on PrRd if no other processor has a copy Need shared signal on bus wired-or asserted in response to BusRd 21

MESI State Transition Diagram M PrRd,PrWr/- Write-Back, Invalidation Protocol PrWr/- PrWr/BusRdX E BusRd/Flush PrWr/BusRdX PrRd/- BusRd/Flush BusRdX/Flush PrRd/BusRd(S ) S BusRdX/Flush BusRdX/Flush PrRd/- PrRd/ BusRd/Flush BusRd(S) I BusRd(S) means shared line asserted on BusRd transaction Flush : if cache-to-cache sharing, only one cache flushes data Extended to MOESI protocol: Owned state others may be in shared state, memory may be invalid (Owned state is responsible for memory write-back) 22

Lower-Level Protocol Choices Who supplies data on miss when not in M state Memory or cache? Original (Illinois MESI): cache, since assumed faster than memory : cache-to-cache sharing Not true in modern systems intervening in another cache more expensive than getting from memory Cache-to-cache sharing also adds complexity How does memory know it should supply data must wait for caches Selection algorithm if multiple caches have valid data But valuable for cache-coherent machines with distributed memory May be cheaper to obtain from nearby cache than distant memory Especially when constructed out of SMP nodes (Stanford DASH) 23

Dragon: Write-Back Update Protocol 5 states (or 4 states without Invalid) Invalid (I): no data in cache block if in cache, cannot be invalid Exclusive-clean or Exclusive (E): I and memory have it Shared clean (Sc): I, others, and maybe memory, but I m not owner Shared modified (Sm): I and others but not memory, but I m the owener Sm and Sc can coexist in different caches, with only one Sm Modified or Dirty (D): I and nobody else New features New processor events PrRdMiss, PrWrMiss introduced to specify actions, when block not present in cache New bus transactions BusUpd broadcasts single word written on bus: updates other relevant caches 24

Dragon State Transition Diagram Write-Back, Update Protocol I PrRd/- PrRdMiss/BusRd(S) E BusRd/- Sc PrRd/- BusUpd/Update PrRdMiss/BusRd(S) I PrWr/- PrWr/BusUpd(S) PrWr/BusUpd(S ) BusUpd/Update I PrWrMiss/(BusRd(S); BusUpd) Sm BusRd/Flush M PrWrMiss/BusRd(S) I PrRd/- PrWr/BusUpd(S) BusRd/Flush PrWr/BusUpd(S ) PrRd/- PrWr/- 25

Low-Level Protocol Choices Can shared-modified state be eliminated? Yes, if update memory as well on BusUpd transactions (DEC Firefly) Dragon protocol doesn t (assume DRAM memory slow to update) Should replacement of an Sc block be broadcast? Would allow last copy to go to E state and not generate updates Replacement bus transaction is not in critical path, later update may be in critical path Shouldn t update local copy on write hit before controller gets bus Otherwise, it can mess up serialization Coherence, consistency considerations much like write-through case In general, many subtle race conditions in protocols 26

Assessing Protocol Tradeoffs Tradeoffs affected by performance and organization characteristics Part art and part science Art: experience, intuition and aesthetics of designers Science: workload-driven evaluation for cost-performance Methodology Use simulator choose parameters per earlier methodology e.g. 64KB~1MB, 4-way, 64-byte block, 16 processors Use idealized memory performance model to avoid changes of reference across processors Cheap simulation no need to model contention 27

Impact of Protocol Optimizations Effect of E state, and of BusUpgr instead of BusRdX MSI vs. MESI doesn t seem to matter for BW for these workloads Upgrades instead of read-exclusive helps Ill : MESI 3St: MSI w/ BusUpgr (S M) RdEx: MSI w/ BusRdX (S M) 28

Impact of Cache Block Size Multiprocessors add new kind of misses Coherence misses in addition to cold, capacity, conflict Both miss rate and traffic matter Reducing misses in invalidation protocol Capacity enlarge cache; increase block size (if spatial locality) Conflict increase associativity Cold and coherence only block size Increasing block size has pros and cons Can reduce misses if spatial locality is good Can hurt too Increase misses due to false sharing, if spatial locality is not good Increase misses due to conflicts in fixed-size cache Increase traffic due to fetching unnecessary data and false sharing Can increase miss penalty and perhaps hit cost 29

Miss rate (%) Impact of Block Size on Miss Rate Results shown here only for default problem size Varied behavior for different problem size and p as well False sharing increase for some as block size larger Radiosity, Radix for 64 bytes and up 30

Traffic (bytes/instruction) Impact of Block Size on Traffic Traffic affects performance indirectly contention Results different from miss rate traffic almost always increase When working set fits, overall traffic still small, except Radix (due to false sharing) Fixed overhead is significant component 16~32B block is optimal rather than 8B Working set doesn t fit (on 64KB cache) even 128B good for Ocean due to many capacity misses 31

Making Large Blocks More Effective Software Improve spatial locality by better data structuring Compiler techniques Hardware Retain granularity of transfer but reduce granularity of coherence Use subblocks: same tag but different state bits Reduce both granularities, but prefetch more blocks on a miss Proposals for adjustable cache block size More subtle approach delay propagation of invalidations and perform all at once, but can change consistency model Use update instead of invalidate protocol to reduce false sharing effect 32

Update vs. Invalidate Much debate over the years Tradeoff depends on sharing patterns Intuition If processor that was using the data before write wants to see the new value in the future, update should do better e.g. producerconsumer pattern If processor holding the old data unlikely to use again, updates not good useless update traffic consumes interconnect and controller resource Can construct scenarios where one or the other is much better Can combine them in hybrid schemes Competitive: observe patterns at runtime and change protocol 33

Update vs. Invalidate : Miss Rates Depends on patterns Lots of coherence misses: updates help Lots of capacity misses: updates may hurt (keep useless data in cache) Updates seem to help, but this ignores upgrade and update traffic 0.60 2.50 34

Upgrade/update upgrade or update rate (%) rates (%) upgrade or update rates (%) Upgrade and Update Rates (Traffic) Update traffic is substantial Main cause is multiple writes by a processor before a read by other Many bus transactions could delay updates or use merging Overall, trend is away from update based protocol as default Updates potentially have greater problems for scalable systems (Rates relative to total memory references) 35