Home | History | Annotate | Download | only in tutorial
      1 {
      2  "cells": [
      3   {
      4    "cell_type": "markdown",
      5    "metadata": {},
      6    "source": [
      7     "# Tutorial Goal"
      8    ]
      9   },
     10   {
     11    "cell_type": "markdown",
     12    "metadata": {},
     13    "source": [
     14     "This tutorial aims to show how to **configure and run** a **synthetic workload** using the **wlgen module** provided by LISA."
     15    ]
     16   },
     17   {
     18    "cell_type": "markdown",
     19    "metadata": {},
     20    "source": [
     21     "# Configure logging"
     22    ]
     23   },
     24   {
     25    "cell_type": "code",
     26    "execution_count": null,
     27    "metadata": {
     28     "collapsed": true
     29    },
     30    "outputs": [],
     31    "source": [
     32     "import logging\n",
     33     "from conf import LisaLogging\n",
     34     "LisaLogging.setup()"
     35    ]
     36   },
     37   {
     38    "cell_type": "code",
     39    "execution_count": 1,
     40    "metadata": {
     41     "collapsed": true
     42    },
     43    "outputs": [],
     44    "source": [
     45     "# Execute this cell to enabled devlib debugging statements\n",
     46     "logging.getLogger('ssh').setLevel(logging.DEBUG)"
     47    ]
     48   },
     49   {
     50    "cell_type": "code",
     51    "execution_count": 2,
     52    "metadata": {
     53     "collapsed": false
     54    },
     55    "outputs": [],
     56    "source": [
     57     "# Other python modules required by this notebook\n",
     58     "import json\n",
     59     "import os"
     60    ]
     61   },
     62   {
     63    "cell_type": "markdown",
     64    "metadata": {},
     65    "source": [
     66     "# Test environment setup"
     67    ]
     68   },
     69   {
     70    "cell_type": "code",
     71    "execution_count": 3,
     72    "metadata": {
     73     "collapsed": false
     74    },
     75    "outputs": [],
     76    "source": [
     77     "# Setup a target configuration\n",
     78     "conf = {\n",
     79     "    \n",
     80     "    # Target is localhost\n",
     81     "    \"platform\"    : 'linux',\n",
     82     "    \"board\"       : \"juno\",\n",
     83     "    \n",
     84     "    # Login credentials\n",
     85     "    \"host\"        : \"192.168.0.1\",\n",
     86     "    \"username\"    : \"root\",\n",
     87     "    \"password\"    : \"\",\n",
     88     "\n",
     89     "    # Binary tools required to run this experiment\n",
     90     "    # These tools must be present in the tools/ folder for the architecture\n",
     91     "    \"tools\"   : ['rt-app', 'taskset', 'trace-cmd'],\n",
     92     "    \n",
     93     "    # Comment the following line to force rt-app calibration on your target\n",
     94     "#     \"rtapp-calib\" : {\n",
     95     "#        \"0\": 355, \"1\": 138, \"2\": 138, \"3\": 355, \"4\": 354, \"5\": 354\n",
     96     "#     },\n",
     97     "    \n",
     98     "    # FTrace events end buffer configuration\n",
     99     "    \"ftrace\"  : {\n",
    100     "         \"events\" : [\n",
    101     "             \"sched_switch\",\n",
    102     "             \"cpu_frequency\"\n",
    103     "         ],\n",
    104     "         \"buffsize\" : 10240\n",
    105     "    },\n",
    106     "\n",
    107     "    # Where results are collected\n",
    108     "    \"results_dir\" : \"WlgenExample\",\n",
    109     "    \n",
    110     "    # Devlib modules we'll need\n",
    111     "    \"modules\": [\"cpufreq\"]\n",
    112     "}"
    113    ]
    114   },
    115   {
    116    "cell_type": "code",
    117    "execution_count": 4,
    118    "metadata": {
    119     "collapsed": false,
    120     "scrolled": false
    121    },
    122    "outputs": [
    123     {
    124      "name": "stderr",
    125      "output_type": "stream",
    126      "text": [
    127       "12:22:12  INFO    :         Target - Using base path: /home/derkling/Code/lisa\n",
    128       "12:22:12  INFO    :         Target - Loading custom (inline) target configuration\n",
    129       "12:22:12  INFO    :         Target - Devlib modules to load: ['bl', 'hwmon', 'cpufreq']\n",
    130       "12:22:12  INFO    :         Target - Connecting linux target:\n",
    131       "12:22:12  INFO    :         Target -   username : root\n",
    132       "12:22:12  INFO    :         Target -       host : 192.168.0.1\n",
    133       "12:22:12  INFO    :         Target -   password : \n",
    134       "12:22:50  INFO    :         Target - Initializing target workdir:\n",
    135       "12:22:50  INFO    :         Target -    /root/devlib-target\n",
    136       "12:22:59  INFO    :         Target - Topology:\n",
    137       "12:22:59  INFO    :         Target -    [[0, 3, 4, 5], [1, 2]]\n",
    138       "12:23:01  INFO    :       Platform - Loading default EM:\n",
    139       "12:23:01  INFO    :       Platform -    /home/derkling/Code/lisa/libs/utils/platforms/juno.json\n",
    140       "12:23:02  INFO    :         FTrace - Enabled tracepoints:\n",
    141       "12:23:02  INFO    :         FTrace -   sched_switch\n",
    142       "12:23:02  INFO    :         FTrace -   cpu_frequency\n",
    143       "12:23:02  INFO    :    EnergyMeter - Scanning for HWMON channels, may take some time...\n",
    144       "12:23:02  INFO    :    EnergyMeter - Channels selected for energy sampling:\n",
    145       "12:23:02  INFO    :    EnergyMeter -    a57_energy\n",
    146       "12:23:02  INFO    :    EnergyMeter -    a53_energy\n",
    147       "12:23:02  WARNING :         Target - Using configuration provided RTApp calibration\n",
    148       "12:23:02  INFO    :         Target - Using RT-App calibration values:\n",
    149       "12:23:02  INFO    :         Target -    {\"0\": 355, \"1\": 138, \"2\": 138, \"3\": 355, \"4\": 354, \"5\": 354}\n",
    150       "12:23:02  WARNING :        TestEnv - Wipe previous contents of the results folder:\n",
    151       "12:23:02  WARNING :        TestEnv -    /home/derkling/Code/lisa/results/WlgenExample\n",
    152       "12:23:02  INFO    :        TestEnv - Set results folder to:\n",
    153       "12:23:02  INFO    :        TestEnv -    /home/derkling/Code/lisa/results/WlgenExample\n",
    154       "12:23:02  INFO    :        TestEnv - Experiment results available also in:\n",
    155       "12:23:02  INFO    :        TestEnv -    /home/derkling/Code/lisa/results_latest\n"
    156      ]
    157     }
    158    ],
    159    "source": [
    160     "# Support to access the remote target\n",
    161     "from env import TestEnv\n",
    162     "\n",
    163     "# Initialize a test environment using:\n",
    164     "# the provided target configuration (my_target_conf)\n",
    165     "# the provided test configuration   (my_test_conf)\n",
    166     "te = TestEnv(conf)\n",
    167     "target = te.target"
    168    ]
    169   },
    170   {
    171    "cell_type": "markdown",
    172    "metadata": {},
    173    "source": [
    174     "## Workload execution utility"
    175    ]
    176   },
    177   {
    178    "cell_type": "code",
    179    "execution_count": 27,
    180    "metadata": {
    181     "collapsed": false
    182    },
    183    "outputs": [],
    184    "source": [
    185     "def execute(te, wload, res_dir):\n",
    186     "    \n",
    187     "    logging.info('# Create results folder for this execution')\n",
    188     "    !mkdir {res_dir}\n",
    189     "    \n",
    190     "    logging.info('# Setup FTrace')\n",
    191     "    te.ftrace.start()\n",
    192     "\n",
    193     "    logging.info('## Start energy sampling')\n",
    194     "    te.emeter.reset()\n",
    195     "\n",
    196     "    logging.info('### Start RTApp execution')\n",
    197     "    wload.run(out_dir=res_dir)\n",
    198     "\n",
    199     "    logging.info('## Read energy consumption: %s/energy.json', res_dir)\n",
    200     "    nrg_report = te.emeter.report(out_dir=res_dir)\n",
    201     "\n",
    202     "    logging.info('# Stop FTrace')\n",
    203     "    te.ftrace.stop()\n",
    204     "\n",
    205     "    trace_file = os.path.join(res_dir, 'trace.dat')\n",
    206     "    logging.info('# Save FTrace: %s', trace_file)\n",
    207     "    te.ftrace.get_trace(trace_file)\n",
    208     "\n",
    209     "    logging.info('# Save platform description: %s/platform.json', res_dir)\n",
    210     "    plt, plt_file = te.platform_dump(res_dir)\n",
    211     "    \n",
    212     "    logging.info('# Report collected data:')\n",
    213     "    logging.info('   %s', res_dir)\n",
    214     "    !ls -la {res_dir}\n",
    215     "    \n",
    216     "    return nrg_report, plt, plt_file, trace_file"
    217    ]
    218   },
    219   {
    220    "cell_type": "markdown",
    221    "metadata": {},
    222    "source": [
    223     "# Single task RTApp workload"
    224    ]
    225   },
    226   {
    227    "cell_type": "markdown",
    228    "metadata": {},
    229    "source": [
    230     "## 1) creation"
    231    ]
    232   },
    233   {
    234    "cell_type": "code",
    235    "execution_count": 28,
    236    "metadata": {
    237     "collapsed": false
    238    },
    239    "outputs": [
    240     {
    241      "name": "stderr",
    242      "output_type": "stream",
    243      "text": [
    244       "12:38:37  INFO    :          WlGen - Setup new workload example1\n"
    245      ]
    246     }
    247    ],
    248    "source": [
    249     "# Support to configure and run RTApp based workloads\n",
    250     "from wlgen import RTA\n",
    251     "\n",
    252     "# Create a new RTApp workload generator using the calibration values\n",
    253     "# reported by the TestEnv module\n",
    254     "rtapp_name = 'example1'\n",
    255     "rtapp = RTA(target, rtapp_name, calibration=te.calibration())"
    256    ]
    257   },
    258   {
    259    "cell_type": "markdown",
    260    "metadata": {},
    261    "source": [
    262     "## 2) configuration"
    263    ]
    264   },
    265   {
    266    "cell_type": "code",
    267    "execution_count": 29,
    268    "metadata": {
    269     "collapsed": false
    270    },
    271    "outputs": [
    272     {
    273      "name": "stderr",
    274      "output_type": "stream",
    275      "text": [
    276       "12:38:39  INFO    :          RTApp - Workload duration defined by longest task\n",
    277       "12:38:39  INFO    :          RTApp - Default policy: SCHED_OTHER\n",
    278       "12:38:39  INFO    :          RTApp - ------------------------\n",
    279       "12:38:39  INFO    :          RTApp - task [task_p20], sched: {'policy': 'OTHER', 'priotity': 130}\n",
    280       "12:38:39  INFO    :          RTApp -  | calibration CPU: 1\n",
    281       "12:38:39  INFO    :          RTApp -  | loops count: 1\n",
    282       "12:38:39  INFO    :          RTApp -  | CPUs affinity: 0\n",
    283       "12:38:39  INFO    :          RTApp - + phase_000001: duration 5.000000 [s] (50 loops)\n",
    284       "12:38:39  INFO    :          RTApp - |  period   100000 [us], duty_cycle  20 %\n",
    285       "12:38:39  INFO    :          RTApp - |  run_time  20000 [us], sleep_time  80000 [us]\n"
    286      ]
    287     }
    288    ],
    289    "source": [
    290     "# RTApp configurator for generation of PERIODIC tasks\n",
    291     "from wlgen import Periodic \n",
    292     "\n",
    293     "# Configure this RTApp instance to:\n",
    294     "rtapp.conf(\n",
    295     "\n",
    296     "    # 1. generate a \"profile based\" set of tasks\n",
    297     "    kind = 'profile',\n",
    298     "    \n",
    299     "    # 2. define the \"profile\" of each task\n",
    300     "    params = {\n",
    301     "        \n",
    302     "        # 3. PERIODIC task with\n",
    303     "        'task_p20': Periodic (\n",
    304     "            period_ms      = 100, # period [ms]\n",
    305     "            duty_cycle_pct =  20, # duty cycle [%]\n",
    306     "            duration_s     =  5,  # duration [s]\n",
    307     "            delay_s        =  0,  # start after that delay [s]\n",
    308     "            sched          = {    # run as a low-priority SCHED_OTHER task\n",
    309     "                'policy'   : 'OTHER',\n",
    310     "                'priotity' : 130,\n",
    311     "            },\n",
    312     "            cpus           =      # pinned on first online CPU\n",
    313     "                              str(target.list_online_cpus()[0])\n",
    314     "            # ADD OTHER PARAMETERS\n",
    315     "        ).get(),\n",
    316     "\n",
    317     "    },\n",
    318     "    \n",
    319     ");"
    320    ]
    321   },
    322   {
    323    "cell_type": "code",
    324    "execution_count": 30,
    325    "metadata": {
    326     "collapsed": false
    327    },
    328    "outputs": [
    329     {
    330      "name": "stderr",
    331      "output_type": "stream",
    332      "text": [
    333       "12:38:42  INFO    : Generated RTApp JSON file:\n"
    334      ]
    335     },
    336     {
    337      "name": "stdout",
    338      "output_type": "stream",
    339      "text": [
    340       "{\n",
    341       "    \"global\": {\n",
    342       "        \"calibration\": 138, \n",
    343       "        \"default_policy\": \"SCHED_OTHER\", \n",
    344       "        \"duration\": -1, \n",
    345       "        \"logdir\": \"/root/devlib-target\"\n",
    346       "    }, \n",
    347       "    \"tasks\": {\n",
    348       "        \"task_p20\": {\n",
    349       "            \"cpus\": [\n",
    350       "                0\n",
    351       "            ], \n",
    352       "            \"loop\": 1, \n",
    353       "            \"phases\": {\n",
    354       "                \"p000001\": {\n",
    355       "                    \"loop\": 50, \n",
    356       "                    \"run\": 20000, \n",
    357       "                    \"timer\": {\n",
    358       "                        \"period\": 100000, \n",
    359       "                        \"ref\": \"task_p20\"\n",
    360       "                    }\n",
    361       "                }\n",
    362       "            }, \n",
    363       "            \"policy\": \"SCHED_OTHER\", \n",
    364       "            \"priotity\": 130\n",
    365       "        }\n",
    366       "    }\n",
    367       "}\n"
    368      ]
    369     }
    370    ],
    371    "source": [
    372     "# Inspect the JSON file used to run the application\n",
    373     "with open('./{}_00.json'.format(rtapp_name), 'r') as fh:\n",
    374     "    rtapp_json = json.load(fh)\n",
    375     "logging.info('Generated RTApp JSON file:')\n",
    376     "print json.dumps(rtapp_json, indent=4, sort_keys=True)"
    377    ]
    378   },
    379   {
    380    "cell_type": "markdown",
    381    "metadata": {},
    382    "source": [
    383     "## 3) execution"
    384    ]
    385   },
    386   {
    387    "cell_type": "code",
    388    "execution_count": 31,
    389    "metadata": {
    390     "collapsed": false
    391    },
    392    "outputs": [
    393     {
    394      "name": "stderr",
    395      "output_type": "stream",
    396      "text": [
    397       "12:38:45  INFO    : # Create results folder for this execution\n",
    398       "12:38:45  INFO    : # Setup FTrace\n",
    399       "12:38:49  INFO    : ## Start energy sampling\n",
    400       "12:38:51  INFO    : ### Start RTApp execution\n",
    401       "12:38:51  INFO    :          WlGen - Workload execution START:\n",
    402       "12:38:51  INFO    :          WlGen -    /root/devlib-target/bin/rt-app /root/devlib-target/example1_00.json\n",
    403       "12:38:57  INFO    : ## Read energy consumption: /home/derkling/Code/lisa/results/WlgenExample/example1/energy.json\n",
    404       "12:38:57  INFO    :   EnergyReport - Energy [             a53]: 5.125284\n",
    405       "12:38:57  INFO    :   EnergyReport - Energy [             a57]: 3.037161\n",
    406       "12:38:57  INFO    : # Stop FTrace\n",
    407       "12:38:59  INFO    : # Save FTrace: /home/derkling/Code/lisa/results/WlgenExample/example1/trace.dat\n",
    408       "12:39:01  INFO    : # Save platform description: /home/derkling/Code/lisa/results/WlgenExample/example1/platform.json\n",
    409       "12:39:01  INFO    : # Report collected data:\n",
    410       "12:39:01  INFO    :    /home/derkling/Code/lisa/results/WlgenExample/example1\n"
    411      ]
    412     },
    413     {
    414      "name": "stdout",
    415      "output_type": "stream",
    416      "text": [
    417       "total 4008\r\n",
    418       "drwxrwxr-x 2 derkling derkling    4096 Mar  2 12:39 .\r\n",
    419       "drwxrwxr-x 3 derkling derkling    4096 Mar  2 12:38 ..\r\n",
    420       "-rw-rw-r-- 1 derkling derkling      52 Mar  2 12:38 energy.json\r\n",
    421       "-rw-r--r-- 1 derkling derkling     644 Mar  2 12:38 example1_00.json\r\n",
    422       "-rw-rw-r-- 1 derkling derkling     235 Mar  2 12:38 output.log\r\n",
    423       "-rw-rw-r-- 1 derkling derkling    1075 Mar  2 12:39 platform.json\r\n",
    424       "-rw-r--r-- 1 derkling derkling    6360 Mar  2 12:38 rt-app-task_p20-0.log\r\n",
    425       "-rw-r--r-- 1 derkling derkling    6360 Mar  2 12:38 rt-app-task_p20-3.log\r\n",
    426       "-rw-r--r-- 1 derkling derkling 4063232 Mar  2 12:39 trace.dat\r\n"
    427      ]
    428     }
    429    ],
    430    "source": [
    431     "res_dir = os.path.join(te.res_dir, rtapp_name)\n",
    432     "nrg_report, plt, plt_file, trace_file = execute(te, rtapp, res_dir)"
    433    ]
    434   },
    435   {
    436    "cell_type": "markdown",
    437    "metadata": {},
    438    "source": [
    439     "## 4) Check collected data"
    440    ]
    441   },
    442   {
    443    "cell_type": "code",
    444    "execution_count": 32,
    445    "metadata": {
    446     "collapsed": false
    447    },
    448    "outputs": [
    449     {
    450      "name": "stderr",
    451      "output_type": "stream",
    452      "text": [
    453       "12:39:07  INFO    : Energy: /home/derkling/Code/lisa/results/WlgenExample/example1/energy.json\n"
    454      ]
    455     },
    456     {
    457      "name": "stdout",
    458      "output_type": "stream",
    459      "text": [
    460       "{\n",
    461       "    \"LITTLE\": \"5.125284\", \n",
    462       "    \"big\": \"3.037161\"\n",
    463       "}\n"
    464      ]
    465     }
    466    ],
    467    "source": [
    468     "# Dump the energy measured for the LITTLE and big clusters\n",
    469     "logging.info('Energy: %s', nrg_report.report_file)\n",
    470     "print json.dumps(nrg_report.channels, indent=4, sort_keys=True)"
    471    ]
    472   },
    473   {
    474    "cell_type": "code",
    475    "execution_count": 33,
    476    "metadata": {
    477     "collapsed": false
    478    },
    479    "outputs": [
    480     {
    481      "name": "stderr",
    482      "output_type": "stream",
    483      "text": [
    484       "12:39:07  INFO    : Platform description: /home/derkling/Code/lisa/results/WlgenExample/example1/platform.json\n"
    485      ]
    486     },
    487     {
    488      "name": "stdout",
    489      "output_type": "stream",
    490      "text": [
    491       "{\n",
    492       "    \"clusters\": {\n",
    493       "        \"big\": [\n",
    494       "            1, \n",
    495       "            2\n",
    496       "        ], \n",
    497       "        \"little\": [\n",
    498       "            0, \n",
    499       "            3, \n",
    500       "            4, \n",
    501       "            5\n",
    502       "        ]\n",
    503       "    }, \n",
    504       "    \"cpus_count\": 6, \n",
    505       "    \"freqs\": {\n",
    506       "        \"big\": [\n",
    507       "            450000, \n",
    508       "            625000, \n",
    509       "            800000, \n",
    510       "            950000, \n",
    511       "            1100000\n",
    512       "        ], \n",
    513       "        \"little\": [\n",
    514       "            450000, \n",
    515       "            575000, \n",
    516       "            700000, \n",
    517       "            775000, \n",
    518       "            850000\n",
    519       "        ]\n",
    520       "    }, \n",
    521       "    \"nrg_model\": {\n",
    522       "        \"big\": {\n",
    523       "            \"cluster\": {\n",
    524       "                \"nrg_max\": 64\n",
    525       "            }, \n",
    526       "            \"cpu\": {\n",
    527       "                \"cap_max\": 1024, \n",
    528       "                \"nrg_max\": 616\n",
    529       "            }\n",
    530       "        }, \n",
    531       "        \"little\": {\n",
    532       "            \"cluster\": {\n",
    533       "                \"nrg_max\": 57\n",
    534       "            }, \n",
    535       "            \"cpu\": {\n",
    536       "                \"cap_max\": 447, \n",
    537       "                \"nrg_max\": 93\n",
    538       "            }\n",
    539       "        }\n",
    540       "    }, \n",
    541       "    \"topology\": [\n",
    542       "        [\n",
    543       "            0, \n",
    544       "            3, \n",
    545       "            4, \n",
    546       "            5\n",
    547       "        ], \n",
    548       "        [\n",
    549       "            1, \n",
    550       "            2\n",
    551       "        ]\n",
    552       "    ]\n",
    553       "}\n"
    554      ]
    555     }
    556    ],
    557    "source": [
    558     "# Dump the platform descriptor, which could be useful for further analysis\n",
    559     "# of the generated results\n",
    560     "logging.info('Platform description: %s', plt_file)\n",
    561     "print json.dumps(plt, indent=4, sort_keys=True)"
    562    ]
    563   },
    564   {
    565    "cell_type": "markdown",
    566    "metadata": {},
    567    "source": [
    568     "## 5) trace inspection"
    569    ]
    570   },
    571   {
    572    "cell_type": "code",
    573    "execution_count": 34,
    574    "metadata": {
    575     "collapsed": false,
    576     "scrolled": true
    577    },
    578    "outputs": [
    579     {
    580      "name": "stdout",
    581      "output_type": "stream",
    582      "text": [
    583       "version = 6\n",
    584       "trace-cmd: No such file or directory\n",
    585       "  [vmscan:mm_vmscan_writepage] function sizeof not defined\n",
    586       "  unknown op '~'\n",
    587       "  Error: expected type 5 but read 0\n",
    588       "  Error: expected type 4 but read 0\n",
    589       "  unknown op '~'\n",
    590       "  Error: expected type 5 but read 0\n",
    591       "  Error: expected type 4 but read 0\n",
    592       "  unknown op '~'\n",
    593       "  Error: expected type 5 but read 0\n",
    594       "  Error: expected type 4 but read 0\n",
    595       "  unknown op '~'\n",
    596       "  Error: expected type 5 but read 0\n",
    597       "  Error: expected type 4 but read 0\n",
    598       "  [sunrpc:xs_tcp_data_recv] function __builtin_constant_p not defined\n",
    599       "  [sunrpc:xprt_transmit] function __builtin_constant_p not defined\n",
    600       "  [sunrpc:xprt_lookup_rqst] function __builtin_constant_p not defined\n",
    601       "  [sunrpc:xprt_complete_rqst] function __builtin_constant_p not defined\n",
    602       "  [sunrpc:svc_send] function __builtin_constant_p not defined\n",
    603       "  [sunrpc:svc_recv] function __builtin_constant_p not defined\n",
    604       "  [sunrpc:svc_process] function __builtin_constant_p not defined\n",
    605       "  [ras:mc_event] function mc_event_error_type not defined\n",
    606       "  [libata:ata_qc_complete_internal] function libata_trace_parse_qc_flags not defined\n",
    607       "  [libata:ata_qc_complete_failed] function libata_trace_parse_qc_flags not defined\n",
    608       "  [libata:ata_qc_complete_done] function libata_trace_parse_qc_flags not defined\n",
    609       "  [libata:ata_eh_link_autopsy_qc] function libata_trace_parse_qc_flags not defined\n",
    610       "  [libata:ata_eh_link_autopsy] function libata_trace_parse_eh_action not defined\n",
    611       "  [kvm:kvm_arm_set_regset] function __print_array not defined\n",
    612       "  [kmem:mm_page_pcpu_drain] function sizeof not defined\n",
    613       "  [kmem:mm_page_free_batched] function sizeof not defined\n",
    614       "  [kmem:mm_page_free] function sizeof not defined\n",
    615       "  [kmem:mm_page_alloc_zone_locked] function sizeof not defined\n",
    616       "  Error: expected type 4 but read 0\n",
    617       "  [kmem:mm_page_alloc_extfrag] function sizeof not defined\n",
    618       "  [kmem:mm_page_alloc] function sizeof not defined\n",
    619       "  Error: expected type 4 but read 0\n",
    620       "  [filemap:mm_filemap_delete_from_page_cache] function sizeof not defined\n",
    621       "  [filemap:mm_filemap_add_to_page_cache] function sizeof not defined\n",
    622       "\n",
    623       "(kernelshark:11002): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GtkStatusbar'\n",
    624       "\n",
    625       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_statusbar_push: assertion 'GTK_IS_STATUSBAR (statusbar)' failed\n",
    626       "\n",
    627       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_widget_show: assertion 'GTK_IS_WIDGET (widget)' failed\n",
    628       "\n",
    629       "(kernelshark:11002): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GtkStatusbar'\n",
    630       "\n",
    631       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_statusbar_push: assertion 'GTK_IS_STATUSBAR (statusbar)' failed\n",
    632       "\n",
    633       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_widget_show: assertion 'GTK_IS_WIDGET (widget)' failed\n",
    634       "\n",
    635       "(kernelshark:11002): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GtkStatusbar'\n",
    636       "\n",
    637       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_statusbar_push: assertion 'GTK_IS_STATUSBAR (statusbar)' failed\n",
    638       "\n",
    639       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_widget_show: assertion 'GTK_IS_WIDGET (widget)' failed\n",
    640       "\n",
    641       "(kernelshark:11002): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GtkStatusbar'\n",
    642       "\n",
    643       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_statusbar_push: assertion 'GTK_IS_STATUSBAR (statusbar)' failed\n",
    644       "\n",
    645       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_widget_show: assertion 'GTK_IS_WIDGET (widget)' failed\n",
    646       "\n",
    647       "(kernelshark:11002): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GtkStatusbar'\n",
    648       "\n",
    649       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_statusbar_push: assertion 'GTK_IS_STATUSBAR (statusbar)' failed\n",
    650       "\n",
    651       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_widget_show: assertion 'GTK_IS_WIDGET (widget)' failed\n",
    652       "\n",
    653       "(kernelshark:11002): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GtkStatusbar'\n",
    654       "\n",
    655       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_statusbar_push: assertion 'GTK_IS_STATUSBAR (statusbar)' failed\n",
    656       "\n",
    657       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_widget_show: assertion 'GTK_IS_WIDGET (widget)' failed\n",
    658       "\n",
    659       "(kernelshark:11002): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GtkStatusbar'\n",
    660       "\n",
    661       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_statusbar_push: assertion 'GTK_IS_STATUSBAR (statusbar)' failed\n",
    662       "\n",
    663       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_widget_show: assertion 'GTK_IS_WIDGET (widget)' failed\n",
    664       "\n",
    665       "(kernelshark:11002): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GtkStatusbar'\n",
    666       "\n",
    667       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_statusbar_push: assertion 'GTK_IS_STATUSBAR (statusbar)' failed\n",
    668       "\n",
    669       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_widget_show: assertion 'GTK_IS_WIDGET (widget)' failed\n",
    670       "\n",
    671       "(kernelshark:11002): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GtkStatusbar'\n",
    672       "\n",
    673       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_statusbar_push: assertion 'GTK_IS_STATUSBAR (statusbar)' failed\n",
    674       "\n",
    675       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_widget_show: assertion 'GTK_IS_WIDGET (widget)' failed\n",
    676       "\n",
    677       "(kernelshark:11002): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GtkStatusbar'\n",
    678       "\n",
    679       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_statusbar_push: assertion 'GTK_IS_STATUSBAR (statusbar)' failed\n",
    680       "\n",
    681       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_widget_show: assertion 'GTK_IS_WIDGET (widget)' failed\n",
    682       "\n",
    683       "(kernelshark:11002): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GtkStatusbar'\n",
    684       "\n",
    685       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_statusbar_push: assertion 'GTK_IS_STATUSBAR (statusbar)' failed\n",
    686       "\n",
    687       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_widget_show: assertion 'GTK_IS_WIDGET (widget)' failed\n",
    688       "\n",
    689       "(kernelshark:11002): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GtkStatusbar'\n",
    690       "\n",
    691       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_statusbar_push: assertion 'GTK_IS_STATUSBAR (statusbar)' failed\n",
    692       "\n",
    693       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_widget_show: assertion 'GTK_IS_WIDGET (widget)' failed\n",
    694       "\n",
    695       "(kernelshark:11002): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GtkStatusbar'\n",
    696       "\n",
    697       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_statusbar_push: assertion 'GTK_IS_STATUSBAR (statusbar)' failed\n",
    698       "\n",
    699       "(kernelshark:11002): Gtk-CRITICAL **: IA__gtk_widget_show: assertion 'GTK_IS_WIDGET (widget)' failed\n"
    700      ]
    701     }
    702    ],
    703    "source": [
    704     "!kernelshark {trace_file} 2>/dev/null"
    705    ]
    706   },
    707   {
    708    "cell_type": "markdown",
    709    "metadata": {},
    710    "source": [
    711     "# Workload composition using RTApp"
    712    ]
    713   },
    714   {
    715    "cell_type": "markdown",
    716    "metadata": {},
    717    "source": [
    718     "## 1) creation"
    719    ]
    720   },
    721   {
    722    "cell_type": "code",
    723    "execution_count": 37,
    724    "metadata": {
    725     "collapsed": false
    726    },
    727    "outputs": [
    728     {
    729      "name": "stderr",
    730      "output_type": "stream",
    731      "text": [
    732       "12:43:40  INFO    :          WlGen - Setup new workload example2\n"
    733      ]
    734     }
    735    ],
    736    "source": [
    737     "# Support to configure and run RTApp based workloads\n",
    738     "from wlgen import RTA\n",
    739     "\n",
    740     "# Create a new RTApp workload generator using the calibration values\n",
    741     "# reported by the TestEnv module\n",
    742     "rtapp_name = 'example2'\n",
    743     "rtapp = RTA(target, rtapp_name, calibration=te.calibration())"
    744    ]
    745   },
    746   {
    747    "cell_type": "markdown",
    748    "metadata": {},
    749    "source": [
    750     "## 2) configuration"
    751    ]
    752   },
    753   {
    754    "cell_type": "code",
    755    "execution_count": 40,
    756    "metadata": {
    757     "collapsed": false
    758    },
    759    "outputs": [
    760     {
    761      "name": "stderr",
    762      "output_type": "stream",
    763      "text": [
    764       "12:44:39  INFO    :          RTApp - Workload duration defined by longest task\n",
    765       "12:44:39  INFO    :          RTApp - Default policy: SCHED_OTHER\n",
    766       "12:44:39  INFO    :          RTApp - ------------------------\n",
    767       "12:44:39  INFO    :          RTApp - task [task_ramp], sched: using default policy\n",
    768       "12:44:39  INFO    :          RTApp -  | calibration CPU: 1\n",
    769       "12:44:39  INFO    :          RTApp -  | loops count: 1\n",
    770       "12:44:39  INFO    :          RTApp -  | CPUs affinity: 1\n",
    771       "12:44:39  INFO    :          RTApp - + phase_000001: duration 1.000000 [s] (100 loops)\n",
    772       "12:44:39  INFO    :          RTApp - |  period    10000 [us], duty_cycle  10 %\n",
    773       "12:44:39  INFO    :          RTApp - |  run_time   1000 [us], sleep_time   9000 [us]\n",
    774       "12:44:39  INFO    :          RTApp - + phase_000002: duration 1.000000 [s] (20 loops)\n",
    775       "12:44:39  INFO    :          RTApp - |  period    50000 [us], duty_cycle  10 %\n",
    776       "12:44:39  INFO    :          RTApp - |  run_time   5000 [us], sleep_time  45000 [us]\n",
    777       "12:44:39  INFO    :          RTApp - + phase_000003: duration 1.000000 [s] (20 loops)\n",
    778       "12:44:39  INFO    :          RTApp - |  period    50000 [us], duty_cycle  30 %\n",
    779       "12:44:39  INFO    :          RTApp - |  run_time  15000 [us], sleep_time  35000 [us]\n",
    780       "12:44:39  INFO    :          RTApp - + phase_000004: duration 1.000000 [s] (20 loops)\n",
    781       "12:44:39  INFO    :          RTApp - |  period    50000 [us], duty_cycle  50 %\n",
    782       "12:44:39  INFO    :          RTApp - |  run_time  25000 [us], sleep_time  25000 [us]\n",
    783       "12:44:39  INFO    :          RTApp - + phase_000005: duration 1.000000 [s] (20 loops)\n",
    784       "12:44:39  INFO    :          RTApp - |  period    50000 [us], duty_cycle  70 %\n",
    785       "12:44:39  INFO    :          RTApp - |  run_time  35000 [us], sleep_time  15000 [us]\n",
    786       "12:44:39  INFO    :          RTApp - + phase_000006: duration 1.000000 [s] (20 loops)\n",
    787       "12:44:39  INFO    :          RTApp - |  period    50000 [us], duty_cycle  90 %\n",
    788       "12:44:39  INFO    :          RTApp - |  run_time  45000 [us], sleep_time   5000 [us]\n",
    789       "12:44:39  INFO    :          RTApp - + phase_000007: duration 0.100000 [s] (1 loops)\n",
    790       "12:44:39  INFO    :          RTApp - |  period   100000 [us], duty_cycle  90 %\n",
    791       "12:44:39  INFO    :          RTApp - |  run_time  90000 [us], sleep_time  10000 [us]\n"
    792      ]
    793     }
    794    ],
    795    "source": [
    796     "# RTApp configurator for generation of PERIODIC tasks\n",
    797     "from wlgen import Periodic, Ramp\n",
    798     "\n",
    799     "# Light workload\n",
    800     "light  = Periodic(duty_cycle_pct=10, duration_s=1.0, period_ms= 10,\n",
    801     "              cpus=str(target.bl.bigs_online[0]))\n",
    802     "# Ramp workload\n",
    803     "ramp   = Ramp(start_pct=10, end_pct=90, delta_pct=20, time_s=1, period_ms=50)\n",
    804     "# Heavy workload\n",
    805     "heavy  = Periodic(duty_cycle_pct=90, duration_s=0.1, period_ms=100)\n",
    806     "\n",
    807     "# Composed workload\n",
    808     "lrh_task = light + ramp + heavy\n",
    809     "\n",
    810     "# Configure this RTApp instance to:\n",
    811     "rtapp.conf(\n",
    812     "\n",
    813     "    # 1. generate a \"profile based\" set of tasks\n",
    814     "    kind = 'profile',\n",
    815     "    \n",
    816     "    # 2. define the \"profile\" of each task\n",
    817     "    params = {\n",
    818     "        \n",
    819     "        # 3. PERIODIC task with\n",
    820     "        'task_ramp': lrh_task.get() \n",
    821     "\n",
    822     "    },\n",
    823     "    \n",
    824     ");"
    825    ]
    826   },
    827   {
    828    "cell_type": "code",
    829    "execution_count": 41,
    830    "metadata": {
    831     "collapsed": false
    832    },
    833    "outputs": [
    834     {
    835      "name": "stderr",
    836      "output_type": "stream",
    837      "text": [
    838       "12:45:34  INFO    : Generated RTApp JSON file:\n"
    839      ]
    840     },
    841     {
    842      "name": "stdout",
    843      "output_type": "stream",
    844      "text": [
    845       "{\n",
    846       "    \"global\": {\n",
    847       "        \"calibration\": 138, \n",
    848       "        \"default_policy\": \"SCHED_OTHER\", \n",
    849       "        \"duration\": -1, \n",
    850       "        \"logdir\": \"/root/devlib-target\"\n",
    851       "    }, \n",
    852       "    \"tasks\": {\n",
    853       "        \"task_ramp\": {\n",
    854       "            \"cpus\": [\n",
    855       "                1\n",
    856       "            ], \n",
    857       "            \"loop\": 1, \n",
    858       "            \"phases\": {\n",
    859       "                \"p000001\": {\n",
    860       "                    \"loop\": 100, \n",
    861       "                    \"run\": 1000, \n",
    862       "                    \"timer\": {\n",
    863       "                        \"period\": 10000, \n",
    864       "                        \"ref\": \"task_ramp\"\n",
    865       "                    }\n",
    866       "                }, \n",
    867       "                \"p000002\": {\n",
    868       "                    \"loop\": 20, \n",
    869       "                    \"run\": 5000, \n",
    870       "                    \"timer\": {\n",
    871       "                        \"period\": 50000, \n",
    872       "                        \"ref\": \"task_ramp\"\n",
    873       "                    }\n",
    874       "                }, \n",
    875       "                \"p000003\": {\n",
    876       "                    \"loop\": 20, \n",
    877       "                    \"run\": 15000, \n",
    878       "                    \"timer\": {\n",
    879       "                        \"period\": 50000, \n",
    880       "                        \"ref\": \"task_ramp\"\n",
    881       "                    }\n",
    882       "                }, \n",
    883       "                \"p000004\": {\n",
    884       "                    \"loop\": 20, \n",
    885       "                    \"run\": 25000, \n",
    886       "                    \"timer\": {\n",
    887       "                        \"period\": 50000, \n",
    888       "                        \"ref\": \"task_ramp\"\n",
    889       "                    }\n",
    890       "                }, \n",
    891       "                \"p000005\": {\n",
    892       "                    \"loop\": 20, \n",
    893       "                    \"run\": 35000, \n",
    894       "                    \"timer\": {\n",
    895       "                        \"period\": 50000, \n",
    896       "                        \"ref\": \"task_ramp\"\n",
    897       "                    }\n",
    898       "                }, \n",
    899       "                \"p000006\": {\n",
    900       "                    \"loop\": 20, \n",
    901       "                    \"run\": 45000, \n",
    902       "                    \"timer\": {\n",
    903       "                        \"period\": 50000, \n",
    904       "                        \"ref\": \"task_ramp\"\n",
    905       "                    }\n",
    906       "                }, \n",
    907       "                \"p000007\": {\n",
    908       "                    \"loop\": 1, \n",
    909       "                    \"run\": 90000, \n",
    910       "                    \"timer\": {\n",
    911       "                        \"period\": 100000, \n",
    912       "                        \"ref\": \"task_ramp\"\n",
    913       "                    }\n",
    914       "                }\n",
    915       "            }, \n",
    916       "            \"policy\": \"SCHED_OTHER\"\n",
    917       "        }\n",
    918       "    }\n",
    919       "}\n"
    920      ]
    921     }
    922    ],
    923    "source": [
    924     "# Inspect the JSON file used to run the application\n",
    925     "with open('./{}_00.json'.format(rtapp_name), 'r') as fh:\n",
    926     "    rtapp_json = json.load(fh)\n",
    927     "logging.info('Generated RTApp JSON file:')\n",
    928     "print json.dumps(rtapp_json, indent=4, sort_keys=True)"
    929    ]
    930   },
    931   {
    932    "cell_type": "markdown",
    933    "metadata": {},
    934    "source": [
    935     "## 3) execution"
    936    ]
    937   },
    938   {
    939    "cell_type": "code",
    940    "execution_count": 42,
    941    "metadata": {
    942     "collapsed": false
    943    },
    944    "outputs": [
    945     {
    946      "name": "stderr",
    947      "output_type": "stream",
    948      "text": [
    949       "12:48:02  INFO    : # Create results folder for this execution\n",
    950       "12:48:02  INFO    : # Setup FTrace\n",
    951       "12:48:06  INFO    : ## Start energy sampling\n",
    952       "12:48:07  INFO    : ### Start RTApp execution\n",
    953       "12:48:07  INFO    :          WlGen - Workload execution START:\n",
    954       "12:48:07  INFO    :          WlGen -    /root/devlib-target/bin/rt-app /root/devlib-target/example2_00.json\n",
    955       "12:48:14  INFO    : ## Read energy consumption: /home/derkling/Code/lisa/results/WlgenExample/example2/energy.json\n",
    956       "12:48:16  INFO    :   EnergyReport - Energy [             a53]: 1.495969\n",
    957       "12:48:16  INFO    :   EnergyReport - Energy [             a57]: 25.145680\n",
    958       "12:48:16  INFO    : # Stop FTrace\n",
    959       "12:48:17  INFO    : # Save FTrace: /home/derkling/Code/lisa/results/WlgenExample/example2/trace.dat\n",
    960       "12:48:19  INFO    : # Save platform description: /home/derkling/Code/lisa/results/WlgenExample/example2/platform.json\n",
    961       "12:48:19  INFO    : # Report collected data:\n",
    962       "12:48:19  INFO    :    /home/derkling/Code/lisa/results/WlgenExample/example2\n"
    963      ]
    964     },
    965     {
    966      "name": "stdout",
    967      "output_type": "stream",
    968      "text": [
    969       "total 4124\r\n",
    970       "drwxrwxr-x 2 derkling derkling    4096 Mar  2 12:48 .\r\n",
    971       "drwxrwxr-x 4 derkling derkling    4096 Mar  2 12:48 ..\r\n",
    972       "-rw-rw-r-- 1 derkling derkling      53 Mar  2 12:48 energy.json\r\n",
    973       "-rw-r--r-- 1 derkling derkling    2121 Mar  2 12:48 example2_00.json\r\n",
    974       "-rw-rw-r-- 1 derkling derkling     235 Mar  2 12:48 output.log\r\n",
    975       "-rw-rw-r-- 1 derkling derkling    1075 Mar  2 12:48 platform.json\r\n",
    976       "-rw-r--r-- 1 derkling derkling   25084 Mar  2 12:48 rt-app-task_ramp-0.log\r\n",
    977       "-rw-r--r-- 1 derkling derkling 4169728 Mar  2 12:48 trace.dat\r\n"
    978      ]
    979     }
    980    ],
    981    "source": [
    982     "res_dir = os.path.join(te.res_dir, rtapp_name)\n",
    983     "nrg_report, plt, plt_file, trace_file = execute(te, rtapp, res_dir)"
    984    ]
    985   },
    986   {
    987    "cell_type": "markdown",
    988    "metadata": {},
    989    "source": [
    990     "## 4) trace inspection"
    991    ]
    992   },
    993   {
    994    "cell_type": "code",
    995    "execution_count": 48,
    996    "metadata": {
    997     "collapsed": false
    998    },
    999    "outputs": [
   1000     {
   1001      "name": "stdout",
   1002      "output_type": "stream",
   1003      "text": [
   1004       "version = 6\r\n"
   1005      ]
   1006     }
   1007    ],
   1008    "source": [
   1009     "!kernelshark {trace_file} 2>/dev/null"
   1010    ]
   1011   },
   1012   {
   1013    "cell_type": "markdown",
   1014    "metadata": {},
   1015    "source": [
   1016     "# Custom RTApp connfiguration"
   1017    ]
   1018   },
   1019   {
   1020    "cell_type": "code",
   1021    "execution_count": 51,
   1022    "metadata": {
   1023     "collapsed": false
   1024    },
   1025    "outputs": [
   1026     {
   1027      "name": "stderr",
   1028      "output_type": "stream",
   1029      "text": [
   1030       "12:55:36  INFO    :          WlGen - Setup new workload example3\n"
   1031      ]
   1032     }
   1033    ],
   1034    "source": [
   1035     "# Support to configure and run RTApp based workloads\n",
   1036     "from wlgen import RTA\n",
   1037     "\n",
   1038     "# Create a new RTApp workload generator using the calibration values\n",
   1039     "# reported by the TestEnv module\n",
   1040     "rtapp_name = 'example3'\n",
   1041     "rtapp = RTA(target, rtapp_name, calibration=te.calibration())\n",
   1042     "\n",
   1043     "# Configure this RTApp to use a custom JSON\n",
   1044     "rtapp.conf(\n",
   1045     "\n",
   1046     "    # 1. generate a \"custom\" set of tasks\n",
   1047     "    kind = 'custom',\n",
   1048     "    \n",
   1049     "    # 2. define the \"profile\" of each task\n",
   1050     "    params = \"../../assets/mp3-short.json\",\n",
   1051     "    \n",
   1052     "    # In this case only few values of the orignal JSON can be tuned:\n",
   1053     "    #    DURATION : maximum duration of the workload [s]\n",
   1054     "    #    PVALUE   : calibration value\n",
   1055     "    #    LOGDIR   : folder used for generated logs\n",
   1056     "    #    WORKDIR  : working directory on target\n",
   1057     "    \n",
   1058     "    # 3. defined a maximum duration for that workload\n",
   1059     "    duration = 5,\n",
   1060     "    \n",
   1061     ");"
   1062    ]
   1063   },
   1064   {
   1065    "cell_type": "code",
   1066    "execution_count": 52,
   1067    "metadata": {
   1068     "collapsed": false
   1069    },
   1070    "outputs": [
   1071     {
   1072      "name": "stderr",
   1073      "output_type": "stream",
   1074      "text": [
   1075       "12:55:53  INFO    : # Create results folder for this execution\n",
   1076       "12:55:53  INFO    : # Setup FTrace\n",
   1077       "12:55:57  INFO    : ## Start energy sampling\n",
   1078       "12:55:58  INFO    : ### Start RTApp execution\n",
   1079       "12:55:58  INFO    :          WlGen - Workload execution START:\n",
   1080       "12:55:58  INFO    :          WlGen -    /root/devlib-target/bin/rt-app /root/devlib-target/example3_00.json\n",
   1081       "12:56:03  INFO    : ## Read energy consumption: /home/derkling/Code/lisa/results/WlgenExample/example3/energy.json\n",
   1082       "12:56:04  INFO    :   EnergyReport - Energy [             a53]: 2.481205\n",
   1083       "12:56:04  INFO    :   EnergyReport - Energy [             a57]: 8.981533\n",
   1084       "12:56:04  INFO    : # Stop FTrace\n",
   1085       "12:56:05  INFO    : # Save FTrace: /home/derkling/Code/lisa/results/WlgenExample/example3/trace.dat\n",
   1086       "12:56:07  INFO    : # Save platform description: /home/derkling/Code/lisa/results/WlgenExample/example3/platform.json\n",
   1087       "12:56:07  INFO    : # Report collected data:\n",
   1088       "12:56:07  INFO    :    /home/derkling/Code/lisa/results/WlgenExample/example3\n"
   1089      ]
   1090     },
   1091     {
   1092      "name": "stdout",
   1093      "output_type": "stream",
   1094      "text": [
   1095       "total 5048\r\n",
   1096       "drwxrwxr-x 2 derkling derkling    4096 Mar  2 12:56 .\r\n",
   1097       "drwxrwxr-x 5 derkling derkling    4096 Mar  2 12:55 ..\r\n",
   1098       "-rw-rw-r-- 1 derkling derkling      52 Mar  2 12:56 energy.json\r\n",
   1099       "-rw-r--r-- 1 derkling derkling    1324 Mar  2 12:56 example3_00.json\r\n",
   1100       "-rw-rw-r-- 1 derkling derkling     807 Mar  2 12:56 output.log\r\n",
   1101       "-rw-rw-r-- 1 derkling derkling    1075 Mar  2 12:56 platform.json\r\n",
   1102       "-rw-r--r-- 1 derkling derkling 5144576 Mar  2 12:56 trace.dat\r\n"
   1103      ]
   1104     }
   1105    ],
   1106    "source": [
   1107     "res_dir = os.path.join(te.res_dir, rtapp_name)\n",
   1108     "nrg_report, plt, plt_file, trace_file = execute(te, rtapp, res_dir)"
   1109    ]
   1110   },
   1111   {
   1112    "cell_type": "code",
   1113    "execution_count": 53,
   1114    "metadata": {
   1115     "collapsed": false
   1116    },
   1117    "outputs": [
   1118     {
   1119      "name": "stderr",
   1120      "output_type": "stream",
   1121      "text": [
   1122       "12:56:21  INFO    : Generated RTApp JSON file:\n"
   1123      ]
   1124     },
   1125     {
   1126      "name": "stdout",
   1127      "output_type": "stream",
   1128      "text": [
   1129       "{\n",
   1130       "    \"global\": {\n",
   1131       "        \"calibration\": 138, \n",
   1132       "        \"default_policy\": \"SCHED_OTHER\", \n",
   1133       "        \"duration\": 5, \n",
   1134       "        \"frag\": 1, \n",
   1135       "        \"ftrace\": false, \n",
   1136       "        \"gnuplot\": false, \n",
   1137       "        \"lock_pages\": true, \n",
   1138       "        \"log_basename\": \"mp3\", \n",
   1139       "        \"logdir\": \"/root/devlib-target\"\n",
   1140       "    }, \n",
   1141       "    \"tasks\": {\n",
   1142       "        \"AudioOut\": {\n",
   1143       "            \"loop\": -1, \n",
   1144       "            \"priority\": -19, \n",
   1145       "            \"resume\": \"AudioTrack\", \n",
   1146       "            \"run\": 4725, \n",
   1147       "            \"suspend\": \"AudioOut\"\n",
   1148       "        }, \n",
   1149       "        \"AudioTick\": {\n",
   1150       "            \"cpus\": [\n",
   1151       "                0\n",
   1152       "            ], \n",
   1153       "            \"loop\": -1, \n",
   1154       "            \"phases\": {\n",
   1155       "                \"p1\": {\n",
   1156       "                    \"loop\": 1, \n",
   1157       "                    \"resume\": \"AudioOut\", \n",
   1158       "                    \"timer\": {\n",
   1159       "                        \"period\": 6000, \n",
   1160       "                        \"ref\": \"tick\"\n",
   1161       "                    }\n",
   1162       "                }, \n",
   1163       "                \"p2\": {\n",
   1164       "                    \"loop\": 4, \n",
   1165       "                    \"timer\": {\n",
   1166       "                        \"period\": 6000, \n",
   1167       "                        \"ref\": \"tick\"\n",
   1168       "                    }\n",
   1169       "                }\n",
   1170       "            }, \n",
   1171       "            \"priority\": -19\n",
   1172       "        }, \n",
   1173       "        \"AudioTrack\": {\n",
   1174       "            \"loop\": -1, \n",
   1175       "            \"priority\": -16, \n",
   1176       "            \"resume\": \"mp3.decoder\", \n",
   1177       "            \"run\": 300, \n",
   1178       "            \"suspend\": \"AudioTrack\"\n",
   1179       "        }, \n",
   1180       "        \"OMXCall\": {\n",
   1181       "            \"lock\": \"mutex\", \n",
   1182       "            \"loop\": -1, \n",
   1183       "            \"priority\": -2, \n",
   1184       "            \"run\": 300, \n",
   1185       "            \"signal\": \"queue\", \n",
   1186       "            \"unlock\": \"mutex\", \n",
   1187       "            \"wait\": {\n",
   1188       "                \"mutex\": \"mutex\", \n",
   1189       "                \"ref\": \"queue\"\n",
   1190       "            }\n",
   1191       "        }, \n",
   1192       "        \"mp3.decoder\": {\n",
   1193       "            \"lock\": \"mutex\", \n",
   1194       "            \"loop\": -1, \n",
   1195       "            \"priority\": -2, \n",
   1196       "            \"run\": 150, \n",
   1197       "            \"signal\": \"queue\", \n",
   1198       "            \"suspend\": \"mp3.decoder\", \n",
   1199       "            \"unlock\": \"mutex\", \n",
   1200       "            \"wait\": {\n",
   1201       "                \"mutex\": \"mutex\", \n",
   1202       "                \"ref\": \"queue\"\n",
   1203       "            }\n",
   1204       "        }\n",
   1205       "    }\n",
   1206       "}\n"
   1207      ]
   1208     }
   1209    ],
   1210    "source": [
   1211     "# Inspect the JSON file used to run the application\n",
   1212     "with open('./{}_00.json'.format(rtapp_name), 'r') as fh:\n",
   1213     "    rtapp_json = json.load(fh)\n",
   1214     "logging.info('Generated RTApp JSON file:')\n",
   1215     "print json.dumps(rtapp_json, indent=4, sort_keys=True)"
   1216    ]
   1217   },
   1218   {
   1219    "cell_type": "markdown",
   1220    "metadata": {},
   1221    "source": [
   1222     "# Running Hackbench"
   1223    ]
   1224   },
   1225   {
   1226    "cell_type": "markdown",
   1227    "metadata": {},
   1228    "source": [
   1229     "## 1) creation and configuration"
   1230    ]
   1231   },
   1232   {
   1233    "cell_type": "code",
   1234    "execution_count": 72,
   1235    "metadata": {
   1236     "collapsed": false
   1237    },
   1238    "outputs": [
   1239     {
   1240      "name": "stderr",
   1241      "output_type": "stream",
   1242      "text": [
   1243       "01:08:28  INFO    :          WlGen - Setup new workload hackbench\n"
   1244      ]
   1245     },
   1246     {
   1247      "data": {
   1248       "text/plain": [
   1249        "'hackbench_00'"
   1250       ]
   1251      },
   1252      "execution_count": 72,
   1253      "metadata": {},
   1254      "output_type": "execute_result"
   1255     }
   1256    ],
   1257    "source": [
   1258     "# Support to configure and run RTApp based workloads\n",
   1259     "from wlgen import PerfMessaging\n",
   1260     "\n",
   1261     "# Create a \"perf bench sched messages\" (i.e. hackbench) workload\n",
   1262     "perf_name = 'hackbench'\n",
   1263     "perf = PerfMessaging(target, perf_name)\n",
   1264     "\n",
   1265     "perf.conf(group=1, loop=100, pipe=True, thread=True)\n"
   1266    ]
   1267   },
   1268   {
   1269    "cell_type": "markdown",
   1270    "metadata": {},
   1271    "source": [
   1272     "## 2) execution"
   1273    ]
   1274   },
   1275   {
   1276    "cell_type": "code",
   1277    "execution_count": 73,
   1278    "metadata": {
   1279     "collapsed": false
   1280    },
   1281    "outputs": [
   1282     {
   1283      "name": "stderr",
   1284      "output_type": "stream",
   1285      "text": [
   1286       "01:08:29  INFO    : # Create results folder for this execution\n"
   1287      ]
   1288     },
   1289     {
   1290      "name": "stdout",
   1291      "output_type": "stream",
   1292      "text": [
   1293       "mkdir: cannot create directory /home/derkling/Code/lisa/results/WlgenExample/hackbench: File exists\r\n"
   1294      ]
   1295     },
   1296     {
   1297      "name": "stderr",
   1298      "output_type": "stream",
   1299      "text": [
   1300       "01:08:29  INFO    : # Setup FTrace\n",
   1301       "01:08:31  INFO    : ## Start energy sampling\n",
   1302       "01:08:31  INFO    : ### Start RTApp execution\n",
   1303       "01:08:31  INFO    :          WlGen - Workload execution START:\n",
   1304       "01:08:31  INFO    :          WlGen -    /root/devlib-target/bin/perf bench sched messaging --pipe --thread --group 1 --loop 100\n",
   1305       "01:08:32  INFO    :      PerfBench - Completion time: 0.126000, Performance 7.936508\n",
   1306       "01:08:32  INFO    : ## Read energy consumption: /home/derkling/Code/lisa/results/WlgenExample/hackbench/energy.json\n",
   1307       "01:08:33  INFO    :   EnergyReport - Energy [             a53]: 1.066525\n",
   1308       "01:08:33  INFO    :   EnergyReport - Energy [             a57]: 2.245705\n",
   1309       "01:08:33  INFO    : # Stop FTrace\n",
   1310       "01:08:34  INFO    : # Save FTrace: /home/derkling/Code/lisa/results/WlgenExample/hackbench/trace.dat\n",
   1311       "01:08:36  INFO    : # Save platform description: /home/derkling/Code/lisa/results/WlgenExample/hackbench/platform.json\n",
   1312       "01:08:36  INFO    : # Report collected data:\n",
   1313       "01:08:36  INFO    :    /home/derkling/Code/lisa/results/WlgenExample/hackbench\n"
   1314      ]
   1315     },
   1316     {
   1317      "name": "stdout",
   1318      "output_type": "stream",
   1319      "text": [
   1320       "total 10396\r\n",
   1321       "drwxrwxr-x 2 derkling derkling     4096 Mar  2 13:08 .\r\n",
   1322       "drwxrwxr-x 6 derkling derkling     4096 Mar  2 13:08 ..\r\n",
   1323       "-rw-rw-r-- 1 derkling derkling       52 Mar  2 13:08 energy.json\r\n",
   1324       "-rw-rw-r-- 1 derkling derkling      147 Mar  2 13:08 output.log\r\n",
   1325       "-rw-rw-r-- 1 derkling derkling       61 Mar  2 13:08 performance.json\r\n",
   1326       "-rw-rw-r-- 1 derkling derkling     1075 Mar  2 13:08 platform.json\r\n",
   1327       "-rw-r--r-- 1 derkling derkling 10620928 Mar  2 13:08 trace.dat\r\n"
   1328      ]
   1329     }
   1330    ],
   1331    "source": [
   1332     "res_dir = os.path.join(te.res_dir, perf_name)\n",
   1333     "nrg_report, plt, plt_file, trace_file = execute(te, perf, res_dir)"
   1334    ]
   1335   },
   1336   {
   1337    "cell_type": "markdown",
   1338    "metadata": {},
   1339    "source": [
   1340     "## 3) explore the performance report"
   1341    ]
   1342   },
   1343   {
   1344    "cell_type": "code",
   1345    "execution_count": 76,
   1346    "metadata": {
   1347     "collapsed": false
   1348    },
   1349    "outputs": [
   1350     {
   1351      "name": "stderr",
   1352      "output_type": "stream",
   1353      "text": [
   1354       "01:10:40  INFO    : Generated performance JSON file:\n"
   1355      ]
   1356     },
   1357     {
   1358      "name": "stdout",
   1359      "output_type": "stream",
   1360      "text": [
   1361       "{\n",
   1362       "    \"ctime\": 0.126, \n",
   1363       "    \"performance\": 7.936507936507937\n",
   1364       "}\n"
   1365      ]
   1366     }
   1367    ],
   1368    "source": [
   1369     "# Inspect the generated performance report\n",
   1370     "perf_file = os.path.join(te.res_dir, perf_name, 'performance.json')\n",
   1371     "with open(perf_file, 'r') as fh:\n",
   1372     "    perf_json = json.load(fh)\n",
   1373     "logging.info('Generated performance JSON file:')\n",
   1374     "print json.dumps(perf_json, indent=4, sort_keys=True)"
   1375    ]
   1376   },
   1377   {
   1378    "cell_type": "markdown",
   1379    "metadata": {},
   1380    "source": [
   1381     "## 4) trace inspection "
   1382    ]
   1383   },
   1384   {
   1385    "cell_type": "code",
   1386    "execution_count": 77,
   1387    "metadata": {
   1388     "collapsed": false
   1389    },
   1390    "outputs": [
   1391     {
   1392      "name": "stdout",
   1393      "output_type": "stream",
   1394      "text": [
   1395       "version = 6\r\n"
   1396      ]
   1397     }
   1398    ],
   1399    "source": [
   1400     "!kernelshark {trace_file} 2>/dev/null"
   1401    ]
   1402   }
   1403  ],
   1404  "metadata": {
   1405   "celltoolbar": "Raw Cell Format",
   1406   "kernelspec": {
   1407    "display_name": "Python 2",
   1408    "language": "python",
   1409    "name": "python2"
   1410   },
   1411   "language_info": {
   1412    "codemirror_mode": {
   1413     "name": "ipython",
   1414     "version": 2
   1415    },
   1416    "file_extension": ".py",
   1417    "mimetype": "text/x-python",
   1418    "name": "python",
   1419    "nbconvert_exporter": "python",
   1420    "pygments_lexer": "ipython2",
   1421    "version": "2.7.9"
   1422   }
   1423  },
   1424  "nbformat": 4,
   1425  "nbformat_minor": 0
   1426 }
   1427