FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
taskflow/benchmarks/linear_chain/tbb.cpp at master · code-in-cpp/taskflow · GitHub
code-in-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
taskflow
/
benchmarks
/
linear_chain
/
tbb.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
48 lines (37 loc) · 1.04 KB
Breadcrumbs
taskflow
/
benchmarks
/
linear_chain
/
tbb.cpp
Copy path
File metadata and controls
48 lines (37 loc) · 1.04 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
#
include
"
linear_chain.hpp
"
#
include
<
tbb/task_scheduler_init.h
>
#
include
<
tbb/flow_graph.h
>
//
linear_chain_tbb
void
linear_chain_tbb
(
size_t
length,
unsigned
num_threads) {
using
namespace
tbb
;
using
namespace
tbb
::flow
;
size_t
counter =
0
;
tbb::task_scheduler_init
init
(num_threads);
graph g;
std::vector<continue_node<continue_msg>*>
tasks
(length);
for
(
size_t
i=
0
; i<tasks.
size
(); i++) {
tasks[i] =
new
continue_node<continue_msg>(g,
[&](
const
continue_msg& ) {
counter++;
}
);
if
(i) {
make_edge
(*tasks[i-
1
], *tasks[i]);
}
}
tasks[
0
]->
try_put
(
continue_msg
());
g.
wait_for_all
();
for
(
auto
& task : tasks) {
delete
task;
}
assert
(counter == tasks.
size
());
}
std::chrono::microseconds
measure_time_tbb
(
size_t
length,
unsigned
num_threads
) {
auto
beg =
std::chrono::high_resolution_clock::now
();
linear_chain_tbb
(length, 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