CppCon 2017: Fedor Pikus “C++ atomics, from basic to advanced. What do they really do?”

205,847
0
Published 2017-10-10
CppCon.org/

Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2017

C++11 introduced atomic operations. They allowed C++ programmers to express a lot of control over how memory is used in concurrent programs and made portable lock-free concurrency possible. They also allowed programmers to ask a lot of questions about how memory is used in concurrent programs and made a lot of subtle bugs possible.

This talk analyzes C++ atomic features from two distinct points of view: what do they allow the programmer to express? what do they really do? The programmer always has two audiences: the people who will read the code, and the compilers and machines which will execute it. This distinction is, unfortunately, often missed. For lock-free programming, the difference between the two viewpoints is of particular importance: every time an explicit atomic operation is present, the programmer is saying to the reader of the program "pay attention, something very unusual is going on here." Do we have the tools in the language to precisely describe what is going on and in what way it is unusual? At the same time, the programmer is saying to the compiler and the hardware "this needs to be done exactly as I say, and with maximum efficiency since I went to all this trouble."

This talk starts from the basics, inasmuch as this term can be applied to lock-free programming. We then explore how the C++ lock-free constructs are used to express programmer's intent clearly (and when they get in the way of clarity). Of course, there will be code to look at and to be confused by. At the same time, we never lose track of the fact that the atomics are one of the last resorts of efficiency, and the question of what happens in hardware and how fast does it happen is of paramount importance. Of course, the first rule of performance — "never guess about performance!" — applies, and any claim about speed must be supported by benchmarks.

If you never used C++ atomics but want to learn, this is the talk for you. If you think you know C++ atomics but are unclear on few details, come to fill these few gaps in your knowledge. If you really do know C++ atomics, come to feel good (or to be surprised, and then feel even better).

Fedor Pikus: Mentor Graphics - Siemens business, Chief Scientist

Fedor G Pikus is a Chief Engineering Scientist in the Design to Silicon division of Mentor Graphics Corp. His earlier positions included a Senior Software Engineer at Google and a Chief Software Architect for Calibre PERC, LVS, DFM at Mentor Graphics. He joined Mentor Graphics in 1998 when he made a switch from academic research in computational physics to software industry. His responsibilities as a Chief Scientist include planning long-term technical direction of Calibre products, directing and training the engineers who work on these products, design and architecture of the software, and research in new design and software technologies. Fedor has over 25 patents and over 90 papers and conference presentations on physics, EDA, software design, and C++ language.

Videos Filmed & Edited by Bash Films: www.BashFilms.com/

*-----*
Register Now For CppCon 2022: cppcon.org/registration/
*-----*

All Comments (21)
  • @TheEmT33
    i used to think all these conferences were bs, but man.. these days i just kept watching cppcon when i was supposed to watch memes and vines
  • @philipye7936
    Really love this talk, using 1 hour watching this video is actually more efficient than reading cpp reference using a day :)
  • @dirtbikersteve
    Finally a good explanation of memory orders without hand waving and saying 'it's to complex to worry about'
  • @sumeshnb2
    Finally, this guy made me understand memory ordering. Nice presentation...
  • @Sychonut
    I really enjoy listening to Fedor. Knowledgeable speaker doing a great job explaining complicated topics.
  • @assonancex
    This talk was superb. Complex topic delivered eloquently. Thanks for that.
  • @JiveDadson
    I was hoping for a clear explanation of the various std::memory_order types. It starts at 42:26
  • the most decent and clear explanation of atomics i've seen so far
  • @Gulzt
    Very insightful. Especially with the pictures things fell in the place!
  • @flisboac
    Amazing presentation. Learned a lot. Thank you!
  • @kullatnunu6894
    Very good talk! Thank you very much for speeding up my learning about atomics and lock free algorithms.
  • @hl2mukkel
    What an amazing talk! Very well explained!
  • @ogalevn
    That's a great talk! Worth to watch!
  • @ilnurKh
    Great. Thanks for speech, examples and bechmarks.
  • @QT-yt4db
    Excellent. First time I really understand these ideas.
  • @joeybluee
    Great talk, it's the clearest explanation I ever watched.