summaryrefslogtreecommitdiff
path: root/lib/data_parameters.py
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2019-05-08 16:30:47 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2019-05-08 16:30:47 +0200
commit62919d668c475a9191ff9cc8c4016a3baee1667c (patch)
treed9f6926dc76b5926ae523beb494356e1b6a045f9 /lib/data_parameters.py
parentc75a3e2034aa73277c5c499423941259cf6fda49 (diff)
add cpu cycles -> cpu energy and packet size -> tx energy for protocolmodeling
Diffstat (limited to 'lib/data_parameters.py')
-rw-r--r--lib/data_parameters.py61
1 files changed, 60 insertions, 1 deletions
diff --git a/lib/data_parameters.py b/lib/data_parameters.py
index 4dde850..ef463bc 100644
--- a/lib/data_parameters.py
+++ b/lib/data_parameters.py
@@ -6,6 +6,7 @@ length of lists, ane more.
"""
from protocol_benchmarks import codegen_for_lib
+import cycles_to_energy, size_to_radio_energy, utils
import numpy as np
import ubjson
@@ -175,7 +176,7 @@ class Protolog:
['text_serdes', 'text_size_serdes', idem],
]
- def __init__(self, logfile):
+ def __init__(self, logfile, cpu_conf = None, cpu_conf_str = None, radio_conf = None, radio_conf_str = None):
"""
Load and enrich raw protobench log data.
@@ -267,6 +268,64 @@ class Protolog:
except KeyError:
pass
+ if cpu_conf_str:
+ cpu_conf = utils.parse_conf_str(cpu_conf_str)
+
+ if cpu_conf:
+ cpu = cycles_to_energy.get_class(cpu_conf['model'])
+ for key, value in cpu.default_params.items():
+ if not key in cpu_conf:
+ cpu_conf[key] = value
+ for key in self.aggregate.keys():
+ for arch in self.aggregate[key].keys():
+ for lib, val in self.aggregate[key][arch].items():
+ try:
+ val['energy_enc'] = int(val['cycles_enc'] * cpu.get_current(cpu_conf) * cpu_conf['voltage'] / cpu_conf['cpu_freq'] * 1e9)
+ except KeyError:
+ pass
+ try:
+ val['energy_ser'] = int(val['cycles_ser'] * cpu.get_current(cpu_conf) * cpu_conf['voltage'] / cpu_conf['cpu_freq'] * 1e9)
+ except KeyError:
+ pass
+ try:
+ val['energy_encser'] = int(val['cycles_encser'] * cpu.get_current(cpu_conf) * cpu_conf['voltage'] / cpu_conf['cpu_freq'] * 1e9)
+ except KeyError:
+ pass
+ try:
+ val['energy_des'] = int(val['cycles_des'] * cpu.get_current(cpu_conf) * cpu_conf['voltage'] / cpu_conf['cpu_freq'] * 1e9)
+ except KeyError:
+ pass
+ try:
+ val['energy_dec'] = int(val['cycles_dec'] * cpu.get_current(cpu_conf) * cpu_conf['voltage'] / cpu_conf['cpu_freq'] * 1e9)
+ except KeyError:
+ pass
+ try:
+ val['energy_desdec'] = int(val['cycles_desdec'] * cpu.get_current(cpu_conf) * cpu_conf['voltage'] / cpu_conf['cpu_freq'] * 1e9)
+ except KeyError:
+ pass
+
+ if radio_conf_str:
+ radio_conf = utils.parse_conf_str(radio_conf_str)
+
+ if radio_conf:
+ radio = size_to_radio_energy.get_class(radio_conf['model'])
+ for key, value in radio.default_params.items():
+ if not key in radio_conf:
+ radio_conf[key] = value
+ for key in self.aggregate.keys():
+ for arch in self.aggregate[key].keys():
+ for lib, val in self.aggregate[key][arch].items():
+ try:
+ radio_conf['txbytes'] = val['serialized_size']
+ if radio_conf['txbytes'] > 0:
+ val['energy_tx'] = int(radio.get_energy(radio_conf) * 1e9)
+ else:
+ val['energy_tx'] = 0
+ val['energy_encsertx'] = val['energy_encser'] + val['energy_tx']
+ except KeyError:
+ pass
+
+
def add_datapoint(self, arch, lib, key, value, aggregate_label, data_label, getter):
"""
Set self.aggregate[key][arch][lib][aggregate_Label] = getter(value[data_label]['v']).