Math Assembly

86c043eaa94314399cc064d153a93d26
0
_NOISEcore 101 Aug 27, 2011 at 19:32

Hi there,

I have been working on my own “engine” for a while now,
and I believe that it is time that I start optimizing my mathematics
through assembly. I have already optimized some mathematical functions,
but not through assembly.

The question I have however,
is where can I find some descent information about integrating
assembly into C++.

I already looked around a bit, but I didn’t find anything that explained it descently (How does it work, how do the registers work, etc..)

I thank you in advance..

2 Replies

Please log in or register to post a reply.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Aug 27, 2011 at 19:55

You almost certainly don’t need to write actual assembly. If you want to use SIMD or other architecture-specific features, there are intrinsics available, which translate directly to specific hardware instructions but allow you to keep using C++ syntax (and all the other benefits of automated code generation). For example, here is the Intel x86 intrinsics reference (MMX, SSE 1-4, a few other things).

Moreover, optimizing algorithms and data layout (cache locality) are almost certainly going to be more effective than optimizing at the instruction level. If you want to improve your engine’s performance, those would be the place to start. Be sure to profile your engine to actually measure what’s taking the most time, so you can make intelligent optimization decisions based on real numbers rather than assumptions!

86c043eaa94314399cc064d153a93d26
0
_NOISEcore 101 Aug 27, 2011 at 22:47

Thank you, I will surely look into that.
I have heard of those, and they sure seem interesting.

At the moment, it is mostly matrix transformations that take up
quite a lot (relative of course) of time. Maybe this will help.
Thank you for the info.

EDIT: Also, on a side note. This “engine” isn’t being written as use of an actual engine,
see it more as a little project on which I work to test and expand my knowledge of programming.