Re: [eigen] Low performance in DEBUG mode |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Low performance in DEBUG mode
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Mon, 25 Oct 2010 07:21:58 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=u3waP7iLXKFdFHg++TMOOGKhCWqmcsLLtrtzj9ASzwE=; b=Oheznk1uEjf2fHTa3mD5wBf0YwhOTdbmVBPzqrYLyNzcDJDPfuXqjZ+fNXGoKItncG o8oD+g105yjs8Co3vJVqZrQFExVHN+57vefZTB/o1F13qPhrg+RmMQz0imXA8L77M5ZI NUpxCa7Tl1u3ZpE/cv4rHYdTXdwYQHscDZK0E=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=EQ6j1ztx5lfilLmmdreFN3FEzbVzq9Kd2md5zXdkdS7fWbDiZmazqI6jGsYfIoqZQi tcMVDbcwt3uq8Gs04Hcw54QJRVPrIW8W+QcSwjH5iPWkNeQqoRNiXKBuS0HRi/5PrzdI 1Qnr/8BbR5osigKrW5vW6SBipqYgdmLqmgPTQ=
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)
Benoit
>
> best regards
> Mathias
>
> --
> Institut für Informatik
> Universität Leipzig
> Johannisgasse 26, 04103 Leipzig
> Phone: +493419732283
>
>
>