CppCon 2016: Instruction Re-ordering Everywhere: The C++ 'As-If' Rule and the Role...--Charles Bay
Have you registered for CppCon 2017 in September? Don’t delay – Registration is open now.
While we wait for this year’s event, we’re featuring videos of some of the 100+ talks from CppCon 2016 for you to enjoy. Here is today’s feature:
Instruction Re-ordering Everywhere: The C++ 'As-If' Rule and the Role of Sequence
by Charles Bay
Summary of the talk:
This is an introductory (i.e., "First Principles") dive into instruction re-ordering (at compile-time, and at run-time) due to conspiring by the compiler and CPU to make most efficient use of execution units and resources within the CPU processor core. Discussion is made of the role for sequence, for tracing of data flows and control flows, how "out-of-order" execution occurs within the compiler and CPU, and why that's a "good thing". The importance of the C++ "As-If" rule that allows these optimizations is explained.
Exploration is made of imperative versus sequential devices, physical versus logical sequences, and the role of the CPU cache line. At the end of this talk, it will be obvious for how and why instruction re-ordering occurs, and the programmer's need to consider logical dependencies (and not instruction order) when defining algorithms.
This talk is ideal for any programmer confused after observing instruction reordering in their running systems, and provides a solid basis to begin reasoning about how to leverage parallelism and be concerned with concurrency.