Skip to content
This repository was archived by the owner on Nov 26, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
language: python
python:
- "2.7"
- "2.7.12"
- "3.4.8"
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq libfreetype6-dev
- sudo apt-get install -qq libpng12-dev
- wget http://ftp.us.debian.org/debian/pool/main/t/trace-cmd/trace-cmd_2.4.0-1_amd64.deb
- sudo dpkg -i trace-cmd_2.4.0-1_amd64.deb
install:
- pip install matplotlib
- pip install Cython --install-option="--no-cython-compile"
- pip install pandas
- pip install hypothesis
- pip install ipython[all]
- pip install --upgrade trappy
# IPython 6.0.0 requires Python 3.3. Use an older version so we can keep using
# Python 2.7
- pip install "ipython[all]<6.0.0"
- python ./setup.py install
script: nosetests
virtualenv:
system_site_packages: true
notifications:
email:
recipients:
Expand Down
3 changes: 3 additions & 0 deletions bart/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#

"""Initialization for bart"""
from __future__ import unicode_literals
from __future__ import division
from __future__ import print_function

import bart.sched
import bart.common
Expand Down
4 changes: 4 additions & 0 deletions bart/common/Analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
also intended to have aggregator based functionality. This is not
implemented yet.
"""
from __future__ import unicode_literals
from __future__ import division
from __future__ import print_function

from builtins import object
from trappy.stats.grammar import Parser
import warnings
import numpy as np
Expand Down
4 changes: 4 additions & 0 deletions bart/common/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
#

"""Utility functions for sheye"""
from __future__ import unicode_literals
from __future__ import division
from __future__ import print_function

from past.builtins import basestring
import trappy
import numpy as np

Expand Down
4 changes: 3 additions & 1 deletion bart/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#

"""Initialization for bart.common"""

from __future__ import unicode_literals
from __future__ import division
from __future__ import print_function

from bart.common import Utils
from bart.common import Analyzer
4 changes: 4 additions & 0 deletions bart/common/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@
- :code:`"trappy.event.class:event_column"`

"""
from __future__ import division
from __future__ import unicode_literals
from __future__ import print_function

from builtins import object
from trappy.stats.grammar import Parser
from trappy.stats import StatConf
from bart.common.Utils import area_under_curve, interval_sum
Expand Down
4 changes: 4 additions & 0 deletions bart/sched/SchedAssert.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
The analysis is based on TRAPpy's statistics framework and is potent enough
to aggregate statistics over processor hierarchies.
"""
from __future__ import division
from __future__ import unicode_literals
from __future__ import print_function

from builtins import object
import trappy
import itertools
import math
Expand Down
7 changes: 6 additions & 1 deletion bart/sched/SchedMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,13 @@
assertSiblings(A3, 2, operator.eq)
assertSiblings(A4, 2, operator.eq)
"""
from __future__ import unicode_literals
from __future__ import division
from __future__ import print_function


from builtins import str
from builtins import range
from builtins import object
import sys
import trappy
import numpy as np
Expand Down
23 changes: 15 additions & 8 deletions bart/sched/SchedMultiAssert.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@

"""A library for asserting scheduler scenarios based on the
statistics aggregation framework"""
from __future__ import unicode_literals
from __future__ import division
from __future__ import print_function

from builtins import object
import re
import inspect
import functools
import trappy
from bart.sched import functions as sched_funcs
from bart.sched.SchedAssert import SchedAssert
Expand Down Expand Up @@ -176,21 +181,23 @@ def _populate_pids(self):

return list(set(pids))

def _create_method(self, attr_name):
def _create_method(self, attr, attr_name):
"""A wrapper function to create a dispatch function"""

return lambda *args, **kwargs: self._dispatch(attr_name, *args, **kwargs)
@functools.wraps(attr)
def wrapper(*args, **kwargs):
return self._dispatch(attr_name, *args, **kwargs)

return wrapper

def _populate_methods(self):
"""Populate Methods from SchedAssert"""

for attr_name in dir(SchedAssert):
attr = getattr(SchedAssert, attr_name)

