Intel® VTune™ Amplifier for Systems helps you optimize the power management of your code on Linux* embedded platforms, Android* or Windows* systems through the Intel® Energy Profiler analysis. Through analysis of power consumption one can identify the behaviors that waste energy and dramatically increase the battery life of your device.
Monitor different hardware sleep states, including the reasons for hardware wakes-ups from a sleep state. Explore CPU frequency to analyze power consumption issues on your system. And perform visual comparison of results to quickly quantify and demonstrate improvements.
This guide walks through energy profiling on an Android target using tools included with Intel® System Studio as installed on a Windows host machine. Some additional text provided for minor differences when running on a Linux host will be included. It is assumed that the Mac* host will be similar, however the author does not have access to a Mac* host to directly verify the veracity of this claim. Screen captures were taken off a Windows host.
There are several components to the IntelEnergy Profiler for an Android target. There are the kernel level Android drivers which need system level permissions, correct permissions are easiest to deal with if these drivers were built with the Android kernel and already exist on the device. Then there is the low level application which interfaces with those drivers and include the command line interface for data collection, this is commonly called Intel SoC Watch collector as the command name is socwatch and is easily installed via an ADB script. Finally there is the visualization component which is incorporated into the Intel VTune Amplifier GUI. It is possible to collect the energy analysis data using the Intel SoC Watch command line and process the results manually without using the GUI interface supplied within Intel VTune Amplifier. That is why so much of the literature on this tool refers only to "Intel SoC Watch" analysis tool rather than Intel Energy Profiler.
To check if the drivers already exist on your target device and what version of the collection tool will be needed simply open up an adb shell and check either the /lib/modules/ or /system/lib/modules/ directory for a SOCWATCHx_x.ko driver.
As can be seen above the device in this example has the /lib/modules/SOCWATCH1_3.ko driver already included in the system image, thus this example will make use of the Intel SoC Watch collector version 1.3 command line for data collection. Should the driver found have been SOCWATCH1_5.ko then the version 1.5 data collector would be used. Note The Android Lollipop* images will likely have the driver in the /system/lib/modules directory instead.
If the driver does not exist on the system already then it will need to be built which is outside the scope of this article. Some instructions are provided in the user guide section "Building the Kernel Modules". Of particular concern is the need for the driver to have the same security signature as the system kernel or the ability to otherwise provide the driver with system level permissions.
Now that we have identified which version of the data collector to use by checking the driver on the device we need to install that version of the data collection app to the device as well. Note This only needs to be done once per device.
Locate the system_studio_target.tgz file included with your installation of Intel System Studio. This should be in <ISS_install_dir>/Targets where <ISS_install_dir> is the location of your System Studio installation. Typically on a Windows host this is "C:\Program Files (x86)\Intel\System Studio yyyy.x.xxx" and on a Linux host is "/opt/intel/system_studio_yyyy.x.xxx" where yyyy.x.xxx are the version number of your particular installation. This same tgz file has the files needed for either a Windows or Linux host. Unzip the file including directories somewhere on your system which you can find shortly. For this example and screenshots I have placed it here "C:\Users\Public\ISS-2015_SoCWatch".
From a command line prompt navigate to the directory you just unzipped which matches the version of Intel SoC Watch driver previously identified on the device. For this example: C:\Users\Public\ISS-2015_SoCWatch\system\studio\target\socwatch_android_v1.3d\
Note This directory will include the User Guide containing a lot of potentially useful information. Including but not limited to descriptions of all the options available for the particular version of the collector being used, information about how to analyze results, and even a quick start guide which goes over much of what is in the document you are currently reading.
Run the install script with the device still connected through USB. For windows run the socwatch_android_install.bat batch file, and on Linux run the socwatch_android_install.sh shell script. If you have already done this once on the device then you will be notified and nothing will be done, so if you've accidentally installed the wrong version then you'll need to adb shell onto the device and delete the /data/socwatch directory before running again. Otherwise you will see a list of files being copied over to the device.
Collecting data for analysis in its simplest form consists of three steps, setting up the environment, loading the driver, and running the collection script.
This step will need to be completed every time you connect a new ADB shell to the device for the purpose of doing a data collection.
Connect to the device via an ADB shell and change directory to the /data/socwatch directory. There you will find the setup_socwatch_env.sh script. Source the script so that the environment settings get propagated to the current shell. You will notice this reminds you to load the driver which is the next step. Either:
source ./setup_socwatch_env.sh or . ./setup_socwatch_env.sh
This step will need to be completed every time the device is booted prior to doing a data collection. Not necessarily every time a new adb shell is connected.
Here you load the driver located in the previous section "Checking for Drivers" into the device's active memory for usage with the insmod command. For this example the driver located was /lib/modules/SOCWATCH1_3.ko so that is the driver loaded. You can double check that the driver is loaded by listing loaded drivers with the lsmod command. Some versions of socwatch will also require an additional driver loaded such as the socperf_xxx.ko driver, this will be clarified by the output from the set_socwatch_env.sh script.
This step is run every time a new data file is needed for analysis. Exact parameters will vary depending upon the version of collector being used, features supported by the hardware in question, and information to be collected for analysis. Many of these are explained at least a little through use of the --help option. Here is an example command line which collects data on the core cstates and pstates, waits 5 seconds prior to starting collection, collects data for a total of 30 seconds, and outputs the results into the /data/socwatch/results/ directory with file names starting with GSG_examplerun.
./socwatch --max-detail -f cpu -s 5 -t 30 -o ./results/GSG_examplerun
Note As connection of the USB cable to the device is likely to affect power states one often disconnects the cable after issuing the collection command and before it starts collection. This would be done through use of background tasks and nohup, for example "nohup ./socwatch <options>" and then disconnecting the cable.
Note Often it is desirable to collect data only during the execution of a particular application, this is possible through use of the "-p" switch for the socwatch command, see the --help documentation and user guide for more information.
There are two steps to getting the results into Intel VTune Amplifier, first pulling the result files off of the device, and then importing them into the analyzer.
Back at the command prompt on the host device navigate to a directory where you can store some the data files. It is suggested that this not be the Intel VTune Amplifier project directory itself as importing them into your project will automatically copy them to the project directory already, instead use a simple temporary directory. Attempting to skip this step and navigate directly to the file via the devicename/internal storage/data path does not necessarily work for various permission related reasons. From your temporary directory get the result files via adb pull, if the specific file names cannot be easily remembered they can be listed through "adb shell ls /data/socwatch/results".
adb pull /data/socwatch/results/GSG_examplerun.csv adb pull /data/socwatch/results/GSG_examplerun.sw1
For this step only the sw1 file pulled off of the device is needed. The csv (comma separated values) file is a text file of the results provided for your custom analysis scripts or other amusements.
Launch the Intel VTune Amplifier application and load your project of interest. If you are unfamiliar with how to do this please see the Getting Started with Intel VTune Amplifier for Systems article or similar. From the "Welcome" tab click on the "Import Result..." link. Or From a "New Analysis tab" choose "Energy Analysis" for the Analysis Type and then click "Import Data".
NoteThis method only works for Intel System Studio 2015 Update 1 or later. If using a previous version of Intel System Studio it may be necessary to run a command line amplifier tool to import the data.
Both cases will lead to the "Import a File and Create a Result" tab where you can browse to the sw1 file pulled off of your device and select it for import.
Click on Import, then watch as it's analyzed and displayed for data review!
The specific information available will be highly dependent upon the hardware, collector version, and command line options used for the collection. Upon loading the results the Platform Power Analysis viewpoint should be the default (and generally the only option), and the summary tab screen should be shown. The summary tab will show some useful information such as the Elapsed time for the run and the available core time (generally the number of cores available multiplied by the elapsed time), as well as wake-up events per second per core, and some information on frequencies of active cores and cause of wake up events. Here is an example from a run using the following command line while the device is asleep with the screen dark but with the USB cable still attached. As expected the results indicate the device to be in a very low power state.
./socwatch --max-detail -f cpu -f device -f sys -t 30 -s 5 –o ./results/idleasleep
Another useful tab is the "Correlate Metrics" which will show a timeline with various state and event information. It is quite simple to zoom in on a timeframe of particular interest and investigate timing of different events. Note that hovering the mouse over a bit of data will often result in a pop up with more information as can be seen here.
Of potential interest it is possible to compare two results within the same window, this would allow easy comparison of two different runs under similar conditions to search for expected improvement or reproducibility of results. To do this first import both results independently and then close their analysis tabs. It is recommended at this point to rename the results in the Project Navigator window for ease of reference but is in no way necessary. Then click on the Compare Results icon and identify the two results to be compared. The analyzer will then show both results with a side by side comparison. Below are some example screen shots comparing two runs running different benchmark tests.
Intel, VTune and the Intel logo are trademarks of Intel Corporation in the U.S. and/or other countries.
* Other names and brands may be claimed as the property of others.
Microsoft, Windows, and the Windows logo are trademarks, or registered trademarks of Microsoft Corporation in the United States and/or other countries.
Links to non-Intel sites are provided for convenience only and do not constitute any responsibility or guarantee any level of accuracy or functionality for the site or its conten
Copyright © 2015-2016, Intel Corporation. All rights reserved.
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. Microprocessor-dependent 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