summaryrefslogtreecommitdiff
path: root/bin/analyze-config.py
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2021-06-23 15:30:03 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2021-06-23 15:30:03 +0200
commit5e99716ee3c935c4619bd784fdfd02ba4a361f29 (patch)
tree33bd509fb463f91b0a0c4422b668e0901a38ebc3 /bin/analyze-config.py
parentf0a60dfa77f7d73e799ee99546b244bc491242b3 (diff)
analyze-config: Fix a nasty RAM model bug
Diffstat (limited to 'bin/analyze-config.py')
-rwxr-xr-xbin/analyze-config.py32
1 files changed, 25 insertions, 7 deletions
diff --git a/bin/analyze-config.py b/bin/analyze-config.py
index add759c..f96a680 100755
--- a/bin/analyze-config.py
+++ b/bin/analyze-config.py
@@ -116,7 +116,7 @@ def main():
by_name["multipass"]["rom_usage"].append(attr["total"]["ROM"])
by_name["multipass"]["ram_usage"].append(attr["total"]["RAM"])
by_name["multipass"]["param"].append(config_vector)
- data.append((config_vector, attr["total"]["ROM"], attr["total"]["RAM"]))
+ data.append((config_vector, (attr["total"]["ROM"], attr["total"]["RAM"])))
print(
"Processing {:d} unique configurations of {:d} total".format(
@@ -125,14 +125,27 @@ def main():
)
print(
- "std of all data: {:5.0f} Bytes".format(np.std(list(map(lambda x: x[1], data))))
+ "std of all data: {:5.0f} Bytes".format(
+ np.std(list(map(lambda x: x[1][0], data)))
+ )
)
model = AnalyticModel(by_name, params, compute_stats=False)
- def get_min(this_symbols, this_data, data_index=1, threshold=100, level=0):
+ def get_min(this_symbols, this_data, data_index=0, threshold=100, level=0):
+ """
+ Build a Decision Tree on `this_data`.
+
+ :param this_symbols: parameter names
+ :param this_data: list of measurements. Each entry is a (param vector, mearusements vector) tuple.
+ param vector holds parameter values (same order as parameter names). mearuserements vector holds measurements.
+ :param data_index: Index in measurements vector to use for model generation. Default 0.
+ :param threshold: Return a StaticFunction leaf node if std(data[data_index]) < threshold. Default 100.
+
+ :returns: SplitFunction or StaticFunction
+ """
- rom_sizes = list(map(lambda x: x[data_index], this_data))
+ rom_sizes = list(map(lambda x: x[1][data_index], this_data))
if np.std(rom_sizes) < threshold or len(this_symbols) == 0:
return StaticFunction(np.mean(rom_sizes))
@@ -143,6 +156,11 @@ def main():
unique_values = list(set(map(lambda vrr: vrr[0][i], this_data)))
+ if None in unique_values:
+ # param is a choice and undefined in some configs. Do not split on it.
+ mean_stds.append(np.inf)
+ continue
+
child_values = list()
for value in unique_values:
child_values.append(
@@ -156,7 +174,7 @@ def main():
children = list()
for child in child_values:
- children.append(np.std(list(map(lambda x: x[1], child))))
+ children.append(np.std(list(map(lambda x: x[1][data_index], child))))
if np.any(np.isnan(children)):
mean_stds.append(np.inf)
@@ -208,10 +226,10 @@ def main():
)
model.attr_by_name["multipass"]["rom_usage"].model_function = get_min(
- params, data, 1, 100
+ params, data, 0, 100
)
model.attr_by_name["multipass"]["ram_usage"].model_function = get_min(
- params, data, 2, 20
+ params, data, 1, 20
)
with open("kconfigmodel.json", "w") as f: