9

I've been learning up a little on the cpu features and stumbled upon NEON.

From what I've read, it looks like NEON requires specific programming to use this, but is this completely true, or do the cpus that have this feature still find ways to untilize it and speed media processes for some applications even though there is not specific code for it?

Tam
  • 1,189
  • 10
  • 15
  • The instruction set extensions need to be targeted by *something* (drivers/kernel/C library, etc). –  Jul 17 '12 at 02:30
  • In the sense that the Android compiler will do this to a certain level (since not all cpus have the feature.) ? I am seeing this like the MMX extensions the intel cpus had which I believe originally had to be targeted by the programmer, then compilers just assumed it existed, then it got antiquated.. – Tam Jul 17 '12 at 02:34
  • 1
    There might be some optimization that compilers can make use of -- but for those claimed "60%-150% numbers", it still takes hand-coding and intrinsic knowledge of use .. (Not that you'd write an entire program in assembly, but rather the heavy-lifting parts of CODECs or 3d transformations, etc.) –  Jul 17 '12 at 02:47

1 Answers1

10

There are a number of ways to make use of the NEON instructions. Some of them are:

  • Libraries. It is a good chance that your memcpy is handcrafted using NEON. Music/video playback libs in the API are using NEON and/or GPU for acceleration. Aso, there are third-pary libs that use it. FastCV from Qualcomm is a good example
  • Compiler-issued instructions. Some compilers, when provided with the correct options will issue NEON instructions. Most compilers will use neon for float operations, but not vectorize them. They will use the unit as a single-data unit, just because it is fast and convenient. There are some vectorization capabilities in GCC and ARM compiler, but they are really limited in scope and results.
  • Hand-coded C with intrinsics http://gcc.gnu.org/onlinedocs/gcc/ARM-NEON-Intrinsics.html It is probably the best way to get started in the NEON world.
  • Hand-coded assembler. This seems to be the best, if you want to achieve max performance. It also requires a good deal of effort and CS knowledge.

  • Last but not least, you can use NEON by just downloading apps that use it. Your favourite music player and your camera app put the NEON unit in your smartphone to good use.

Conclusion: NEON has a lot of usages, but it is only used if the code specifically contains NEON instructions. More technically, as @pst said, it must be targeted by a piece of code.

Sam
  • 19,708
  • 4
  • 59
  • 82
  • Thank you. Does your mention of Music/video playback mean that Android uses it automatically (that is compiles for it) when we use the SoundPool? (I've noticed quite a difference in speed of starting a sound effect for two phones, one with and one with out neon listed in the cpu features.) – Tam Jul 18 '12 at 04:24
  • Most probably Android offers an optimized version for its audio API, for use with the phones that support NEON, etc, and simple C++ versions for those without NEON. I did not check the Android source code or drivers, but this is a standard model. – Sam Jul 18 '12 at 07:57