CppCon 2016: JF Bastien “No Sane Compiler Would Optimize Atomics'

preview_player
Показать описание


False.

Compilers do optimize atomics, memory accesses around atomics, and utilize architecture-specific knowledge. My hobby is to encourage compilers to do more of this, programmers to rely on it, and hardware vendors to give us new atomic toys to optimize with. Oh, and standardize yet more close-to-the-metal concurrency and parallelism tools.

But, you say, surely volatile always means volatile, there’s nothing wrong with my benign races, nothing could even go wrong with non-temporal accesses, and who needs 6 memory orderings anyways‽ I’m glad you asked, let me tell you about my hobby…

JF Bastien
Jest-in-Time Compiler, template
JF Bastien is a compiler engineer, currently focusing on performance and security to bring portable, fast and secure code to the Web. JF is a member of the C++ standards committee, where his mechanical engineering degree serves little purpose. He’s worked on startup incubators, business jets, flight simulators, CPUs, dynamic binary translation, systems, and compilers.


*-----*
*-----*
Рекомендации по теме
Комментарии
Автор


I had a think-o in my slides: "want a release store (there is no release store)" should have been "release load".

Bourg
Автор

Finally a motivated and easy to understand man who can talk nice and interesting. He drank enough coffee ! :D

hanneshauptmann
Автор

I'm guessing the two other atomic talks he refers to in the beginning are,
The Speed of Concurrency: Is Lock-Free Faster?, Fedor Pikus
and Using Weakly Ordered Atomics Correctly. by Hans Boehm
but neither have been posted yet so we'll just have to wait and see.

johnwoolverton
Автор

If I'm in AMD64 and I want to read the contents of CR3, or store a new value in CR2, I may neeed to drop an assemby line.

Fetrovsky
Автор

You are saying that 'this a horrible example, don't write this code...' at the slide 'Simple Usage' 11:00, but it seems you don't give any explanation why. Did I miss something?

andreicheremukhin
Автор

-Regarding your need to optimize atomic operations, no company that uses C++ as a language cares about the C++ memory model, we don't have that many target platforms(ARM and AMD64, the rest are in maintenance or dead) we care about performance and we can get performance because we have domain specific knowledge, we know what to ignore and get viable results, don't break code for 3% on some benchmark with no real world value.
-All real software out there has at least some inline assembly in it because we can get better performance then the compiler, we have domain/problem specific knowledge, we don't care about correct results in all situations, we care about correct results for our data.
-No real software is 100% without undefined/unspecified behavior.
-We will send a bug report if we find something that bother us, but we need to ship code today, actually we have the same relation with you people that you have with the hardware guys, we get a response in 5-10 months.

PopescuAlexandruCristian