My job is mainly in high-performance 'scientific' computing. I've been doing that for ~15 years now, but only recently realized that my software wastes computational time. In short words: my ways of writing efficient C++ code no longer work.
From time to time I see a piece of code, written by some kid, that does basically the same calculations as mine (same algorithm, similar approach), but - magically! - performs far faster. In most cases I'm even unable of tracking down the origins of the difference!
My question is: how can I learn the art of modern C++ code optimization? Perhaps something on SSE, caching/mem alignment issues? Any suggestion of book, PDF, article, exercise or website is welcome!
PS. I'm well aware of tricks that are either:
- Too general (e.g. 'Use profiler', 'Use good algorithms', 'Go multithreaded')
- Trivial (e.g. 'Avoid virtual functions', 'Do ++i instead of i++', 'Enable -O3')
- Questionable (e.g. 'Reuse memory with reinterpret_cast<>', 'Tabularize sine and cosine', 'Write inline assembly')
- Ridiculous (e.g. 'Do template metaprogramming')
These are not what I'm asking about.