FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-taskflow/sandbox/jacobi/taskflow.cpp at master · busySZl/cpp-taskflow · GitHub
busySZl
cpp-taskflow
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpp-taskflow
/
sandbox
/
jacobi
/
taskflow.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
54 lines (48 loc) · 1.35 KB
Breadcrumbs
cpp-taskflow
/
sandbox
/
jacobi
/
taskflow.cpp
Copy path
File metadata and controls
54 lines (48 loc) · 1.35 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
#
include
"
poisson.hpp
"
#
include
<
taskflow/taskflow.hpp
>
#
include
<
vector
>
/*
#pragma omp task depend version of SWEEP.
*/
void
taskflow
(
int
nx,
int
ny,
double
dx,
double
dy,
double
*f_,
int
itold,
int
itnew,
double
*u_,
double
*unew_,
int
block_size,
unsigned
num_threads)
{
int
i;
double
* f = f_;
double
* u = u_;
double
* unew = unew_;
tf::Taskflow flow;
std::vector<tf::Task> tasks;
for
(i=
0
; i<nx; i++) {
tasks.
emplace_back
(flow.
emplace
(
[&, i]() {
for
(
int
j =
0
; j < ny; j++) {
u[i*ny + j] = unew[i*ny + j];
}
}
));
}
for
(i=
0
; i<nx; i++) {
auto
t = flow.
emplace
(
[&, i]() {
for
(
int
j =
0
; j < ny; j++) {
if
(i ==
0
|| j ==
0
|| i == nx -
1
|| j == ny -
1
) {
unew[i*ny + j] = f[i*ny + j];
}
else
{
unew[i*ny + j] =
0.25
* (u[(i-
1
)*ny + j] + u[i* ny + j +
1
] +
u[(i)*ny + j-
1
] + u[(i+
1
)* ny + j] +
f[i*ny + j] * dx * dy);
}
}
}
);
tasks[i].
precede
(t);
if
(i >
0
) {
tasks[i-
1
].
precede
(t);
}
if
(i < nx-
1
) {
tasks[i+
1
].
precede
(t);
}
}
tf::Executor executor {num_threads};
executor.
run_n
(flow, itnew).
wait
();
}
Back
|
FazBrowse Home
|
New Git URL