Using Intel® VTune™ Amplifier 2014 for Systems on non-rooted Android* devices

For the first time Intel® VTune™ Amplifier 2014 for Systems brings the most important, core capability of determining the hotspot in the C/C++ portion of your application to most Android* devices on Intel® processors (including rooted, not-rooted devices and with or without version compatible device drivers), such as those available at http://software.intel.com/en-us/android/get-device.  This article will concentrate on the options required to make this work on non-rooted devices.

Hotspots Viewpoint in VTune Amplifier 2014 for Systems

Note: Intel® VTune™ Amplifier 2014 for Systems provides many more features if you have a rooted device and version compatible device drivers.  See http://software.intel.com/en-us/articles/android-features-in-intel-vtune-amplifier-2014-for-systems-requirements

Finding hotspots in your C/C++ code on Android* is easy and involves the following steps:

  1. Prepare application for tuning:[i]
    • [On “Non-Rooted” Device] When Creating a Signed/Released binary set debuggable:=true in the Application Manifest.  Otherwise VTune Amplifier will fail when it tries to collect data.
    • It is recommended you compile your C/C++ .so(s) in release mode (compile without the switch -O0), you can use one of the following ways:
      • use ndk-build NDK_DEBUG=0
      • set APP_OPTIM := release in Application.mk
      • Sometimes release is the default when JNI code is built.
    • Make sure to use the default behavior of producing symbols (Compiler Switch -g) when your C/C++ binary is compiled, else VTune Amplifier will not be able to associate your hotspot to C/C++ source.
    • Install this application to the device.  There are many ways to do this, one method is
           $> adb install package.apk

  2. Enable “USB debugging” on your Android device and “ADB” on your host system[ii]
  3. Find your Application Package Name on the device
    • From a Command Prompt on the host dev system
          $> adb shell pm list packages
          $> […many lines deleted…]
          $> package:com.android.CalculatePi
          $> […many lines deleted…]
    • Find your package name in the list
  4. Setup remote VTune Amplifier collection[iii]
    • Create A Project in VTune Amplifier.
      Intro Screen for Intel VTune Amplifier 2014 for Systems - New Project Option Highlighted
    • Set Project to do a remote collection to an Android system over ADB.
      Remote Project Settings
      • In Project Properties: Target Tab
      • For “Target system” choose: Android device (ADB)
      • For “Choose a device” select the device attached to your host system that you want to analyze.
      • Choose your Target Type “Target type”
        • Attach to Process(For this you need to launch your application before running the collection)
        • Profile System will not work on Non-Rooted devices
        • Launch Android Package (This will start your application for you)
        • Launch Application – Launches Linux* like commands from the ADB prompt
      • Under “Package name” put the name of your package that we found earlier.
      • Optionally Specify Other Options
        • Setting Your Binary/Symbol Search Path and Source Path now will allow you to immediately drill to source instead of assembly (You can do this later though).  See Help: Intel VTune 2014 for Systems Help: Intel VTune Amplifier: User’s Guide: Running Analysis Remotely: Specifying Search Directories for Android* for information on good directories to set this to.
      • Press OK

  5. Launch New Hotspot Analysis
    • Select “New Analysis” from the toolbar
    • Select “Basic Hotspots” under Algorithm Analysis in the “Analysis Type” window. (this is the only available option for Non-Rooted devices)
    • Wait for the tool to connect & recognize that the device is ready.
    • Set other options  for Basic Hotspots as desired.
    • Click Start
    • Start Workload/Benchmark running in the App on your Device
    • Click Stop

  6. View Results
    • If need be in Project Properties under Analysis Type, set the Binary/Symbols/Source Search Paths as needed to point to binaries with symbols that reside on your host system.  Then select "Re-resolve", to be able to see source vs assembly and to get more accurate function mappings.
 

[i] Make sure the compiler does not use -O0 when it builds your C/C++ .so else VTune Amplifier will locate the hotspot of debug code which may be different then the hotspot of release mode code.  It is also important to make sure the compiler uses the switch -g to generate symbols, else VTune Amplifier will not be able to associate C/C++ source to your hotspot.  The default behavior for Android builds is to produce 2 binaries, one with the symbols, and one without.  It then copies the one without symbols into the .apk and that is what is installed onto the device.  The version of the binary with symbols will be available on the host build system.  The linux command file will report if symbols are available in a binary.  Android has a complicated set of defaults when it compiles your binary for Release Mode vs Debug Mode.  Compiling your JNI code with ndk-build V=1 will allow you to see what compiler options were used.    You can find more Information in the following references:
In the Google NDK docs see : APP_OPTIM under “Application.mk File” and the various build options under “NDK Build”
See android:debuggable at http://developer.android.com/guide/topics/manifest/application-element.html
http://developer.android.com/tools/publishing/preparing.html#publishing-build

[ii] [For Rooted Device] Optionally Install VTune Amplifier Remote Collector to support Java/Dalvik collection.  This feature requires a “Rooted” Device and an instrumented version of the Java/Dalvik runtime.  For More Information see:  http://software.intel.com/en-us/node/496398   

[iii] You can also You can also do remote collections from the command line.  See http://software.intel.com/en-us/node/496398   

For more complete information about compiler optimizations, see our Optimization Notice.