FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-taskflow/benchmark/mandelbrot_set/taskflow.cpp at master · cppwanderboy/cpp-taskflow · GitHub
cppwanderboy
/
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
/
mandelbrot_set
/
taskflow.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
61 lines (49 loc) · 1.32 KB
Breadcrumbs
cpp-taskflow
/
benchmark
/
mandelbrot_set
/
taskflow.cpp
Copy path
File metadata and controls
61 lines (49 loc) · 1.32 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
54
55
56
57
58
59
60
#
include
"
mandel.hpp
"
#
include
<
taskflow/taskflow.hpp
>
//
void run_taskflow_parallel_for(int num_threads, int d = D) {
//
//
tf::Taskflow flow;
//
//
flow.parallel_for(0, h, 1, [&](int i){
//
for(int j=0; j<w; j++) {
//
//
auto [xx, yy] = scale_xy(i, j);
//
auto value = escape_time(xx, yy, d);
//
//
auto k = 3 * ( j * w + i );
//
//
auto [r, g, b] = get_color(value);
//
//
rgb[k] = r;
//
rgb[k+1] = g;
//
rgb[k+2] = b;
//
}
//
});
//
//
tf::Executor executor {num_threads};
//
executor.run(flow).wait();
//
}
void
mandelbrot_taskflow
(
unsigned
num_threads,
int
d = D) {
tf::Taskflow flow;
for
(
int
i=
0
; i<H; i++) {
flow.
emplace
([&, i=i](){
for
(
int
j=
0
; j<W; j++) {
auto
[xx, yy] =
scale_xy
(i, j);
auto
value =
escape_time
(xx, yy, d);
auto
k =
3
*(j*W + i);
auto
[r, g, b] =
get_color
(value);
RGB
[k] = r;
RGB
[k+
1
] = g;
RGB
[k+
2
] = b;
}
});
}
tf::Executor executor {num_threads};
executor.
run
(flow).
wait
();
}
std::chrono::microseconds
measure_time_taskflow
(
unsigned
num_threads) {
auto
beg =
std::chrono::high_resolution_clock::now
();
mandelbrot_taskflow
(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