Павел Чупин_Development and optimization android x86 applications от Intel

  • 385 views
Uploaded on

 

More in: Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
385
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
9
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Development and optimization Android* x86 applications Pavel Chupin Staff Software Engineer October 2013
  • 2. Agenda • Where we are on Android* • Tools to start development on IA • Get full speed with Android* NDK • Tips and tricks on porting from ARM* to IA • Resources and contacts 2 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 3. Devices 3 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 4. Devices details Model number (codename) Atom Z2460 (platform Medfield)[4][5] Atom Z2480 (platform Medfield) Atom Z2420 (Lexington)[15] Availabili Utilizing devices ty Lenovo K800, Orange San L1: 32kB Instruction 32-bit Dual-channel Diego, Lava XOLO X900, 1.6 GHz single-core PowerVR SGX 540 @ + 24kB Data, L2: 400 MHz LPDDR2Q2 2012 MegaFon Mint, ZTE Grand X IN, Saltwell 400 MHz 512kB 800 (6.4 GB/sec) Ramos W32, XOLO x910, Senkatel Maximus L1: 32kB Instruction 32-bit Dual-channel 2 GHz single-core PowerVR SGX 540 @ Motorola RAZR i, XOLO X1000, + 24kB Data, L2: 400 MHz LPDDR22012 Saltwell 400 MHz Casper Via A6108 512kB 800 (6.4 GB/sec) CPU CPU cache GPU Memory technology L1: 32kB Instruction 32-bit Dual-channel Xolo X500, Yolo, Acer Liquid 1.2 GHz single-core PowerVR SGX 540 @ + 24kB Data, L2: 400 MHz LPDDR2Q1, 2013 C1, Asus FonePad, Etisalat ESaltwell 400 MHz 512kB 800 (6.4 GB/sec) 20, Prestigio Multiphone 5430 L1: 32kB Instruction 32-bit Dual-channel PowerVR SGX 545 @ + 24kB Data, L2: 400 MHz LPDDR2Q4 2012 533 MHz 512kB (per core) 800 (6.4 GB/sec) Asus VivoTab, Asus VivoTab Smart, HP Envy x2, HP ElitePad 900, Dell Latitude 10 Lenovo Thinkpad Tablet 2, Lenovo IdeaTab Lynx, Samsung Series 5 Slate Acer Iconia W510 ZTE V98, Acer Iconia W3, Samsung ATIV Tab 3 Atom Z2560 1.6 GHz dual-core (Clover Trail+)[41] Saltwell L1: 32kB Instruction PowerVR SGX 544 + 24kB Data, L2: MP2 @ 400 MHz 512kB (per core) 32-bit Dual-channel 533 MHz LPDDR2Q2 2013 1066 (8.5 GB/sec) ASUS FonePad Note FHD 6, Asus Memo Pad FHD 10, Samsung Galaxy Tab 3 10.1inch Atom Z2580 2 GHz dual-core (Clover Trail+)[46] Saltwell L1: 32kB Instruction PowerVR SGX 544 + 24kB Data, L2: MP2 @ 533 MHz 512kB (per core) 32-bit Dual-channel 533 MHz LPDDR2Q2 2013 1066 (8.5 GB/sec) Lenovo K900, ZTE Grand X2 In Atom Z2760 (Cloverview,[23] platform Clover Trail[24] 1.8 GHz dual-core Saltwell 4 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 5. Next gen: Silvermont™ architecture • 22nm SoC process using 3-D Tri-gate transistors Out of order execution Scalable up to 8x cores SIMD support up to SSE4.2 Up to ~3x peak performance at ~5x lower power over the current-generation Intel® Atom™ processor core* Will appear in 2013 Coming soon • *More details here: • • • • • http://newsroom.intel.com/community/intel_newsroom/blog/2013/05/06/intel-launcheslow-power-high-performance-silvermont-microarchitecture 5 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 6. Agenda • Where we are on Android* • Tools to start development on IA • Get full speed with Android* NDK • Tips and tricks on porting from ARM* to IA • Resources and contacts 6 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 7. Beacon Mountain Preview v0.6.1 A Development Environment for Native Android* Apps on ARM* & Intel® Atom™ Devices Intel & Third-Party Tools Host Support for Microsoft Windows* 7 & 8 and Apple OS X* Android* Support for Jelly Bean 4.2 and up Free download at: intel.com/software/BeaconMountain 7 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 8. Beacon Mountain Preview v0.6.1 A Development Environment for Native Android* Apps on ARM* & Intel® Atom™ Devices      Comprehensive Android* Development Environment For Intel® Atom™ & ARM* Smartphones, Tablets App Tools for Design, Code, Debug & Acceleration Update Notifications and Optional installation Helps Shorten the Android* App Development Cycle Intel Tools for x86  Intel® Hardware Accelerated Execution Manager  Intel® Graphics Performance Analyzers System Analyzer  Intel® Integrated Performance Primitives Preview  Intel® Threading Building Blocks  Intel® Software Manager Third-Party Tools for ARM/x86  Google* Android* SDK (ADT Bundle)  Android* NDK  Eclipse* Integrated Development Environment  Android* Design  Cygwin* (for Microsoft* Windows operating systems) Free and Easy installation: intel.com/software/BeaconMountain 8 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 9. Intel Tools Supporting Intel® AtomTM Devices Intel® Hardware Accelerated Execution Manager A hardware-assisted virtualization engine that uses Intel® Virtualization Technology to speed up Android* emulation in a host environment. Intel® Graphics Performance Analyzers System Analyzer Optimize OpenGL* ES 1.0/2.0 workloads by providing a real-time view of over two dozen critical system metrics covering the CPU, GPU, and the OpenGL* ES API. Intel® Threading Building Blocks C++ template library of pre-tested algorithms and features allow developers to efficiently thread C++ mobile applications for performance, while lowering system energy. Intel® Integrated Performance Primitives Preview A library of pre-optimized image processing functions supporting Intel® smartphone and tablet platforms running Android* OS. The preview release is a subset of the full Intel IPP product. Intel® Software Manager A utility that pushes messages about tool updates and other communications to developers. 9 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 10. Third-Party Tools Supporting Intel® Atom™ & ARM* Devices Google* Android* SDK (ADT Bundle for Microsoft Windows*) API libraries and developer tools to build, test, and debug apps for Android Android* NDK for x86 Supports implementation of application code using native C++/C Eclipse* Integrated Development Environment Part of the ADT bundle. Provides an integrated environment to build applications Android* Design Stencils, icons, styles and more to use within apps without restriction Cygwin* Linux-like environment for mixing Java and C/C++ code on Windows* systems Oracle* Java SE Development Kit A tool for building applications and components using Java1 10 1 Beacon Mountain checks your system to ensure you have the JDK installed. If you don’t, Beacon Mountain directs you to the Oracle site to download the correct version Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 11. Faster Android* Emulation using an IA-based host PC 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 Much Faster Emulation • Intel® Hardware Accelerated Execution Manager (HAXM) for Mac and Windows uses Intel® Virtualization Technology (VT) to accelerate Android* emulator by 2-4x • Intel VT is already supported in Linux* (KVM) for x86. See www.intel.com/software/Android* for demo videos & installation tips 11 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners. Intel x86 Atom System Image Intel x86 Emulator Accelerator
  • 12. Intel® Graphics Performance Analyzers System Analyzer for Android • Real-time system-level performance analysis for Intelbased Android* devices • Immediate experiments and overwrites enable developers to isolate CPU and GPU performance problems • Metrics for CPU, GPU, API, memory, network, power, etc. 12 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 13. For on-device app testing: Intel® GPA System Analyzer Real-time Remote Performance and Power Profiling Real-timecharts: • • • • CPU metrics Graphics API level metrics Processor graphics hardware metrics Power metrics Data Android* Smart Phone Intel® GPA System Analyzer running on a PC USB adb Connection Wi-Fi Connection Download Intel® GPA for FREE at intel.com/software/GPA 13 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 14. Intel® C++ Compiler for Android* • Based on Intel® C/C++ Compiler XE 13.0 for Linux* • Integrates into the Android* NDK as additional toolchain which can be used from the command-line • Supports Intel® Atom™ processor optimization FREE for limited time Available on http://software.intel.com/c-compiler-android 14 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 15. Agenda • Where we are on Android* • Tools to start development on IA • Get full speed with Android* NDK • Tips and tricks on porting from ARM* to IA • Resources and contacts 15 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 16. Android* Native Development Kit (NDK) Why use it? • Performance intensive tasks • signal-processing, complex algorithms, physics simulation, graphics, etc. • Take advantage of direct CPU/HW access • write hot code using SIMD instructions • Reuse code • e.g. from PC segment • Start from here: http://developer.android.com/tools/sdk/ndk/index.html 16 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 17. NDK Application Development C/C++ Code APP_ABI := all or APP_ABI := x86 SDK APIs Java calls ndkbuild Makefile GDB debug through JNI Java Android* ApplicationsApplication Java Framework JNI Native Libs Bionic C Library 17 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners. NDK APIs
  • 18. Fat binaries build and install libs/x86/mylib.so myapp.apk libs/arm/mylib.so libs/arm-v7a/mylib.so libs/mips/mylib.so libs/x86/mylib.so libs/?/mylib.so 18 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners. libs/arm-v7a/mylib.so
  • 19. NDK compiler • x86 is supported from NDK r6 • Get latest and greatest NDK-r9 (July 2013)! • Support for Android* 4.3 (API level 18) • GCC-4.8 included with Silvermont™ tuning available (-march=slm/-mtune=slm switches) • Bugfixes 19 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 20. Android* C++ support By default, libstdc++ is used. It lacks: - Standard C++ Library support (except some headers) - C++ exceptions support - RTTI support Fortunately, you have other libs available with the NDK: Choose which library to compile against in your Makefile (Application.mk file): Runtime Exceptions RTTI STL system No No No gabi++ Yes Yes No stlport Yes Yes Yes APP_STL := gnustl_shared gnustl Yes Yes Yes Postfix the runtime with _static or _shared For using C++ features, you also need to enable these in your Makefile: LOCAL_CPP_FEATURES += exceptions rtti 20 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 21. Why should I update GCC x86 compiler? EEMBC® CoreMark® example (higher = better) base: • -O2 -ffast-math -mfpmath=sse -m32 -march=atom • base + if conversion • -O2 -ffast-math -mfpmath=sse -ftree-loop-if-convert -m32 -march=atom • • peak • -Ofast -funroll-loops -mfpmath=sse -m32 march=atom for 4.4 and 4.5 versions “-Ofast” is replaced with O3 -ffast-math http://software.intel.com/en-us/blogs/2013/05/28/why-should-i-update-gccx86-compiler-or-gcc-compiler-performance-on-intel-atom-from 21 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 22. Recommended GCC compiler options Optimization level: • • use -O2 at least, -Ofast for peak Architecture: • • • • -march=atom –mtune=atom –mssse3 to target Atom -march=slm –mtune=slm –msse4.2 to target Silvermont Note: -march=atom turns on -mmovbe which is not supported on all x86. To avoid add –mno-movbe. Math: • • • -ffast-math – fast but less accurate. Usually you don’t care -mfpmath=sse – use sse for FP calculations instead of i387 Even more performance: • • -flto • -funroll-loops More: http://software.intel.com/blogs/2012/09/26/gcc-x86performance-hints 22 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 23. Recommended ICC compiler options • Optimization level: • -O2 is default, -fast for peak (implies -static) • Architecture: • • -xATOM_SSSE3 to target Atom -xATOM_SSE4.2 to target Silvermont (not available yet in 13.0) • Math: • • -no-prec-div – fast but less accurate. Usually you don’t care -mfpmath=sse – use sse for FP calculations instead of i387 • Even more performance: • • -O3 -ansi-alias • -ipo • -auto-p32 • -parallel 23 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 24. Agenda • Where we are on Android* • Tools to start development on IA • Get full speed with Android* NDK • Tips and tricks on porting from ARM* to IA • Resources and contacts 24 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 25. Compatibility “I want my app to run on all architectures” • You already done for Java & HTML • NDK based apps usually just needs a recompilation APP_ABI := all Application.mk 25 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 26. Target compiler options • NDK-build system Android.mk file evaluated for each architecture • Variable TARGET_ARCH_ABI describes actual architecture TARGET_ARCH_ABI x86 armeabi armeabi-v7a ifeq ($(TARGET_ARCH_ABI),x86) LOCAL_CFLAGS := -mtune=atom -mssse3 endif ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) LOCAL_CFLAGS := -march=armv7-a Endif mips Android.mk 26 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 27. Compiler macros • Directly inside source code • No runtime overhead • Works with all build configurations #ifdef __i386__ strlcat(buf, "__i386__", sizeof(buf)); #endif #ifdef __arm__ strlcat(buf, "__arm__", sizeof(buf)); #endif #ifdef __mips__ strlcat(buf, "__mips__", sizeof(buf)); #endif source.c 27 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 28. Porting Native (C/C++) Android* Apps to x86 http://software.intel.com/en-us/articles/ndk-android-application-portingmethodologies/ Native Apps • Optimized NDK for Intel Atom based devices available on http://developer.android.com/sdk/n dk/index.html since July’11. • For most apps, changing the make file and a recompile should be sufficient to port to Intel Atom devices. • If ARM-specific features are used, Intel SSE equivalents should be added (build flag) • Developer recompiles, repackages and publishes. 28 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 29. Memory Alignment By default struct TestStruct { int mVar1; long long mVar2; int mVar3; }; Easy fix struct TestStruct { int mVar1; long long mVar2 __attribute__ ((aligned(8))); int mVar3; }; 29 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 30. ARM* NEON to Intel® SSE • Single Instruction Multiple Data (SIMD) • Most ARM NEON functions have a 1:1 equivalent in Intel® SSE • Intel provides C++ header file to do the mapping // VADD.I8 d0,d0,d0 int8x8_t vadd_s8(int8x8_t a, int8x8_t b); #ifdef USE_MMX #define vadd_s8 _mm_add_pi8 //MMX #else #define vadd_s8 _mm_add_epi8 #endif NEONtoSSE.h http://software.intel.com/en-us/blogs/2012/12/12/from-arm-neon-to-intelmmxsse-automatic-porting-solution-tips-and-tricks 30 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 31. Agenda • Where we are on Android* • Tools to start development on IA • Get full speed with Android* NDK • Tips and tricks on porting from ARM* to IA • Resources and contacts 31 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 32. Beacon Mountain on the Web Your Source for Beacon Mountain Information & Support  Free Download  Product Brief  Support Form Follow us @IntelSoftware Free download at: intel.com/software/BeaconMountain 32 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 33. For More Information on Individual Tools PRODUCT URL Intel® Hardware Accelerated Execution Manager http://software.intel.com/ en-us/articles/intelhardware-acceleratedexecution-manager Intel® Graphics Performance Analyzers www.intel.com/software/gp a Intel® Threading Building Blocks software.intel.com/vcsource /tools/threading-buildingblocks Intel® Integrated Performance Primitives software.intel.com/intel-ipp Intel® Software Manager www.software.intel.com Google* Android* SDK www.developer.android.com Android* NDK for x86 www.developer.android.com Eclipse* Integrated Development Environment http://www.eclipse.org/ Android* Design www.developer.android.com Cygwin* http://cygwin.com/ Oracle* Java SE Development Kit www.oracle.com 33 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 34. Single entry point to remember  http://software.intel.com/android/ 34 Copyright© 2013, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners.
  • 35. Legal Disclaimer & Optimization Notice INFORMATION IN THIS DOCUMENT IS PROVIDED “AS IS”. NO LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT. INTEL ASSUMES NO LIABILITY WHATSOEVER AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO THIS INFORMATION INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. 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. Copyright © , Intel Corporation. All rights reserved. Intel, the Intel logo, Xeon, Xeon Phi, Core, VTune, and Cilk are trademarks of Intel Corporation in the U.S. and other countries. Optimization Notice 35 Intel’s compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessordependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice. Notice revision #20110804 Copyright© 2013, Intel Corporation. All rights reserved. 2012, *Other brands and names are the property of their respective owners.