IPhone 4 and iPad 2: Benefits of Fixed-Point Arithmetic over Floating-Point

I heard that the iPhone 4 and iPad have fpu called VFP, which somehow optimizes floating point arithmetic, even allowing SIMD (although GCC uses this, which is doubtful). However, I read that for some Android devices, accelerating the use of a fixed point over a floating point can lead to a 20-fold increase in performance.

What would be the benefits of implementing part of the floating point code using fixed point arithmetic over the floating point in these devices.

+2
source share
2 answers

A VFP floating-point unit was configured on the iPhone 3G armv6 processor, which had higher bandwidth than the same integer calculations. GCC supports the creation of VFP instructions planned for pipelining. The iPhone 3GS and iPhone 4 armv7 processor does not have a VFP conveyor unit, and thus, in fact, it is slightly slower in some floating point sequences than the iPhone 3G; but the armv7 processor is faster in a vector short floating point, because instead it has a parallel NEON vector block. Some processors of Android devices do not have a floating point hardware module at all, so the OS uses software emulation for FP, which can be more than an order of magnitude slower than an integer or fixed one.

A general rule may be that if your algorithms can only process 24 bits of mantissa precision and don’t do many conversions between float and integer, use a short floating point on iOS. It is almost always faster.

But if you want to support older Android devices with your C code (using NDK), use a scaled integer.

If your application does not do a lot of crunches, for a typical application that does less than 0.1%, none of the above really makes a noticeable difference.

+7
source

As hotpaw2 said, both the iPhone 4 and iPad 2 have a hardware floating point, so you will not see accelerations of the order of magnitude that you get on platforms that lack such equipment.

However, the NEON vector unit supports operations with integers as well as floating point, and you can speed up certain operations by discarding them as fixed point problems. However , if you really do not understand what you are doing and are ready to write an assembly of implementations of your critical procedures, you will not see any benefit.

Stick to a floating point if it matches your problem. If you need to improve performance, I guarantee that tracking the progress of your application will be much better for tuning.

+1
source

Source: https://habr.com/ru/post/1439866/


All Articles