Xinyu Feng University of Science and Technology of China

Slides:



Advertisements
Similar presentations
Dataflow Analysis for Datarace-Free Programs (ESOP 11) Arnab De Joint work with Deepak DSouza and Rupesh Nasre Indian Institute of Science, Bangalore.
Advertisements

Bounded Model Checking of Concurrent Data Types on Relaxed Memory Models: A Case Study Sebastian Burckhardt Rajeev Alur Milo M. K. Martin Department of.
© 2005 P. Kouznetsov Computing with Reads and Writes in the Absence of Step Contention Hagit Attiya Rachid Guerraoui Petr Kouznetsov School of Computer.
Memory Consistency Models Kevin Boos. Two Papers Shared Memory Consistency Models: A Tutorial – Sarita V. Adve & Kourosh Gharachorloo – September 1995.
Multiprocessor Architectures for Speculative Multithreading Josep Torrellas, University of Illinois The Bulk Multicore Architecture for Programmability.
Memory Models (1) Xinyu Feng University of Science and Technology of China.
Java PathRelaxer: Extending JPF for JMM-Aware Model Checking Huafeng Jin, Tuba Yavuz-Kahveci, and Beverly Sanders Computer and Information Science and.
A Rely-Guarantee-Based Simulation for Verifying Concurrent Program Transformations Hongjin Liang, Xinyu Feng & Ming Fu Univ. of Science and Technology.
D u k e S y s t e m s Time, clocks, and consistency and the JMM Jeff Chase Duke University.
Memory Models: A Case for Rethinking Parallel Languages and Hardware † Sarita Adve University of Illinois Acks: Mark Hill, Kourosh Gharachorloo,
DRF x A Simple and Efficient Memory Model for Concurrent Programming Languages Dan Marino Abhay Singh Todd Millstein Madan Musuvathi Satish Narayanasamy.
PARTIAL-COHERENCE ABSTRACTIONS FOR RELAXED MEMORY MODELS Presented by Michael Kuperstein, Technion Joint work with Martin Vechev, IBM Research and Eran.
Memory Models: The Case for Rethinking Parallel Languages and Hardware Sarita Adve University of Illinois at Urbana-Champaign
ADVERSARIAL MEMORY FOR DETECTING DESTRUCTIVE RACES Cormac Flanagan & Stephen Freund UC Santa Cruz Williams College PLDI 2010 Slides by Michelle Goodstein.
“THREADS CANNOT BE IMPLEMENTED AS A LIBRARY” HANS-J. BOEHM, HP LABS Presented by Seema Saijpaul CS-510.
Formalisms and Verification for Transactional Memories Vasu Singh EPFL Switzerland.
On the Relationship Between Concurrent Separation Logic and Assume-Guarantee Reasoning Xinyu Feng Yale University Joint work with Rodrigo Ferreira and.
Specifying Java Thread Semantics Using a Uniform Memory Model Jason Yue Yang Ganesh Gopalakrishnan Gary Lindstrom School of Computing University of Utah.
Computer Architecture II 1 Computer architecture II Lecture 9.
1 Ivan Lanese Computer Science Department University of Bologna Italy Concurrent and located synchronizations in π-calculus.
The Java Memory Model. JMM: SC intuition may fail Application programmer supposes sequential consistent memory model The trace proves that the memory.
Semantics of Multithreaded Java Jeremy Manson and William Pugh Background Material Jack Newton University of Alberta
Memory Consistency Models Some material borrowed from Sarita Adve’s (UIUC) tutorial on memory consistency models.
A Behavioral Memory Model for the UPC Language Kathy Yelick Joint work with: Dan Bonachea, Jason Duell, Chuck Wallace.
Exceptions and Mistakes CSE788 John Eisenlohr. Big Question How can we improve the quality of concurrent software?
Compositional Verification of Termination-Preserving Refinement of Concurrent Programs Hongjin Liang Univ. of Science and Technology of China (USTC) Joint.
Evaluation of Memory Consistency Models in Titanium.
Yang Liu, Jun Sun and Jin Song Dong School of Computing National University of Singapore.
Foundations of the C++ Concurrency Memory Model Hans-J. Boehm Sarita V. Adve HP Laboratories UIUC.
Rethinking Hardware and Software for Disciplined Parallelism Sarita V. Adve University of Illinois
Aritra Sengupta, Swarnendu Biswas, Minjia Zhang, Michael D. Bond and Milind Kulkarni ASPLOS 2015, ISTANBUL, TURKEY Hybrid Static-Dynamic Analysis for Statically.
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.
Pattern-based Synthesis of Synchronization for the C++ Memory Model Yuri Meshman, Noam Rinetzky, Eran Yahav 1.
Data races, informally [More formal definition to follow] “race condition” means two different things Data race: Two threads read/write, write/read, or.
Threads Cannot be Implemented as a Library Hans-J. Boehm.
Memory Consistency Models 1. Uniform Consistency Models Only have read and write operations Sequential Consistency Pipelined-RAM Causal Consistency Coherence.
Threads cannot be implemented as a library Hans-J. Boehm (presented by Max W Schwarz)
Memory Consistency Zhonghai Lu Outline Introduction What is a memory consistency model? Who should care? Memory consistency models Strict.
ICFEM 2002, Shanghai Reasoning about Hardware and Software Memory Models Abhik Roychoudhury School of Computing National University of Singapore.
A Safety-First Approach to Memory Models Madan Musuvathi Microsoft Research ISMM ‘13 Keynote 1.
CS533 Concepts of Operating Systems Jonathan Walpole.
Aritra Sengupta, Man Cao, Michael D. Bond and Milind Kulkarni PPPJ 2015, Melbourne, Florida, USA Toward Efficient Strong Memory Model Support for the Java.
Specifying Multithreaded Java semantics for Program Verification Abhik Roychoudhury National University of Singapore (Joint work with Tulika Mitra)
Fundamentals of Memory Consistency Smruti R. Sarangi Prereq: Slides for Chapter 11 (Multiprocessor Systems), Computer Organisation and Architecture, Smruti.
Prescient Memory: Exposing Weak Memory Model Behavior by Looking into the Future MAN CAO JAKE ROEMER ARITRA SENGUPTA MICHAEL D. BOND 1.
Lecture 20: Consistency Models, TM
An Operational Approach to Relaxed Memory Models
Faults and fault-tolerance
Aritra Sengupta Man Cao Michael D. Bond and Milind Kulkarni
Memory Consistency Models
Threads Cannot Be Implemented As a Library
Memory Consistency Models
Specifying Multithreaded Java semantics for Program Verification
Hongjin Liang, Xinyu Feng & Ming Fu
Threads and Memory Models Hal Perkins Autumn 2011
Changing thread semantics
Progress of Concurrent Objects with Partial Methods
Shared Memory Consistency Models: A Tutorial
Faults and fault-tolerance
Threads and Memory Models Hal Perkins Autumn 2009
Background for Debate on Memory Consistency Models
Design and Implementation Issues for Atomicity
Store Atomicity What does atomicity really require?
Memory Consistency Models
Relaxed Consistency Part 2
Relaxed Consistency Finale
Tools for the development of parallel applications
Compilers, Languages, and Memory Models
Programming with Shared Memory Specifying parallelism
Presentation transcript:

