Re: [eigen] array functionality... |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] array functionality...
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Tue, 9 Mar 2010 14:59:26 -0500
- 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 :date:message-id:subject:from:to:content-type; bh=DFO8rQ+9Bl2dAApUtGt665CPhlmvQY0nohnsenqVyEk=; b=OMRwvN5Ymj132e/IG/SPcoxG0bHckQMjHzzQZt2O9LWgPmtnOlvJ/CUkkI4rL8iaHG 6WlTySZjHXeouAm9EJvOJXXIvN80/kGJMN8ZTTBU/cGrdWMREFcOjgc3LSheSKSqz3r2 CBFAsKS/40Pu/kqJ0kyanzzyxHYqPHV4YjDsI=
- 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; b=k+SoTzjhcgiulzHxLP37cZ7Jta9VOoKq3+uam2Y5wJXzTOJ4YcitQwyCJExxLfJzyu oTrSI5Y5dZzJiG6PY0pGjx4LaVaeEczSdrj4qarvZ7KwiXLJq4aBIr/71JoTHhE3/Ui0 wYqG9AqljpyWLCKCHw15utVN2mXVHOHukUyk0=
2010/3/9 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
> On Tue, Mar 9, 2010 at 3:26 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
>>> Just did that and the Eigen-fied version
>>>
>>> norms = (x.replicate(1,y.cols()) - y).matrix().squaredNorm()
>>>
>>> is way slower...
>>
>> How about using a colwise() here?
>
> Which is what I actually did - it was just a typo. I also know right
> now, why this is so much slower. The issue is that the final reduction
> does not see that this is vectorizable so an unvectorized path is
> chosen.
Sorry, I didn't read your post carefully enough.
The fact that it's not getting vectorized looks like a bug: it should
be perfectly vectorizable.
I am not opposed to adding squaredNorm() for arrays too although
"norm" is matrix terminology. I agree there are such use cases.
Benoit
>
>> (Dont remember for sure if squaredNorm is available in partial
>> reductions, but if it's not then it's easy to add, or you can replace
>> by this:
>>
>> norms = (x-y).abs2().colwise().sum()
>
> That one was a quite good hint since now I am getting vectorization.
>
> I attached an example of computing the column-wise squared norm of a
> matrix. I tried out four possibilities.
>
> 1) manual (0.163722 secs)
> 2) semi-manual, loop+abs2().sum() (0.360112 secs)
> 3) semi-manual, loop+matrix().squaredNorm() (0.358127 secs)
> 4) full-automatic (1.1833 secs)
>
> On MSVC 1) is the clear winner - probably and hopefully, in GCC 1/2
> and 3 will be en par
> 2) and 3) perform nearly identical
> 4) is loosing since a non-vectorized path is chosen
>
> I don't want to cause more work than you already have right now - so
> letting this topic rest is fine with me.
>
> There is only one thing I would like to bring up for the future. Eigen
> is offering many possibilities to solve one and the same problem. In
> general, it is clear that not all of them offer or even can offer the
> same performance -- nonetheless I think we might consider making
> people more sensitive about this fact by adding some information to
> the docs.
>
> I will put a marker on this post and try to find some time in the future.
>
> - Hauke
>