Skip to content

Commit 03fa822

Browse files
committed
added benchmark plot
1 parent eff8d1e commit 03fa822

5 files changed

Lines changed: 7236 additions & 16 deletions

File tree

benchmarks/benchmarks.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,13 @@ Currently, we provide the following applications:
2727
+ [Matrix Multiplication](./matrix_multiplication): multiplies two matrices
2828
+ [MNIST](./mnist): trains a neural network-based image classfier on the MNIST dataset
2929

30-
We have provided a python wrapper [regression.py](./regression.py) to help
30+
We have provided a python wrapper [benchmarks.py](./benchmarks.py) to help
3131
configure the benchmark of each application,
3232
including thread count, rounds to average, tasking methods, and plot.
3333

3434
```bash
35-
usage: regression.py [-h] -b
36-
{wavefront,graph_traversal,binary_tree,linear_chain,matrix_multiplication,mnist}
37-
[{wavefront,graph_traversal,binary_tree,linear_chain,matrix_multiplication,mnist} ...]
38-
[-m {tf,tbb,omp} [{tf,tbb,omp} ...]] -t THREADS
39-
[THREADS ...] [-r NUM_ROUNDS] [-p PLOT]
35+
~$ chmod 755 benchmarks.py # change the permission to execute
36+
~$ ./benchmarks.py -h # show the help message
4037
```
4138

4239
For example, the following command benchmarks
@@ -47,13 +44,20 @@ with data collected in an average of ten runs.
4744
Results are illustrated in a plot and saved to `result.png`.
4845

4946
```bash
50-
~$ python regression.py -m tf omp tbb \
51-
-b graph_traversal wavefront linear_chain \
52-
-t 1 4 8 16 \
53-
-r 10 \
54-
-plot true
47+
~$ ./benchmarks.py -m tf omp tbb \
48+
-b graph_traversal wavefront linear_chain \
49+
-t 1 4 8 16 \
50+
-r 10 \
51+
-p true \
52+
-o result.png
5553
```
5654

55+
When the program completes, you will see a combined plot of all specified benchmarsk.
56+
The x-axis represents the growth of problem size and the y-axis denotes the runtime
57+
in millisecond.
58+
59+
![](../image/benchmarks.svg)
60+
5761

5862
---
5963

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
import os
33
import subprocess
44
import sys
@@ -97,6 +97,13 @@ def main():
9797
help='show the plot or not',
9898
default=False
9999
)
100+
101+
parser.add_argument(
102+
'-o', '--output',
103+
type=str,
104+
help='file name to save the plot result',
105+
default="result.png"
106+
)
100107

101108
# parse the arguments
102109
args = parser.parse_args()
@@ -132,14 +139,24 @@ def main():
132139
# horizontalalignment='center',
133140
# transform=ax.transAxes
134141
#)
135-
plot.plot(X, Y, label=method)
142+
if method == 'tf':
143+
marker = ''
144+
color = 'b'
145+
elif method == 'omp':
146+
marker = '+'
147+
color = 'g'
148+
else:
149+
marker = '.'
150+
color = 'r'
151+
152+
plot.plot(X, Y, label=method, marker=marker, color=color)
136153
plot.legend()
137154
print(X)
138155
print(Y)
139156
plot_index = plot_index + 1
140157

141158
plot.tight_layout()
142-
plot.savefig('result.png')
159+
plot.savefig(args.output)
143160

144161
if args.plot:
145162
plot.show()

benchmarks/mnist/dnn.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ struct MNIST {
175175
MNIST() {
176176
std::string path = std::experimental::filesystem::current_path();
177177
path = path.substr(0, path.rfind("cpp-taskflow") + 12);
178-
path += "/benchmark/mnist/";
178+
path += "/benchmarks/mnist/";
179179

180180
images = read_mnist_image(path + "./train-images.data");
181181
labels = read_mnist_label(path + "./train-labels.data");

benchmarks/mnist/seq.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "dnn.hpp"
22

3-
void run_sequential(MNIST& D, unsigned num_threads) {
3+
void run_sequential(MNIST& D, unsigned) {
44

55
const auto iter_num = D.images.rows()/D.batch_size;
66

0 commit comments

Comments
 (0)