[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] nesting
- From: Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>
- Date: Thu, 4 Feb 2010 23:26:58 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=GjAkp2otnOiM0CxI7+1f3Ijyymk9NeRVTnybM+Jhpa4=; b=PW7zh1ESnO1zKIGAN+nbWJjzQj1fkpIIxIebCCut2OHGGt2/SDyQvgFzUJgfmCJj9L f2914leZmSqc5eK+mbu9OhX/0JoIQVUwIuCXeQjE6+rkj4Qy2w7LMoYmOOspaUssEFca 3aALjq3bt2k1uxGth3NDJqPP+0qboBnCGGayU=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=u5KDetwBcUWxZBxFagowLZfaix+vWW1pktUZCQDSVVAgvlqYYjuA8QBm9KK0U8nLRP kdNx3n2H2yVK6e0jH5o8NgJZpVTb6G41CWo/aqw3UCMZECebWtxQTsdM8VhIUG80XF49 yzPYh0Z1Q9BJgXNT7HKFqhCCchGHRZB3KnsgU=
On Thu, Feb 4, 2010 at 11:23 PM, Gael Guennebaud
<gael.guennebaud@xxxxxxxxx> wrote:
> On Thu, Feb 4, 2010 at 11:17 PM, Gael Guennebaud
> <gael.guennebaud@xxxxxxxxx> wrote:
>> On Thu, Feb 4, 2010 at 11:11 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
>>> Just one thing that I don't follow:
>>>
>>> 2010/2/4 Gael Guennebaud <gael.guennebaud@xxxxxxxxx>:
>>>> Our real problem is the following:
>>>>
>>>> A*B + A1 + A2 + A3 + A4 + A5
>>>>
>>>> creates 5 temporary matrices, the result of A*B is copied 4 times....
>>>
>>> Why is it so? After A*B has evaluated into a temporary matrix, isn't
>>> it the same as
>>>
>>> tmp + A1 + A2 + A3 + A4 + A5
>>>
>>> ? That doesn't evaluate at every step ...!
>>
>> this is the problem that Hauke is talking about: since we nest by
>> value, tmp is stored in the expression of tmp + A1, so sizeof(tmp+A1)
>> = big, so does (tmp+A1)+A2, etc. I did not check but I think that the
>> way it works.
>>
>> on the other hand if you write:
>>
>> (A*B).eval() + A1 + A2 + A3 + A4 + A5
>>
>> then it is fine fine because the temporary is explicitly created on
>> the stack and stored by reference by the binary expressions...
>
> I checked:
>
> r = x*x +y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y;
>
> => 0.22sec
>
> r = (x*x).eval()
> +y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y+y;
>
> => 0.063sec
>
> gael.
By the way, when I was debugging this, I used the ctor stuff from the
unit tests...
static int nb_temporaries;
#define EIGEN_DEBUG_MATRIX_CTOR { \
if(SizeAtCompileTime==Dynamic) \
nb_temporaries++; \
}
I have to go now...
- Hauke