Question

I'm making an vector/matrix library for Game which utilizes SIMD unit on iPhone (3GS or later). How can I do this? I searched about this, now I know several options:

  • Accelerate framework (BLAS+LAPACK+...) from Apple (iPhone OS 4)
  • OpenMAX implementation library from ARM
  • GCC auto-vectorization feature

What's the most suitable way for vector/matrix library for game?

Was it helpful?

Solution

To do it well you will probably need to write your own SIMD routines. Use the Neon C intrinsics in gcc rather than assembler to ease the pain of doing this.

OTHER TIPS

You should assume GCC won't auto-vectorize your code, because it sounds like that is very unlikely to happen!

Like Paul said, to get the most performance from your iPhone you should write your own ARM Assembly code using NEON SIMD instructions for as much of it as you can. But that assumes you understand ARM assembly language as well as NEON, timing delays, etc. So if you don't want to learn ARM Assembly language, then Apple's Accelerate framework and ARM's OpenMAX libraries both have numerous functions that are already written in ARM assembly language with NEON SIMD instructions.

So either Accelerate or OpenMAX should be very good if you can use them. I haven't compared the 2 to see which one is actually faster, but I assume ARM's OpenMAX is slightly faster than Apple's implementation since ARM designed the NEON specs! But they should both run extremely fast.

With time come new answers:

The bullet physics engine is now optimized for NEON SIMD by Apple. http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=8490

I created a couple of NEON optimized Mat*Mat and Mat*Vec routine using inline ASM. They are part of the Oolong Engine, but they are under the MIT license, so you can use them as you like:

http://code.google.com/p/oolongengine/source/browse/trunk/Oolong%20Engine2/Math/neonmath/neon_matrix_impl.cpp

Apple now has <simd/simd.h> which is a library of optimized math routines for small vectors, matrices, and quaternions as part of the Accelerate framework you mention. Seems like that's probably the easiest way today. https://developer.apple.com/documentation/accelerate/simd?language=objc

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top