Introduction
Intel® System Studio 2015 now contains an energy and power profiler called Intel® Energy Profiler. Using the Intel Energy Profiler allows you to collect sleep state, frequency and temperature data that lets you find the software that is causing unwanted power use. This article provides an overview of the Intel® Energy Profiler.
Background
Two key indicators that effect how much power your system is using are CPU Sleep states and CPU Frequency.
- CPU Sleep states (C-States)
- CPU Sleep states indicate during what intervals your CPU is asleep. The main goal of CPU Sleep states is to show when the system is sleeping, what sleep state it was in and what woke up the system. The higher the sleep state the lower the power usage.
- CPU Frequency (P-states)
- CPU’s also have the ability to change the core clock frequency, power usage will be higher the greater the frequency.
The following diagram shows how these c-states and p-states inter-relate.
Depending on your Android target you will need to use a different collector:
- Silvermont, Haswell systems
- socwatch collector
- Clovertrail+
- wuwatch
- Other embedded linux* systems.
- amplxe-cl
The remainder of this article will focus on how you can collect C-state and P-state data for your system and visualize this data using Intel® VTune™ Amplifier 2015 for Systems using socwatch.
Socwatch
SoC Watch (aka SoCWatch) is a command line tool for monitoring system behaviors related to power consumption on Intel® architecture-based platforms. It monitors power states, frequencies, wakeups, and various other metrics that provide insight into the system’s energy efficiency.
The following diagram shows how socwatch can be used.
Installation
SoCWatch is currently intended for Android-based systems. See the release notes for detailed system requirements.
It is possible that your Android based system already had the socwatch kernel modules integrated into the system. If this is not the case then see the section marked “Building the kernel module”.
Make sure your host is connected to the target via adb before running the install script.
1. After unzipping the SoCWatch package on your host system, run the socwatch_android_install.sh script on a Linux host or from a Cygwin window on a Windows host. Run the socwatch_android_install.bat file from a Windows host.
socwatch_android_install.sh or socwatch_android_install.bat
The script installs the socwatch executables to the /data/socwatch directory on the target by default. Use the –d option to select a different install directory and the –s option to define a specific Android* device if multiple devices are connected to the host via adb.
2. Using the adb command, start a shell with root privileges.
> adb root
> adb shell
3. Navigate to the directory containing the driver.
> cd /lib/modules
4. Load the driver.
> insmod SOCWATCH1_*.ko
5. Confirm the driver is loaded.
> lsmod
6. When necessary, type rmmod SOCWATCH1_* to unload the driver.
Building the Kernel Module
If the SoCWatch device driver is not pre-installed in the OS image, you will need to build it.
1. Copy the socwatch_android.zip file to the host system used to build the Android* kernel.
2. Extract the contents with the command:
> tar xvzf socwatch_android.zip The socwatch_android directory is created.
3. cd into the socwatch_android/socwatch_driver directory.
4. Execute the build_driver script with the command: > sh ./build_driver –k <kernel-build-dir> where <kernel-build-dir> is replaced with the local Android* lib/modules directory produced while building the Android* kernel. The –k switch is optional and is not required if the DEFAULT_KERNEL_BUILD_DIR value is properly set in the build_driver script.
Collecting data on your system
cd /data/socwatch
. ./setup_socwatch_env.sh
To collect c-state and p-state data on your system run the following socwtach command.
>./socwatch –-max-detail –f cpu-cstate –f cpu-pstate –t 60 –o ./results/test
This command will run for 60 seconds and create a files called test.sw1 and test.csv located in results directory.
To view the colelcted data you need to copy the files back to your host system using adb.
> adb pull /data/socwatch/results/test.csv c:\results
> adb pull /data/socwatch/results/test.sw1 c:\results
To import these files into VTune Amplfier 2015 for Systems run the following commands, from the windows prompt:
- First run the amplxe-vars.bat file in the VTune Amplifier install directory.
- Run amplxe-cl.exe -import test.sw1 C:\results\test
This will create a results directory called test in C:\results. You can open this result directory using the following command:
amplxe-gui.exe C:\results\test
Frequency summary:
Sleep state summary: