CppCon 2017: Fedor Pikus “C++ atomics, from basic to advanced. What do they really do?”
Channel:CppCon · Length:1:14:22 · Published:2017-10-10 · Views:290349
Summary
Fedor Pikus's CppCon 2017 talk on C++ atomics, looking at what they let the programmer express and what the hardware actually does. It covers memory ordering and lock-free programming from basic to advanced.
Why HN recommends it
HN recommends it as an enlightening explanation of atomics, caches and memory ordering from a strong presenter.
Watching this was enlightening to say the least (and the presenter is very good) — HN, 2017
C, C++, Rust, Go & systems languages · Computer architecture & CPUs
Subtitles (excerpt)
- All right. Welcome, come in. Welcome to the Defense Against the Dark Arts class, where you will learn about the more radioactive parts of C++. For this class, I have several goals. One is just educational. If you don't know about atomics, I will introduce them from the beginning and all the way to where I want you to be. But there will be things that, for those who know something about them, might be interesting. More importantly, there will be things for those who think they know something about them. Okay, so let's start about C++ atomics. Now, if you're here on a class about atomic operations, it's probably because you want to learn something about lock-free programming or you want to learn something useful for lock-free programming. And if you want to learn something useful for lock-free programming, it's because lock-free programming is fast, right? Is everybody here for that? Okay, so lock-free programming is fast. And to demonstrate that, everybody was at Bjarne's keynote, right? Bjarne said you should start your presentation with an application. So I put in the application. I have two programs that do exactly the same thing, and they do it correctly. There are no tricks. There are no wait loops.
On Hacker News
No, from what I understand, you can't even do it in software anyway due to how the caches work between cores inside the CPU. Watching this was enlightening to say the least (and the presenter is very good): [VIDEO] — speps, 2017-11
tl;dr: In a multi-threaded context, memory reads and writes can be reordered by hardware. It gets more complicated with shared cache. Imagine that you have core 1 writing to some address at (nearly) the same time that core 2 reads from that. Does core 2 read the old or the new? Especially if they don't share the same cache -- core 1 might "write" to a given address, but it only gets written to co… — inetknght, 2025-08
Fedor Pikus has given a number of great talks on the subject at cppcon over the years some links, in no particular order: CppCon 2017: Fedor Pikus “C++ atomics, from basic to advanced. What do they really do? [VIDEO] CppCon 2016: Fedor Pikus “The speed of concurrency (is lock-free faster?)" [LINK] CppCon 2015: Fedor Pikus PART 1 “Live Lock-Free or Deadlock (Practical Lock-free Programming)" [LINK… — chrsig, 2022-09
Related videos
- Inside Africa's Food Forest Mega-Project · Andrew Millison · 14:10
- De-fragmenting C++: Making Exceptions and RTTI More Affordable and Usable - Herb Sutter CppCon 2019 · CppCon · 1:33:12
- CppCon 2017: Chandler Carruth “Going Nowhere Faster” · CppCon · 1:00:57
- Amazon Sells Fake Electrical Fuses · Louis Rossmann · 31:04
- Jared Mauch - Getting Fiber To My Town (NLNOG Live! September 2020) · NLNOG · 34:42
- The essence of calculus · 3Blue1Brown · 17:04
- CppCon 2016: Jason Turner “Rich Code for Tiny Computers: A Simple Commodore 64 Game in C++17” · CppCon · 1:19:52
- C++ Exceptions for Smaller Firmware - Khalil Estell - CppCon 2024 · CppCon · 1:24:36
- EV Road Trips Suck Now (Except in a Tesla) · Aging Wheels · 35:40
- 8-bit computer update · Ben Eater · 6:53
- CppCon 2015: Andrei Alexandrescu “std::allocator...” · CppCon · 1:12:27
- Light Years Ahead | The 1969 Apollo Guidance Computer · TNMoC · 1:21:22
- Lexical Scanning in Go - Rob Pike · GoogleFOSSSydney · 51:17
- “Hello, world” from scratch on a 6502 — Part 1 · Ben Eater · 27:24
- Finding the Missing Memristor - R. Stanley Williams · The Qualcomm Institute · 47:52
- The Ultimate Game Boy Talk (33c3) · media.ccc.de · 1:01:06