blob: 8715550e0489930c5d6a71774e06f7de61fd8f0d [file] [log] [blame]
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Energy Meter Examples\n",
"\n",
"## ARM Energy Probe\n",
"\n",
"*NOTE*: `caiman` is required to collect data from the probe. Instructions on how to install it can be found here https://github.com/ARM-software/lisa/wiki/Energy-Meters-Requirements#arm-energy-probe-aep."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2016-12-08 12:40:07,000 INFO : root : Using LISA logging configuration:\n",
"2016-12-08 12:40:07,000 INFO : root : /home/vagrant/lisa/logging.conf\n"
]
}
],
"source": [
"import logging\n",
"from conf import LisaLogging\n",
"LisaLogging.setup()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Import required modules"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Generate plots inline\n",
"%matplotlib inline\n",
"\n",
"import os\n",
"\n",
"# Support to access the remote target\n",
"import devlib\n",
"from env import TestEnv\n",
"\n",
"# RTApp configurator for generation of PERIODIC tasks\n",
"from wlgen import RTA, Ramp"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Target Configuration\n",
"The target configuration is used to describe and configure your test environment.\n",
"You can find more details in **examples/utils/testenv_example.ipynb**."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Setup target configuration\n",
"my_conf = {\n",
"\n",
" # Target platform and board\n",
" \"platform\" : 'linux',\n",
" \"board\" : 'juno',\n",
" \"host\" : '192.168.0.1',\n",
"\n",
" # Folder where all the results will be collected\n",
" \"results_dir\" : \"EnergyMeter_AEP\",\n",
"\n",
" # Define devlib modules to load\n",
" \"exclude_modules\" : [ 'hwmon' ],\n",
"\n",
" # Energy Meters Configuration for ARM Energy Probe\n",
" \"emeter\" : {\n",
" \"instrument\" : \"aep\",\n",
" \"conf\" : {\n",
" # Value of the shunt resistor in Ohm\n",
" 'resistor_values' : [0.099],\n",
" # Device entry assigned to the probe on the host\n",
" 'device_entry' : '/dev/ttyACM0',\n",
" },\n",
" 'channel_map' : {\n",
" 'BAT' : 'BAT'\n",
" }\n",
" },\n",
" \n",
" # Tools required by the experiments\n",
" \"tools\" : [ 'trace-cmd', 'rt-app' ],\n",
" \n",
" # Comment this line to calibrate RTApp in your own platform\n",
" \"rtapp-calib\" : {\"0\": 360, \"1\": 142, \"2\": 138, \"3\": 352, \"4\": 352, \"5\": 353},\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false,
"scrolled": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"03:58:29 INFO : Target - Using base path: /data/lisa\n",
"03:58:29 INFO : Target - Loading custom (inline) target configuration\n",
"03:58:29 INFO : Target - Devlib modules to load: ['bl', 'cpufreq']\n",
"03:58:29 INFO : Target - Connecting linux target:\n",
"03:58:29 INFO : Target - username : root\n",
"03:58:29 INFO : Target - host : 192.168.0.1\n",
"03:58:29 INFO : Target - password : \n",
"03:58:29 INFO : Target - Connection settings:\n",
"03:58:29 INFO : Target - {'username': 'root', 'host': '192.168.0.1', 'password': ''}\n",
"03:58:33 INFO : Target - Initializing target workdir:\n",
"03:58:33 INFO : Target - /root/devlib-target\n",
"03:58:39 INFO : Target - Topology:\n",
"03:58:39 INFO : Target - [[0, 3, 4, 5], [1, 2]]\n",
"03:58:40 INFO : Platform - Loading default EM:\n",
"03:58:40 INFO : Platform - /data/lisa/libs/utils/platforms/juno.json\n",
"03:58:40 WARNING : Target - Using configuration provided RTApp calibration\n",
"03:58:40 INFO : Target - Using RT-App calibration values:\n",
"03:58:40 INFO : Target - {\"0\": 360, \"1\": 142, \"2\": 138, \"3\": 352, \"4\": 352, \"5\": 353}\n",
"03:58:40 INFO : AEP - AEP configuration\n",
"03:58:40 INFO : AEP - {'instrument': 'aep', 'channel_map': {'BAT': 'BAT'}, 'conf': {'resistor_values': [0.099], 'device_entry': '/dev/ttyACM0'}}\n",
"03:58:40 INFO : AEP - Channels selected for energy sampling:\n",
"[CHAN(BAT_current), CHAN(BAT_power), CHAN(BAT_voltage)]\n",
"03:58:40 INFO : TestEnv - Set results folder to:\n",
"03:58:40 INFO : TestEnv - /data/lisa/results/EnergyMeter_AEP\n",
"03:58:40 INFO : TestEnv - Experiment results available also in:\n",
"03:58:40 INFO : TestEnv - /data/lisa/results_latest\n"
]
}
],
"source": [
"# Initialize a test environment using:\n",
"te = TestEnv(my_conf, wipe=False, force_new=True)\n",
"target = te.target"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Workload Execution and Power Consumptions Samping\n",
"\n",
"Detailed information on RTApp can be found in **examples/wlgen/rtapp_example.ipynb**.\n",
"\n",
"Each **EnergyMeter** derived class has two main methods: **reset** and **report**.\n",
" - The **reset** method will reset the energy meter and start sampling from channels specified in the target configuration. <br>\n",
" - The **report** method will stop capture and will retrieve the energy consumption data. This returns an EnergyReport composed of the measured channels energy and the report file. Each of the samples can also be obtained, as you can see below."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"03:58:42 INFO : WlGen - Setup new workload ramp\n",
"03:58:42 INFO : RTApp - Workload duration defined by longest task\n",
"03:58:42 INFO : RTApp - Default policy: SCHED_OTHER\n",
"03:58:42 INFO : RTApp - ------------------------\n",
"03:58:42 INFO : RTApp - task [ramp], sched: using default policy\n",
"03:58:42 INFO : RTApp - | calibration CPU: 1\n",
"03:58:42 INFO : RTApp - | loops count: 1\n",
"03:58:42 INFO : RTApp - + phase_000001: duration 0.500000 [s] (5 loops)\n",
"03:58:42 INFO : RTApp - | period 100000 [us], duty_cycle 60 %\n",
"03:58:42 INFO : RTApp - | run_time 60000 [us], sleep_time 40000 [us]\n",
"03:58:42 INFO : RTApp - + phase_000002: duration 0.500000 [s] (5 loops)\n",
"03:58:42 INFO : RTApp - | period 100000 [us], duty_cycle 55 %\n",
"03:58:42 INFO : RTApp - | run_time 55000 [us], sleep_time 45000 [us]\n",
"03:58:42 INFO : RTApp - + phase_000003: duration 0.500000 [s] (5 loops)\n",
"03:58:42 INFO : RTApp - | period 100000 [us], duty_cycle 50 %\n",
"03:58:42 INFO : RTApp - | run_time 50000 [us], sleep_time 50000 [us]\n",
"03:58:42 INFO : RTApp - + phase_000004: duration 0.500000 [s] (5 loops)\n",
"03:58:42 INFO : RTApp - | period 100000 [us], duty_cycle 45 %\n",
"03:58:42 INFO : RTApp - | run_time 45000 [us], sleep_time 55000 [us]\n",
"03:58:42 INFO : RTApp - + phase_000005: duration 0.500000 [s] (5 loops)\n",
"03:58:42 INFO : RTApp - | period 100000 [us], duty_cycle 40 %\n",
"03:58:42 INFO : RTApp - | run_time 40000 [us], sleep_time 60000 [us]\n",
"03:58:42 INFO : RTApp - + phase_000006: duration 0.500000 [s] (5 loops)\n",
"03:58:42 INFO : RTApp - | period 100000 [us], duty_cycle 35 %\n",
"03:58:42 INFO : RTApp - | run_time 35000 [us], sleep_time 65000 [us]\n",
"03:58:42 INFO : RTApp - + phase_000007: duration 0.500000 [s] (5 loops)\n",
"03:58:42 INFO : RTApp - | period 100000 [us], duty_cycle 30 %\n",
"03:58:42 INFO : RTApp - | run_time 30000 [us], sleep_time 70000 [us]\n",
"03:58:42 INFO : RTApp - + phase_000008: duration 0.500000 [s] (5 loops)\n",
"03:58:42 INFO : RTApp - | period 100000 [us], duty_cycle 25 %\n",
"03:58:42 INFO : RTApp - | run_time 25000 [us], sleep_time 75000 [us]\n",
"03:58:42 INFO : RTApp - + phase_000009: duration 0.500000 [s] (5 loops)\n",
"03:58:42 INFO : RTApp - | period 100000 [us], duty_cycle 20 %\n",
"03:58:42 INFO : RTApp - | run_time 20000 [us], sleep_time 80000 [us]\n",
"03:58:44 INFO : WlGen - Workload execution START:\n",
"03:58:44 INFO : WlGen - /root/devlib-target/bin/rt-app /root/devlib-target/ramp_00.json 2>&1\n"
]
}
],
"source": [
"# Create and RTApp RAMP task\n",
"rtapp = RTA(te.target, 'ramp', calibration=te.calibration())\n",
"rtapp.conf(kind='profile',\n",
" params={\n",
" 'ramp' : Ramp(\n",
" start_pct = 60,\n",
" end_pct = 20,\n",
" delta_pct = 5,\n",
" time_s = 0.5).get()\n",
" })\n",
"\n",
"# EnergyMeter Start\n",
"te.emeter.reset()\n",
"\n",
"rtapp.run(out_dir=te.res_dir)\n",
"\n",
"# EnergyMeter Stop and samples collection\n",
"nrg_report = te.emeter.report(te.res_dir)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"03:58:50 INFO : Collected data:\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[01;34m/data/lisa/results/EnergyMeter_AEP\u001b[00m\r\n",
"├── energy.json\r\n",
"├── output.log\r\n",
"├── ramp_00.json\r\n",
"├── rt-app-ramp-0.log\r\n",
"└── samples.csv\r\n",
"\r\n",
"0 directories, 5 files\r\n"
]
}
],
"source": [
"logging.info(\"Collected data:\")\n",
"!tree $te.res_dir"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Power Measurements Data"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"03:58:50 INFO : Measured channels energy:\n",
"03:58:50 INFO : {'BAT': 0.02506927080038548}\n"
]
}
],
"source": [
"logging.info(\"Measured channels energy:\")\n",
"logging.info(\"%s\", nrg_report.channels)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"03:58:51 INFO : Generated energy file:\n",
"03:58:51 INFO : /data/lisa/results/EnergyMeter_AEP/energy.json\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\r\n",
" \"BAT\": 0.02506927080038548\r\n",
"}"
]
}
],
"source": [
"logging.info(\"Generated energy file:\")\n",
"logging.info(\" %s\", nrg_report.report_file)\n",
"!cat $nrg_report.report_file"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"03:58:52 INFO : Samples collected for the BAT channel (only first 10)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"BAT_current,BAT_power,BAT_voltage\r",
"\r\n",
"0.049,0.007,0.146\r",
"\r\n",
"0.035,0.004,0.142\r",
"\r\n",
"0.027,0.003,0.141\r",
"\r\n",
"0.029,0.004,0.151\r",
"\r\n",
"0.046,0.006,0.147\r",
"\r\n",
"0.033,0.004,0.143\r",
"\r\n",
"0.025,0.003,0.142\r",
"\r\n",
"0.029,0.004,0.154\r",
"\r\n",
"0.049,0.007,0.15\r",
"\r\n"
]
}
],
"source": [
"logging.info(\"Samples collected for the BAT channel (only first 10)\")\n",
"samples_file = os.path.join(te.res_dir, 'samples.csv')\n",
"!head $samples_file"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
},
"toc": {
"toc_cell": false,
"toc_number_sections": true,
"toc_threshold": 6,
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 0
}