FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
taskflow/examples/sycl/sycl_rebind.cpp at master · ModuleWorks/taskflow · GitHub
ModuleWorks
/
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
taskflow
/
examples
/
sycl
/
sycl_rebind.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
50 lines (33 loc) · 1.07 KB
Breadcrumbs
taskflow
/
examples
/
sycl
/
sycl_rebind.cpp
Copy path
File metadata and controls
50 lines (33 loc) · 1.07 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
//
This program demonstrates how to rebind syclFlow tasks
//
to different device operations.
#
include
<
taskflow/syclflow.hpp
>
int
main
() {
size_t
N =
10000
;
sycl::queue queue;
auto
data = sycl::malloc_shared<
int
>(N, queue);
tf::syclFlow
syclflow
(queue);
//
fill data with -1
std::cout <<
"
filling data with -1 ...
\n
"
;
tf::syclTask task = syclflow.
fill
(data, -
1
, N);
syclflow.
offload
();
for
(
size_t
i=
0
; i<N; i++) {
if
(data[i] != -
1
) {
throw
std::runtime_error
(
"
unexpected result after fill
"
);
}
}
std::cout <<
"
correct result after fill
\n
"
;
//
rebind the task to for-each task setting each element to 100
//
You can rebind a syclTask to any other task type.
std::cout <<
"
rebind task to for_each task setting each element to 100
\n
"
;
syclflow.
for_each
(
task, data, data+N, [](
int
& i){ i =
100
; }
);
syclflow.
offload
();
for
(
size_t
i=
0
; i<N; i++) {
if
(data[i] !=
100
) {
throw
std::runtime_error
(
"
unexpected result after for_each
"
);
}
}
std::cout <<
"
correct result after updating for_each
\n
"
;
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL