developing and optimizing android* apps for intel atom ...ftp.software-sources.co.il/developing...

37
Developing and Optimizing Android* Apps for Intel ® Atom™-based Platforms Christoph Jechlitschek Software and Services Group Intel Corporation June 25, 2012

Upload: truongkhanh

Post on 02-Jul-2018

225 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Developing and Optimizing Android* Apps for Intel® Atom™-based Platforms

Christoph Jechlitschek

Software and Services Group

Intel Corporation

June 25, 2012

Page 2: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Agenda

•Android* on IA Momentum

•Developing Android Apps for IA

•App Development with x86 NDK

•Case Study – NDK App Porting

•Summary

Page 3: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

GPS, Context Sensing

BT

Wi-Fi

Wireless Display

Security

Hardware Accelerated Multimedia

Graphics, Imaging 2G, 3G

Integrating Features into Our Silicon for Better

Performance and Lower Power

Powering the whole

range of devices…

Page 4: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

IDF 2011: Intel and Google Team Up

• Optimize Android* for Intel® Atom™-

based platforms

• Native support for x86 architecture

in Android SDK and NDK

• Grow Android application ecosystem

• Optimize top Android apps

• Optimize Dalvik

• Port native apps

Page 5: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

CES 2012: Intel Announces Agreements with

Lenovo and Motorola Mobility

Debut of the Lenovo K800* Smartphone

• Features low-power Intel®

Atom™ processor Z2460

• Available in China soon

Intel strikes a multi-year, multi-device partnership with Motorola Mobility*

• Collaborating across hardware, software and services

Page 6: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Mobile World Congress: Intel Announces New

Agreements, Extends Smartphone Roadmap

• Orange*, Lava*, ZTE* to sell Intel Phones

• Demonstration of Lenovo K2* pre-production tablet

• Best new tablet (Gizmodo)

Lava Xolo X900now shipping!

Orange San Diegonow shipping!

Page 7: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Momentum is Building

Intel Smartphones Coming to UK, France, China India

February 27, 2012

Page 8: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Intel Community for Android* Developers

Intel® Software Network (ISN)• Real developers sharing knowledge and offering help

• Dedicated communities and forums focused on your interests

• Worldwide reach• News and insights on cutting edge technology

Intel Developer Community• Great content you won’t find anywhere else• Technical articles, tools, and “How-To” guides• Native app porting tips & case studies• Info on x86 emulator and Intel® Hardware Accelerated Execution Manager

• Active forums and blogs written by Intel and community experts

intel.com/software/android

Page 9: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Agenda

•Android* on IA Momentum

•Developing Android Apps for IA

•App Development with x86 NDK

•Case Study – NDK App Porting

•Summary

Page 10: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Applications

Application Framework

Home Contacts Phone Browser

Activity Manager

Windows Manager

Telephony Manager

Resource Manager

Content Providers

View System

Location Manager

Notifica-tionManager

Package Manager

Surface Manager

OpenGL | ES

SGL

Media Framework

FreeType

SSL

SQLite

WebKit

libc

Core Libraries

DalvikVirtual Machine

Display Driver

Camera Driver

Flash Memory Driver

Binder (IPC) Driver

Keypad Driver

WiFiDriver

Audio Drivers

Power Manage-ment

Libraries

Linux Kernel

Android Runtime

Ap

ps

User

Exp

erie

nce

Mid

dle

ware

Op

erati

ng

S

yste

m

Android* on Intel® Atom™ processor-based platforms

Page 11: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Android* Optimizations for Intel® Atom™-based devices

• Dalvik VM runtime optimization

• x86 trace-based JIT and Native Code Generation

• Enriched memory management (e.g., garbage collection)

• JNI streamlining

• Tuning of native libraries

• Bionic optimizations

• Javascript & HTML5 optimization

• Power Management for Android

• OpenGL ES 1.1/2.0 Driver

• HW Overlay

• HW Accelerated Media decode/encode

• Library to integrate w/ Android & reference implementation (MIX)

• Standard SoC drivers, middleware and applications optimized for power

Power ReductionPerformance Tuning

Intel has a rich history optimizing Java for IA. We’ve applied that knowledge to Dalvik Java with impressive results

Page 12: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Performance Gains from optimizations

0

1

2

3

4

5

6

7

Trace JIT enabled

Up to 6x Improvement!

Perfo

rm

an

ce

Source: Intel Software and Solutions Group1 Intel Z670 reference design with Honeycomb2 SSE = Streaming SIMD Testing on Medfield (Z2460) CDK with Gingerbread.

