Re: [eigen] About performance with 3-double vectors and self written library |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] About performance with 3-double vectors and self written library
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Tue, 2 Mar 2010 14:51:12 -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 :content-transfer-encoding; bh=yJv95jJVdOU9tzf64cOd7EjzprDWOzXH6NU8OWqfcvI=; b=AKCSXdIitlkI4H+gqrXjEDz+GObUwP4Ih1l3lPg+4F2g0wrDKpJyXPLEhUcY0FCQ09 wh/V/y4C1FUhSPmy745wUY3aC+3GFtSzSaxwEldvwytL9i1j7519tsOwXES9FwVwY5Ck JjCWVAItQsd52/ZOwpg1rhcINrSJExbu2C79Q=
- 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:content-transfer-encoding; b=Px0AcQ+ja5waRXKZGtHC1YEx9e8yUJPMzXsq/lo6SpYeDQriUlA0r2QGlXpb5whwkj N+Wc2EUveGCC55Ld9XmqDKFU6k0RVNKqXdymYPM5HpobjYSeuSkZfMlXO79iYbSlYZOs znFnxzVI9YngJ1/iNQKCB4qaanGkg94Rq4+io=
thanks!
let's wait till 4.5 is released before we worry about the performance
of its generated code :)
Benoit
2010/3/2 William Oquendo <woquendo@xxxxxxxxx>:
> Hi,
> I have just rewritten the code following a suggestion on the irc eigen
> channel. Now the loops operation depend on loop counter.
>
> The performance is almost the same for both my library and eigen with both
> g++ 4.5 and 4.2, although g++ 4.5 times are slower than 4.2 ones.
>
> The new code is attached.
>
> Best regards / Cordialmente,
>
> --
> William Oquendo
> Phd Candidate
> Simulation Of Physical Systems Group
> National University of Colombia
> Linux User # 321481
> *********************
> Este correo puede carecer de tildes o eñes ya que el teclado no contiene
> estos caracteres. Presento excusas por eso.
>
> *********************
>
>
>
> On Tue, Mar 2, 2010 at 1:45 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
> wrote:
>>
>> I played with your example a bit, but it's hard to extract anything
>> meaningful from it. Indeed, the performance difference is most
>> probably explained by the ability of the compiler to
>> reorganize/simplify these simple arithmetic operations. That explains
>> the difference between gcc 4.2 and 4.5.
>>
>> Now in order to check this for sure, we have to study the asm, but
>> here it's not too easy because you're testing a bunch of operations at
>> once. So the first step would be to isolate the part of your benchmark
>> where the performance difference occurs.
>>
>> Even though, if, as I suspect, it's just the compiler optimizing away
>> / reorganizing arithmetic operations, then it's not a good benchmark
>> and so is not worth trying to make run faster.
>>
>> Benoit
>>
>>
>> 2010/3/2 William Oquendo <woquendo@xxxxxxxxx>:
>> > Dear all,
>> >
>> > I have written a small 3 dimensional - double - vector library, and I
>> > was
>> > expecting that eigen performance was better than my library.
>> > Unfortunately,
>> > that is not the case. I have run a test and, for g++ 4.2 I got aprox 12
>> > secons with eigen and aprox 6 seconds with my library. With g++ 4.5, I
>> > got
>> > 5.5 aprox for eigen and 7 aprox for my library.
>> >
>> > I wluld like to know if I am using eigen the wrong way and that is the
>> > cause
>> > of this c++4.2 performance penalty (I do not have access to g++ 4.5 on
>> > the
>> > production servers) or this is just an special case.
>> >
>> > I am attaching the code and copying it here:
>> >
>> > #include "vector3d.hh"
>> > #include <eigen2/Eigen/Core>
>> > #include <eigen2/Eigen/Geometry>
>> > USING_PART_OF_NAMESPACE_EIGEN
>> > #include <iostream>
>> > using namespace std;
>> >
>> > typedef Vector3D vec_t; // my library
>> > //typedef Vector3d vec_t; // Eigen
>> >
>> > const double STEPS = 1.0e4;
>> >
>> > int main(void)
>> > {
>> > double i;
>> > vec_t v1, v2;
>> > vec_t v3 = v2;
>> > vec_t v5;
>> > ///*
>> > for(double j = 0; j < STEPS; j++) {
>> > v3 = v2;
>> > // copy constructor
>> > for(i = 0; i < STEPS; i++) {
>> > vec_t v4 = v3;
>> > }
>> > // copy
>> > for(i = 0; i < STEPS; i++) {
>> > v3 = vec_t(i/0.34, i, i*i);
>> > }
>> > // accessing one element
>> > for(i = 0; i < STEPS; i++) {
>> > v3[1] = i;
>> > }
>> > // long airhmetic operations
>> > v1 = vec_t(1,2.2,3.4);
>> > v2 = vec_t(-2, 3, 3);
>> > for(i = 0; i < STEPS; i++) {
>> > v3 = vec_t(i/0.34, i, i*i);
>> > v5 = v1+v2-v3;
>> > }
>> > // scalar product
>> > double result;
>> > for(i = 0; i < STEPS; i++) {
>> > result = v3.dot(v5);
>> > }
>> > // cross product
>> > for(i = 0; i < STEPS; i++) {
>> > v5 = v1.cross(v2);
>> > }
>> > // complex operation
>> > for(i = 0; i < 10*STEPS; i++) {
>> > v5 = v1 + 2.0*v2 - v3/4.0 + (v3.cross(v2));
>> > }
>> > // normalize
>> > for(i = 0; i < STEPS; i++) {
>> > v3 = v5.normalized();
>> > }
>> > for(i = 0; i < STEPS; i++) {
>> > v5.normalize();
>> > }
>> > }
>> > //*/
>> > clog << v1 << endl;
>> > clog << v2 << endl;
>> > clog << v3 << endl;
>> > clog << v5 << endl;
>> > return 0;
>> > }
>> >
>> >
>> >
>> > Best regards / Cordialmente,
>> >
>> > --
>> > William Oquendo
>> > Phd Candidate
>> > Simulation Of Physical Systems Group
>> > National University of Colombia
>> > Linux User # 321481
>> > *********************
>> > Este correo puede carecer de tildes o eñes ya que el teclado no contiene
>> > estos caracteres. Presento excusas por eso.
>> >
>> > *********************
>> >
>> >
>
>