Re: [eigen] Low performance in DEBUG mode

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


2010/10/25 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>:
> 2010/10/25 Mathias Goldau <math@xxxxxxxxxxxxxxxxxxxxxxxxx>:
>> Hi,
>>
>> today I encountered a really strange thing: I compiled my unittest which need
>> in Release mode just about 3 sec, in Debug mode. It uses just some matrix
>> vector multiplication and the inverse computation. However in Debug mode it
>> needs about 3:32 minutes!!
>> A colleague of mine told me this could have to do with expression templates,
>> and as I've seen in the "We need more Gaels"-thread that Eigen uses a lot of
>> expression templates, I want to ask: Is this assumption true?
>
> This is one third of the explanation. Expression templates mean that
> we have lots and lots of trivial functions and objects that must be
> simplified away by the compiler so they have zero cost; but in debug
> mode, all optimization is turned off so the whole thing gets compiled
> so the simplest operation results in dozens of function calls.
>
> A second third is that Eigen is a low-level library doing stuff from
> scratch. In a typical application, even if you compile it in debug
> mode, it still calls libraries that have been compiled with
> optimizations, so in effect it's still benefiting from optimizations
> in these libraries, and that's typically the most performance critical
> part. In Eigen, everything is home-made so when you compile without
> compiler optimizations, you really get no optimization at all.
>
> The last third is specific to Eigen's unit tests. They enable special
> Eigen debugging code that makes them slower than regular debug mode
> (EIGEN_INTERNAL_DEBUGGING). Basically, every coefficient access, even
> internal ones, is checked to be in range (default debug mode skips
> that on eigen-internal coefficient addressing and only checks user
> addressing).
>
>>, is there a way
>> around to compile my unit tests also in debug mode, but with a bit more
>> performance in the end?
>> Even setting our cmake build type to: RelWithDebugInfo resulting effective in
>> those CXX flags: "-g -DDEBUG -O2" shows no improvement. I assume this depends
>> on the "-DDEBUG", am I right?
>
> No, -DDEBUG is just enabling regular assertions, that's not too slow.
>
> It's weird that RelWithDebInfo wasn't any faster for you. I checked
> the whole command line with VERBOSE=1 make,  and it should really be
> optimized and fast:
>
>   -g2 -O2 -g  -O2 -g2
>
> (redundancy is no problem)

Please try today's hg development branch with RelWithDebInfo. a Cmake
issue was recently fixed.

Benoit

>
> Benoit
>
>>
>> best regards
>> Mathias
>>
>> --
>> Institut für Informatik
>> Universität Leipzig
>> Johannisgasse 26, 04103 Leipzig
>> Phone: +493419732283
>>
>>
>>
>



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/