Memory Consistency Models

Slides:



Advertisements
Similar presentations
Chapter 5 Part I: Shared Memory Multiprocessors
Advertisements

Symmetric Multiprocessors: Synchronization and Sequential Consistency.
1 Episode III in our multiprocessing miniseries. Relaxed memory models. What I really wanted here was an elephant with sunglasses relaxing On a beach,
Memory Consistency Models Sarita Adve Department of Computer Science University of Illinois at Urbana-Champaign Ack: Previous tutorials.
Synchronization. How to synchronize processes? – Need to protect access to shared data to avoid problems like race conditions – Typical example: Updating.
Memory Consistency Models Kevin Boos. Two Papers Shared Memory Consistency Models: A Tutorial – Sarita V. Adve & Kourosh Gharachorloo – September 1995.
Relaxed Consistency Models. Outline Lazy Release Consistency TreadMarks DSM system.
CS 162 Memory Consistency Models. Memory operations are reordered to improve performance Hardware (e.g., store buffer, reorder buffer) Compiler (e.g.,
Shared Memory – Consistency of Shared Variables The ideal picture of shared memory: CPU0CPU1CPU2CPU3 Shared Memory Read/ Write The actual architecture.
1 Munin, Clouds and Treadmarks Distributed Shared Memory course Taken from a presentation of: Maya Maimon (University of Haifa, Israel).
1 Lecture 12: Hardware/Software Trade-Offs Topics: COMA, Software Virtual Memory.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
By Sarita Adve & Kourosh Gharachorloo Review by Jim Larson Shared Memory Consistency Models: A Tutorial.
Memory consistency models Presented by: Gabriel Tanase.
1 Lecture 7: Consistency Models Topics: sequential consistency, requirements to implement sequential consistency, relaxed consistency models.
Lecture 13: Consistency Models
Computer Architecture II 1 Computer architecture II Lecture 9.
1 Lecture 15: Consistency Models Topics: sequential consistency, requirements to implement sequential consistency, relaxed consistency models.
1 Lecture 12: Relaxed Consistency Models Topics: sequential consistency recap, relaxing various SC constraints, performance comparison.
Shared Memory – Consistency of Shared Variables The ideal picture of shared memory: CPU0CPU1CPU2CPU3 Shared Memory Read/ Write The actual architecture.
Shared Memory Consistency Models: A Tutorial By Sarita V Adve and Kourosh Gharachorloo Presenter: Meenaktchi Venkatachalam.
Processor Consistency [Goodman 1989]* Processor Consistency is a memory model in which the result of any execution is the same as if the operations of.
Shared Memory Consistency Models: A Tutorial By Sarita V Adve and Kourosh Gharachorloo Presenter: Sunita Marathe.
Memory Consistency Models Some material borrowed from Sarita Adve’s (UIUC) tutorial on memory consistency models.
Distributed Shared Memory Systems and Programming
Shared Memory – Consistency of Shared Variables The ideal picture of shared memory: CPU0CPU1CPU2CPU3 Shared Memory Read/ Write The actual architecture.
TreadMarks Distributed Shared Memory on Standard Workstations and Operating Systems Pete Keleher, Alan Cox, Sandhya Dwarkadas, Willy Zwaenepoel.
©RG:E0243:L2- Parallel Architecture 1 E0-243: Computer Architecture L2 – Parallel Architecture.
Lazy Release Consistency for Software Distributed Shared Memory Pete Keleher Alan L. Cox Willy Z.
Shared Memory Consistency Models: A Tutorial Sarita V. Adve Kouroush Ghrachorloo Western Research Laboratory September 1995.
TECHNIQUES FOR REDUCING CONSISTENCY- RELATED COMMUNICATION IN DISTRIBUTED SHARED-MEMORY SYSTEMS J. B. Carter University of Utah J. K. Bennett and W. Zwaenepoel.
Memory Consistency Models Alistair Rendell See “Shared Memory Consistency Models: A Tutorial”, S.V. Adve and K. Gharachorloo Chapter 8 pp of Wilkinson.
1 Lecture 12: Hardware/Software Trade-Offs Topics: COMA, Software Virtual Memory.
Ch 10 Shared memory via message passing Problems –Explicit user action needed –Address spaces are distinct –Small Granularity of Transfer Distributed Shared.
By Sarita Adve & Kourosh Gharachorloo Slides by Jim Larson Shared Memory Consistency Models: A Tutorial.
Distributed Shared Memory Presentation by Deepthi Reddy.
Shared Memory Consistency Models. SMP systems support shared memory abstraction: all processors see the whole memory and can perform memory operations.
Memory Consistency Models. Outline Review of multi-threaded program execution on uniprocessor Need for memory consistency models Sequential consistency.
Memory Consistency Models 1. Uniform Consistency Models Only have read and write operations Sequential Consistency Pipelined-RAM Causal Consistency Coherence.
Release Consistency Yujia Jin 2/27/02. Motivations Place partial order on memory accesses for correct parallel program behavior Relax partial order for.
Implementation and Performance of Munin (Distributed Shared Memory System) Dongying Li Department of Electrical and Computer Engineering University of.
DISTRIBUTED COMPUTING
Page 1 Distributed Shared Memory Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation.
Memory Consistency Zhonghai Lu Outline Introduction What is a memory consistency model? Who should care? Memory consistency models Strict.
1 Chapter 9 Distributed Shared Memory. 2 Making the main memory of a cluster of computers look as though it is a single memory with a single address space.
ICFEM 2002, Shanghai Reasoning about Hardware and Software Memory Models Abhik Roychoudhury School of Computing National University of Singapore.
CS533 Concepts of Operating Systems Jonathan Walpole.
Lazy Release Consistency for Software Distributed Shared Memory Pete Keleher Alan L. Cox Willy Z. By Nooruddin Shaik.
Distributed shared memory u motivation and the main idea u consistency models F strict and sequential F causal F PRAM and processor F weak and release.
August 13, 2001Systems Architecture II1 Systems Architecture II (CS ) Lecture 11: Multiprocessors: Uniform Memory Access * Jeremy R. Johnson Monday,
EE 382 Processor DesignWinter 98/99Michael Flynn 1 EE382 Processor Design Winter 1998 Chapter 8 Lectures Multiprocessors, Part I.
Implementation and Performance of Munin (Distributed Shared Memory System) Dongying Li Department of Electrical and Computer Engineering University of.
Symmetric Multiprocessors: Synchronization and Sequential Consistency
COSC6385 Advanced Computer Architecture
CS5102 High Performance Computer Systems Memory Consistency
Distributed Shared Memory
Memory Consistency Models
Lecture 11: Consistency Models
Memory Consistency Models
Symmetric Multiprocessors: Synchronization and Sequential Consistency
Shared Memory Consistency Models: A Tutorial
Symmetric Multiprocessors: Synchronization and Sequential Consistency
Background for Debate on Memory Consistency Models
Distributed Shared Memory
Shared Memory Consistency Models: A Tutorial
Lecture 10: Consistency Models
Memory Consistency Models
Programming with Shared Memory Specifying parallelism
Lecture 11: Relaxed Consistency Models
Lecture 11: Consistency Models
Presentation transcript:

Memory Consistency Models Adapted from slides by Sarita V. Adve and Kourosh Gharachorloo And slides from Gabriel Tanase CIS 429/529 - W’07 - Memory Consistency

Memory Consistency Models Memory Consistency (definition) Sequential Consistency Processor Consistency Weak Consistency Release Consistency Early Release Consistency Lazy Release Consistency Entry Consistency CIS 429/529 - W’07 - Memory Consistency

CIS 429/529 - W’07 - Memory Consistency Def: A memory consistency model for a shared address space specifies constraints on the order in which memory operations must appear to be performed (i.e. to become visible to the processors) with respect to one another. P1 P2 (A, flag are zero initial) A=1 while(flag == 0); flag=1 print A; (Culler, Singh, Gupta) CIS 429/529 - W’07 - Memory Consistency

Memory Consistency Model Definition: Order in which memory operations will appear to execute -- what value can a read return -- a read should return the value of the “last” write to the same memory location (P&H coherence) Affects 3P -- Programmability (easy-of-programming) -- Performance (optimization) -- Portability (moving software across different systems) CIS 429/529 - W’07 - Memory Consistency

Sequential Consistency Sequential Consistency(Lamport) “A multiprocessor is sequentially consistent if the result of any execution is the same as if the operations of all the processors were executed in some sequential order, and the operations of each individual processor occur in this sequence in the order specified by its program.” CIS 429/529 - W’07 - Memory Consistency

CIS 429/529 - W’07 - Memory Consistency Implicit Memory Model Sequential consistency (SC) [Lamport ‘76] Result of an execution appears as if All operations executed in some sequential order Memory operations of each process in program order MEMORY P1 P3 P2 Pn CIS 429/529 - W’07 - Memory Consistency

Architectures without Caches: example Write buffer CIS 429/529 - W’07 - Memory Consistency

Architectures without Caches: example Initially Flag1 = Flag2 = 0 P1 P2 Flag1 = 1 Flag2 = 1 if (Flag2 == 0) if (Flag1 == 0) critical section critical section At runtime: (Operation, Location, Value) (Operation, Location, Value) Write, Flag1, 1 Write, Flag2, 1 Read, Flag2, 0 Read, Flag1, 0? CIS 429/529 - W’07 - Memory Consistency

Architectures without Caches: example P1 P2 (Operation, Location, Value) (Operation, Location, Value) Write, Flag1, 1 Write, Flag2, 1 Read, Flag2, 0 Read, Flag1, 0 Can happen if Reorder write followed by read in h/w or compiler Allocate copies of Flag1 or Flag2 in registers Write buffers with read bypassing (Optimization by use of writer buffer is safe on conventional uniprocessor, but it can violate SC in multiprocessor system.) CIS 429/529 - W’07 - Memory Consistency

Architectures With Caches Cache Coherence and Sequential Consistency (SC) Cache Coherence A write is visible to all processors Serialization of writes to the same location SC Serialization of writes to all locations Operations appear to execute in program order SC implies Cache Coherence: A memory consistency model as the policy that places an early and late bound on when a new value can be propagated by invalidating or updating Atomicity for writes Serialize write can avoid the violation of SC Ordering of updates/invalidates between source and destination is preserved by network Or delay an update/invalidate from being sent out until any updates or invalidates from previous write are acknowledged CIS 429/529 - W’07 - Memory Consistency

Sequential Consistency 1. Every process issues memory operations in program order. 2. After a write operation is issued, the issuing process waits for the write to complete before issuing its next operation. 3. After a read operation is issued, the issuing process waits for the read to complete, and for the write whose value is being returned by the read to complete, before issuing its next operation. That is, if the write whose value is being returned has performed with respect to this processor (as it must have if its value is being returned) then the processor should wait until the write has performed with respect to all processors. (Culler, Singh, Gupta) CIS 429/529 - W’07 - Memory Consistency

CIS 429/529 - W’07 - Memory Consistency Is SC enough? SC constrains all memory operations: Simple model for reasoning about parallel programs But, intuitively reasonable reordering of memory operations in a uniprocessor may violate sequential consistency model in multiprocessor Modern microprocessors reorder operations all the time to obtain performance (write buffers, overlapped writes,non-blocking reads…). How do we reconcile sequential consistency model with the demands of performance? CIS 429/529 - W’07 - Memory Consistency

Processor Consistency Writes from the same processor should be observed in program order; The order in which the writes from two processors occur (as observed by themselves or a third processor need NOT be identical(Gharachorloo & al.) 1. Before a read is allowed to perform with respect to any other processor, all previous reads must be performed and 2. Before a write is allowed to performed with respect to any other processor all previous accesses(reads and writes) must be performed The above conditions relax sequential consistency by allowing reads following a write to bypass the write; CIS 429/529 - W’07 - Memory Consistency

CIS 429/529 - W’07 - Memory Consistency Weak Consistency Distinguish Ordinary shared accesses v. Synchronization accesses Conditions for weak consistency Before an ordinary read/write access is allowed to perform with respect to any other processor, all previous synchronization accesses must be performed and Before a synchronization access is allowed to performed with respect to any other processor, all previous ordinary read/write accesses must be performed and Synchronization accesses are sequentially consistent. CIS 429/529 - W’07 - Memory Consistency

CIS 429/529 - W’07 - Memory Consistency Release Consistency Categorization of shared memory accesses Shared access Competing non-competing Synchronization non-synchronization Acquire Release CIS 429/529 - W’07 - Memory Consistency

RC: Properly-Labeled Programs shared special ordinary synch nsynch acq rel Two ways of labelling Parallelizing compilers Programming methodology CIS 429/529 - W’07 - Memory Consistency

Conditions for Release Consistency Before an ordinary read or write access is allowed to perform with respect to any other processor, all previous acquire accesses must be performed and Before a release access is allowed to perform with respect to any other processor, all previous ordinary read and writes accesses must be performed, and Acquire accesses are sequentially consistent with other aquire accesses; same for release access. CIS 429/529 - W’07 - Memory Consistency

Comparison of the four models CIS 429/529 - W’07 - Memory Consistency

Performance Potential CIS 429/529 - W’07 - Memory Consistency

Lazy release consistency for Software DSM CIS 429/529 - W’07 - Memory Consistency

Eager Release Consistency CIS 429/529 - W’07 - Memory Consistency

Lazy Release Consistency CIS 429/529 - W’07 - Memory Consistency

Lazy release consistency “happened-before-1” partial order Write notice propagation Multiple writer protocols Modify different parts of a page concurrently False sharing Reduces the amount of messages Invalidate vs. update(on the acquiring processor) CIS 429/529 - W’07 - Memory Consistency

CIS 429/529 - W’07 - Memory Consistency Lazy versus Eager CIS 429/529 - W’07 - Memory Consistency

Other Consistency Models Entry consistency (Bershad et. Al.) memory becomes consistent up entry to programmer defined critical section Scope consistency (Iftode et. Al.) Any modification during a consistency scope session become visible to processes that enter sessions of that scope Can have multiple related scope sessions CIS 429/529 - W’07 - Memory Consistency

CIS 429/529 - W’07 - Memory Consistency Delayed Consistency CIS 429/529 - W’07 - Memory Consistency

CIS 429/529 - W’07 - Memory Consistency Delayed protocols CIS 429/529 - W’07 - Memory Consistency

CIS 429/529 - W’07 - Memory Consistency

Update based cache protocols CIS 429/529 - W’07 - Memory Consistency

CIS 429/529 - W’07 - Memory Consistency Bibliography Memory consistency and event ordering in scalable shared-memory multiprocessors; Kourosh Gharacahorloo, Daniel Lenosky, James Laudon, Philip Gibbons, Anoop Gupta and John Hennessy. Lazy release consistency for software distributed shared memory; Pete Keleher, Alan Cox, Willy Zwaenepoel The Midway distributed shared memory; Brian Bershad & al. Scope Consistency: A bridge between release consistency and entry consistency; L. Iftode , J.P. Singh, K. Li Parallel computer architecture(chapter 5 and 9); David Culler, J.P. Singh, A. Gupta CIS 429/529 - W’07 - Memory Consistency