0

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

Significant improvements in both web (HTML5) and Java* workloads due to optimizations for Intel SSE instructions in Android graphics libraries.

Perfo

rm

an

ce

No Trace JIT1

Dalvik Runtime Optimizations Android* Native Library

No SSE2 with SSE

Linpack CaffeineMark

HTML5

Slideshow

HTML5

Zoom

HTML5

Animation

HTML5

Fancy Show

JetBoy*

StressAlbum

Slideshow(SA)

Page 13: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Faster Emulation and Prebuilt Atom Images

Pre-built Atom Images• Android SDK manager has x86 emulation

images built-in• To emulate an Atom-based Android phone,

install the “Intel Atom x86 System Image” available in the Android SDK Manager

• http://software.intel.com/en-us/articles/installing-the-intel-

atom-tm-android-x86-emulator-image-add-on-from-the-

android-sdk-manager/

Much Faster Emulation• Intel® Hardware Accelerated Execution Manager

(HAXM) for Mac and Windows uses Intel®

Virtualization Technology (VT) to accelerate x86 emulation by an order of magnitude

• VT is supported in Linux* (KVM) for x86• http://software.intel.com/en-us/articles/intel-hardware-

accelerated-execution-manager/

Page 14: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Intel® Graphics Performance Analyzers (Intel® GPA)

• Provides real-time performance

analysis of your OpenGL-ES*

applications

• Conduct real-time experiments

with OpenGL-ES* state overrides

• Triage system-level performance

with CPU, Power and GPU metrics

System Analyzer

Note: Public release of Intel GPA for Android* is targeted for 2H-2012

Page 15: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Using Intel® Graphics Performance Analyzers

1. Install APK 2. Run Intel® GPA System Analyzer

on development machine

3. View Profile

Page 16: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Agenda

•Android* on IA Momentum

•Developing Android Apps for IA

•App Development with x86 NDK

•Case Study – NDK App Porting

•Summary

Page 17: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Android* Native Development Kit (NDK)

� Build scripts/toolkit to incorporate native

c/c++ code in Android Apps via JNI

� Why Use NDK?

• Performance intensive tasks

• eg: signal-processing/custom-algorithms

• Differentiated app that takes advantage

of direct CPU/HW access

• Eg: specialized games

• Software Code reuse

• Legacy Code

• Huge legacy IA code base & libraries

Page 18: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Android* Application Overview

Android NDK Application

Dalvik Application

Android App Class

Java Source

Compile with Javac

Java Native Library Class

Java Native Library

Compile with Javac

Create C header with Javah -jni

Header File

C Source Code

Compile and Link C Code

Dynamic Library

Application File

Makefile

Page 19: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Adding Native Code to Android * Apps

Standard Android* Project Structure

Native Sources - JNI Folder

1. Create JNI folder for native sources

3. Create Android.mk with build rules

4. Build Native code using NDK-BUILD script.

2. Reuse or create native c/c++ sources

NDK will automatically create ABI lib folder.

Page 20: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Creating NDK-based Apps: Code Re-use Example

1. Create default Android* App project

~/labs/lab2$ android create project --target android-13 --activity CPUIdApp --package com.example.cpuid --path .

Page 21: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Sample Native Code for CPUID

Page 22: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Code Re-use Example (cont’d)

2. Define JNI Native Calls in Java* source to access CPUID native code3. Declare call to Load native lib cpuid.so (““““cpuid””””)

Page 23: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Code Re-use Example (cont’d)

4. Build with ““““ant”””” to generate Java* classes5. Use ““““javah”””” to generate JNI headers

Page 24: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Code Re-use Example (cont’d)

6. Implement native source stub based on generated header stub

7. Create Android.mk build rules for compiling native code with NDK

Page 25: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Code Re-use Example (cont’d)

8. Compile native sources with ““““ndk-build”””” script : specify APP_ABI=x869. Rebuild the final APK with ant, and optional install on emulator!

Page 26: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Porting Existing NDK-based Apps

A simple 4-step process:

1. Recompile existing native module with APP_ABI=all

2. Update the project to use Android* platform of choice (e.g. ICS target API is ““““Android-15””””)

Page 27: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Porting Existing NDK-based Apps (cont’d)

3. Repackage the project into final APK file

- Example: Using ““““ant debug”””” for demo purposes

4. Install/Test the App (APK) on x86 Android* emulator or device

Page 28: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

NDK Tips: Let the NDK Do the Hard Work

• Include all ABIs in jni/Application.mk

