Re: [eigen] About performance with 3-double vectors and self written library

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Thank you very for taking the time and playing with the code.

I will implement the eigen interface in the real code (Molecular Dynamics simulation of granular media) and compare the performance.

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.
>
> *********************
>
>



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/