FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-taskflow/benchmark/graph_traversal/taskflow.cpp at master · navono/cpp-taskflow · GitHub
navono
cpp-taskflow
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpp-taskflow
/
benchmark
/
graph_traversal
/
taskflow.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
52 lines (40 loc) · 1.24 KB
Breadcrumbs
cpp-taskflow
/
benchmark
/
graph_traversal
/
taskflow.cpp
Copy path
File metadata and controls
52 lines (40 loc) · 1.24 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
#
include
<
iostream
>
#
include
<
chrono
>
#
include
<
taskflow/taskflow.hpp
>
#
include
"
levelgraph.hpp
"
struct
TF
{
TF
(LevelGraph& graph) {
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] = tf.
silent_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] = tf.
silent_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
run
() {
tf.
wait_for_all
();
}
tf::Taskflow tf;
std::vector<std::vector<tf::Task>> tasks;
};
void
traverse_level_graph_taskflow
(LevelGraph& graph){
TF
tf
(graph);
tf.
run
();
}
std::chrono::microseconds
measure_time_taskflow
(LevelGraph& graph){
auto
beg =
std::chrono::high_resolution_clock::now
();
traverse_level_graph_taskflow
(graph);
auto
end =
std::chrono::high_resolution_clock::now
();
return
std::chrono::duration_cast<std::chrono::microseconds>(end - beg);
}
Back
|
FazBrowse Home
|
New Git URL