[eigen] Re: small sums: vectorization not worth it

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


and in case you wonder: the situation is almost the same for dot product

(attached file dot.cpp)

runs 2x slower with SSE...

Cheers,
Benoit

2009/1/16 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>:
> Note: i think the old heuristic was wrong anyway.
>
> Maybe take this occasion to introduce a EIGEN_COST_OF_PREDUX (since
> this cost depends greatly on the simd platform) ?
> And then do a natural heuristic rather than a quick hack like we used to have?
>
> Benoit
>
> 2009/1/16 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>:
>> 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 * 1e-30;
    v[0] = v.dot(v);
    v[1] = v.dot(v);
    v[0] = v.dot(v);
    v[1] = v.dot(v);
    v[0] = v.dot(v);
    // std::cout << v << "\n"; // check it's not inf...
  }
  return int(v[0]);
}


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