Foundations of the C++ Concurrency Memory Model Hans-J. Boehm Sarita V. Adve HP Laboratories UIUC.

Slides:



Advertisements
Similar presentations
Bounded Model Checking of Concurrent Data Types on Relaxed Memory Models: A Case Study Sebastian Burckhardt Rajeev Alur Milo M. K. Martin Department of.
Advertisements

Threads Cannot be Implemented As a Library Andrew Hobbs.
Memory Consistency Models Sarita Adve Department of Computer Science University of Illinois at Urbana-Champaign Ack: Previous tutorials.
Memory Consistency Models Kevin Boos. Two Papers Shared Memory Consistency Models: A Tutorial – Sarita V. Adve & Kourosh Gharachorloo – September 1995.
CS 162 Memory Consistency Models. Memory operations are reordered to improve performance Hardware (e.g., store buffer, reorder buffer) Compiler (e.g.,
Memory Models: A Case for Rethinking Parallel Languages and Hardware † Sarita Adve University of Illinois Acks: Mark Hill, Kourosh Gharachorloo,
Outline CPU caches Cache coherence Placement of data Hardware synchronization instructions Correctness: Memory model & compiler Performance: Programming.
CS492B Analysis of Concurrent Programs Consistency Jaehyuk Huh Computer Science, KAIST Part of slides are based on CS:App from CMU.
Memory Models: The Case for Rethinking Parallel Languages and Hardware Sarita Adve University of Illinois at Urbana-Champaign
“THREADS CANNOT BE IMPLEMENTED AS A LIBRARY” HANS-J. BOEHM, HP LABS Presented by Seema Saijpaul CS-510.
1 Lecture 21: Transactional Memory Topics: consistency model recap, introduction to transactional memory.
Summary of Boehm’s “threads … as a library” + other thoughts and class discussions CS 5966, Feb 4, 2009, Week 4.
Computer Architecture II 1 Computer architecture II Lecture 9.
1 Sharing Objects – Ch. 3 Visibility What is the source of the issue? Volatile Dekker’s algorithm Publication and Escape Thread Confinement Immutability.
Memory Model Safety of Programs Sebastian Burckhardt Madanlal Musuvathi Microsoft Research EC^2, July 7, 2008.
CS510 Concurrent Systems Class 5 Threads Cannot Be Implemented As a Library.
Threads CNS What is a thread?  an independent unit of execution within a process  a "lightweight process"  an independent unit of execution within.
Shared Memory Consistency Models: A Tutorial By Sarita V Adve and Kourosh Gharachorloo Presenter: Meenaktchi Venkatachalam.
1 Lecture 22: Synchronization & Consistency Topics: synchronization, consistency models (Sections )
Semantics of Multithreaded Java Jeremy Manson and William Pugh Background Material Jack Newton University of Alberta
Processes Part I Processes & Threads* *Referred to slides by Dr. Sanjeev Setia at George Mason University Chapter 3.
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.
Memory Models: A Case for Rethinking Parallel Languages and Hardware † Sarita V. Adve University of Illinois Acks: Mark Hill, Kourosh.
Evaluation of Memory Consistency Models in Titanium.
Memory Models: A Case for Rethinking Parallel Languages and Hardware COE 502/CSE 661 Fall 2011 Parallel Processing Architectures Professor: Muhamed Mudawar,
Multi-core systems System Architecture COMP25212 Daniel Goodman Advanced Processor Technologies Group.
Shared Memory Consistency Models: A Tutorial Sarita V. Adve Kouroush Ghrachorloo Western Research Laboratory September 1995.
CDP 2012 Based on “C++ Concurrency In Action” by Anthony Williams and The C++11 Memory Model and GCC WikiThe C++11 Memory Model and GCC Created by Eran.
CDP 2013 Based on “C++ Concurrency In Action” by Anthony Williams, The C++11 Memory Model and GCCThe C++11 Memory Model and GCC Wiki and Herb Sutter’s.
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.
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.
Detecting and Eliminating Potential Violation of Sequential Consistency for concurrent C/C++ program Duan Yuelu, Feng Xiaobing, Pen-chung Yew.
Threads cannot be implemented as a library Hans-J. Boehm (presented by Max W Schwarz)
Page 1 Distributed Shared Memory Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation.
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.
CoreDet: A Compiler and Runtime System for Deterministic Multithreaded Execution Tom Bergan Owen Anderson, Joe Devietti, Luis Ceze, Dan Grossman To appear.
Specifying Multithreaded Java semantics for Program Verification Abhik Roychoudhury National University of Singapore (Joint work with Tulika Mitra)
The C++11 Memory Model CDP Based on “C++ Concurrency In Action” by Anthony Williams, The C++11 Memory Model and GCCThe C++11 Memory Model and GCC Wiki.
Chapter 4: Threads Modified by Dr. Neerja Mhaskar for CS 3SH3.
Symmetric Multiprocessors: Synchronization and Sequential Consistency
Lecture 20: Consistency Models, TM
The C++11 Memory Model CDP
Chapter 4: Multithreaded Programming
Outline CPU caches Cache coherence Placement of data
Memory Consistency Models
Threads Cannot Be Implemented As a Library
Lecture 11: Consistency Models
Chapter 5: Threads Overview Multithreading Models Threading Issues
Memory Consistency Models
Specifying Multithreaded Java semantics for Program Verification
Threads and Memory Models Hal Perkins Autumn 2011
Chapter 4: Threads.
Symmetric Multiprocessors: Synchronization and Sequential Consistency
Shared Memory Consistency Models: A Tutorial
The C++ Memory model Implementing synchronization)
Symmetric Multiprocessors: Synchronization and Sequential Consistency
Introduction to High Performance Computing Lecture 20
Threads and Memory Models Hal Perkins Autumn 2009
Background for Debate on Memory Consistency Models
EE 4xx: Computer Architecture and Performance Programming
Store Atomicity What does atomicity really require?
Memory Consistency Models
Relaxed Consistency Finale
Lecture 21: Synchronization & Consistency
Problems with Locks Andrew Whitaker CSE451.
Presentation transcript:

