Re: [eigen] New true array class ? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] New true array class ?
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Fri, 29 Jan 2010 21:24:35 +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 :content-transfer-encoding; bh=mdLMysz1fUbX3DlO3eUnIJnFBcBBLYUhIrBPnvCP5qg=; b=OpeEz2C+URplTL9JlSsq57410XjiScMkP86dTCw17bTox6lRFZd9XZyXEhR/9xdhiH vPB0PS5fYQX55kuhkP6VvPlcrpAw/wgpQX0VdGcdlqn2+890ZUqMZ3MZmbYly8ExfW08 Y8XEF8OrWgQ+h8P0ZmBdIoYGQAdOBwrRpijU4=
- 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:content-transfer-encoding; b=kv75URFwC/XYxS9ChKlVpe6SOM9ueKgZkQeFr/bXZByISyzhprIEs1FJI7X1cAcT9V Hutxw5GQJ4u22QFwb7tPWZLSYJgysLmrLgqr0rE6ufy8l78Tr4T8q/hWsxXyiTaz2JQC uxJpPX7yTz6pgKDmcoxFO8V7GQoNqiq2+6hDs=
indeed, because switching from ArrayXd to VectorXd and replacing the
"*" by cwiseProduct() makes Eigen significantly faster.... I'm
investigating...
gael
On Thu, Jan 28, 2010 at 3:11 AM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
> 2010/1/27 Boris Mansencal <boris.mansencal@xxxxxxxx>:
>> Quoting Gael Guennebaud <gael.guennebaud@xxxxxxxxx>:
>>
>>> this is because this was not implemented. done now for sin, cos, exp,
>>> log, abs, and sqrt. feel free to send a patch to support more (I've no
>>> time right now)
>>
>> Thanks a lot. Perfect.
>>
>> One more question, the attached test try to compare std::valarray &
>> Eigen::Array for a simple computation.
>> Eigen::Array is much slower than std::valrray.
>>
>> It seems that Array copy constructor is called too many times (and
>> posix_memalign with it).
>>
>> Do you have any idea from where it comes from ?
>> Is it because of missed inlining ?
>
> Wow, indeed, there's a problem. While the valarray version is
> perfectly vectorized and without any temporaries, the Eigen version
> has a lot of posix_memalign() and free() going on in the loop.
>
> A small improvement for both valarray and Eigen is to use the v4 that
> you constructed instead of declaring a local v4 inside of the for
> loop. So:
>
> for (size_t i=0; i<NB_REPEATS; ++i) {
> v4 = v1 * M_PI * (v2 * 0.321) * (0.5 * v2);
> v3 += v4;
> }
>
> valarray is still easily 4x faster than eigen.
>
> Definitely a big issue! My best guess is that a bug is causing Eigen
> to evaluate each product into a temporary.
>
> Benoit
>
>
>