-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbench.cpp
More file actions
104 lines (84 loc) · 3.07 KB
/
bench.cpp
File metadata and controls
104 lines (84 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#define BENCHPRESS_CONFIG_MAIN
#include "benchpress/benchpress.hpp"
#include "matrix.h"
#include <chrono>
#include <iostream>
#include <vector>
using namespace std;
Matrix mul(bool transpose, int num_threads) {
Matrix A(32, 32, 10);
Matrix B(32, 32, 100);
return A.multiply(B, transpose, num_threads);
}
BENCHMARK("Multiply without transpose. 1 thread", [](benchpress::context* ctx) {
for (size_t i = 0; i < ctx->num_iterations(); ++i)
mul(false, 1);
});
BENCHMARK("Multiply with transpose. 1 thread", [](benchpress::context* ctx) {
for (size_t i = 0; i < ctx->num_iterations(); ++i)
mul(true, 1);
});
BENCHMARK("Multiply without transpose. 2 threads", [](benchpress::context* ctx) {
for (size_t i = 0; i < ctx->num_iterations(); ++i)
mul(false, 2);
});
BENCHMARK("Multiply with transpose. 2 threads", [](benchpress::context* ctx) {
for (size_t i = 0; i < ctx->num_iterations(); ++i)
mul(true, 2);
});
BENCHMARK("Multiply without transpose. 3 threads", [](benchpress::context* ctx) {
for (size_t i = 0; i < ctx->num_iterations(); ++i)
mul(false, 3);
});
BENCHMARK("Multiply with transpose. 3 threads", [](benchpress::context* ctx) {
for (size_t i = 0; i < ctx->num_iterations(); ++i)
mul(true, 3);
});
BENCHMARK("Multiply without transpose. 4 threads", [](benchpress::context* ctx) {
for (size_t i = 0; i < ctx->num_iterations(); ++i)
mul(false, 4);
});
BENCHMARK("Multiply with transpose. 4 threads", [](benchpress::context* ctx) {
for (size_t i = 0; i < ctx->num_iterations(); ++i)
mul(true, 4);
});
BENCHMARK("Multiply without transpose. 5 threads", [](benchpress::context* ctx) {
for (size_t i = 0; i < ctx->num_iterations(); ++i)
mul(false, 5);
});
BENCHMARK("Multiply with transpose. 5 threads", [](benchpress::context* ctx) {
for (size_t i = 0; i < ctx->num_iterations(); ++i)
mul(true, 5);
});
BENCHMARK("Multiply without transpose. 8 threads", [](benchpress::context* ctx) {
for (size_t i = 0; i < ctx->num_iterations(); ++i)
mul(false, 8);
});
BENCHMARK("Multiply with transpose. 8 threads", [](benchpress::context* ctx) {
for (size_t i = 0; i < ctx->num_iterations(); ++i)
mul(true, 8);
});
BENCHMARK("Multiply without transpose. 10 threads", [](benchpress::context* ctx) {
for (size_t i = 0; i < ctx->num_iterations(); ++i)
mul(false, 10);
});
BENCHMARK("Multiply with transpose. 10 threads", [](benchpress::context* ctx) {
for (size_t i = 0; i < ctx->num_iterations(); ++i)
mul(true, 10);
});
BENCHMARK("Multiply without transpose. 15 threads", [](benchpress::context* ctx) {
for (size_t i = 0; i < ctx->num_iterations(); ++i)
mul(false, 15);
});
BENCHMARK("Multiply with transpose. 15 threads", [](benchpress::context* ctx) {
for (size_t i = 0; i < ctx->num_iterations(); ++i)
mul(true, 15);
});
BENCHMARK("Multiply without transpose. 20 threads", [](benchpress::context* ctx) {
for (size_t i = 0; i < ctx->num_iterations(); ++i)
mul(false, 20);
});
BENCHMARK("Multiply with transpose. 20 threads", [](benchpress::context* ctx) {
for (size_t i = 0; i < ctx->num_iterations(); ++i)
mul(true, 20);
});