Alex Rivera | Logout

Computationally efficient C++ - general reading

Asked 2012-02-27T11:23:16.070
10

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.

Edit
Report

1 Answer

3

The book "Computer architecture- a quantitative approach" hennessey and patterson. Not specifically targeting C++ but even more important the overall architecture. This is crucial for HPC even more than any "trick and tips".

answered 2012-02-27T12:07:44.167

Your Answer