This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Slow build time

Tags: None
(comma "," separated)
zoharl
Registered Member
Posts
55
Karma
0
OS

Slow build time

Thu Aug 15, 2013 5:13 pm
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
sunnyhsu
Registered Member
Posts
4
Karma
0

Re: Slow build time

Thu Aug 15, 2013 9:59 pm
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.
zoharl
Registered Member
Posts
55
Karma
0
OS

Re: Slow build time

Sat Aug 17, 2013 11:49 am
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.
sunnyhsu
Registered Member
Posts
4
Karma
0

Re: Slow build time

Sat Aug 17, 2013 8:31 pm
`Expression Templates`. Not `Templates`. It's a kind of static optimization technique via compiling.

Please refer to
http://en.wikipedia.org/wiki/Expression_templates
zoharl
Registered Member
Posts
55
Karma
0
OS

Re: Slow build time

Sat Aug 17, 2013 8:48 pm
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.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]