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

How to pre-compile Eigen header to speed up compiling

Tags: None
(comma "," separated)
zhanxw
Registered Member
Posts
17
Karma
0
Hi,

I tried to compile Eigen header files using this command:

Eigen> find . -exec g++ -I ~/rvtests/third/eigen/ -MMD -O2 -msse2 -DNDEBUG -D__STDC_LIMIT_MACROS -x c++ -O2 -c {} \; >&/dev/null

I checked that there are Eigenvalues.gch file. That means the pre-compiled header has been generated.

Then I compile my C++ source code,

g++ -MMD -O2 -msse2 -DNDEBUG -D__STDC_LIMIT_MACROS -c Skat.cpp -I../libsrc -I../third/eigen

I found the compilation time is about the same, and g++ seems not picking up Eigen header.
I wonder if anybody here use the pre-compiling technique can correct my error or demonstrate a working example.

Thanks.
johnm1019
Registered Member
Posts
46
Karma
0
The Eigen library is a header-only library. This means that when you compile your code all of Eigen's magic meta-programming must happen at source-compile time.
zhanxw
Registered Member
Posts
17
Karma
0
I understand Eigen will spend time on optimization.
But from this post:

[url]viewtopic.php?f=74&t=96384&p=201640&hilit=compile+speed#p201961
[/url]

There seems to be a way to speed compiling up.
I wonder the details.
johnm1019
Registered Member
Posts
46
Karma
0
zhanxw wrote:I understand Eigen will spend time on optimization.
But from this post:

[url]viewtopic.php?f=74&t=96384&p=201640&hilit=compile+speed#p201961
[/url]

There seems to be a way to speed compiling up.
I wonder the details.


Interesting to note -- surprises my first intuition. In this case I believe your issue is then probably better solved by asking this question on a GCC related forum.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Works here by generating the pch with: "g++ <your_options> -x c++-header path/to/Eigen/Eigen -o another/path/to/Eigen.gch" and to increase your chance that gcc does use the generated pch then compile your cpp files with "-include another/path/to/Eigen". Here I earn about 0.3s....


Bookmarks



Who is online

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