Jump to content
  • Advertisement
Sign in to follow this  
Vortez

MMX and SIMD optimization question

This topic is 2567 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, just wanted to know, when optimization is turned on (in a c++ program), will the compiler try to optimize for MMX or SSE if possible? or do you always have to do this by hand?

Share this post


Link to post
Share on other sites
Advertisement

Hi, just wanted to know, when optimization is turned on (in a c++ program), will the compiler try to optimize for MMX or SSE if possible? or do you always have to do this by hand?


It depends on the compiler. But "modern" compilers should be able to optimize for it if the corresponding flags are set. At the same time, those are the kind of optimizations where you cannot assume the compiler will do it better than a competent programmer by hand. Often "handoptimizing" better than the compiler is very hard. But when it comes to the SIMD my experience is that the compiler will only be able to do it in the most obvious cases.

Share this post


Link to post
Share on other sites
To be more specific VS 2010 will use some SSE/SSE2 instructions if you pick the appropriate setting, but it won't automatically use the SIMD instructions at all. The latest beta does do some auto vectorization. You can see some more details at http://virtualdub.org/blog/pivot/entry.php?id=353

I believe recent versions of gcc can also do some auto vectorization, but I'm not sure how well it works.

In performance critical code using either SSE intrinsics or assembly directly is your best option at the moment. However intrinsics and assembly are much more awkward to write and maintain, so I'd only use them where profiling finds there's a significant bottleneck that could be improved a lot with SIMD.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!