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:29:09 +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=iR9HU1eicwylayLWTLz1/QxofRMXsD6TfOlYo9R9j6I=; b=tE7L446OIjFafBOspoXdURevoXdfc+eKzNDwfyHFXtLbhEjXyAQLc2GymvWvT3SSax yBWI5TsgUAvfg7uCCYI6QAWfZnmrDp2YZ9pfY87lSttbC5O/M4dTo4ndVwYrgXWJQ0Lg 7aFVkV4uwefUDNFQ1+C2MFZKt5ZuwdnwHlmPI=
- 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=f1GUnLS0vIOpG6Slt5dFcKy0ux/rKnsCP1fq7IQj0CVbYZdI3k1erR+Ho+xImNgtrN LFjOKS/+xyAqRm1lt4/JnWakvkn88XF5lxzt0LWWI+Kx7mUXBIuWvxuyS4W83Agh+m/v ucKAHl0urQ6OW1/gsWBsgtXrFli1e1mg1H2d0=
ok, problem solved.
(I've forgotten to specialize ei_ref_selector for Array when I did the merge)
gael
On Fri, Jan 29, 2010 at 9:24 PM, Gael Guennebaud
<gael.guennebaud@xxxxxxxxx> wrote:
> 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
>>
>>
>>
>