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

Eigen includes (but not using eigen) slowing down program

Tags: None
(comma "," separated)
LonelyStar
Registered Member
Posts
6
Karma
0
Hi,

I have a boost-python program.
If I do
#include <eigen2/Eigen/Core>

In the main source file, but without using anything of again at any place, the program is slowed down by a factor of 2 ...

Anyone knows why?
Can this be circumvented?

Thanks!
Nathan
User avatar
bjacob
Registered Member
Posts
658
Karma
3
Do you mean that the compilation takes twice longer? That is normal, you could ease this with precompiled headers.

Or that the execution of the program itself is slower? That would not be normal. What Eigen version? Can you dump Eigen symbol tables,
Code: Select all
nm -C your_program | grep Eigen

with and without including Eigen? Can you profile your program to determine where it's spending time?
LonelyStar
Registered Member
Posts
6
Karma
0
Hi,

No, I am not talking about compile time. The actual run time increases.

I am compiling with "-O2 -g". For both (with and without Eigen), the output of

nm -C your_program | grep Eigen

is empty. Since it is a boost_python program, I can not (or at least do not know how) profile this program directly. I will write a C++ one and see what I can find out.

Regards,
Nathan
User avatar
bjacob
Registered Member
Posts
658
Karma
3
This is crazy... I can't understand what is going on. The fact that there are no Eigen symbols pretty much proves that it can't be spending time in Eigen code...


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
LonelyStar
Registered Member
Posts
6
Karma
0
Hi,

OK, it the differences in the profiling output I see:
exp also calls fsetenv, fholdexcept and fsetround.
In the version with eigen included.

Could it be that eigen somehow redefines the exp function?
If yes, Can this be avoided?

Thanks!
nathan
User avatar
bjacob
Registered Member
Posts
658
Karma
3
I just checked:
Code: Select all
~$ cd eigen2.0/Eigen/src/Core/
~/eigen2.0/Eigen/src/Core$ grep -Rn \ exp\( .
./Cwise.h:110:    const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_exp_op)      exp() const;


That is a method in class Cwise, not the global exp() or std::exp().

So the answer is no, we don't redefine exp() or std::exp().


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
User avatar
bjacob
Registered Member
Posts
658
Karma
3
From the function names that you cite, it looks like something is something to play with floating-point exceptions. Like setting a FP exception handler, or something like that. Eigen doesn't do anything in that area.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
LonelyStar
Registered Member
Posts
6
Karma
0
OK, this is most strange!

I use exp a lot in my program.

- When I include math.h and use exp, the runtime is ~1 second
- When I include cmath and use std::exp, the runtime is ~4 second
- When I include math.h, use exp AND include eigen, the runtime is ~4 seonds

If find this extremly strange. Anyone any idea?
Thanks!
Nathan
LonelyStar
Registered Member
Posts
6
Karma
0
And I found out another thing:
It is not including eigen, it is including cmath which triggers the problem.
You might be right with FP exception handlers ...

So eigen has nothing to do with it.
Thanks for the help!
Nathan
User avatar
bjacob
Registered Member
Posts
658
Karma
3
I wonder if this could indirectly be related to c++ exceptions. Have you tried compiling with c++ exceptions disabled? -fno-exceptions


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
LonelyStar
Registered Member
Posts
6
Karma
0
Hey,

Good idea, I tried that. But no, did not change a thing.


Bookmarks



Who is online

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