for attr_name, attr in inspect.getmembers(SchedAssert):
valid_method = attr_name.startswith("get") or \
attr_name.startswith("assert")
if inspect.ismethod(attr) and valid_method:
func = self._create_method(attr_name)
if callable(attr) and valid_method:
func = self._create_method(attr, attr_name)
setattr(self, attr_name, func)

def get_task_name(self, pid):
Expand Down Expand Up @@ -253,7 +260,7 @@ def getCPUBusyTime(self, level, node, window=None, percent=False):
"""
residencies = self.getResidency(level, node, window=window)

busy_time = sum(v["residency"] for v in residencies.itervalues())
busy_time = sum(v["residency"] for v in residencies.values())

if percent:
if window:
Expand Down
4 changes: 3 additions & 1 deletion bart/sched/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#

"""Initialization for bart.sched"""

from __future__ import unicode_literals
from __future__ import division
from __future__ import print_function

from bart.sched import SchedAssert
from bart.sched import SchedMultiAssert
Expand Down
9 changes: 6 additions & 3 deletions bart/sched/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@

.. seealso:: :mod:`trappy.stats.Topology.Topology`
"""
from __future__ import division
from __future__ import unicode_literals
from __future__ import print_function

import numpy as np
from trappy.stats.Trigger import Trigger
Expand Down Expand Up @@ -180,7 +183,7 @@ def filter_small_gaps(series):
"""

start = None
for index, value in series.iteritems():
for index, value in series.items():

if value == SCHED_SWITCH_IN:
if start == None:
Expand Down Expand Up @@ -298,7 +301,7 @@ def residency_sum(series, window=None):
running = select_window(org_series.cumsum(), window)
if running.values[0] == TASK_RUNNING and running.values[-1] == TASK_RUNNING:
return window[1] - window[0]
except Exception,e:
except Exception as e:
pass

if len(s_in) != len(s_out):
Expand Down Expand Up @@ -433,7 +436,7 @@ def binary_correlate(series_x, series_y):
agree = len(series_x[series_x == series_y])
disagree = len(series_x[series_x != series_y])

return (agree - disagree) / float(len(series_x))
return (agree - disagree) / len(series_x)

def get_pids_for_process(ftrace, execname, cls=None):
"""Get the PIDs for a given process
Expand Down
34 changes: 19 additions & 15 deletions bart/sched/pelt.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@
behavior. Specifically, the Simulator requires also the PeriodicTask which signal
has to be computed.
"""
from __future__ import unicode_literals
from __future__ import division
from __future__ import print_function

from builtins import range
from builtins import object
import math

from collections import namedtuple as namedtuple
Expand Down Expand Up @@ -143,8 +148,8 @@ def isRunning(self, time_ms):
def __str__(self):
return "PeriodicTask(start: {:.3f} [ms], period: {:.3f} [ms], run: {:.3f} [ms], "\
"duty_cycle: {:.3f} [%], pelt_avg: {:d})"\
.format(self.start_us / 1e3, self.period_us / 1e3,
self.run_us / 1e3, self.duty_cycle_pct,
.format(self.start_us/1e3, self.period_us/1e3,
self.run_us/1e3, self.duty_cycle_pct,
self.pelt_avg)


Expand Down Expand Up @@ -249,7 +254,7 @@ def __init__(self, init_value=0, half_life_ms=32, decay_cap_ms=None):
self.half_life_ms = half_life_ms
self.decay_cap_ms = decay_cap_ms

self._geom_y = pow(0.5, 1. / half_life_ms)
self._geom_y = pow(0.5, 1 / half_life_ms)
self._geom_u = float(self._signal_max) * (1. - self._geom_y)

self.task = None
Expand Down Expand Up @@ -313,7 +318,7 @@ def stableRange(self, task):
raise ValueError("Wrong time for task parameter")

def _to_pelt_samples(time_us):
return float(time_us) / self._sample_us
return time_us / self._sample_us

# Compute max value
max_pelt = (1. - pow(self._geom_y, _to_pelt_samples(task.run_us)))
Expand Down Expand Up @@ -428,8 +433,7 @@ def getSignal(self, task, start_s=0, end_s=10):
pelt_value = self._geomSum(pelt_value, active_us)

# Append PELT sample
sample = (_us_to_s(t_us), t_us /
self._sample_us, running, pelt_value)
sample = (_us_to_s(t_us), t_us/self._sample_us, running, pelt_value)
samples.append(sample)

# Prepare for next sample computation
Expand Down Expand Up @@ -537,7 +541,7 @@ def estimateInitialPeltValue(cls, first_val, first_event_time_s,

:returns: int - Estimated value of PELT signal when the task starts
"""
geom_y = pow(0.5, 1. / half_life_ms)
geom_y = pow(0.5, 1/half_life_ms)
geom_u = float(cls._signal_max) * (1. - geom_y)

