[eigen] small sums: vectorization not worth it

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


Hi Gael *cough* List,

ei_predux is costly because it consists of >1 SIMD instruction.

So until recently we had sum() only vectorize if the size was big enough.
However this was recently changed.

Attached is a benchmark that runs 2.5x slower with SSE (2 or 3) than
without. It's just Vector2d::sum().

So, revert to old behavior?

Moreover: matrix product innerVectorization also uses a ei_predux. Same here?

Cheers,
Benoit
#include<Eigen/Core>

int main()
{
  Eigen::Vector2d v; v << 1, 0;
  for(int i = 0; i < 10000000; i++)
  {
    v = Eigen::Vector2d::Constant(1) + v/10000;
    v[0] = v.sum();
    v[1] = v.sum();
    v[0] = v.sum();
    v[1] = v.sum();
    v[0] = v.sum();
    v[1] = v.sum();
    v[0] = v.sum();
    v[1] = v.sum();
    v[0] = v.sum();
    v[1] = v.sum();
    //std::cout << v << "\n"; // check it's not inf...
  }
  return int(v[0]);
}


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