summaryrefslogtreecommitdiff
path: root/scripts/benchmark
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2017-04-01 14:00:46 +0200
committerCedric Nugteren <web@cedricnugteren.nl>2017-04-01 14:00:46 +0200
commit1ee71fdc8067377d9dad27d8cdae1cec9f0fb475 (patch)
tree0a64065e030abf9582c6f04043c4d5ffd6ed6808 /scripts/benchmark
parentfa5c4b00b713afec0a564e203c6fd1984b12eca2 (diff)
Tuned the plots for a tight-layout for in papers and presentations
Diffstat (limited to 'scripts/benchmark')
-rw-r--r--scripts/benchmark/plot.py117
-rw-r--r--scripts/benchmark/settings.py88
2 files changed, 121 insertions, 84 deletions
diff --git a/scripts/benchmark/plot.py b/scripts/benchmark/plot.py
index dc4800fe..bc9529a6 100644
--- a/scripts/benchmark/plot.py
+++ b/scripts/benchmark/plot.py
@@ -6,9 +6,37 @@
import utils
+from matplotlib import rcParams
import matplotlib.pyplot as plt
+# Tight plot (for in a paper or presentation) or regular (for display on a screen)
+TIGHT_PLOT = False
+if TIGHT_PLOT:
+ PLOT_SIZE = 5
+ W_SPACE = 0.20
+ H_SPACE = 0.39
+ TITLE_FROM_TOP = 0.11
+ LEGEND_FROM_TOP = 0.17
+ LEGEND_FROM_TOP_PER_ITEM = 0.04
+ X_LABEL_FROM_BOTTOM = 0.09
+ LEGEND_SPACING = 0.0
+ FONT_SIZE = 15
+ FONT_SIZE_LEGEND = 13
+ FONT_SIZE_TITLE = FONT_SIZE
+else:
+ PLOT_SIZE = 8
+ W_SPACE = 0.15
+ H_SPACE = 0.22
+ TITLE_FROM_TOP = 0.09
+ LEGEND_FROM_TOP = 0.10
+ LEGEND_FROM_TOP_PER_ITEM = 0.07
+ X_LABEL_FROM_BOTTOM = 0.06
+ LEGEND_SPACING = 0.8
+ FONT_SIZE = 15
+ FONT_SIZE_LEGEND = FONT_SIZE
+ FONT_SIZE_TITLE = 18
+# Colors
BLUEISH = [c / 255.0 for c in [71, 101, 177]] # #4765b1
REDISH = [c / 255.0 for c in [214, 117, 104]] # #d67568
PURPLISH = [c / 255.0 for c in [85, 0, 119]] # #550077
@@ -28,48 +56,59 @@ def plot_graphs(results, file_name, num_rows, num_cols,
assert len(y_labels) == len(results)
# Initializes the plot
- size_x = 6 * num_cols
- size_y = 6 * num_rows
+ size_x = PLOT_SIZE * num_cols
+ size_y = PLOT_SIZE * num_rows
fig, axes = plt.subplots(nrows=num_rows, ncols=num_cols, figsize=(size_x, size_y), facecolor='w', edgecolor='k')
- fig.text(.5, .93, title, horizontalalignment="center", fontsize=18)
+ fig.text(.5, 0.92, title, horizontalalignment="center", fontsize=FONT_SIZE_TITLE)
+ plt.subplots_adjust(wspace=W_SPACE, hspace=H_SPACE)
+ rcParams.update({'font.size': FONT_SIZE})
# Loops over each subplot
- for index, result in enumerate(results):
- ax = axes.flat[index]
- plt.sca(ax)
- print("[plot] Plotting subplot %d" % index)
-
- # Sets the x-axis labels
- x_list = [[r[x_key] for r in result] for x_key in x_keys[index]]
- x_ticks = [",".join([utils.float_to_kilo_mega(v) for v in values]) for values in zip(*x_list)]
- x_location = range(len(x_ticks))
-
- # Sets the y-data
- y_list = [[r[y_key] for r in result] for y_key in y_keys[index]]
- y_max = max([max(y) for y in y_list])
-
- # Sets the axes
- y_rounding = 10 if y_max < 80 else 50 if y_max < 400 else 200
- y_axis_limit = (y_max * 1.2) - ((y_max * 1.2) % y_rounding) + y_rounding
- plt.ylim(ymin=0, ymax=y_axis_limit)
- plt.xticks(x_location, x_ticks, rotation='vertical')
-
- # Sets the labels
- ax.set_title(titles[index], fontsize=14, y=0.93)
- ax.set_ylabel(y_labels[index], fontsize=14)
- ax.set_xlabel(x_labels[index], fontsize=14)
- ax.xaxis.set_label_coords(0.5, 0.06)
-
- # Plots the graph
- assert len(COLORS) >= len(y_keys[index])
- assert len(MARKERS) >= len(y_keys[index])
- assert len(label_names) == len(y_keys[index])
- for i in range(len(y_keys[index])):
- ax.plot(x_location, y_list[i], MARKERS[i], label=label_names[i], color=COLORS[i])
-
- # Sets the legend
- leg = ax.legend(loc=(0.02, 0.88 - 0.05 * len(y_keys[index])))
- leg.draw_frame(False)
+ for row in range(num_rows):
+ for col in range(num_cols):
+ index = row * num_cols + col
+ result = results[index]
+ ax = axes.flat[index]
+ plt.sca(ax)
+ print("[plot] Plotting subplot %d" % index)
+
+ # Sets the x-axis labels
+ x_list = [[r[x_key] for r in result] for x_key in x_keys[index]]
+ x_ticks = [",".join([utils.float_to_kilo_mega(v) for v in values]) for values in zip(*x_list)]
+ x_location = range(len(x_ticks))
+
+ # Optional sparsifying of the labels on the x-axis
+ if TIGHT_PLOT and len(x_location) > 10:
+ x_ticks = [v if not (i % 2) else "" for i, v in enumerate(x_ticks)]
+
+ # Sets the y-data
+ y_list = [[r[y_key] for r in result] for y_key in y_keys[index]]
+ y_max = max([max(y) for y in y_list])
+
+ # Sets the axes
+ y_rounding = 10 if y_max < 80 else 50 if y_max < 400 else 200
+ y_axis_limit = (y_max * 1.2) - ((y_max * 1.2) % y_rounding) + y_rounding
+ plt.ylim(ymin=0, ymax=y_axis_limit)
+ plt.xticks(x_location, x_ticks, rotation='vertical')
+
+ # Sets the labels
+ ax.set_title(titles[index], y=1.0 - TITLE_FROM_TOP)
+ if col == 0 or y_labels[index] != y_labels[index - 1]:
+ ax.set_ylabel(y_labels[index])
+ ax.set_xlabel(x_labels[index])
+ ax.xaxis.set_label_coords(0.5, X_LABEL_FROM_BOTTOM)
+
+ # Plots the graph
+ assert len(COLORS) >= len(y_keys[index])
+ assert len(MARKERS) >= len(y_keys[index])
+ assert len(label_names) == len(y_keys[index])
+ for i in range(len(y_keys[index])):
+ ax.plot(x_location, y_list[i], MARKERS[i], label=label_names[i], color=COLORS[i])
+
+ # Sets the legend
+ leg = ax.legend(loc=(0.02, 1.0 - LEGEND_FROM_TOP - LEGEND_FROM_TOP_PER_ITEM * len(y_keys[index])),
+ handletextpad=0.1, labelspacing=LEGEND_SPACING, fontsize=FONT_SIZE_LEGEND)
+ leg.draw_frame(False)
# Saves the plot to disk
fig.savefig(file_name, bbox_inches='tight')
diff --git a/scripts/benchmark/settings.py b/scripts/benchmark/settings.py
index 0243832f..cc7220e1 100644
--- a/scripts/benchmark/settings.py
+++ b/scripts/benchmark/settings.py
@@ -16,35 +16,35 @@ AXPY = {
{
"name": "axpy",
"title": "multiples of 256K",
- "x_label": "vector sizes (n)", "x_keys": ["n"],
+ "x_label": "sizes (n)", "x_keys": ["n"],
"y_label": "GB/s (higher is better)", "y_keys": ["GBs_1", "GBs_2"],
"arguments": [{"n": utils.k(256), "incx": 1, "incy": 1, "step": utils.k(256), "num_steps": 16}],
},
{
"name": "axpy",
"title": "multiples of 256K+1",
- "x_label": "vector sizes (n)", "x_keys": ["n"],
+ "x_label": "sizes (n)", "x_keys": ["n"],
"y_label": "GB/s (higher is better)", "y_keys": ["GBs_1", "GBs_2"],
"arguments": [{"n": utils.k(256) + 1, "incx": 1, "incy": 1, "step": utils.k(256) + 1, "num_steps": 16}],
},
{
"name": "axpy",
- "title": "around n=1M",
- "x_label": "vector sizes (n)", "x_keys": ["n"],
+ "title": "around 1M",
+ "x_label": "sizes (n)", "x_keys": ["n"],
"y_label": "GB/s (higher is better)", "y_keys": ["GBs_1", "GBs_2"],
"arguments": [{"n": utils.m(1), "incx": 1, "incy": 1, "step": 1, "num_steps": 16}],
},
{
"name": "axpy",
- "title": "around n=16M",
- "x_label": "vector sizes (n)", "x_keys": ["n"],
+ "title": "around 16M",
+ "x_label": "sizes (n)", "x_keys": ["n"],
"y_label": "GB/s (higher is better)", "y_keys": ["GBs_1", "GBs_2"],
"arguments": [{"n": utils.m(16), "incx": 1, "incy": 1, "step": 1, "num_steps": 16}],
},
{
"name": "axpy",
- "title": "strides (n=8M)",
- "x_label": "increments/strides for x,y", "x_keys": ["incx", "incy"],
+ "title": "strides n=8M",
+ "x_label": "increments for x,y", "x_keys": ["incx", "incy"],
"y_label": "GB/s (higher is better)", "y_keys": ["GBs_1", "GBs_2"],
"arguments": [{"n": utils.m(8), "incx": inc_x, "incy": inc_y, "step": 0, "num_steps": 1}
for inc_x in [1, 2, 4] for inc_y in [1, 2, 4]],
@@ -52,7 +52,7 @@ AXPY = {
{
"name": "axpy",
"title": "powers of 2",
- "x_label": "vector sizes (n)", "x_keys": ["n"],
+ "x_label": "sizes (n)", "x_keys": ["n"],
"y_label": "GB/s (higher is better)", "y_keys": ["GBs_1", "GBs_2"],
"arguments": [{"n": n, "incx": 1, "incy": 1, "step": 0, "num_steps": 1}
for n in utils.powers_of_2(utils.k(32), utils.m(64))],
@@ -67,41 +67,41 @@ GEMV = {
{
"name": "gemv",
"title": "multiples of 256",
- "x_label": "matrix/vector sizes (n=m)", "x_keys": ["n"],
+ "x_label": "sizes (n=m)", "x_keys": ["n"],
"y_label": "GB/s (higher is better)", "y_keys": ["GBs_1", "GBs_2"],
"arguments": [{"n": 256, "m": 256, "incx": 1, "incy": 1, "layout": 102, "step": 256, "num_steps": 20}],
},
{
"name": "gemv",
"title": "multiples of 257",
- "x_label": "matrix/vector sizes (n=m)", "x_keys": ["n"],
+ "x_label": "sizes (n=m)", "x_keys": ["n"],
"y_label": "GB/s (higher is better)", "y_keys": ["GBs_1", "GBs_2"],
"arguments": [{"n": 257, "m": 257, "incx": 1, "incy": 1, "layout": 102, "step": 257, "num_steps": 20}],
},
{
"name": "gemv",
- "title": "around n=m=4K",
- "x_label": "matrix/vector sizes (n=m)", "x_keys": ["n"],
+ "title": "around 4K",
+ "x_label": "sizes (n=m)", "x_keys": ["n"],
"y_label": "GB/s (higher is better)", "y_keys": ["GBs_1", "GBs_2"],
"arguments": [{"n": 4096, "m": 4096, "incx": 1, "incy": 1, "layout": 102, "step": 1, "num_steps": 16}],
},
{
"name": "gemv",
"title": "multiples of 256 rotated",
- "x_label": "matrix/vector sizes (n=m)", "x_keys": ["n"],
+ "x_label": "sizes (n=m)", "x_keys": ["n"],
"y_label": "GB/s (higher is better)", "y_keys": ["GBs_1", "GBs_2"],
"arguments": [{"n": 256, "m": 256, "incx": 1, "incy": 1, "layout": 101, "step": 256, "num_steps": 20}],
},
{
"name": "gemv",
"title": "multiples of 257 rotated",
- "x_label": "matrix/vector sizes (n=m)", "x_keys": ["n"],
+ "x_label": "sizes (n=m)", "x_keys": ["n"],
"y_label": "GB/s (higher is better)", "y_keys": ["GBs_1", "GBs_2"],
"arguments": [{"n": 257, "m": 257, "incx": 1, "incy": 1, "layout": 101, "step": 257, "num_steps": 20}],
},
{
"name": "gemv",
- "title": "strides (n=m=4K)",
+ "title": "strides n=m=4K",
"x_label": "increments/strides for x,y", "x_keys": ["incx", "incy"],
"y_label": "GB/s (higher is better)", "y_keys": ["GBs_1", "GBs_2"],
"arguments": [{"n": 4096, "m": 4096, "incx": inc_x, "incy": inc_y, "layout": 102, "step": 0, "num_steps": 1}
@@ -117,7 +117,7 @@ GEMM = {
{
"name": "gemm",
"title": "multiples of 128",
- "x_label": "matrix sizes (m=n=k)", "x_keys": ["m"],
+ "x_label": "sizes (m=n=k)", "x_keys": ["m"],
"y_label": "GFLOPS (higher is better)", "y_keys": ["GFLOPS_1", "GFLOPS_2"],
"arguments": [{"m": 128, "n": 128, "k": 128, "layout": 102,
"transA": 111, "transB": 111, "step": 128, "num_steps": 20}],
@@ -125,30 +125,30 @@ GEMM = {
{
"name": "gemm",
"title": "multiples of 129",
- "x_label": "matrix sizes (m=n=k)", "x_keys": ["m"],
+ "x_label": "sizes (m=n=k)", "x_keys": ["m"],
"y_label": "GFLOPS (higher is better)", "y_keys": ["GFLOPS_1", "GFLOPS_2"],
"arguments": [{"m": 129, "n": 129, "k": 129, "layout": 102,
"transA": 111, "transB": 111, "step": 129, "num_steps": 20}],
},
{
"name": "gemm",
- "title": "around m=n=k=512",
- "x_label": "matrix sizes (m=n=k)", "x_keys": ["m"],
+ "title": "around 512",
+ "x_label": "sizes (m=n=k)", "x_keys": ["m"],
"y_label": "GFLOPS (higher is better)", "y_keys": ["GFLOPS_1", "GFLOPS_2"],
"arguments": [{"m": 512, "n": 512, "k": 512, "layout": 102,
"transA": 111, "transB": 111, "step": 1, "num_steps": 16}],
},
{
"name": "gemm",
- "title": "around m=n=k=2048",
- "x_label": "matrix sizes (m=n=k)", "x_keys": ["m"],
+ "title": "around 2048",
+ "x_label": "sizes (m=n=k)", "x_keys": ["m"],
"y_label": "GFLOPS (higher is better)", "y_keys": ["GFLOPS_1", "GFLOPS_2"],
"arguments": [{"m": 2048, "n": 2048, "k": 2048, "layout": 102,
"transA": 111, "transB": 111, "step": 1, "num_steps": 16}],
},
{
"name": "gemm",
- "title": "layouts/transposing (m=n=k=1K)",
+ "title": "layouts/transpose",
"x_label": "layout, transA, transB", "x_keys": ["layout", "transA", "transB"],
"y_label": "GFLOPS (higher is better)", "y_keys": ["GFLOPS_1", "GFLOPS_2"],
"arguments": [{"m": 1024, "n": 1024, "k": 1024, "layout": layout,
@@ -158,7 +158,7 @@ GEMM = {
{
"name": "gemm",
"title": "powers of 2",
- "x_label": "matrix sizes (m=n=k)", "x_keys": ["m"],
+ "x_label": "sizes (m=n=k)", "x_keys": ["m"],
"y_label": "GFLOPS (higher is better)", "y_keys": ["GFLOPS_1", "GFLOPS_2"],
"arguments": [{"m": n, "n": n, "k": n, "layout": 102,
"transA": 111, "transB": 111, "step": 0, "num_steps": 1}
@@ -174,7 +174,7 @@ GEMM_SMALL = {
{
"name": "gemm",
"title": "small matrices in steps of 16",
- "x_label": "matrix sizes (m=n=k)", "x_keys": ["m"],
+ "x_label": "sizes (m=n=k)", "x_keys": ["m"],
"y_label": "GFLOPS (higher is better)", "y_keys": ["GFLOPS_1", "GFLOPS_2"],
"arguments": [{"m": 128, "n": 128, "k": 128, "layout": 102,
"transA": 111, "transB": 111, "step": 16, "num_steps": 57}],
@@ -182,7 +182,7 @@ GEMM_SMALL = {
{
"name": "gemm",
"title": "small matrices in steps of 1",
- "x_label": "matrix sizes (m=n=k)", "x_keys": ["m"],
+ "x_label": "sizes (m=n=k)", "x_keys": ["m"],
"y_label": "GFLOPS (higher is better)", "y_keys": ["GFLOPS_1", "GFLOPS_2"],
"arguments": [{"m": 128, "n": 128, "k": 128, "layout": 102,
"transA": 111, "transB": 111, "step": 1, "num_steps": 385}],
@@ -198,7 +198,7 @@ SYMM = {
{
"name": "symm",
"title": "multiples of 128",
- "x_label": "matrix sizes (m=n)", "x_keys": ["m"],
+ "x_label": "sizes (m=n)", "x_keys": ["m"],
"y_label": "GFLOPS (higher is better)", "y_keys": ["GFLOPS_1", "GFLOPS_2"],
"arguments": [{"m": 128, "n": 128, "layout": 102,
"side": 141, "triangle": 121, "step": 128, "num_steps": 20}],
@@ -206,30 +206,30 @@ SYMM = {
{
"name": "symm",
"title": "multiples of 129",
- "x_label": "matrix sizes (m=n)", "x_keys": ["m"],
+ "x_label": "sizes (m=n)", "x_keys": ["m"],
"y_label": "GFLOPS (higher is better)", "y_keys": ["GFLOPS_1", "GFLOPS_2"],
"arguments": [{"m": 129, "n": 129, "layout": 102,
"side": 141, "triangle": 121, "step": 129, "num_steps": 20}],
},
{
"name": "symm",
- "title": "around m=n=512",
- "x_label": "matrix sizes (m=n)", "x_keys": ["m"],
+ "title": "around 512",
+ "x_label": "sizes (m=n)", "x_keys": ["m"],
"y_label": "GFLOPS (higher is better)", "y_keys": ["GFLOPS_1", "GFLOPS_2"],
"arguments": [{"m": 512, "n": 512, "layout": 102,
"side": 141, "triangle": 121, "step": 1, "num_steps": 16}],
},
{
"name": "symm",
- "title": "around m=n=2048",
- "x_label": "matrix sizes (m=n)", "x_keys": ["m"],
+ "title": "around 2048",
+ "x_label": "sizes (m=n)", "x_keys": ["m"],
"y_label": "GFLOPS (higher is better)", "y_keys": ["GFLOPS_1", "GFLOPS_2"],
"arguments": [{"m": 2048, "n": 2048, "layout": 102,
"side": 141, "triangle": 121, "step": 1, "num_steps": 16}],
},
{
"name": "symm",
- "title": "layouts/sides/triangles (m=n=1K)",
+ "title": "layouts/sides/triangles",
"x_label": "layout, side, triangle", "x_keys": ["layout", "side", "triangle"],
"y_label": "GFLOPS (higher is better)", "y_keys": ["GFLOPS_1", "GFLOPS_2"],
"arguments": [{"m": 1024, "n": 1024, "layout": layout,
@@ -239,7 +239,7 @@ SYMM = {
{
"name": "symm",
"title": "powers of 2",
- "x_label": "matrix sizes (m=n)", "x_keys": ["m"],
+ "x_label": "sizes (m=n)", "x_keys": ["m"],
"y_label": "GFLOPS (higher is better)", "y_keys": ["GFLOPS_1", "GFLOPS_2"],
"arguments": [{"m": n, "n": n, "layout": 102,
"side": 141, "triangle": 121, "step": 0, "num_steps": 1}
@@ -255,7 +255,7 @@ SYRK = {
{
"name": "syrk",
"title": "multiples of 128",
- "x_label": "matrix sizes (n=k)", "x_keys": ["n"],
+ "x_label": "sizes (n=k)", "x_keys": ["n"],
"y_label": "GFLOPS (higher is better)", "y_keys": ["GFLOPS_1", "GFLOPS_2"],
"arguments": [{"n": 128, "k": 128, "layout": 102,
"side": 141, "triangle": 121, "step": 128, "num_steps": 20}],
@@ -263,30 +263,30 @@ SYRK = {
{
"name": "syrk",
"title": "multiples of 129",
- "x_label": "matrix sizes (n=k)", "x_keys": ["n"],
+ "x_label": "sizes (n=k)", "x_keys": ["n"],
"y_label": "GFLOPS (higher is better)", "y_keys": ["GFLOPS_1", "GFLOPS_2"],
"arguments": [{"n": 129, "k": 129, "layout": 102,
"side": 141, "triangle": 121, "step": 129, "num_steps": 20}],
},
{
"name": "syrk",
- "title": "around n=k=512",
- "x_label": "matrix sizes (n=k)", "x_keys": ["n"],
+ "title": "around 512",
+ "x_label": "sizes (n=k)", "x_keys": ["n"],
"y_label": "GFLOPS (higher is better)", "y_keys": ["GFLOPS_1", "GFLOPS_2"],
"arguments": [{"n": 512, "k": 512, "layout": 102,
"side": 141, "triangle": 121, "step": 1, "num_steps": 16}],
},
{
"name": "syrk",
- "title": "around n=k=2048",
- "x_label": "matrix sizes (n=k)", "x_keys": ["n"],
+ "title": "around 2048",
+ "x_label": "sizes (n=k)", "x_keys": ["n"],
"y_label": "GFLOPS (higher is better)", "y_keys": ["GFLOPS_1", "GFLOPS_2"],
"arguments": [{"n": 2048, "k": 2048, "layout": 102,
"side": 141, "triangle": 121, "step": 1, "num_steps": 16}],
},
{
"name": "syrk",
- "title": "layouts/sides/triangles (n=k=1K)",
+ "title": "layouts/sides/triangles",
"x_label": "layout, triangle, transA", "x_keys": ["layout", "triangle", "transA"],
"y_label": "GFLOPS (higher is better)", "y_keys": ["GFLOPS_1", "GFLOPS_2"],
"arguments": [{"n": 1024, "k": 1024, "layout": layout,
@@ -296,7 +296,7 @@ SYRK = {
{
"name": "syrk",
"title": "powers of 2",
- "x_label": "matrix sizes (n=k)", "x_keys": ["n"],
+ "x_label": "sizes (n=k)", "x_keys": ["n"],
"y_label": "GFLOPS (higher is better)", "y_keys": ["GFLOPS_1", "GFLOPS_2"],
"arguments": [{"n": n, "k": n, "layout": 102,
"side": 141, "triangle": 121, "step": 0, "num_steps": 1}
@@ -307,7 +307,7 @@ SYRK = {
SUMMARY = {
"label_names": ["CLBlast", "clBLAS"],
- "num_rows": 4, "num_cols": 2,
+ "num_rows": 3, "num_cols": 2,
"benchmarks": [
AXPY["benchmarks"][0],
AXPY["benchmarks"][1],
@@ -315,7 +315,5 @@ SUMMARY = {
GEMV["benchmarks"][1],
GEMM["benchmarks"][0],
GEMM["benchmarks"][1],
- SYMM["benchmarks"][0],
- SYMM["benchmarks"][1],
]
}