Sign in to follow this  
Bakura

SIMD Intrinsics and STL algorithms

Recommended Posts

Bakura    139
Hi everyone, in order to have a more compact code and because I have a lot of small functions, I would like to use STL algorithms (and also because I love how they look on the screen ^^), and replace that :
[source code="cpp"]for (std::size_t i = 0 ; i != 4 ; ++i)
   data[i] = _mm_setzero_ps();
by the more compact :
[source code="cpp"]std::generate (data, data + 4, _mm_setzero_ps);
The problem is that I have a link error : unresolved external symbol __mm_setzero_ps The strange thing about that is that if I replace the _mm_setzero_ps by this generator function :
[source code="cpp"]__m128 Func ()
{
   return _mm_setzero_ps();
}

... In my function :

std::generate (data, data + 4, Func);
It works ! So, is there an error in MSVC intrinsics definition ? Thanks for your answer

Share this post


Link to post
Share on other sites
swiftcoder    18432
Quote:
Original post by Bakura
The problem is that I have a link error :
unresolved external symbol __mm_setzero_ps
The strange thing about that is that if I replace the _mm_setzero_ps by this generator function :
It works ! So, is there an error in MSVC intrinsics definition ?
I don't have a copy of MSVC in front of me, but I would guess that those intrinsics are macros, not functions.

Share this post


Link to post
Share on other sites
Rattenhirn    3114
Quote:
Original post by Bakura
Hum... That's possible... Is there an easy way to overcome this problem ? I'm gonna try to find those files !


The easiest way to overcome this problem, regardless of what's causing it, is to make a small wrapper like you did in your original post.

Or like this, for maximum performance:

struct SetZeroHelper
{
__m128 operator()()
{
return _mm_setzero_ps();
}
};

In your function:

std::generate (data, data + 4, SetZeroHelper);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this