# Compute period of time between when the task started and when the
Expand All @@ -549,7 +553,7 @@ def estimateInitialPeltValue(cls, first_val, first_event_time_s,
'happens before the task starts')
# Compute number of times the simulated PELT would be updated in this
# period of time
updates_since_start = int(time_since_start / (cls._sample_us / 1e6))
updates_since_start = int(time_since_start/(cls._sample_us/1e6))
pelt_val = first_val
for i in range(updates_since_start):
pelt_val = (pelt_val - geom_u) / geom_y
Expand Down Expand Up @@ -588,8 +592,8 @@ def _s_to_us(time_s, interval_us=1e3, nearest_up=True):
:type nearest_up: bool
"""
if nearest_up:
return interval_us * int(math.ceil((1e6 * time_s) / interval_us))
return interval_us * int(math.floor((1e6 * time_s) / interval_us))
return interval_us * int(math.ceil((1e6 * time_s)/interval_us))
return interval_us * int(math.floor((1e6 * time_s)/interval_us))


def _ms_to_us(time_ms, interval_us=1e3, nearest_up=True):
Expand Down Expand Up @@ -619,23 +623,23 @@ def _ms_to_us(time_ms, interval_us=1e3, nearest_up=True):
:type nearest_up: bool
"""
if nearest_up:
return interval_us * int(math.ceil((1e3 * time_ms) / interval_us))
return interval_us * int(math.floor((1e3 * time_ms) / interval_us))
return interval_us * int(math.ceil((1e3 * time_ms)/interval_us))
return interval_us * int(math.floor((1e3 * time_ms)/interval_us))


def _us_to_s(time_us):
"""Convert [us] into (float) [s]
"""
return (float(time_us) / 1e6)
return time_us/1e6


def _us_to_ms(time_us):
"""Convert [us] into (float) [ms]
"""
return (float(time_us) / 1e3)
return time_us/1e3


def _ms_to_s(time_ms):
"""Convert [ms] into (float) [s]
"""
return (float(time_ms) / 1e3)
return time_ms/1e3
6 changes: 5 additions & 1 deletion bart/thermal/ThermalAssert.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
"""A thermal specific library to assert certain thermal
behaviours
"""
from __future__ import unicode_literals
from __future__ import division
from __future__ import print_function

from builtins import object
from bart.common import Utils
from bart.common.Analyzer import Analyzer
import numpy as np
Expand Down Expand Up @@ -78,7 +82,7 @@ def getThermalResidency(self, temp_range, window, percent=False):

if percent:
result[pivot] = (
result[pivot] * 100.0) / self._ftrace.get_duration()
(result[pivot] * 100.0)/self._ftrace.get_duration())

return result

Expand Down
4 changes: 3 additions & 1 deletion bart/thermal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#

"""Initialization for bart.thermal"""

from __future__ import unicode_literals
from __future__ import division
from __future__ import print_function

import bart.thermal.ThermalAssert
3 changes: 3 additions & 0 deletions docs/api_reference/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#
# All configuration values have a default; values that are commented out
# serve to show the default.
from __future__ import unicode_literals
from __future__ import division
from __future__ import print_function

import sys
import os
Expand Down
4 changes: 4 additions & 0 deletions docs/examples/thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"""
An example file for usage of Analyzer for thermal assertions
"""
from __future__ import unicode_literals
from __future__ import division
from __future__ import print_function

from bart.common.Analyzer import Analyzer
from trappy.stats.Topology import Topology
import unittest
Expand Down
Loading