Tags
Language
Tags
June 2025
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 1 2 3 4 5
    Attention❗ To save your time, in order to download anything on this site, you must be registered 👉 HERE. If you do not have a registration yet, it is better to do it right away. ✌

    ( • )( • ) ( ͡⚆ ͜ʖ ͡⚆ ) (‿ˠ‿)
    SpicyMags.xyz

    C++ Concurrency : C++ Atomics And Memory Model Deep Dive

    Posted By: ELK1nG
    C++ Concurrency : C++ Atomics And Memory Model Deep Dive

    C++ Concurrency : C++ Atomics And Memory Model Deep Dive
    Published 3/2023
    MP4 | Video: h264, 1280x720 | Audio: AAC, 44.1 KHz
    Language: English | Size: 1.02 GB | Duration: 3h 6m

    C++ Memory model, concurreny, multithreading, performance, modern C++, C++11/14/17/20, gdb, valgrind, C++ atomics

    What you'll learn

    Details of C++ memory model on which atomics are built

    Concepts of memory barriers and memory order in C++

    Using Modern C++ to design lock free algorithms with C++ atomics and memory model

    Importance of sequential consistency in concurrency

    Getting high performane using C++ memory model

    External factors influencing performance of atomics

    Tools to use in production while working with C++ in production

    Requirements

    Should have basic experience with C++ syntax

    Should be able to follow up on details independently

    The course provides guidelines and detailed concepts, patience needed to grasp the design ideas.

    Description

    This intermediate-level course is for C++ developers who want to deepen their understanding of memory models in C++.Memory models are critical to modern software development, especially for concurrent programming. In this course, you will learn about the C++ memory model, including the Sequential Consistency-Data Race Free (SC-DRF) guarantee, which ensures that concurrent programs are well-defined and behave as expected.You will also learn about the different memory barriers used to enforce ordering constraints between memory accesses in a concurrent program. Finally, you will explore the impact of these barriers on performance and learn how to use them to optimize your code.In addition, you will delve into false sharing in caches, which can lead to significant performance degradation in multi-threaded programs. You will learn how to identify and avoid false sharing in your code.The course will also cover the performance of atomics in C++ and how to use them to implement efficient synchronization mechanisms in your programs. You will explore the different types of atomics available in C++, including lock-free and wait-free algorithms, and learn how to use them effectively.Finally, the course will provide an overview of performance analysis tools such as perf, Valgrind, Intel Vtune, Google Orbit, and gdb, which can be used to profile, debug, and optimize your code.Throughout the course, you will work on practical examples and hands-on exercises to reinforce your understanding of the material. By the end of this course, you will have a solid experience with memory models in C++ and be able to write correct, efficient, high-performance concurrent programs.Importance of memory models in Modern C++Learning memory models in modern C++ is crucial for developing high-performance applications and avoiding tricky bugs resulting from the misuse of concurrent programming constructs.Memory models define the rules for accessing shared memory in a multi-threaded program. As multi-core processors become more prevalent, writing concurrent programs that correctly and efficiently utilize shared memory is essential for achieving high performance.Misuse of memory models can lead to subtle and hard-to-find bugs that can be difficult to diagnose and fix. These bugs can result in incorrect behavior, data corruption, and crashes. Therefore, understanding memory models and the various synchronization primitives provided by modern C++ is essential for developing reliable concurrent programs.By learning memory models in modern C++, developers can write efficient and correct multi-threaded programs that fully utilize the available hardware resources. They can also avoid common pitfalls and tricky bugs arising from the incorrect use of memory models.In short, learning memory models in modern C++ is a critical skill for developers who want to develop high-performance applications that utilize multiple cores and avoid the common pitfalls and tricky bugs associated with concurrent programming.Evolution of the C++ Memory ModelThe C++ concurrency model has evolved significantly from C++11 to C++20, introducing new language features and library components that provide more powerful and flexible support for concurrent programming. Here are some of the significant changes that have occurred:C++11: C++11 introduced the first set of language-level concurrency features, including the std::thread class for creating and managing threads, mutexes and condition variables for synchronization, and atomic types for lock-free programming. C++11 also defined the Sequential Consistency-Data Race Free (SC-DRF) memory model, which guarantees correct behavior for well-synchronized programs.C++14: C++14 introduced several improvements to the concurrency features introduced in C++11, including new constructors and member functions for std::thread, support for heterogeneous lookup in concurrent containers, and enhancements to the std::atomic template.C++17: C++17 introduced several new concurrency features and enhancements, including support for parallel algorithms in the Standard Template Library (STL), structured bindings for returning multiple values from std::thread functions, and support for shared_mutex for shared read access and exclusive write access. C++17 also introduced a new memory model that provides stronger guarantees for atomic operations.C++20: C++20 builds on the concurrency features introduced in previous language versions and adds several new features and enhancements. These include the atomic_ref class, which provides a safer way to access shared variables without the need for explicit synchronization, improvements to the memory model to reduce the need for explicit fences and barriers, and enhancements to the coroutines library that make it easier to write asynchronous code.The evolution of the C++ concurrency model from C++11 to C++20 has provided developers with a more powerful and flexible set of tools for writing efficient and correct concurrent programs. The new language features and library components introduced in each version have addressed many of the challenges and limitations of earlier versions. In addition, they have made concurrent programming in C++ more accessible and easier to use.

    Overview

    Section 1: Introduction

    Lecture 1 Introduction

    Lecture 2 C++ Memory Model from standard to production

    Section 2: Modern C++ Memory Model : Closer look

    Lecture 3 Memory Model guarantees

    Lecture 4 External factors affecting the program execution workflow of a C++ program

    Lecture 5 Sequential conisistency definition in multithreaded applications

    Lecture 6 Race condition in concurrency with regard to sequential consistency

    Lecture 7 SC-DRF : Sequential Concistency (Data Race Free)

    Lecture 8 Role of Modern C++ memory model in guarantee of SC-DRF

    Section 3: Code Optimizations: Behind the scenes

    Lecture 9 Simple optimization example

    Lecture 10 Code walkthrough of issue with the concurrent execution of multithreaded code

    Lecture 11 Optimization example with single threaded code

    Lecture 12 Summary and general tips around optimization of concurrent code in modern C++

    Section 4: Concurrency and barriers

    Lecture 13 Thinking in Transactions

    Lecture 14 The concept of critical section in concurrent and multithreaded applications

    Lecture 15 Concurrency considerations while moving code out of critical sections

    Lecture 16 Concurrency considerations while moving code inside of critical sections

    Lecture 17 Concept of acquire and release barriers in concurrency memory models

    Lecture 18 Considerations while choosing memory barriers while desiging for multithreading

    Lecture 19 A closer look at barriers and their relation to sequential consistency

    Lecture 20 Summary of memory barriers in concurrent applications

    Lecture 21 Impact of external optimizations on concurreny in modern C++ applications

    Section 5: Performance analysis of atomics data types in modern C++

    Lecture 22 Considerations while making performace measurements

    Lecture 23 Code experiment recommended to be performed by students.

    Lecture 24 Code demonstartion of behavoir of atomic variables in practice

    Lecture 25 Do atomic variables wait for each other?

    Lecture 26 False sharing in concurrency and multithreading

    Section 6: Compare and Swap in Modern C++

    Lecture 27 Introduction to compare and swap

    Lecture 28 Example of compare and swap

    Lecture 29 Pseudo code implementation of compare and exchange strong

    Lecture 30 Pseudo code implementation of compare exchange strong - faster

    Lecture 31 Compare and exchange weak - reason for spurios failures

    Section 7: Memory ordering in multithreading with Modern C++ memory model

    Lecture 32 Memory ordering basics in concurrency

    Lecture 33 Memory ordering nuances

    Lecture 34 Memory ordering and memory barriers in modern C++ language

    Lecture 35 Acquire Barrier in Modern C++

    Lecture 36 Release Barrier in Modern C++

    Lecture 37 Using acquire and release barriers for synchronization in multithreading

    Lecture 38 Using memory barriers as locks for efficient concurreny with modern C++

    Lecture 39 Bidirectional barriers in Modern C++ memory model

    Lecture 40 Why does compare and exchange in C++ have two parameters for memory ordering?

    Section 8: Memory order : Software Design and performance cosniderations

    Lecture 41 Purpose of memory order in modern C++ concurrency memory model

    Lecture 42 Memory order as a tool to convey the C++ programmer's intent

    Lecture 43 Memory order as programmer's intent : Example - 1

    Lecture 44 Memory order as programmer's intent : Example - 2

    Lecture 45 Memory order as programmer's intent : Example - 3

    Lecture 46 Memory barriers and performance implications

    Lecture 47 Sequential consistency and performance implications

    Lecture 48 Design and implementation guidelines for using std::atomics

    Lecture 49 When to use the atomics provided by the modern C++?

    Section 9: Tools to work with concurrency and multithreading in C++ at production level

    Lecture 50 Demo code: Walkthrough of code sample being used to genreate results of tools

    Lecture 51 top utility output from Linux machine

    Lecture 52 htop utility output from Linux machine

    Lecture 53 perf utility output from Linux machine

    Lecture 54 gprof utility output from Linux machine

    Lecture 55 Intel Vtune utility output from Linux machine

    Lecture 0 Google Orbit utility output from Linux machine

    Lecture 0 Heaptrack utility output from Linux machine

    Lecture 0 Valgrind utility output from Linux machine

    Lecture 0 pahole utility output from Linux machine

    Lecture 0 Demonstration of false sharing in concurrent applications using modern C++

    Lecture 0 Other tools to explore: gdb, gcore, visual studio code, debugging tools

    Lecture 0 Conclusion

    Lecture 0 [Bonus Lecture]

    Intermediate C++ developers,C++ developers curious to understand the details of C++ memory model,C++ developers exploring options to write high performance concurrent applications in C++