Xinyu Feng University of Science and Technology of China Memory Models (1) Xinyu Feng University of Science and Technology of China

Why Memory Models C1 || C2 Compiler Result Memory

Why Memory Models C1 || C2 Compiler Result Which reads see which write? Memory

Sequential Consistent (SC) Model [Lamport 1979] Interleaving semantics: . . . P1 P2 P3 Pn Memory

The need of weak memory models SC model prohibits many optimization: Initially: x = y = 0 x = 1; r1 = y; y = 1; r2 = x; r1 = y; x = 1 y = 1; r2 = x; r1 = r2 = 0? Impossible in SC model, but allowed in x86 or Java. Weak memory model allow more behaviors.

Design Criteria Usability: DRF guarantee Not too strong DRF programs have the same behaviors as in SC model Not too strong Allow common optimization techniques In some sense hijacked by the mainstream compiler Preserve type-safety and security guarantee Cannot be too weak Very challenging to satisfy all the requirements!

Compiler Optimization Can Be Smart Initially: x = 0, y = 1 r1 = x; r2 = x; if (r1 == r2) y = 2; y = 2; r1 = x; r2 = r1; if (true) r3 = y; x = r3; r1 = r2 = r3 = 2? Redundant read elim. Must be allowed!

Efforts for Java Memory Model (JMM) First edition in Java Language Spec Fatally flawed, not support key optimizations [Pough 2000] Current JMM [Manson et al. 2005] Based on 5-year discussion and many failed proposals “very complex” [Adve & Boehm 2010] Surprising behaviors and bugs [Aspinall & Sevcik 2007]

Happens-Before Order [Lamport 1978] Program execution: a set of events, and some orders between them. Time T1 T2 rel acq po: sw: Happens-before order (hb): transitive closure of posw

Happens-Before Order w1 w2 w1 r w2 r r w2 Not: rel acq T1 w1 w2 r T2 hb w2 w1 hb r w2 hb r r hb w2 Not: rel acq T1 w1 w2 r T2 acq rel Time po: sw: Happens-before order (hb): transitive closure of posw

Happens-Before Memory Model (HMM) Read can see (1) the most recent write that happens-before it, or (2) a write that has no happens-before relation. rel acq T1 w1 w2 r T2 acq rel Time r could see both w1 (which happens-before it) and w2 (with which there is no happens-before relation)

HMM – Relaxed Ordering Initially: x = y = 0 x = 1; r1 = y; y = 1; r2 = x; r1 = r2 = 0? Allowed in HMM

HMM – Examples with Global Analysis Initially: x = 0, y = 1 Speculation: r3 reads 2 Justified! r1 = x; r2 = x; if (r1 == r2) y = 2; r3 = y; x = r3; r1 = r2 = r3 = 2? Allowed in HMM!

HMM – Out-of-Thin-Air Read Initially: x = y = 0 Speculation: r1 will get 42 Justified! r1 = x; y = r1; r2 = y; x = r2; r1 = r2 = 42? May break the security and type-safety of Java! Allowed in HMM!

Good speculation. Should allow! Speculation: r3 reads 2 r1 = x; r2 = x; if (r1 == r2) y = 2; r3 = y; x = r3; Good speculation. Should allow! r1 = r2 = r3 = 2? r1 = x; y = r1; r2 = y; x = r2; r1 = r2 = 42? Speculation: r1 will get 42 Bad speculation. Disallow!

JMM Take HMM as the core, and try hard to distinguish good speculation from bad speculation! Introduce 9 axioms to constrain causality. Very complex, with surprising results and bugs.

JMM – Surprising Results lock l; C1; C2; unlock l; C3 C1; lock l; C2; unlock l; C3 lock l; C1; unlock l; C2; C3 Adding more synchronization may increase behaviors!

JMM – Surprising Results (2) C1; C2; C1; C2; C3 C3; Inlining threads may increase behaviors! More: Re-ordering independent operations may change behaviors. Adding/removing redundant reads may change behaviors.