NDK : Build X86 binary for Intel Atom platform

2751 ワード

Abstract


This paper introduces detailed methods for building binary for the Intel Atom platform using the Android Native Development Kit (NDK) and optimizing performance.

Build


Same with NDK build for ARM based platform, for Intel Atom platform, it needs same directory structure, Android.mk and Application.mk too. Differences between them are just some flags.

Different flags for Intel Atom

      Application.mk  :  
           APP_ABI := x86
      Android.mk :
           LOCAL_CFLAGS +=  -march=i686 -mtune=atom -mstackrealign -msse3 -mfpmath=sse -m32
      For Android.mk, ARM related flags should be deleted.
      
      Intel official link : http://software.intel.com/en-us/articles/creating-and-porting-ndk-based-android-apps-for-ia/ 

Optimizing


Porting NEON* Instructions to SSE.
Use Inline instead of Frequently Used Short.
Use Float instead of Double.
Multi-thread coding.
Use compiler flags.
Compiler Flags
-march=cpu-type : Generate instructions for the machine type cpu-type
-mtune=cpu-type : Tune to cpu-type everything applicable about the generated code, except for the ABI and the set of available instructions.For example, if GCC is configured for i686 then -mtune=atom generates code that is tuned for atom but still runs on i686 machines.
-msse3 : Enable the use of instructions in the SSE3.
-mfpmath=sse : Generate floating-point arithmetic for selected see unit.
-m32 : The -m32 option sets int, long, and pointer types to 32 bits, and generates code that runs on any i386 system.

For more flags, please refer to http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html .

Others


X86 project for OS engine is added into svn(both trunk and V3.7C), you can refer to it and also with the NDK documents, which locate at $NDK_PATH/docs.