[Interest] Cross platform accelerated instructions framework

Allan Sandfeld Jensen kde at carewolf.com
Thu May 14 14:52:45 CEST 2015


On Thursday 14 May 2015, Nuno Santos wrote:
> Hi,
> 
> Sorry if the title is not the most appropriated.
> 
> I’m developing an app that will be target for iOS/Android/x86/x86_64
> 
> Since this is CPU intensive application I think that I will reach a point
> were assembly and vector instructions will be needed for maximum
> performance.
> 
> Since ARM and x86 instruction set is completely different, how should one
> handle such cases? Can I assume arm instructions will be the same for iOS
> and Android? Or even at the arm level I will have great differences? Are
> there any cross platform framework for developing high performance tasks
> at this level?
> 
Write in an auto-vectorizing friendly way and compile with -O3.

Alternatively use vector intrinsics, but the generic intrinsics are not that 
powerful.

To write in a way that the compiler can auto-vectorize, write the CPU 
intensive work in simple inner loops without function calls (or only inlined 
ones), use no array access by anything other than the index counter, and also 
avoid branches as much as possible. If you do need branches, write them as 
using conditional assign with c ? a : b.

And no iOS and Android ARM are not identical. On iOS you can rely on NEON 
iDiv, and on newer devices AArch64, on Android NEON is optional (but in all 
high-end devices), and AArch64 CPUs not yet commonly available.

In general don't worry too much until you have actual performance issues. The 
issues can often be in other places than you imagine.

`Allan



More information about the Interest mailing list