FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-taskflow/benchmark/linear_chain/omp.cpp at cpp14 · walker2010cs/cpp-taskflow · GitHub
walker2010cs
/
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
/
linear_chain
/
omp.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
47 lines (38 loc) · 981 Bytes
Breadcrumbs
cpp-taskflow
/
benchmark
/
linear_chain
/
omp.cpp
Copy path
File metadata and controls
47 lines (38 loc) · 981 Bytes
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
"
linear_chain.hpp
"
#
include
<
omp.h
>
//
linear_chain_omp
void
linear_chain_omp
(
size_t
length,
unsigned
num_threads) {
size_t
counter =
0
;
size_t
*D =
new
size_t
[length];
#
pragma
omp parallel num_threads(num_threads)
{
#
pragma
omp single
{
for
(
size_t
i=
0
; i<length; ++i) {
if
(i==
0
) {
#
pragma
omp task firstprivate(i) depend(out:D[i])
{
++counter;
}
}
else
{
#
pragma
omp task firstprivate(i) depend(out:D[i]) depend(in:D[i-1])
{
++counter;
}
}
}
}
}
assert
(counter == length);
delete []
D;
}
std::chrono::microseconds
measure_time_omp
(
size_t
length,
unsigned
num_threads
) {
auto
beg =
std::chrono::high_resolution_clock::now
();
linear_chain_omp
(length, 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