Reply to topic

How to pre-compile Eigen header to speed up compiling

zhanxw
Registered Member
Posts
7
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
45
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
7
Karma
0
I understand Eigen will spend time on optimization.
But from this post:

[url]http://forum.kde.org/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
45
Karma
0
zhanxw wrote:I understand Eigen will spend time on optimization.
But from this post:

[url]http://forum.kde.org/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
2193
Karma
15
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....

 
Reply to topic

Bookmarks



Who is online

Registered users: AGB, airdrik, alake, Alexa [Bot], anditosan, Artmessiah, asevens, Baidu [Spider], belnac, Bing [Bot], colomar, Exabot [Bot], garthecho, Google [Bot], google01103, GreatEmerald, kainz.a, koriun, La Ninje, MiceAreVeryNice, mmistretta, nezumi, parzt, Philippe44, scummos, SeaJey, SurfFalke, Tuukka, wolfi323, Yahoo [Bot]