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

Analyzing the performance of C/C++ and debugging OpenGL ES* frames on mainstream ARM* and x86 Android* devices

$
0
0

When developing an Android* application, you usually need to test, optimize, and debug on many different platforms. While basically every hardware and chip manufacturer provides a set of custom tools for this, developers can find it cumbersome to install and learn how to use all of them.

Since their latest releases (2014 R2 as of now), Intel® Graphics Performance Analyzers (Intel® GPA), Intel® Frame Debugger, and Intel® VTune™  Amplifier are able to support most mainstream Android 4.x devices, regardless of their architecture (ARM* or x86).

We have tested these Intel tools and successfully used them on the ARM Android devices listed here, but basically any Android 4.x device is probably compatible.

Summary:
Getting a high level view of how your app is performing, using GPA System Analyzer.
Debugging an OpenGL rendered view, using Intel® Frame Debugger.
Analyzing the performance of C/C++ code from Android applications, using Intel® VTune Amplifier.

Getting a high-level view of how your app is performing using Intel® GPA System Analyzer.

Intel GPA System Analyzer can run on: Windows* 7/8.x, Mac* OS X*, and Linux* and can be used to analyze apps running on almost any Android 4.x device connected over ADB.

It’s a free tool, part of the Intel GPA suite you can get from this dedicated page or INDE.

If your device is rooted, this tool can analyze any application installed on the device. Otherwise, it can only analyze apps with Internet permission and the debuggable flag set to true.

Setting the debuggable flag to true in the AndroidManifest is done automatically when you’re doing a debug build with gradle or ant / Android Studio or Eclipse*. But when it comes to analyzing the real performance of an application, you want to run a version that has been optimized for release!

You can manually set this flag to true in your manifest, but lint will complain about it and cause your build to abort. You can easily overcome that.

In Eclipse: disable “HardcodedDebugMode” in Lint Error checking inside Android Preferences. In Android Studio: set inside your build.gradle

android {
	lintOptions {
		disable 'HardcodedDebugMode'
}
}

Now, when running Intel GPA System Analyzer, you first get a list of applications running on the device you’ve chosen:

Selecting one will trigger its launch on the device, along with its real-time analysis:

From there, you can drag&drop any metric from the left side to see its value evolve in real time.

You may not get hardware-specific metrics on every device as their support varies, but you’ll have at least: Target App CPU Load, RAM usage, Device and Network IOs, OpenGL* metrics (draw calls, vertex count, frame time).

In addition to these real-time values, you have the ability to trigger “state overrides” from the bottom left of the window. This will help you determine the current bottleneck in your application:

 

Normal scene:

with all the textures set to a simple 2x2 one:

with disabled alpha-blending:

showing wireframe:

 

You can also disable all the Draw calls. Then no graphics will be rendered, but if the FPS improves, the bottleneck isn’t on the OpenGL* side.

A more in-depth article on Intel GPA along with a sample code is available here: https://software.intel.com/en-us/android/articles/using-the-intel-gpa-system-analyzer-to-improve-android-apps

Debugging an OpenGL rendered view using Intel® Frame Debugger

Intel Frame Debugger is used to capture and fully debug OpenGL frames. It’s once again a free tool you can get from this dedicated page or INDE and fully works on most Android devices.

As of now, it can be run on Windows 7/8.x platforms only.

First add a frame from a device by clicking “Add”:

This will show you a list of applications that you may, or may not, have the right to analyze. Just like previously with Intel GPA System Analyzer, you may analyze any application on a rooted device. Otherwise, only the ones with Internet permission and the debuggable flags set to true:

Double-click to launch one and click on “capture” to get a frame. Once it’s done, go back to the previous view and select the captured frame:

You can see all the draw calls that have been made on the left side and the associated simulated OpenGL ES framebuffer on the right side.

A double click on one of these draw calls will allow you to inspect all steps of the OpenGL ES pipeline associated with the draw call, among these:

The primitives and the associated Vertex Buffer Objects

The vertex and fragment shaders

You can see and modify these shaders and even modify the values they’re receiving. This will modify the simulated frame as well as the rendered frame on your device if it’s still connected!

Analyzing the performance of C/C++ code from Android applications using Intel® VTune™ Amplifier

Intel VTune Amplifier is part of Intel® System Studio suite. Contrary to the previous tools, this suite isn’t free unless it’s for non-commercial software development. As of now, this tool can be run from Windows and Linux hosts.

To begin with VTune Amplifier, create a new project:

In its properties, choose your device and “Launch Android Package” as type, then you can enter your package name or click on “browse” to look for it:

Once this is done, you can launch a “basic hotspot” analysis. Starting the analysis will launch the app on your device:

Click on Stop to stop the collection (and automatically close the application).

The trace will be collected and displayed:

From there you can, for example, start looking at the results with the “Bottom-up” view and group data by Module / Function / Call Stack:

To associate full library symbols and sources to your results, you can add their paths to your project properties (usually ./obj/local/ABI/ for the non-stripped libs and ./jni for the sources).

More information on performance analysis using VTune can be found here: https://software.intel.com/en-us/node/471808

On supported x86 Android Devices (Intel® reference designs and Dell Venue* 8 with developer image), VTune Amplifier can be used to analyze Java* workloads, get CPU and GPU metrics, and do power analysis! You can find more details here:

 

Notices

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.

UNLESS OTHERWISE AGREED IN WRITING BY INTEL, THE INTEL PRODUCTS ARE NOT DESIGNED NOR INTENDED FOR ANY APPLICATION IN WHICH THE FAILURE OF THE INTEL PRODUCT COULD CREATE A SITUATION WHERE PERSONAL INJURY OR DEATH MAY OCCUR.

Intel may make changes to specifications and product descriptions at any time, without notice. Designers must not rely on the absence or characteristics of any features or instructions marked "reserved" or "undefined." Intel reserves these for future definition and shall have no responsibility whatsoever for conflicts or incompatibilities arising from future changes to them. The information here is subject to change without notice. Do not finalize a design with this information.

The products described in this document 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.

Contact your local Intel sales office or your distributor to obtain the latest specifications and before placing your product order.

Copies of documents which have an order number and are referenced in this document, or other Intel literature, may be obtained by calling 1-800-548-4725, or go to: http://www.intel.com/design/literature.htm

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.

Any software source code reprinted in this document is furnished under a software license and may only be used or copied in accordance with the terms of that license.

Intel, the Intel logo, and VTune are trademarks of Intel Corporation in the U.S. and/or other countries.

Copyright © 2014 Intel Corporation. All rights reserved.

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

 


Viewing all articles
Browse latest Browse all 3384

Trending Articles



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