asm optimization... does it worth?

Started by
12 comments, last by dodheim 18 years, 4 months ago
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,
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.
Unless you're trying to learn, don't bother unless you profile and find that your engine's core functions are a bottleneck.
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
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
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.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
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.
Hi!

Thank you for your answers!

Endar mentioned profiling. What profiler tools do you use for that?

thx
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.
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
Unfortunately (and totally incomprehensible to me), Visual C++ 2003 does not include a profiler.
Luckily DevPartner Profiler Community Edition and AMD CodeAnalyst exist.

[Edited by - Konfusius on November 24, 2005 8:54:31 AM]
Does AMD Code analyst require an AMD procesor like Intel's VTune?
Btw. VTune is a great profile, you can download a demo version from the intel site.

This topic is closed to new replies.

Advertisement