7 thoughts on “Optimizing software in C++

  1. Pingback: Optimizing software and not getting wet in the rain « Entertaining Research

    • That’s a doc by Veldhuizen, the inventor of expression templates! The book on C++ templates by Vandervoorde and Josuttis covers much of the same material.

      This all falls under what Agner calls methods for eggheads that should be avoided. While I’ll admit to being an egghead, I think avoiding template metaprogramming is a big mistake for performance-critical code. We wouldn’t even be able to do auto-dif without it, much less write efficient vectorized distribution functions and gradients. And Eigen leans on it heavily to optimize their matrix library along lines originally introduced by Veldhuizen. This makes C++ matrix libs faster than their C counterparts and analogous to what Fortran compilers can achieve.

      • @Bob Carpenter: I’m very new to fortran, so I’m not sure what you mean by “This makes C++ matrix libs faster than their C counterparts and analogous to what Fortran compilers can achieve.” Do you mean in terms of getting performance like the element-wise operations that you’d have to write in equivalent Fortran code? But that isn’t related to what the Fortran compiler does, just limitations/features of the language.

        Am I missing something?

      • I missed Agner’s “egghead” assessment. It seems odd to view meta-programming as problematic with regard to code maintenance in the same document that covers processor specific vectorization.

Comments are closed.