Page 1 of 1

Bullet for ARM with neon optimization

Posted: Wed Apr 17, 2013 10:02 am
by vladimir
I'm trying to build bullet physics for ARM architecture. My build was sucessful until I've decided to turn on Neon optimization. By default, bullet uses __m128, __m64 types. They are 32 bit. (4 integer can be setted at one __m128 for example.). When I'm configuring build for ARM, __m128 replacing by __n128 (defined at arm_neon.h). This is 64 bit type. Bullet uses this initialization way in LinearMath library:

(alias to __m128) a = {1.0,1.0,1.0,1.0};

For arm it is (alias to __n128 for some reason) a = {1.0,1.0,1.0,1.0}; //got too many initializers error = {1.0,1.0} // ok.

But all bullet linear math functions uses vector from R4.

Another issue is static asserts. (From btVector3.h)

mVec128 = vmulq_n_f32(mVec128, s); //Got identifier static_assert is undefined

Got 6 error of this kind.

Another issue is operator overloading. (From btMatrix3x3.h)

m_el[0].mVec128 = m_el[0].mVec128 + m.m_el[0].mVec128;

error C2679: binary '=' : no operator found which takes a right-hand operand of type 'btVector3' (or there is no acceptable conversion) c:\bulletphysics\bulletrepo\src\linearmath\btMatrix3x3.h

Is someone tried to build bullet engine for ARM with neon?

Re: Bullet for ARM with neon optimization

Posted: Thu Apr 18, 2013 7:10 am
by nakashima@ss
I use Bullet2.81. I could build neon optimized executable with some easy fixes. And it is working with out problem on armv7/neon machine(iPad2, iPhone4S).
I have confirmed neon optimized code is actually running by inserting #error and set a breakpoint on the neon intrinsic line in btVector3 as follows.
ss2013-04-18 16.01.13.png
As long as I check btVector3 code, __m128 type is not used for neon. In neon code, float32x4_t type is used for the purpose.
I doubt BT_USE_NEON flag is defined when you compile the code. To neon get enabled, BT_USE_NEON flag must be defined. In order to let BT_USE_NEON defined( enable neon), you may need to define "__clang__", "__APPLE__" and "__armv7__", and BT_USE_DOUBLE_PRECISION must be not defined that means you can not use double. As you see in btScalar.h below;

Code: Select all

#if (defined (__APPLE__) && (!defined (BT_USE_DOUBLE_PRECISION)))
    #if defined (__i386__) || defined (__x86_64__)
        #define BT_USE_SSE
        .....
    #elif defined( __armv7__ )
        #ifdef __clang__
            #define BT_USE_NEON 1

            #if defined BT_USE_NEON && defined (__clang__)
                #include <arm_neon.h>
            #endif//BT_USE_NEON
       #endif //__clang__
    #endif//__arm__

Re: Bullet for ARM with neon optimization

Posted: Thu Apr 18, 2013 1:34 pm
by vladimir
Thanks for your reply.

I've contacted with erwin coumans.

He told, that bullet supports neon only for Ios.
(You posted neon Ios code too (__APPLE__ is defined))

But my problem assosiated with Windows Rt.

Do you have any experience building bullet + neon for WinRt Arm?

P.S. I really appreciate you replied my post.

Re: Bullet for ARM with neon optimization

Posted: Thu Apr 18, 2013 5:15 pm
by nakashima@ss
I understood your situation. Unfortunately I do not know anything about WindowsRT.
As you may know, if the VC++ compiler for arm is not LLVM compiler, the Neon intrinsics in Bullet math lib won't compile.

VisualStudio2012 supports ARM-NEON intrinsics.
http://msdn.microsoft.com/en-us/library/hh875058.aspx

Re: Bullet for ARM with neon optimization

Posted: Sun Sep 08, 2013 10:38 pm
by corakwue
Hey vladmir, where you able to resolve your compilation issue on WinRT? I am facing similar problems.

Re: Bullet for ARM with neon optimization

Posted: Wed Sep 11, 2013 5:51 pm
by Erwin Coumans
The Neon ARM code is contributed by Apple and is only supported for iOS.

If anyone wants to contribute Windows RT or Android support for Neon, we welcome the contribution.

Until then, Neon support is Apple iOS only.
Thanks,
Erwin

Re: Bullet for ARM with neon optimization

Posted: Mon Apr 14, 2014 2:49 am
by jmlu0619
I'm building bullet physics for android, and I'm trying to turn on Neon optimization.
As said before, neon in bullet is only supported in IOS,
I don't know whether @vladimir has solved turn on Neon optimization in WindowsRT,
I hope to know why the code about neon in bullet physics cannot be used in other platform,
or what should i do if i want to turn on neon optimization for android platform