How to Develop and Evaluate 64-bit Android Apps on Intel x86 Platforms

Published Date
09 - Oct - 2015
| Last Updated
09 - Oct - 2015
 
How to Develop and Evaluate 64-bit Android Apps on Intel x86 Plat...

Introduction

Nowadays more and more mobile end-user devices are powered by 64-bit architecture. Using 64-bit Android* is a great way to gain access to the market. This article will introduce Android on Intel® 64-bit architecture and discuss its unique compatibilities, including technical details, performance gains, problem statements, and available solutions for Android on Intel® Atom™ processor-based platforms.

Intel continually introduces new, cutting-edge features into its 64-bit processors. Developers who want to take advantage of Intel® Advanced Encryption Standard New Instructions (Intel® AES-NI), and other innovations only need to compile their applications in 64-bit mode. Intel is working to optimize Android for 64-bit architectures and create SDKs that expose CPU functionality to higher level developers.

With Google’s recent release of its x86 64-bit Android 5.0 emulator image, developers can create 64-bit apps for Intel Atom processor-based devices.

Android 32-bit vs 64-bit

Many 64-bit platforms today, including Solaris, AIX*, HP-UX*, Linux*, OS X*, BSD, and IBM z/OS*, use anLP64 model. Since Android is based on the Linux kernel, Android 64-bit platforms also use the LP64 model [1]. The data type is shown in Figure 1.

Figure 1: Different data type sizes on LP32 and LP64 Models

Intel 64-bit CPUs have a 32-bit compatibility mode. While 32-bit applications will run on 64-bit processors, compiling with a 64-bit optimizing compiler allows them to take advantage of the architectural benefits of a 64-bit environment.

How to build Android applications for 64-bit

For NDK-based Android applications, you need to build your native libraries to support 64-bit systems. You can do this by performing these steps:

1. Download and install the right NDK version.

You can get it from the official website [2] or build it from the AOSP yourself.
[Note: There are two versions of the NDK for 32- and 64-bit systems starting with NDK R10.]
For both Windows* and Linux systems, you need to decompress the NDK file and set the right path in the system PATH environment.

2. Build your libraries to support 64-bit systems.

Remember to use ABI x86_64 to build your project, using the “ndk-build APP_ABI=x86_64” command. This is the best way to build native libraries for 64-bit Android system on x86 platforms. For other platforms you need to set the APP_ABI to “arm64-v8a” or “mips64”. Or you can add the line “APP_ABI = x86_64” to the Application.mk and use the “ndk-build” command directly.

In most cases, the above command will work well, but sometimes errors will occur. You should correct your native code based on the error information.

3. Rebuild the whole project to get the new application.

Now you can install your newly created application and test it on an emulator or on the targeted devices.

How to run 64-bit apps on emulators

If you don’t have any full 64-bit supported devices, you can test your applications in an emulator. Luckily, Android Dev announced the availability of the Android L 64-bit emulator for Intel x86 architecture [3]. You can download and install the 64-bit system image for the Intel Atom processor using the Android SDK Manager. As Figure 2 shows, in the Android SDK Manager you can choose the “Intel x86 Atom_64 System Image” under Android 5.0 (API 21) and install it.

Figure 2: “Intel® x86 Atom_64 System Image” checkbox in Android* SDK Manager

Create a new Android virtual device (AVD) based on Intel Atom processor 64-bit system image and open the AVD Manager in SDK Manager or ADT. Then click ‘create’ and fill the fields as shown in Figure 3. Now the 64-bit AVD emulator is ready to run.

Figure 3: Create an x64 image in AVD

Follow these steps to run the 64-bit application on the emulator:

  • Edit ./jni/application.mk to APP_ABI := x86_64
  • Compile your native files
  • Run as an Android application on AVD

Figure 4: An app named “x86_64 Hello-JNI”, running on x64 AVD

Performance on 64-bit x86 Android platform

Based on our testing, application performance is faster on the 64-bit systems. We ran an encryption demo on a 64-bit IA device, codenamed Bay Trail. This encryption demo benefits from both the latest version of Android and Intel AES-NI. Figure 5 shows the results of encrypting a 312M mp4 file. Without the I/O time, the total time is 1.56s on a 32-bit Android 5.0 system, while it ran in 1.49s on 64-bit Android 5.0 system, a performance increase of 5% [4].

Figure 5: Time for encrypting mp4 via Intel® AES-NI

Detailed test results are shown in the following table.

Table 1: Detailed test results of running encryption app

We also built a 64-bit FFMPEG and verified the performance on Android 5.0. The result showed that the average FPS of the 64-bit version is ~7% better than the 32-bit version on the same Bay Trail platform [4].

Figure 7: FPS of 1080p MP4 playback through FFMPEG on 64-bit Android*

Here are two more examples that show the performance benefit of 64-bit Android on Intel platforms. The performance benchmarks for several ISV’s software in China shows 7-8% [4] performance gain by using 64-bit compared to 32-bit.

For an ISV’s multimedia decoding application:
This benchmark shows that, in general, playback performance of all formats (3gp, avi, flv, mkv, mov, mp4, rmvb, wmv) increased by ~20% (performance gain of using 64-bit compared to 32-bit) [4].

Figure 8: FPS of the multimedia decoding app on 64-bit Android*

For an ISV’s Voice Recognition application:

the Voice Combination Engine enabled for 64-bit Android shows a performance increase of ~40% on 64-bit + ART (~10% performance gain using 64-bit compared to 32-bit) [4].

Figure 9: Voice combination engine initialization time on 64-bit Android*
We analyzed the modules of this TTS demo on both 64-bit and 32-bit Android, including get token cost, sty cpy cost, stream cost, and getline cost: (ms).

Figure 10: TTS key modules cost on 64-bit Android*

The results show the benefit of 64-bit appliction, especially on the memory I/O and stream operation.

Summary

Android L with 64-bit technologies for Intel Atom processor-based platforms can help developers to optimize their applications now. Building Android applications for 64-bit is just as easy as building traditional 32-bit Android applications. You can now use the official Android 64-bit emulator to run and debug 64-bit apps. To test the performance of 64-bit x86 Android platforms, we rebuilt several open source projects to 64-bit and had several top ISVs in PRC build 64-bit versions of their apps. The performance benchmarks show 7-8% (or even 20% on one special case) performance gains using 64-bit compared to 32-bit.

For more such Android resources and tools from Intel, please visit the Intel® Developer Zone

Source: https://software.intel.com/en-us/android/articles/how-to-develop-and-evaluate-64-bit-android-apps-on-intel-x86-platforms