Re: [eigen] strange SSE2 impact on Vector::array and Array

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


Array and Vector should really give you the same perf, the difference
you get is probably only due to your system load. However, SSE should
give you a significant speed up.

Here is a small bench that you cn try:

#include <Eigen/Core>
#include <bench/BenchTimer.h>
#include <iostream>

using namespace Eigen;

EIGEN_DONT_INLINE void foo_arr(ArrayXd& a, ArrayXd& b)
{
  a += b;
}

EIGEN_DONT_INLINE void foo_vec(VectorXd& a, VectorXd& b)
{
  a += b;
}

int main()
{
  BenchTimer t1, t2;
  const int n=10000,m=10000;
  {
    ArrayXd a(ArrayXd::Random(n)),b(ArrayXd::Random(n));
    BENCH(t1, 20, m, foo_arr(a,b));
  }

  {
    VectorXd a(VectorXd::Random(n)),b(VectorXd::Random(n));
    BENCH(t2, 20, m, foo_vec(a,b));
  }

  std::cout << t1.best() << " " << t2.best() << std::endl;
}

Here I get:

without SSE: 0.122551 0.121282
with SSE: 0.0742666 0.0743076

gael

2011/12/17 Not Sure <kuerzn@xxxxxxxxxxxxxx>:
> void main(){
>
>  const int n=100000,m=10000;
>  {
>    ArrayXd a(ArrayXd::Random(n)),b(ArrayXd::Random(n));
>    for(int i=0;i<m;i++)
>        a += b;
>  }
>  {
>    VectorXd a(VectorXd::Random(n)),b(VectorXd::Random(n));
>    for(int i=0;i<m;i++)
>        a.array() += b.array();
>  }
> }



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