Registered Member
|
Hi,
I really like Eigen. Great performance, friendly API, but the build time really depresses me. I have a short .cpp (less than 300 lines), and it takes it 21 seconds to compile. I understand that templates burdens the compilation, but that's why there is template specialization. For example, MatrixXd shouldn't be a simple typedef, but a non template class, where its implementation (.cpp) uses templates. I really think that you should add an option to eigen that enables the use of standard stuff (even just the double type) without involving templates. What do you think? Zohar |
Registered Member
|
I am not very sure I understand your suggestion correctly. I guess you might not be familiar with the design concept of Eigen. The main architecture of Eigen follows the concept of `Expression Templates` which reduces the redundant memory copies of matrix operations drastically.
If you are really bothered with the compiling time, you may use the precompiled head file and put all Eigen stuffs there. To my knowledge, MSVC and GCC both support this acceleration technique. |
Registered Member
|
How do templates reduce redundant memory copies of matrix operations?
I used precompiled header, and I didn't notice any change. AFAIK, templates provide a convenient way to handle any general data, and unlike polymorphism (class inheritance), there's no overhead of using the vtable for calling the overloaded methods (and I can't see any relation to redundant memory copies). The price is an overload on the compiler. A common solution is using template instantiation, which means that given a template, such as a template function which expects some numerical type variable, we can specialized it to int by defining in a .cpp a new function which accepts an int and calls the template function. Thus the .cpp can be build once (e.g. library), and the compiler won't have to do heavy lifting (21 sec. for 300 lines) later on each changed comma in a code that uses Eigen. |
Registered Member
|
`Expression Templates`. Not `Templates`. It's a kind of static optimization technique via compiling.
Please refer to http://en.wikipedia.org/wiki/Expression_templates |
Registered Member
|
Interesting.
But does it really worth it? I also see that there are alternatives? Maybe Eigen should offer both, and the user would decide? For example, the final release I'll build with templates, but during implementation I'll work with something that is easier on the compiler. |
Registered users: Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]