Timeline for When should I use C++ expression templates in computational science, and when should I *not* use them?
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 29, 2012 at 23:49 | comment | added | Michael C. Lehn | But again, what I complain about is the fact that such sophisticated (in the sense of complicated but inflexible) libraries like Eigen tightly couple notation and evaluation-mechanism and even think it is a good thing. If I use a tool like Matlab I just want to code things and rely that Matlab is doing the best possible thing. If I use a language like C++ then I want to be in control. So appreciate if a default evaluation-mechanism exists but it must be possible to change it. Otherwise I go back and call functions in C++ directly. | |
Sep 29, 2012 at 14:31 | comment | added | Aron Ahmadia | Right, but the number of frequently needed linear algebra operations is combinatoric. If you are going to use a language like C++, you have the choice of either implementing-as-needed using expression templates (this is the Eigen/Blaze approach) by combining sub-blocks and algorithms intelligently using deferred evaluation, or implementing a massive library of every possible routine. I don't advocate either approach, as recent work in Numba and Cython shows we can get similar or better performance working from high-level scripting languages like Python. | |
Sep 29, 2012 at 13:54 | comment | added | Michael C. Lehn | So the key point is: Notation like 'v=x+y+z' and how it finally gets finally computed should be separated. Eigen, MTL, BLITZ, blaze-lib completely fail in this respect. | |
Sep 29, 2012 at 13:46 | comment | added | Michael C. Lehn | No, I think you are missing the point. You have to distinguish between (a) BLAS as a specification of some frequently needed linear algebra operation (b) an implementation of BLAS like ATLAS, GotoBLAS, etc. BTW that how it works in FLENS: By default an expression like (1) would be evaluated by calling axpy from BLAS three times. But without modifying (1) I also could evaluate it like in (2). So what happens logically is the following: if an operation like in (1) is important then the set of specified BLAS operations (a) can be extended. | |
Sep 29, 2012 at 13:31 | comment | added | Aron Ahmadia | Michael, I think you are missing one of the points of expression templates. Your code example (1) does not actually map to any optimized BLAS calls. In fact, even when a BLAS routine exists, the overhead of a BLAS function call makes it fairly terrible for small vectors and matrices. Sophisticated expression template libraries like Blaze and Eigen can use deferred expression evaluation to avoid the use of temporaries, but I'm convinced that almost nothing short of a domain specific language is going to be able to beat hand-rolled linear algebra. | |
Sep 29, 2012 at 12:56 | review | Late answers | |||
Oct 20, 2012 at 1:08 | |||||
Sep 29, 2012 at 12:53 | history | answered | Michael C. Lehn | CC BY-SA 3.0 |