Commit 31abcfd4 authored by Ivo Peterek's avatar Ivo Peterek

FIX: cf, uncf, thrds parameter positions loading from measurement info file #13

parent 49969f27
......@@ -3,6 +3,7 @@ import glob
import csv
import sys
from runpy import run_path
from pathlib import Path
import json
import h5py
......@@ -32,8 +33,33 @@ class DataLoad:
self.data = {"plot_summary_data": [], "nested_regions_report_data": [], "config": self.config_dic}
#TODO: Multiple keys
try:
self.default_key = self.config_dic['def_keys_vals'][0]
self.key_unit = self.config_dic['keys_units'][0]
except IndexError:
self.key_unit = ''
self.default_key = ''
self.default_funcLabel_val = str(round(float(self.config_dic['def_label_val'])*self.funcLabel_multiplier, 2))
self.funcLabel_unit = self.config_dic['func_label_unit']
self.default_xLabel_val = self.config_dic['def_x_val']
self.default_xLabel_unit = self.config_dic['x_val_unit']
measurement_info_path = Path(self.data_path + '/measurementInfo.json')
if measurement_info_path.exists():
with open(measurement_info_path) as f:
try:
measurement_info_file_data = json.load(f)
self.measurement_params = measurement_info_file_data['DataFormat'].split("_")
except json.decoder.JSONDecodeError:
self.__print_error_msg('measurementInfo.json file is not in valid format')
print(self.measurement_params)
self.__load_data_from_csv()
#self.__load_data_from_hdf5()
# self.__load_data_from_hdf5()
def __load_data_from_csv(self):
......@@ -51,42 +77,63 @@ class DataLoad:
for i, item in enumerate(self.file_name_args):
if item[0] == 'funcLabel':
funcLabel_pos = i
funcLabel_data = self.measurement_params[i]
if item[0] == 'xLabel':
xLabel_pos = i
if item[0] == 'key':
xLabel_data = self.measurement_params[i]
if item[0] == 'key':#TODO: Multiple keys
key_pos = i
key_data = self.measurement_params[i]
if funcLabel_data == 'CF':
funcLabel_meric_param = 'FREQUENCY'
if funcLabel_data == 'UnCF':
funcLabel_meric_param = 'UNCORE_FREQUENCY'
if funcLabel_data == 'thrds':
funcLabel_meric_param = 'NUM_THREADS'
if xLabel_data == 'CF':
xLabel_meric_param = 'FREQUENCY'
if xLabel_data == 'UnCF':
xLabel_meric_param = 'UNCORE_FREQUENCY'
if xLabel_data == 'thrds':
xLabel_meric_param = 'NUM_THREADS'
if key_data == 'CF':#TODO multiple keys
key_meric_param = 'FREQUENCY'
if key_data == 'UnCF':
key_meric_param = 'UNCORE_FREQUENCY'
if key_data == 'thrds':
key_meric_param = 'NUM_THREADS'
try:
key_unit = self.config_dic['keys_units'][0]
except IndexError:
opt_key_unit = ''
for region in self.regions:
csv_paths = glob.glob(glob.escape(self.data_path) + '/' + glob.escape(region) + '/*.csv')
# KEY = NUM_THREADS only TODO: different keys in future
# KEY = NUM_THREADS only #TODO: different/multiple keys in future
try:
opt_key = self.meric_config_energy_data[region]['NUM_THREADS']
opt_key = self.meric_config_energy_data[region][key_meric_param]
except KeyError:
opt_key = ''
data_region = []
for key, vals in self.y_label.items():
for i, val in enumerate(vals):
data_region.append([{'arg': vals[i][0],
'category': key,
'index': i,
'unit': vals[i][1]},
{'config': (),#ignore this # espreso 3 cfgs example {'config': ('taurusi6587', '8', 'CONFIG'),
{'config': (),#leave this empty, ignore config parameter
'func_label_name': self.file_name_args[funcLabel_pos][1],
'func_label_unit': self.config_dic['func_label_unit'],
'func_label_unit': self.funcLabel_unit,
'heat_data': [],
# list of lists one of lists contains tuples -> (xLabel, value_in_heatmap)
'key': (opt_key+';'+opt_key_unit,), # optimal key from mericConfig
'key': (opt_key+';'+self.key_unit,), # optimal key from mericConfig, TODO: multiple keys
'lines': [], # funcLabel values
'optim_func_label_value': self.meric_config_energy_data[region]['FREQUENCY'], # optim vals
'optim_x_val': self.meric_config_energy_data[region]['UNCORE_FREQUENCY'],
'optim_func_label_value': self.meric_config_energy_data[region][funcLabel_meric_param], # optim vals
'optim_x_val': self.meric_config_energy_data[region][xLabel_meric_param],
'optim_y_val': sys.maxsize,
'x_label_name': self.file_name_args[xLabel_pos][1],
'x_label_unit': self.config_dic['x_val_unit']}])
......@@ -132,11 +179,12 @@ class DataLoad:
for key, value in dict_plot_data_ylabel.items():
for data in data_region:
str_funclabel_val = str(round(float(funclabel_val)*self.funcLabel_multiplier, 2))
if data[0]['arg'] in key and data[0]['category'] in key:
if str(round(float(funclabel_val)*self.funcLabel_multiplier, 2)) not in data[1]['lines']:
data[1]['lines'].append(str(round(float(funclabel_val)*self.funcLabel_multiplier, 2)))
if str_funclabel_val not in data[1]['lines']:
data[1]['lines'].append(str_funclabel_val)
index_of_line = data[1]['lines'].index(str(round(float(funclabel_val)*self.funcLabel_multiplier, 2)))
index_of_line = data[1]['lines'].index(str_funclabel_val)
if len(data[1]['heat_data'])-1 < index_of_line:
data[1]['heat_data'].append([])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment