blob: 08754ebe929db3dec9cc53e600e9548f5027585d [file] [log] [blame]
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<font size=\"8\">Energy Meter Examples</font>\n",
"<br>\n",
"<font size=\"5\">Linux Kernel HWMon</font>\n",
"<br>\n",
"<hr>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Import Required Modules"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import logging\n",
"from conf import LisaLogging\n",
"LisaLogging.setup()"
]
},
{
"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"
]
},
{
"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_HWMON\",\n",
"\n",
" # Energy Meters Configuration for BayLibre's ACME Cape\n",
" \"emeter\" : {\n",
" \"instrument\" : \"hwmon\",\n",
" \"conf\" : {\n",
" # Prefixes of the HWMon labels\n",
" 'sites' : ['a53', 'a57'],\n",
" # Type of hardware monitor to be used\n",
" 'kinds' : ['energy']\n",
" },\n",
" 'channel_map' : {\n",
" 'LITTLE' : 'a53',\n",
" 'big' : 'a57',\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:59:42 INFO : Target - Using base path: /data/lisa\n",
"03:59:42 INFO : Target - Loading custom (inline) target configuration\n",
"03:59:42 INFO : Target - Devlib modules to load: ['bl', 'hwmon', 'cpufreq']\n",
"03:59:42 INFO : Target - Connecting linux target:\n",
"03:59:42 INFO : Target - username : root\n",
"03:59:42 INFO : Target - host : 192.168.0.1\n",
"03:59:42 INFO : Target - password : \n",
"03:59:42 INFO : Target - Connection settings:\n",
"03:59:42 INFO : Target - {'username': 'root', 'host': '192.168.0.1', 'password': ''}\n",
"04:00:23 INFO : Target - Initializing target workdir:\n",
"04:00:23 INFO : Target - /root/devlib-target\n",
"04:00:28 INFO : Target - Topology:\n",
"04:00:28 INFO : Target - [[0, 3, 4, 5], [1, 2]]\n",
"04:00:30 INFO : Platform - Loading default EM:\n",
"04:00:30 INFO : Platform - /data/lisa/libs/utils/platforms/juno.json\n",
"04:00:30 WARNING : Target - Using configuration provided RTApp calibration\n",
"04:00:30 INFO : Target - Using RT-App calibration values:\n",
"04:00:30 INFO : Target - {\"0\": 360, \"1\": 142, \"2\": 138, \"3\": 352, \"4\": 352, \"5\": 353}\n",
"04:00:30 INFO : HWMon - Scanning for HWMON channels, may take some time...\n",
"04:00:30 INFO : HWMon - Channels selected for energy sampling:\n",
"04:00:30 INFO : HWMon - a57_energy\n",
"04:00:30 INFO : HWMon - a53_energy\n",
"04:00:30 INFO : TestEnv - Set results folder to:\n",
"04:00:30 INFO : TestEnv - /data/lisa/results/EnergyMeter_HWMON\n",
"04:00:30 INFO : TestEnv - Experiment results available also in:\n",
"04:00:30 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"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"04:00:30 INFO : WlGen - Setup new workload ramp\n",
"04:00:30 INFO : RTApp - Workload duration defined by longest task\n",
"04:00:30 INFO : RTApp - Default policy: SCHED_OTHER\n",
"04:00:30 INFO : RTApp - ------------------------\n",
"04:00:30 INFO : RTApp - task [ramp], sched: using default policy\n",
"04:00:30 INFO : RTApp - | calibration CPU: 1\n",
"04:00:30 INFO : RTApp - | loops count: 1\n",
"04:00:30 INFO : RTApp - + phase_000001: duration 0.500000 [s] (5 loops)\n",
"04:00:30 INFO : RTApp - | period 100000 [us], duty_cycle 60 %\n",
"04:00:30 INFO : RTApp - | run_time 60000 [us], sleep_time 40000 [us]\n",
"04:00:30 INFO : RTApp - + phase_000002: duration 0.500000 [s] (5 loops)\n",
"04:00:30 INFO : RTApp - | period 100000 [us], duty_cycle 55 %\n",
"04:00:30 INFO : RTApp - | run_time 55000 [us], sleep_time 45000 [us]\n",
"04:00:30 INFO : RTApp - + phase_000003: duration 0.500000 [s] (5 loops)\n",
"04:00:30 INFO : RTApp - | period 100000 [us], duty_cycle 50 %\n",
"04:00:30 INFO : RTApp - | run_time 50000 [us], sleep_time 50000 [us]\n",
"04:00:30 INFO : RTApp - + phase_000004: duration 0.500000 [s] (5 loops)\n",
"04:00:30 INFO : RTApp - | period 100000 [us], duty_cycle 45 %\n",
"04:00:30 INFO : RTApp - | run_time 45000 [us], sleep_time 55000 [us]\n",
"04:00:30 INFO : RTApp - + phase_000005: duration 0.500000 [s] (5 loops)\n",
"04:00:30 INFO : RTApp - | period 100000 [us], duty_cycle 40 %\n",
"04:00:30 INFO : RTApp - | run_time 40000 [us], sleep_time 60000 [us]\n",
"04:00:30 INFO : RTApp - + phase_000006: duration 0.500000 [s] (5 loops)\n",
"04:00:30 INFO : RTApp - | period 100000 [us], duty_cycle 35 %\n",
"04:00:30 INFO : RTApp - | run_time 35000 [us], sleep_time 65000 [us]\n",
"04:00:30 INFO : RTApp - + phase_000007: duration 0.500000 [s] (5 loops)\n",
"04:00:30 INFO : RTApp - | period 100000 [us], duty_cycle 30 %\n",
"04:00:30 INFO : RTApp - | run_time 30000 [us], sleep_time 70000 [us]\n",
"04:00:30 INFO : RTApp - + phase_000008: duration 0.500000 [s] (5 loops)\n",
"04:00:30 INFO : RTApp - | period 100000 [us], duty_cycle 25 %\n",
"04:00:30 INFO : RTApp - | run_time 25000 [us], sleep_time 75000 [us]\n",
"04:00:30 INFO : RTApp - + phase_000009: duration 0.500000 [s] (5 loops)\n",
"04:00:30 INFO : RTApp - | period 100000 [us], duty_cycle 20 %\n",
"04:00:30 INFO : RTApp - | run_time 20000 [us], sleep_time 80000 [us]\n",
"04:00:35 INFO : WlGen - Workload execution START:\n",
"04:00:35 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": [
"04:00:41 INFO : Collected data:\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[01;34m/data/lisa/results/EnergyMeter_HWMON\u001b[00m\r\n",
"├── energy.json\r\n",
"├── output.log\r\n",
"├── ramp_00.json\r\n",
"├── rt-app-ramp-0.log\r\n",
"├── trace.dat\r\n",
"├── trace.raw.txt\r\n",
"└── trace.txt\r\n",
"\r\n",
"0 directories, 7 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": [
"04:00:41 INFO : Measured channels energy:\n",
"04:00:41 INFO : {'big': 14.410717999999179, 'LITTLE': 1.1058980000016163}\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": [
"04:00:41 INFO : Generated energy file:\n",
"04:00:41 INFO : /data/lisa/results/EnergyMeter_HWMON/energy.json\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\r\n",
" \"LITTLE\": 1.1058980000016163, \r\n",
" \"big\": 14.410717999999179\r\n",
"}"
]
}
],
"source": [
"logging.info(\"Generated energy file:\")\n",
"logging.info(\" %s\", nrg_report.report_file)\n",
"!cat $nrg_report.report_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
}