Quantcast
Channel: Intel Developer Zone Articles
Viewing all articles
Browse latest Browse all 3384

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

$
0
0

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 typeILP32 size (bytes)LP64 size (bytes)
char11
short22
int44
long48
long long88
pointer48
float44
double88
long double1616
structdepends on members (1)depends on members (1)
enum44

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 “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.
  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, 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.0467.3791.4981.649
7.1527.271.491.529
7.0117.3681.5291.57
7.1517.1961.4871.522
7.1827.2821.4681.548
7.10847.2991.49441.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)
1189.58178.39
2190.24178.53
3189.69178.12
4189.45178.31
5188.89177.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 format32-bit version running on BYT-T 32-bit ART in average64-bit version running on BYT-T 64-bit ART in averagePerformance Gain
1080P .WMV22.96 FPS28.3 FPS23.0%
1080P .RMVB43.6 FPS on53.0 FPS21.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) PlatformBYT-T
64-bit ART
BYT-T
32-bit ART
BYT-T
32-bit Dalvik
BYT-CR
32-bit Dalvik
MS/unitASUS T100ASUS T100Intel byt_t_ffrd8Intel anzhen4_mrd7
AVG501556692785

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.


Viewing all articles
Browse latest Browse all 3384

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>