FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-taskflow/benchmark/framework/taskflow.cpp at master · misback/cpp-taskflow · GitHub
misback
/
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
/
framework
/
taskflow.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
46 lines (37 loc) · 1.4 KB
Breadcrumbs
cpp-taskflow
/
benchmark
/
framework
/
taskflow.cpp
Copy path
File metadata and controls
46 lines (37 loc) · 1.4 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
#
include
<
iostream
>
#
include
<
chrono
>
#
include
<
taskflow/taskflow.hpp
>
#
include
"
levelgraph.hpp
"
void
build_framework
(LevelGraph& graph, tf::Framework& framework) {
std::vector<std::vector<tf::Task>> tasks;
tasks.
resize
(graph.
level
());
for
(
size_t
i=
0
; i<tasks.
size
(); ++i) {
tasks[i].
resize
(graph.
length
());
}
for
(
size_t
i=
0
; i<graph.
length
(); i++){
Node& n = graph.
node_at
(graph.
level
()-
1
, i);
tasks[graph.
level
()-
1
][i] = framework.
emplace
([&](){ n.
mark
(); });
}
for
(
int
l=graph.
level
()-
2
; l>=
0
; l--){
for
(
size_t
i=
0
; i<graph.
length
(); i++){
Node& n = graph.
node_at
(l, i);
tasks[l][i] = framework.
emplace
([&](){ n.
mark
();});
for
(
size_t
k=
0
; k<n.
_out_edges
.
size
(); k++){
tasks[l][i].
precede
(tasks[l+
1
][n.
_out_edges
[k]]);
}
}
}
}
void
traverse_level_graph_taskflow
(LevelGraph& graph,
unsigned
num_threads,
int
repeat){
tf::Taskflow
tf
(num_threads);
tf::Framework framework;
build_framework
(graph, framework);
tf.
run_n
(framework, repeat, [&](){ graph.
clear_graph
(); });
tf.
wait_for_all
();
}
std::chrono::microseconds
measure_time_taskflow
(LevelGraph& graph,
unsigned
num_threads,
int
repeat){
auto
beg =
std::chrono::high_resolution_clock::now
();
traverse_level_graph_taskflow
(graph, num_threads, repeat);
auto
end =
std::chrono::high_resolution_clock::now
();
return
std::chrono::duration_cast<std::chrono::microseconds>(end - beg);
}
Back
|
FazBrowse Home
|
New Git URL