[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] nesting
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Sun, 7 Feb 2010 16:51:52 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type; bh=RyEwKvwkvp9r55Mhusn8iZTeRKJDqTz54oZfDyBmlsk=; b=X1r02LAEkv1bqtg2MySZIflfZrVqomAXIZPN9c7lGbLkKm6gY53VQ3B4cIcgt8I8VM pyYHSetAIU4Q0OGxpDHIF/ALWEv1B2NfaCCZXOBJFa/5G+sicEzmUxSphYNSYeAakw0K 7za71XWqWO2D4ZKGO7LAssxoEjBc8REyKrKYc=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=mlHOT1b5gZqBI6Er6PZU7DSBtLhUT9X0gXM6usKlo+fBQJETIOpPgaUqtniV3QVrXE WTK9586pT3r0ksfWv3QevY/5zaAlnq4g36MGQvYLMflmjh7ytG/xTIcM9iejw7legDTf 6o8iRXk79PfwcMzn9S/WMqwNbSdnnJ+vMabn0=
On Sun, Feb 7, 2010 at 12:38 PM, Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>
Do I remember correctly that the need/reason for evaluating products
into temporaries arises from the fact that the resulting code
(assuming no copies) is more efficient? Isn't this effect now shadowed
by the mallocs?
If that is the case, how about this approach:
+ instantiate temporaries as shared ptrs only when the return type of
a product has dynamic size
+ for fixed size objects don't even create a temporary but simply
evaluate the _expression_ as if all sub-expressions were lazy
Regarding the problem in general, we should try really hard to prevent
the need for using a syntax like this
or related code requiring to call .eval() in order to prevent crashes..
I hope we agree on this?
Currently, I am also a little bit confused about the following code
(from the forum):
double p = (P.transpose * P).diagonal().sum();
in the devel branch Product::diagonal is overloaded to handle that case without the need of an explicit lazy.
It is clear that what we can do in 2.0
double p = (P.transpose * P).lazy().diagonal().sum();
leads to way more efficient code than the default _expression_. This
would remain an issue (or better source for improvements), even if the
problem at hand with the temporaries were fixed. What I am trying to
say is that it might be a nice feature to be able to override the
default behavior and deactivate eval-before-nesting.
Finally, I think I need to update the 3.0 TODO list. Personally, I
consider this whole problem a blocking, high-priority issue for 3.0.
On Sun, Feb 7, 2010 at 10:26 AM, Gael Guennebaud
> also note that the nest everything by reference approach we have in Eigen
> 2.0 also leads to unnecessary copies:
> Indeed since (a*b).adjoint() is compiled as:
> the result of a*b gets copied once from the Conjugate to the Transpose
> Finaly, let emphasize again that with either the current devel approach or
> the evaluator I described in the previous email, dynamic sized matrices can
> be easily worked-around using kind of shared pointers or a list of
> temporaries respectively. So the discussion might be focused on fixed size