Albrecht Andrzejewski
Albrecht Andrzejewski

Reputation: 2240

Compilation optimization for iPhone : floating point or fixed point?

I'm building a library for iphone (speex, but i'm sure it will apply to a lot of other libs too) and the make script has an option to use fixed point instead of floating point.

As the iphone ARM processor has the VFP extension and performs very well floating point calculations, do you think it's a better choice to use the fixed point option ?

If someone already benchmarked this and wants to share , i would really thank him.

Upvotes: 1

Views: 1108

Answers (2)

If you are dealing with large blocks of sequential data, NEON is definitely the way to go.

Float or fixed, that's a good question. NEON is somewhat faster dealing with fixed, but I'd keep the native input format since conversions take time and eventually, extra memory.

Even if the lib offers a different output formats as an option, it almost alway means lib-internal conversions. So I guess float is the native one in this case. Stick to it.

Noone prevents you from micro-optimizing better algorithms. And usually, the better the algorithm, the more performance gain can be achieved through micro-optimizations due to the pipelining on modern machines.

I'd stay away from intrinsics though. There are so many posts on the net complaining about intrinsics doing something crazy, especially when dealing with immediate values. It can and will get very troublesome, and you can hardly optimize anything with intrinsics either.

Upvotes: 0

Skyler Saleh
Skyler Saleh

Reputation: 3991

Well, it depends on the setup of your application, here is some guidelines

  1. First try turning on optimization to 0s (Fastest Smallest)
  2. Turn on Relax IEEE Compliance
  3. If your application can easily process floating point numbers in contiguous memory locations independently, you should look at the ARM NEON intrinsic's and assembly instructions, they can process up to 4 floating point numbers in a single instruction.
  4. If you are already heavily using floating point math, try to switch some of your logic to fixed point (but keep in mind that moving from an NEON register to an integer register results in a full pipeline stall)
  5. If you are already heavily using integer math, try changing some of your logic to floating point math.
  6. Remember to profile before optimization
  7. And above all, better algorithms will always beat micro-optimizations such as the above.

Upvotes: 2

Related Questions