Foundations of the C++ Concurrency Memory Model Hans-J. Boehm Sarita V. Adve HP Laboratories UIUC

Multithreaded applications Written in single threaded languages C,C++ Compilers are not thread aware OS thread libraries (e.g pthread) to prevent data races

A need for semantics of multithreaded C++ programs (1) Informal specifications of current thread libraries are ambiguous. What is a data race ?

A need for semantics of multithreaded C++ programs (2) Common compiler transformation violate Compilers need to be thread aware

A need for semantics of multithreaded C++ programs (3) Current facilities for (lock free) atomic data access are expensive and not portable – __sync instrinsics (gcc) – Interlocked (Microsoft)

Memory Consistency Models What values should a shared variable read return in a multithreaded program performance, portability and programmability Sequential Consistency – Simplest – Single total order for memory ops, program order within thread – Restricts compiler/hardware optimizations Relaxed models – Difficult for programmers to understand – Limits some compiler optimizations

Data-Race-Free Models Correct programs are data-race-free in any sequential consistent execution Sequential consistency to correct programs only – Unlike Java Advantages : – Simple programming model (Sequential consistency) – High performance (correct programs) Data-race-free-0 model: two concurrent conflicting accesses – More flexible refinements with more information from programmer

C++ model data-race-free-0 model – Undefined semantics for programs with races – No benign data races Sequentially consistent synchronization operations (atomics) Write-atomicity

Abuse of trylocks Assertion may fail if T1 code reordered Expensive memory fence can prevent reordering Make trylocks fail if lock is available

Relaxing Write Atomicity Independent-Reads-Independent-Writes – single core/single threaded processors – Ownership based invalidation protocol systems Invalid for SMTs and Multicores

Write-to-Read Cauaslity Relaxing write atomicity violates sequential consistency T1T2 L1 T3 L1

Conclusion Simple programming model – Sequential consistency for data race free programs – Break abusive programming idioms (e.g trylocks) Hardware implications – Write Atomicity can not be easily relaxed – Sequential consistent atomics – AMD64, Intel64 map atomics to atomic xchg Compilers – Special handling of atomic types No register promotion No rewriting of adjacent structure fields