Re: [eigen] Matrix multiplication seems to be exceptionally slow in one specific case

[ Thread Index | Date Index | More Archives ]

On 16.06.2014 18:54, Marc Glisse wrote:
On Mon, 16 Jun 2014, Christoph Hertzberg wrote:
While I like the idea in general, I'm not totally sure about that either.

If you have doubts about the proposal, they are just as welcome on the
mailing list I mentioned ;-) Matrix expression-template libraries are
the first expected customer for this feature...

Yes, I might do that. I'd need to read the proposal more thoroughly for that, though.

 auto AB = A*B;          // shall this evaluate into a temporary?

Write auto&& (or auto const&) if you don't want value semantics.

Wouldn't that lose C++11 compatibility? (I have not much experience with C++11/14 so far) What must I write to prohibit evaluation in both C++11 and with the new proposal?

 MatrixXd result = AB+C; // actually, no explicit temporary AB required
                         // direct evaluation would have been better

Unless there is a second use of AB somewhere further in the code. I
think there was an item in bugzilla or elsewhere about adding a profile
mode that would among other things tell you if an expression was used
enough times that it should have been evaluated eagerly?

The new expression evaluator provides a nested_eval struct which takes a template parameter stating the number of times the object will be used. Something like this (excerpt from Gael's Evaluator slides):
  MatrixBase<Derived>::normalized() const {
    typedef nested_eval<Derived,2>::type ThisNested;
    ThisNested n(this->derived());
    return n / n.norm();

I can't recall a discussion about adding a profile mode at the moment. That does sound very interest, but quite complicated to implement.

I posted a bug for that:

I added a similar warning to the GMP manual some time ago:

Yes, that seems to be basically the same problem that we have.


Dipl.-Inf., Dipl.-Math. Christoph Hertzberg
Cartesium 0.049
Universität Bremen
Enrique-Schmidt-Straße 5
28359 Bremen

Tel: +49 (421) 218-64252

Mail converted by MHonArc 2.6.19+