FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-taskflow/benchmark/parallel_loop/taskflow.cpp at master · cg4115/cpp-taskflow · GitHub
cg4115
/
cpp-taskflow
Public
forked from
taskflow/taskflow
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpp-taskflow
/
benchmark
/
parallel_loop
/
taskflow.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
52 lines (40 loc) · 1.29 KB
Breadcrumbs
cpp-taskflow
/
benchmark
/
parallel_loop
/
taskflow.cpp
Copy path
File metadata and controls
52 lines (40 loc) · 1.29 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
include
"
matrix_multiplication.hpp
"
#
include
<
taskflow/taskflow.hpp
>
//
matrix_multiplication_taskflow
void
matrix_multiplication_taskflow
(
unsigned
num_threads) {
tf::Executor
executor
(num_threads);
tf::Taskflow taskflow;
auto
pa = taskflow.
parallel_for
(
0
, N,
1
, [&] (
int
i) {
for
(
int
j=
0
; j<N; ++j) {
a[i][j] = i + j;
}
}, num_threads);
auto
pb = taskflow.
parallel_for
(
0
, N,
1
, [&] (
int
i) {
for
(
int
j=
0
; j<N; ++j) {
b[i][j] = i * j;
}
}, num_threads);
auto
pc = taskflow.
parallel_for
(
0
, N,
1
, [&] (
int
i) {
for
(
int
j=
0
; j<N; ++j) {
c[i][j] =
0
;;
}
}, num_threads);
auto
pr = taskflow.
parallel_for
(
0
, N,
1
, [&] (
int
i) {
for
(
int
j=
0
; j<N; ++j) {
for
(
int
k=
0
; k<N; k++) {
c[i][j] += a[i][k] * b[k][j];
}
}
}, num_threads);
pa.
second
.
precede
(pr.
first
);
pb.
second
.
precede
(pr.
first
);
pc.
second
.
precede
(pr.
first
);
executor.
run
(taskflow).
get
();
//
std::cout << reduce_sum() << std::endl;
}
std::chrono::microseconds
measure_time_taskflow
(
unsigned
num_threads) {
auto
beg =
std::chrono::high_resolution_clock::now
();
matrix_multiplication_taskflow
(num_threads);
auto
end =
std::chrono::high_resolution_clock::now
();
return
std::chrono::duration_cast<std::chrono::microseconds>(end - beg);
}
Back
|
FazBrowse Home
|
New Git URL