The foundation of C++ atomics: The knowledge you need to correctly use C++ atomics

This talk covers all the knowledge you need about atomics to give you a good understanding of how they work under the hood and make sure your code is correct. 


C++11 introduced std::atomic template class which supports six memory orderings, writing correct concurrent programs which use the atomic classes can be challenging. It requires understanding the complexity of how std::atomic works under the hood. The goal of this talk is to encourage programmers to use the atomic classes when appropriate and give them the knowledge to do so correctly. 


This talk will help you confidently use atomics correctly by bringing knowledge of some of the main components that make parallelism possible in modern computer systems, the relationship between these components, and the individual contribution of each of these components in making atomic difficult to use correctly. 


This talk will be aimed at programmers who are new to std::atomic as well as those who have been using these classes. I will show some aspects of atomics which may not be commonly known. 


Topics Covered: 


  • A brief overview of atomics in C++. 

  • Multi-core processors. 

  • Operating system context switching. 

  • Memory Barriers. 

  • Memory Consistency and Cache Coherence.

  • Static & Dynamic Instruction Scheduling. 

  • The C++ memory model 

  • Optimizations Allowed by the memory model. 

  • The Cost of Sequentially Consistent Atomics. 

  • Semantics of Data Races. 

  • Compiler and Hardware introduced Data Races. 

  • The compiler and hardware cooperation to respect the memory model. 

  • The relationships and tradeoffs among atomics and fences/barriers. 

  • How atomic map to their expected machine-instruction implementations on x86 architecture.

Filipe MULONDE

Software Engineer passionate about programming,holds a bachelor's degree in software engineering from Peter the Great St. Petersburg Polytechnic University and is now a final year Master's student in Artificial Intelligence at this same university. I worked as a software engineer at JSC NIIAS-Research and Design Institute of Informatization, Automation , and Communication in Railway Transport of the Russian Federation. Doing code review and increase the performance of an autonomous car using parallelism with C++. 


My bachelor thesis was about the performance of C++ parallel constructs in Clang 10 in Linux (https://www.scribd.com/document/467436640/The-performance-of-C-parallel-constructs-in-Clang-10-in-Linux) I am co-founder of APA(Association of Angolan Programmers) a non-profit organization, helping to build a technological bridge between Africa (Angola) and the rest of the world.https://twitter.com/angolan_of/status/1326848737558335488 In my spare time I'm building a computer from scratch (The C++ abstract machine) using simple logic gates(https://filipemulonde.github.io/Cpp8bitAbstractMAchine.github.io/) or I'm building Autonomous robot orr playing whit x86 assembly. I have interests in x86 assembly,Parallel programming,C++,Digital Design, Microarchitecture and Computer Architecture, Computer Organization,OS, memory models,Digital computer Electronics and design of computing devices, compilers, Machine learning, robotics etc. Former mobile and web developer.