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: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Wed, 27 Jan 2010 21:11:53 -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=ZYFqzOO0XN2m7UxZQyNHPpLnSh44GxVwGZMwGKY4ics=; b=GvfuTwJkIBnTtpsPx/kkd6nu3ERUjOfYunyGhZMptyMzPihPbk1LaOgSjgJzWF9MQb kO4be/8ivO5tRh3U1/N6NyA7Yoz6Dsvygb+dqMCVVfZVAzBaFqG+ZFrzHTmKcCG0goSj MNXooLkjbxPaOwYq596IzhiYLGm3LURcEKY+Y=
- 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=qix07VTzp5aDXmoeAbsjMD5RVHhEpL9dZ5cpWvQ5v4JINkZYB4X9/ltZ8VyRJnOolO HfgPATfx8tmTEPuDUvkLRmH4EtZ/W0Skmr7LxxU1411oSIU4lDq0ma1NTrmNh88Flkeh AEJUBRJ5/WZKdnIB2SwsJqlJoG7I3pfav898E=
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