[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: Eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: [eigen] nesting
- From: Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>
- Date: Thu, 4 Feb 2010 17:13:44 +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=p6cV96BFyffgE0+NxV8Z9o6wkvvooOSPjmollAp7oGk=; b=Sg41B2/5wg0Tva/SY/d4a3nAlDWGf3Y8nkAvbpzTxsfrmTj3NfHacf6rjQHt8c8OxC gzl84QCWd16l6wwotCA2UqbnWVHqyO9rgWJmjUPgFZE9XReHpF8q3nX6+aaktP9yUE2p 3qAvT0LMJOpNf57a5jyYIuer5cbEGSsn4DqfU=
- 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=dgrCVbQ7CFjuhIZlxjU0DwxNqhG2W62PJkQUkFRfWiZOPbEC+v/RBj93l7x5h1HSQy IkuFTka16BS7v5QJpO5n7XSWwuczGsBbFzdMaEHhWjVADIS//u66lljc52z8Q5HHvqIW h5CaMwTyEOu9dopCUhmiENmhl1Z85XdHFpWmc=
This could be a solution:
template <typename T>
typedef typename ei_meta_if<
sizeof(T)<=8, // tiny expression storing e.g. two references
I am failing to add this code since it requires T to be completely
defined. When this is not working, the only alternatives I am seeing
a) to specialize ei_nested or ei_ref_selector for all expressions
b) add traits to expressions stating whether they are 'light weight'
or not and use them in ei_ref_selector
c) going back to copying everything by value
I am still convinced that c) is not a good alternative - not only
because we were required to bring back NestByValue but also because I
am sure that it is less error prone and ignoring for a moment all the
redundant copies we are seeing, there was a measurable performance
increase when I first tested the code with various expressions
(obviously not too many involving products).
On Thu, Feb 4, 2010 at 4:01 PM, Hauke Heibel
> Well, specializing the product is a bad idea. Actually, we need to
> deduce expressions that have products nested (or heavy weight objects
> in general), those must then be nested by reference in order to
> prevent copies.
> - Hauke
> On Thu, Feb 4, 2010 at 2:35 PM, Hauke Heibel
> <hauke.heibel@xxxxxxxxxxxxxx> wrote:
>> While looking into the "performance degradation" issue from the forum
>> I found out that it is due to temporaries - as Benoit already guessed.
>> I am a little bit afraid, that what I once proposed, namely copying
>> expressions by value, is now backfiring. The reason is that initially
>> I assumed expressions to be tiny little objects with close to no copy
>> costs. The issue is related to those expressions holding temporaries.
>> Copying them (e.g. a product expression) means copying all the data
>> including the temporary and that will happen as many times as we nest
>> The only solution I can think about at the moment is the
>> specialization of ei_nested for those types and to go back to nesting
>> by reference for these heavy weight guys.
>> - Hauke