Jump to content
  • Advertisement
Sign in to follow this  
Bakura

SIMD Intrinsics and STL algorithms

This topic is 3554 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 = _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
Advertisement
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
Hum... That's possible... Is there an easy way to overcome this problem ? I'm gonna try to find those files !

Share this post


Link to post
Share on other sites
extern __m128 _mm_setr_ps(float _A, float _B, float _C, float _D);
extern __m128 _mm_setzero_ps(void);

Share this post


Link to post
Share on other sites
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!