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 · cppwanderboy/cpp-taskflow · GitHub
cppwanderboy
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
53 lines (41 loc) · 1.39 KB
Breadcrumbs
cpp-taskflow
/
benchmark
/
graph_traversal
/
taskflow.cpp
Copy path
File metadata and controls
53 lines (41 loc) · 1.39 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
#
include
<
iostream
>
#
include
<
chrono
>
#
include
<
taskflow/taskflow.hpp
>
#
include
"
levelgraph.hpp
"
struct
TF
{
TF
(LevelGraph& graph,
unsigned
num_threads) : executor(num_threads) {
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] = taskflow.
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] = taskflow.
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
() {
executor.
run
(taskflow).
get
();
}
tf::Executor executor;
tf::Taskflow taskflow;
std::vector<std::vector<tf::Task>> tasks;
};
void
traverse_level_graph_taskflow
(LevelGraph& graph,
unsigned
num_threads){
TF
tf
(graph, num_threads);
tf.
run
();
}
std::chrono::microseconds
measure_time_taskflow
(LevelGraph& graph,
unsigned
num_threads){
auto
beg =
std::chrono::high_resolution_clock::now
();
traverse_level_graph_taskflow
(graph, 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