This forum has been archived. All content is frozen. Please use KDE Discuss instead.

setMax function with SSE support

Tags: solved solved solved
(comma "," separated)
manuels
Registered Member
Posts
47
Karma
0

setMax function with SSE support  Topic is solved

Sat Nov 13, 2010 12:56 pm
Hi guys,

I'm wondering if one could optimize this line of code using SSE:
Code: Select all
float max = ...;
VectorXf A = ...;
for(int i = 0; i < A.rows(); ++i)
  if (A(i) > max)
    A(i) = max;


Is it be possible to use SSE4's PMINUW instruction to compute this operation?
If so, one could add setCwiseMax()/setCwiseMin() operations to Eigen.


Cheers,

Manuel
manuels
Registered Member
Posts
47
Karma
0
Well, it just came to my mind that you could do something like
VectorXf v = ...;
VectorXf c = VectorXf::Constant(1.0);

v = v.cwiseMin(c);


According to the implementation this would use std::min() for scalar operations and _mm_min_ps() packet operations -- nice!


Cheers,

Manuel


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient