Jump to content
  • Advertisement
Sign in to follow this  
dodheim

asm optimization... does it worth?

This topic is 4590 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! I'm curious if it's worth rewriting engine core functions in asm, may be the compiler would do a better job anyway. (I'm using Visual Studio 2003.) I speculate that it's worth writing only MMX, SSE, SSE2 etc. code as the compiler would beat me in x86 asm in 99% of the cases. Am I right or maybe newer compilers can even utilize MMX or something? thx,

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by dodheim
I speculate that it's worth writing only MMX, SSE, SSE2 etc. code as the compiler would beat me in x86 asm in 99% of the cases.

That's been my experience. I did some UI optimization in a game that I was able to beat the compiler with my own asm, but only by a small amount; at then end I put the old code back in because the tradeoff between readability wasn't worth it.

Quote:

Am I right or maybe newer compilers can even utilize MMX or something?


I don't really think that the latest stuff is really smart enough to parallalize your code for you beyond instruction pairing. I think you can use the SSE intrinsic functions and sometimes it might find an optimization for you, and it's generally portable between gcc and MSVC but really I've been doing mine by hand.

Share this post


Link to post
Share on other sites
Unless you're trying to learn, don't bother unless you profile and find that your engine's core functions are a bottleneck.

Share this post


Link to post
Share on other sites
Quote:
Original post by Endar
Unless you're trying to learn, don't bother unless you profile and find that your engine's core functions are a bottleneck.

And then make certain that you've performed all algorithmic optimizations possible.

CM

Share this post


Link to post
Share on other sites
The primary use of assembly language is to access processor features that are not utilized by the compiler (or accessible through the compiler). Compilers did not (and some still do not) support features like MMX, SSE, SSE2, ... when they were first available.

Share this post


Link to post
Share on other sites
You have asm, c and c++. Each one has strengths and weaknesses and overtime you'll get to discover them. Also, each one allows you to solve problems in its own way which might be better or worse. So it's no always the speed that matters. Check out Randal Hyde's old masm book and look over that code optimization chapter near the end of the book. It's a good read.

Share this post


Link to post
Share on other sites
Since you're using VS 2003, there's probably a profile option in it. I'm using Visual C++ 6, and the profile option is Build->Profile

It'll probably tell you to change the project options to include profiling, but it'll tell you how.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!