C++11 Atomic Types and Memory Model

Slides:



Advertisements
Similar presentations
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
Advertisements

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.
D u k e S y s t e m s Time, clocks, and consistency and the JMM Jeff Chase Duke University.
CSE 486/586, Spring 2014 CSE 486/586 Distributed Systems Consistency Steve Ko Computer Sciences and Engineering University at Buffalo.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
Slides 8d-1 Programming with Shared Memory Specifying parallelism Performance issues ITCS4145/5145, Parallel Programming B. Wilkinson Fall 2010.
Lock-free Cache-friendly Software Queue for Decoupled Software Pipelining Student: Chen Wen-Ren Advisor: Wuu Yang 學生 : 陳韋任 指導教授 : 楊武 Abstract Multicore.
“THREADS CANNOT BE IMPLEMENTED AS A LIBRARY” HANS-J. BOEHM, HP LABS Presented by Seema Saijpaul CS-510.
Type Systems For Distributed Data Sharing Ben Liblit Alex AikenKathy Yelick.
Evaluation of Memory Consistency Models in Titanium.
Anshul Kumar, CSE IITD CSL718 : Multiprocessors Synchronization, Memory Consistency 17th April, 2006.
Anshul Kumar, CSE IITD ECE729 : Advance Computer Architecture Lecture 26: Synchronization, Memory Consistency 25 th March, 2010.
CSE 425: Concurrency II Semaphores and Mutexes Can avoid bad inter-leavings by acquiring locks –Guard access to a shared resource to take turns using it.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
CSE 486/586 CSE 486/586 Distributed Systems Consistency Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586, Spring 2014 CSE 486/586 Distributed Systems Transactions on Replicated Data Steve Ko Computer Sciences and Engineering University at Buffalo.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
Ch4. Multiprocessors & Thread-Level Parallelism 4. Syn (Synchronization & Memory Consistency) ECE562 Advanced Computer Architecture Prof. Honggang Wang.
Read-Copy-Update Synchronization in the Linux Kernel 1 David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis.
Kernel Synchronization David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
Jim Fawcett CSE 691 – Software Modeling and Analysis Fall 2000
Lecture 20: Consistency Models, TM
Introduction to Generic Programming in C++
CSE 486/586 Distributed Systems Consistency --- 2
Event Handling Patterns Asynchronous Completion Token
CSE 486/586 Distributed Systems Consistency --- 2
Memory Consistency Models
Wrapper Façade Pattern
CSE 486/586 Distributed Systems Consistency --- 1
Linux Pipes and FIFOs David Ferry, Chris Gill
Faster Data Structures in Transactional Memory using Three Paths
Memory Consistency Models
EEC 688/788 Secure and Dependable Computing
Overview of the Lab 2 Assignment: Linux Scheduler Profiling
Overview of the Lab 3 Assignment: Kernel Module Concurrent Memory Use
Computing with anonymous processes
Threads and Memory Models Hal Perkins Autumn 2011
The Active Object Pattern
CSE 486/586 Distributed Systems Consistency --- 3
Chapter 18: Refining Analysis Relationships
Transactional Memory Semaphores, monitors, and conditional critical regions all suffer from limitations based on lock semantics Naïve synchronization may.
Kernel Synchronization II
Integer Programming (정수계획법)
CSE 486/586 Distributed Systems Consistency --- 1
EEC 688/788 Secure and Dependable Computing
Threads and Memory Models Hal Perkins Autumn 2009
Half-Sync/Half-Async (HSHA) and Leader/Followers (LF) Patterns
Iteration Implemented through loop constructs (e.g., in C++)
Lecture 2 Part 2 Process Synchronization
Monitor Object Pattern
Top Half / Bottom Half Processing
Testing and Debugging Concurrent Code
EEC 688/788 Secure and Dependable Computing
Integer Programming (정수계획법)
Kernel Synchronization II
Userspace Synchronization
Chris Gill CSE 522S – Advanced Operating Systems
Relaxed Consistency Part 2
Relaxed Consistency Finale
Type Systems For Distributed Data Sharing
Programming with Shared Memory Specifying parallelism
CS533 Concepts of Operating Systems Class 14
Problems with Locks Andrew Whitaker CSE451.
CSE 486/586 Distributed Systems Consistency --- 2
CSE 486/586 Distributed Systems Consistency --- 3
CSE 486/586 Distributed Systems Consistency --- 1
Shared Memory David Ferry, Chris Gill
More concurrency issues
Presentation transcript:

C++11 Atomic Types and Memory Model E81 CSE 532S: Advanced Multi-Paradigm Software Development C++11 Atomic Types and Memory Model Chris Gill Department of Computer Science and Engineering Washington University in St. Louis cdgill@cs.wustl.edu Title slide

Atomic Types Many atomic types in C++11 STL, some are lock-free Always lock-free: std::atomic_flag If it matters, must test others with is_lock_free() Also can specialize std::atomic<> class template This is already done for many standard non-atomic type Can also do this for your own types that implement a trivial copy-assignment operator, are bitwise equality comparable Watch out for semantic details E.g., bitwise evaluation of float, double, etc. representations Equivalence may differ under atomic operations

Reasoning about Concurrency Operations on atomic types semantically well defined Synchronizes-with relationship ensures that (unambiguously) operation X happens before or after operation Y Can leverage this so eventually Xi happens-before Yj Transitivity then lets you build various happens-before cases, including inter-thread happens-before relationships Other variations on this theme are also useful Dependeny-ordered-before and carries-a-dependency-to are used to reason about cases involving data dependencies I.e., the result of one atomic operation is used in another

Memory Models and Design Trading off stricter ordering vs. higher overhead Sequential consistency is easiest to think about (implement) because it imposes a consistent global total order on threads Acquire-release consistency relaxes that to a pair-wise partial order that admits more concurrency Relaxed ordering is least expensive, but should be applied selectively where available to optimize performance Even these basic constucts allow sophisticated design Memory fences to synchronize otherwise relaxed segments Release chains offer a similar idea for data dependencies Mixing atomic operations in with non-atomic ones to reduce overhead, but still enforce correct semantics (Chapter 7)