FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-taskflow/benchmark/wavefront/tbb.cpp at cpp14 · walker2010cs/cpp-taskflow · GitHub
walker2010cs
/
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
/
wavefront
/
tbb.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
55 lines (41 loc) · 1.27 KB
Breadcrumbs
cpp-taskflow
/
benchmark
/
wavefront
/
tbb.cpp
Copy path
File metadata and controls
55 lines (41 loc) · 1.27 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
51
52
53
#
include
"
matrix.hpp
"
#
include
<
tbb/task_scheduler_init.h
>
#
include
<
tbb/flow_graph.h
>
//
the wavefront computation
void
wavefront_tbb
(
unsigned
num_threads) {
using
namespace
tbb
;
using
namespace
tbb
::flow
;
tbb::task_scheduler_init
init
(num_threads);
continue_node<continue_msg> ***node =
new
continue_node<continue_msg> **[
MB
];
for
(
int
i =
0
; i <
MB
; ++i ) {
node[i] =
new
continue_node<continue_msg> *[
NB
];
};
graph g;
matrix[M-
1
][N-
1
] =
0
;
for
(
int
i=
MB
; --i>=
0
; ) {
for
(
int
j=
NB
; --j>=
0
; ) {
node[i][j] =
new
continue_node<continue_msg>( g,
[=](
const
continue_msg& ) {
block_computation
(i, j);
}
);
if
(i+
1
<
MB
)
make_edge
(*node[i][j], *node[i+
1
][j]);
if
(j+
1
<
NB
)
make_edge
(*node[i][j], *node[i][j+
1
]);
}
}
node[
0
][
0
]->
try_put
(
continue_msg
());
g.
wait_for_all
();
for
(
int
i=
0
; i<
MB
; ++i) {
for
(
int
j=
0
; j<
NB
; ++j) {
delete
node[i][j];
}
delete []
node[i];
}
delete []
node;
}
std::chrono::microseconds
measure_time_tbb
(
unsigned
num_threads) {
auto
beg =
std::chrono::high_resolution_clock::now
();
wavefront_tbb
(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