Want fast C++? Know your hardware!
summary
Benchmarks use Google Benchmark on clang GCC and Visual Studio across two MacBooks; concrete results: row-major traversal beats column-major by ~30–35× for large arrays; MSVC shows a 6× slowdown for unsorted versus sorted ±1 data while gcc/clang do not; unaligned accesses cost ~3× on older hardware; SIMD-friendly loop reshaping yields ~3× speedup; denormal floats slow multiplication about 30×; cache lines are 64 bytes and set associativity causes catastrophic 20× drops at power‑of‑two strides.
AI-written summary · about
chapters (14)
- 0:00Intro
- 0:19ROLI
- 4:56the rest of this talk
- 9:182d array traversal, 10 MB array
- 14:052d array traversal + some work
- 17:442D Array traversal: time profile (Xcode Instruments)
- 21:14temporal cache coherency
- 26:36accessing every Nth array element
- 28:45cache associativity
- 34:23unaligned memory access
- 35:53aligned vs. packed data access
- 42:08"harmless" branches
- 43:12virtual function calls
- 55:02loop vectorisation - clang
related talks
01h 00mIntroduction to Hardware Efficiency in Cpp
01h 06mUtilize your CPU power
01h 05mThe Most Important Optimizations to Apply in Your C++ Programs
01h 04mCPU design effects
42mFaster programs with your compilers autovectorization feature
48m[a bit noisy] Optimizing Generic Algorithms
01h 00mC++ MythBusters
01h 05mTaming the performance Beast
