Introduction
Nowadays more and more mobile devices are powered by 64-bit architecture, and using 64-bit Android* is a great way to gain access to that market. This article will introduce Android on Intel® 64-bit architecture and discuss its unique compatibilities, including technical details and performance gains 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 Vector Extensions (Intel® AVX), 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, allowing developers to work at a higher level of abstraction.
With Google’s recent release of its x86 64-bit Android L preview emulator image, creating 64-bit apps for Intel Atom processor-based devices just got a whole lot easier.
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 an LP64 model. Since Android is based on the Linux kernel, Android 64-bit platforms also use the LP64 model[1]. Figure 1 compares the data types for ILP32 and LP64.
data type | ILP32 size (bytes) | LP64 size (bytes) |
---|---|---|
char | 1 | 1 |
short | 2 | 2 |
int | 4 | 4 |
long | 4 | 8 |
long long | 8 | 8 |
pointer | 4 | 8 |
float | 4 | 4 |
double | 8 | 8 |
long double | 16 | 16 |
struct | depends on members (1) | depends on members (1) |
enum | 4 | 4 |
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:
- 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. - 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 “arm_x86” or “mips_64”. 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 occur. You should correct your native code based on the error information. - 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, Intel has been working with Google and released the first 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 L (API 20, L preview) 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 in 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 the native files (reference:64bit-renhang.docx)
- 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
Testing was performed on two ASUS T100 devices with the same hardware configuration (CPU: Intel Atom processor Z3740; Memory: 2GB; GPU: Intel GMA HD; and 32GB SSD). Our encryption demo code ran faster on the 64-bit systems. 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, and 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
Total Time (+SD R/W) (seconds) | Encryption Time (-SD R/W) (seconds) | ||
---|---|---|---|
Android* 5.0 64-bit | Android 5.0 32-bit | Android 5.0 64-bit | Android 5.0 32-bit |
7.046 | 7.379 | 1.498 | 1.649 |
7.152 | 7.27 | 1.49 | 1.529 |
7.011 | 7.368 | 1.529 | 1.57 |
7.151 | 7.196 | 1.487 | 1.522 |
7.182 | 7.282 | 1.468 | 1.548 |
7.1084 | 7.299 | 1.4944 | 1.5636 |
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]
64.6MB (1920*1080 MP4 File) Battery Power: 20% | ||
---|---|---|
Average FPS | ||
T100 64-bit (Intel® Atom™ Z3740 1.33GHz) | T100 32-bit (Intel Atom Z3740 1.33GHz) | |
1 | 189.58 | 178.39 |
2 | 190.24 | 178.53 |
3 | 189.69 | 178.12 |
4 | 189.45 | 178.31 |
5 | 188.89 | 177.86 |
Figure 7: FPS of 1080p MP4 playback through FFMPEG on 64-bit Android*
Here are two more examples that show the performance benefits of 64-bit Android on Intel platforms. The performance benchmarks for ISV 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 using 64-bit compared to 32-bit).[4]
Video file format | 32-bit version running on BYT-T 32-bit ART in average | 64-bit version running on BYT-T 64-bit ART in average | Performance Gain |
---|---|---|---|
1080P .WMV | 22.96 FPS | 28.3 FPS | 23.0% |
1080P .RMVB | 43.6 FPS on | 53.0 FPS | 21.6% |
Figure 8: FPS of an ISV multimedia decoding app on 64-bit Android*
For an ISV’s Voice Recognition application:
A 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]
64-bit x86 Android TTS (Text to Speech) | ||||
---|---|---|---|---|
Voice Combination Engine Initialization Time (ms) | ||||
Intel® Atom™ Series (Bay Trail) Platform | BYT-T 64-bit ART | BYT-T 32-bit ART | BYT-T 32-bit Dalvik | BYT-CR 32-bit Dalvik |
MS/unit | ASUS T100 | ASUS T100 | Intel byt_t_ffrd8 | Intel anzhen4_mrd7 |
AVG | 501 | 556 | 692 | 785 |
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 applications, 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 optimize their applications. 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 the 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.
Related Articles
64-Bit Android OS:
https://software.Intel.com/en-us/Android/articles/64-bit-Android-os
Understanding x86 vs ARM* Memory Alignment on Android:
https://software.intel.com/en-us/blogs/2011/08/18/understanding-x86-vs-arm-memory-alignment-on-android
Reference
[1] http://en.wikipedia.org/wiki/64-bit_computing
[2] http://developer.Android.com/tools/sdk/ndk/index.html
[3] https://plus.google.com/+AndroidDevelopers/posts/XG1WmNDMe8H
[4] Software and workloads used in performance tests may have been optimized for performance only on Intel microprocessors. Performance tests, such as SYSmark* and MobileMark*, are measured using specific computer systems, components, software, operations and functions. Any change to any of those factors may cause the results to vary. You should consult other information and performance tests to assist you in fully evaluating your contemplated purchases, including the performance of that product when combined with other products. Configurations: [ASUS T100 (Intel® Atom™ processor T Z3740 (codenamed Bay Trail), Memory-2G, and SSD), benchmark test by Zhang Li and Zhou Zhen]. For more information go to http://www.intel.com/performance
About the Authors
Zhen Zhou earned an MSc degree in software engineering from Shanghai Jiaotong University. He joined Intel in 2011 as an application engineer in the Developer Relations Division Mobile Enabling Team. He works with internal stakeholders and external ISVs, SPs, and carriers in the new usage model initiative and prototype development on the Intel Atom processor, traditional Intel architecture, and embedded Intel architecture platforms.
Zhang Li is an application engineer in the Intel Software and Solutions Group (SSG), Developer Relations Division, Mobile Enterprise Enabling team. He focuses on application enabling on Android.