aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux
diff options
context:
space:
mode:
authorCyril SIX <cyril.six@kalray.eu>2019-05-17 16:19:04 +0200
committerCyril SIX <cyril.six@kalray.eu>2019-05-17 16:19:04 +0200
commit9f58c4419596fbab69c8fe25c3d51e66acb613d0 (patch)
treed550d9dd7426b5a90342174e51f6ca8262c7910e /test/monniaux
parent76c41fd907a3f7e7d574da4c075f30656e3ede9f (diff)
downloadcompcert-kvx-9f58c4419596fbab69c8fe25c3d51e66acb613d0.tar.gz
compcert-kvx-9f58c4419596fbab69c8fe25c3d51e66acb613d0.zip
Premier jet de graphes de mesures (à améliorer)
Diffstat (limited to 'test/monniaux')
-rwxr-xr-xtest/monniaux/gengraphs.py89
-rwxr-xr-xtest/monniaux/genmake.py8
-rwxr-xr-xtest/monniaux/run_benches.sh3
-rw-r--r--test/monniaux/too_slow/make.proto1
4 files changed, 97 insertions, 4 deletions
diff --git a/test/monniaux/gengraphs.py b/test/monniaux/gengraphs.py
new file mode 100755
index 00000000..2455c285
--- /dev/null
+++ b/test/monniaux/gengraphs.py
@@ -0,0 +1,89 @@
+#!/usr/bin/python3.6
+
+import numpy as np
+import matplotlib.pyplot as plt
+import pandas as pd
+import sys
+
+##
+# Reading data
+##
+
+if len(sys.argv) != 2:
+ raise Exception("Only 1 argument should be given to this script: the make.proto file")
+csv_file = sys.argv[1]
+
+with open(csv_file, "r") as f:
+ df = pd.read_csv(csv_file)
+
+benches = df["benches"]
+print(benches[0])
+
+host_measures_cols = [col for col in df if "host" in col]
+k1c_measures_cols = [col for col in df if "k1c" in col]
+
+colors = ["forestgreen", "darkorange", "cornflowerblue", "darkorchid", "darksalmon", "dodgerblue", "navy", "gray", "springgreen", "crimson"]
+
+##
+# Generating PDF
+##
+
+def extract_envs(keys):
+ envs = []
+ for key in keys:
+ words = key.split()[:-1]
+ envs.append(" ".join(words))
+ return envs
+
+
+def subdivide_interv(inf, sup, n):
+ return [inf + k*(sup-inf)/n for k in range(n)]
+
+
+def generate_file(f, cols):
+ ind = np.arange(len(df[cols[0]]))
+
+ width = 0.35 # the width of the bars
+
+ envs = extract_envs(cols)
+ start_inds = subdivide_interv(ind, ind+width, len(envs))
+
+ fig, ax = plt.subplots()
+ rects = []
+ for i, env in enumerate(envs):
+ for col in cols:
+ if env in col:
+ break
+ rects.append(ax.bar(start_inds[i], df[col], width, color=colors[i], label=env))
+
+ # Add some text for labels, title and custom x-axis tick labels, etc.
+ ax.set_ylabel('Cycles')
+ ax.set_title('TITLE')
+ ax.set_xticks(ind)
+ ax.set_xticklabels(benches)
+ ax.legend()
+
+ def autolabel(rects, xpos='center'):
+ """
+ Attach a text label above each bar in *rects*, displaying its height.
+
+ *xpos* indicates which side to place the text w.r.t. the center of
+ the bar. It can be one of the following {'center', 'right', 'left'}.
+ """
+
+ xpos = xpos.lower() # normalize the case of the parameter
+ ha = {'center': 'center', 'right': 'left', 'left': 'right'}
+ offset = {'center': 0.5, 'right': 0.57, 'left': 0.43} # x_txt = x + w*off
+
+ for rect in rects:
+ height = rect.get_height()
+ ax.text(rect.get_x() + rect.get_width()*offset[xpos], 1.01*height,
+ '{}'.format(height), ha=ha[xpos], va='bottom')
+
+ for rect in rects:
+ autolabel(rect)
+
+ plt.savefig(f)
+
+generate_file("measures-host.pdf", host_measures_cols)
+#generate_file("measures-k1c.pdf", k1c_measures_cols)
diff --git a/test/monniaux/genmake.py b/test/monniaux/genmake.py
index 30db9ac4..ad460b14 100755
--- a/test/monniaux/genmake.py
+++ b/test/monniaux/genmake.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3.4
+#!/usr/bin/python3.6
""" Custom Makefile generator
@@ -26,7 +26,7 @@ gcc_k1c = Env(compiler = Compiler("gcc", "$(K1C_CC)"), optimizations = [Optim(""
ccomp_x86 = Env(compiler = Compiler("ccomp", "$(CCOMP)"), optimizations = [Optim("", "$(CCOMPFLAGS)")], target = "host")
ccomp_k1c = Env(compiler = Compiler("ccomp", "$(K1C_CCOMP)"), optimizations = [Optim("", "$(K1C_CCOMPFLAGS)")], target = "k1c")
-environments = [gcc_x86, gcc_k1c, ccomp_x86, ccomp_k1c]
+environments = [gcc_x86, ccomp_x86, gcc_k1c, ccomp_k1c]
##
# Argument parsing
@@ -36,7 +36,7 @@ if len(sys.argv) != 2:
yaml_file = sys.argv[1]
with open(yaml_file, "r") as f:
- settings = yaml.load(f.read())
+ settings = yaml.load(f.read(), Loader=yaml.FullLoader)
basename = settings["target"]
objdeps = settings["objdeps"] if "objdeps" in settings else []
@@ -86,7 +86,7 @@ def make_env_list(envs):
def print_measure_rule(environments, measures):
print("measures.csv: $(PRODUCTS_OUT)")
- print(' echo ", {}" > $@'.format(make_env_list(environments)))
+ print(' echo "benches, {}" > $@'.format(make_env_list(environments)))
for measure in measures:
display_measure_name = (len(measures) > 1)
if isinstance(measure, list):
diff --git a/test/monniaux/run_benches.sh b/test/monniaux/run_benches.sh
index 4db4b5a2..479d09eb 100755
--- a/test/monniaux/run_benches.sh
+++ b/test/monniaux/run_benches.sh
@@ -21,3 +21,6 @@ done
nawk 'FNR==1 && NR!=1{next;}{print}' $benches_csv > measures.csv
echo "measures.csv done"
+
+./gengraphs.py measures.csv
+echo "Graphs done"
diff --git a/test/monniaux/too_slow/make.proto b/test/monniaux/too_slow/make.proto
index 0635cdd9..852971fc 100644
--- a/test/monniaux/too_slow/make.proto
+++ b/test/monniaux/too_slow/make.proto
@@ -1,2 +1,3 @@
target: memset_from_bitsliced-aes
measures: [cycles]
+name: memset-aes