• The NDK will generate highly optimized code for all target ABIs

Build ARM v5…

Build ARM v7a…

Build ARM x86…

Page 29: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

NDK Tips: Use “Fat Binaries”

Source Code

Application.mk

with multiple ABIs

libs/armeabi-v7a

libs/x86

libs/armeabi

ndk-build apkbuilder

• Fat Binaries are .apk files that supports multiple ABIs

• Use “APP_ABI := armeabi armeabi-v7a x86” in Application.mk

– Can use “APP_ABI := all” since NDK version r7

Page 30: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Install Will Select The Right .so

Use lib/armeabi libraries

Use lib/armeabi-v7a libraries

Use lib/x86 libraries

• Android Market will automatically filter applications based on ABI support

Page 31: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Agenda

•Android* on IA Momentum

•Developing Android Apps for IA

•App Development with x86 NDK

•Case Study – NDK App Porting

•Summary

Page 32: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Gameloft* Case Study

Asphalt 6 Adrenaline*

• High-end 3D Car racing game

• Takes full advantage of the 1.6GHz Intel® Atom™ processor

and 400MHz PowerVR* SGX 540 GPU

• Gyroscope and accelerometer

• Playable on HD TV screen over HDMI

Modern Combat 2*: Black Pegasus

• High-end 3D FPS game

• Takes full advantage of the 1.6GHz Intel® Atom™ processor

and PowerVR SGX 540 GPU

• Gyroscope

• Playable on HD TV screen over HDMI

UNO HD*

• Casual card game

• Multiplayer option with several connected devices

Asphalt 6 Adrenaline, Modern Combat 2, UNO HD

Page 33: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Gameloft* Case Study

Game Development Premises

• Modern Combat and Asphalt 6 are 3D games making heavy use of Open GL ES 2.0 instructions

• Games are written in C++

• Both games get the core of their effects from OpenGL Shaders

• Modern Combat 2 makes use of post processing effects such as:

• Colorization

• Motion Blur

• Depth of field

• All games are rendered in native 1024x600 resolution making heavy use of the GPU

Page 34: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Gameloft* Case Study

Optimizations and Conclusions

• The games are fully utilizing the GPU

• The GPU is powerful enough to sustain 25fps for Asphalt6 and Modern Combat2

• No optimization was required

• The Intel® Atom™ processor CPU usage is about 40%

• It COULD support more complex games if aligned with a more powerful GPU

• Porting from ARM to X86 was a breeze, development-wise with only minor changes at build deployment level

• Porting and validating both games took about a month in total

Page 35: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

• Intel solutions for Android* are gaining rapid momentum

• Top notch web performance, UX responsiveness, advanced imaging and long battery life for many hours of video and audio playback

• Deep investments to ensure end-to-end Android software stack is power and performance optimized for Intel® Atom™ -based platforms

• Majority of existing Android apps work “as is” on Atom platforms. We encourage Atom-specific optimization of native apps

• Visit www.intel.com/software/android for more

Summary

Page 36: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Thank you!

Page 37: Developing and Optimizing Android* Apps for Intel Atom ...ftp.software-sources.co.il/Developing Android...GPS, Context Sensing BT Wi-Fi Wireless Display Security Hardware Accelerated

Intel Legal Information

INFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH INTEL® PRODUCTS. NO LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR

OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT. EXCEPT AS PROVIDED IN INTEL’S TERMS AND

CONDITIONS OF SALE FOR SUCH PRODUCTS, INTEL ASSUMES NO LIABILITY WHATSOEVER, AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED

WARRANTY, RELATING TO SALE AND/OR USE OF INTEL® PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A

PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.

INTEL PRODUCTS ARE NOT INTENDED FOR USE IN MEDICAL, LIFE SAVING, OR

LIFE SUSTAINING APPLICATIONS.

Intel may make changes to specifications and product descriptions at any time, without notice.

All products, dates, and figures specified are preliminary based on current expectations, and are subject

to change without notice.

Intel, processors, chipsets, and desktop boards may contain design defects or errors known as errata, which may cause the product to deviate

from published specifications. Current characterized errata are available on request.

Intel, Intel logo, Intel Atom, Intel Atom Inside,, Intel Inside, and Intel Inside logo are trademarks of Intel Corporation in the U.S. and other countries.

Android is a registered trademark of Google, Inc.

Java and all Java based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.

For more complete information about performance and benchmark results, visit www.intel.com/benchmarks

Other names and brands may be claimed as the property of others.

Copyright © 2012 Intel Corporation.