fpu instructions

Programming, for all ages and all languages.
Post Reply
Ozguxxx

fpu instructions

Post by Ozguxxx »

Hi, I want to optimize some c++ code for speed and I want to use inline assembly, simply there are some computations(multiplications, divisions, etc) how can I do this? FPU instructions? Any online resources are welcome...
Schol-R-LEA

Re:fpu instructions

Post by Schol-R-LEA »

Let's look at this from another perspective: what part of the code needs to be optimized? Specifically, what have you done to profile the code and determine where the hotspots are?

No offense, but unless you are a truly butch assembly programmer, I find it unlikely that you could write FPU code that runs faster than the code generated by gcc. Furthermore, in most mathematical programs, the bottlenecks are not in the arithmetic code, but in the loops and tests.

There's no benefit to be gained from just jumping and tweaking the code until you know where the bottlenecks are. You should know where the problems lie before even considering any optimization, and try to do as much as you can in C before resorting to assembly. To quote Michael Abrash on this subject:
Assembly language optimization is the final and far from the only step in the optimization chain, and as such should be performed last; converting to assembly too soon can lock in your code before the design is optimal. At the very least, conversion to assembly tends to make future changes and debugging more difficult, slowing you down and limiting your options.
If you have already done this, then I apologize, but I would still need to ask what specific optimizations you were looking to do. I would also strongly recommend reading the Graphics Programing Black Book, which discusses optimization strategy in detail, especially in regard to FP arithmetic. I'd recommend downloading it (yes, all of it) for reference purposes, in fact. HTH.
Al-Arif

Re:fpu instructions

Post by Al-Arif »

Hey, thanx for your response, I am not taking anything personal or offensive, in fact your response is quite what I must do... I need to find where bottleneck is... Also is that download legal?
Schol-R-LEA

Re:fpu instructions

Post by Schol-R-LEA »

I've got to be honest, I'm not entirely sure. While the copy on the site is an authorized mirror of the copy that had been on the DDJ site, the site it mirrors required you have a membership in order to read it, and the page is now removed from it. I don't know what the status of this mirror really is, but AFAIK, it is legitimate.
Post Reply