File tree Expand file tree Collapse file tree 8 files changed +151
-31
lines changed Expand file tree Collapse file tree 8 files changed +151
-31
lines changed Original file line number Diff line number Diff line change 1
1
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2
- #include < CL/sycl.hpp>
3
2
#include < iostream>
3
+ #include < sycl/sycl.hpp>
4
4
5
5
#include < sycl/ext/oneapi/experimental/graph.hpp>
6
6
@@ -83,16 +83,12 @@ int main() {
83
83
// Using shortcut for executing a graph of commands
84
84
q.ext_oneapi_graph (executable_graph).wait ();
85
85
86
- if (*dotp != host_gold_result ()) {
87
- std::cout << " Error unexpected result!\n " ;
88
- }
86
+ assert (*dotp == host_gold_result ());
89
87
90
88
sycl::free (dotp, q);
91
89
sycl::free (x, q);
92
90
sycl::free (y, q);
93
91
sycl::free (z, q);
94
92
95
- std::cout << " done.\n " ;
96
-
97
93
return 0 ;
98
94
}
Original file line number Diff line number Diff line change
1
+ // RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2
+ #include < iostream>
3
+ #include < sycl/sycl.hpp>
4
+
5
+ #include < sycl/ext/oneapi/experimental/graph.hpp>
6
+
7
+ int main () {
8
+
9
+ sycl::property_list properties{
10
+ sycl::property::queue::in_order{},
11
+ sycl::ext::oneapi::property::queue::lazy_execution{}};
12
+
13
+ sycl::queue q{sycl::gpu_selector_v, properties};
14
+
15
+ sycl::ext::oneapi::experimental::command_graph g;
16
+
17
+ const size_t n = 10 ;
18
+ float *x = sycl::malloc_shared<float >(n, q);
19
+
20
+ auto init = g.add ([&](sycl::handler &h) {
21
+ h.parallel_for (sycl::range<1 >{n}, [=](sycl::id<1 > idx) {
22
+ size_t i = idx;
23
+ x[i] = 2 .0f ;
24
+ });
25
+ });
26
+
27
+ auto add = g.add ([&](sycl::handler &h) {
28
+ h.parallel_for (sycl::range<1 >{n}, [=](sycl::id<1 > idx) {
29
+ size_t i = idx;
30
+ x[i] += 2 .0f ;
31
+ });
32
+ });
33
+
34
+ auto mult = g.add ([&](sycl::handler &h) {
35
+ h.parallel_for (sycl::range<1 >{n}, [=](sycl::id<1 > idx) {
36
+ size_t i = idx;
37
+ x[i] *= 3 .0f ;
38
+ });
39
+ });
40
+
41
+ g.make_edge (init, mult);
42
+ g.make_edge (mult, add);
43
+
44
+ auto executable_graph = g.finalize (q.get_context ());
45
+
46
+ q.submit ([&](sycl::handler &h) {
47
+ h.ext_oneapi_graph (executable_graph);
48
+ }).wait ();
49
+
50
+ for (int i = 0 ; i < n; i++)
51
+ assert (x[i] == 8 .0f );
52
+
53
+ sycl::free (x, q);
54
+
55
+ return 0 ;
56
+ }
Original file line number Diff line number Diff line change 1
1
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2
- #include < CL/sycl.hpp>
3
2
#include < iostream>
3
+ #include < sycl/sycl.hpp>
4
4
5
5
#include < sycl/ext/oneapi/experimental/graph.hpp>
6
6
@@ -33,9 +33,10 @@ int main() {
33
33
auto e3 = q.ext_oneapi_graph (executable_graph, e1 );
34
34
q.ext_oneapi_graph (executable_graph, {e2 , e3 }).wait ();
35
35
36
- sycl::free (arr, q);
36
+ for (int i = 0 ; i < n; i++)
37
+ assert (arr[i] == 1 );
37
38
38
- std::cout << " done " << arr[ 0 ] << std::endl ;
39
+ sycl::free ( arr, q) ;
39
40
40
41
return 0 ;
41
42
}
Original file line number Diff line number Diff line change 1
1
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2
- #include < CL/sycl.hpp>
3
2
#include < iostream>
3
+ #include < sycl/sycl.hpp>
4
4
5
5
#include < sycl/ext/oneapi/experimental/graph.hpp>
6
6
@@ -26,12 +26,13 @@ int main() {
26
26
[=](sycl::id<1 > idx, auto &sum) { sum += input[idx]; });
27
27
});
28
28
29
- e.wait ();
29
+ auto executable_graph = g.finalize (q.get_context ());
30
+ q.ext_oneapi_graph (executable_graph).wait ();
31
+
32
+ assert (*output == 45 );
30
33
31
34
sycl::free (input, q);
32
35
sycl::free (output, q);
33
36
34
- std::cout << " done\n " ;
35
-
36
37
return 0 ;
37
38
}
Original file line number Diff line number Diff line change
1
+ // RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2
+ #include < iostream>
3
+ #include < sycl/sycl.hpp>
4
+
5
+ #include < sycl/ext/oneapi/experimental/graph.hpp>
6
+
7
+ int main () {
8
+
9
+ sycl::property_list properties{
10
+ sycl::property::queue::in_order{},
11
+ sycl::ext::oneapi::property::queue::lazy_execution{}};
12
+
13
+ sycl::queue q{sycl::gpu_selector_v, properties};
14
+
15
+ sycl::ext::oneapi::experimental::command_graph g;
16
+
17
+ const size_t n = 10 ;
18
+ float *arr = sycl::malloc_shared<float >(n, q);
19
+ for (int i = 0 ; i < n; i++) {
20
+ arr[i] = 0 ;
21
+ }
22
+
23
+ g.add ([&](sycl::handler &h) {
24
+ h.parallel_for (sycl::range<1 >{n}, [=](sycl::id<1 > idx) {
25
+ size_t i = idx;
26
+ arr[i] += 1 ;
27
+ });
28
+ });
29
+
30
+ bool check = true ;
31
+ for (int i = 0 ; i < n; i++) {
32
+ if (arr[i] != 0 )
33
+ check = false ;
34
+ }
35
+
36
+ auto executable_graph = g.finalize (q.get_context ());
37
+
38
+ for (int i = 0 ; i < n; i++) {
39
+ if (arr[i] != 0 )
40
+ check = false ;
41
+ }
42
+
43
+ q.submit ([&](sycl::handler &h) { h.ext_oneapi_graph (executable_graph); });
44
+
45
+ for (int i = 0 ; i < n; i++) {
46
+ if (arr[i] != 1 )
47
+ check = false ;
48
+ }
49
+
50
+ q.submit ([&](sycl::handler &h) { h.ext_oneapi_graph (executable_graph); });
51
+
52
+ for (int i = 0 ; i < n; i++)
53
+ assert (arr[i] == 2 );
54
+
55
+ sycl::free (arr, q);
56
+
57
+ return 0 ;
58
+ }
Original file line number Diff line number Diff line change 1
1
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2
- #include < sycl/sycl.hpp>
3
2
#include < iostream>
3
+ #include < sycl/sycl.hpp>
4
4
5
5
#include < sycl/ext/oneapi/experimental/graph.hpp>
6
6
@@ -38,12 +38,15 @@ int main() {
38
38
39
39
auto executable_graph = g.finalize (q.get_context ());
40
40
41
- q.submit ([&](sycl::handler &h) { h.ext_oneapi_graph (executable_graph); }).wait ();
41
+ q.submit ([&](sycl::handler &h) {
42
+ h.ext_oneapi_graph (executable_graph);
43
+ }).wait ();
44
+
45
+ for (int i = 0 ; i < n; i++)
46
+ assert (y[i] == 5 .0f );
42
47
43
48
sycl::free (x, q);
44
49
sycl::free (y, q);
45
50
46
- std::cout << " done.\n " ;
47
-
48
51
return 0 ;
49
52
}
Original file line number Diff line number Diff line change 1
1
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2
- #include < CL/sycl.hpp>
3
2
#include < iostream>
3
+ #include < sycl/sycl.hpp>
4
4
5
5
#include < sycl/ext/oneapi/experimental/graph.hpp>
6
6
@@ -16,6 +16,9 @@ int main() {
16
16
17
17
const size_t n = 10 ;
18
18
float *arr = sycl::malloc_shared<float >(n, q);
19
+ for (int i = 0 ; i < n; i++) {
20
+ arr[i] = 0 ;
21
+ }
19
22
20
23
g.add ([&](sycl::handler &h) {
21
24
h.parallel_for (sycl::range<1 >{n}, [=](sycl::id<1 > idx) {
@@ -24,19 +27,25 @@ int main() {
24
27
});
25
28
});
26
29
27
- auto result_before_exec1 = arr[0 ];
30
+ bool check = true ;
31
+ for (int i = 0 ; i < n; i++) {
32
+ if (arr[i] != 0 )
33
+ check = false ;
34
+ }
28
35
29
36
auto executable_graph = g.finalize (q.get_context ());
30
37
31
- auto result_before_exec2 = arr[0 ];
38
+ for (int i = 0 ; i < n; i++) {
39
+ if (arr[i] != 0 )
40
+ check = false ;
41
+ }
32
42
33
43
q.submit ([&](sycl::handler &h) { h.ext_oneapi_graph (executable_graph); });
34
44
35
- auto result = arr[0 ];
45
+ for (int i = 0 ; i < n; i++)
46
+ assert (arr[i] == 1 );
36
47
37
48
sycl::free (arr, q);
38
49
39
- std::cout << " done.\n " ;
40
-
41
50
return 0 ;
42
51
}
Original file line number Diff line number Diff line change 2
2
3
3
// Modified version of the dotp example which submits part of the graph as a
4
4
// sub-graph
5
- #include < CL/sycl.hpp>
6
5
#include < iostream>
6
+ #include < sycl/sycl.hpp>
7
7
8
8
#include < sycl/ext/oneapi/experimental/graph.hpp>
9
9
@@ -70,7 +70,7 @@ int main() {
70
70
auto subGraphExec = subGraph.finalize (q.get_context ());
71
71
72
72
auto node_sub =
73
- g.add ([&](sycl::handler &h) { h.exec_graph (subGraphExec); }, {n_i});
73
+ g.add ([&](sycl::handler &h) { h.ext_oneapi_graph (subGraphExec); }, {n_i});
74
74
75
75
auto node_c = g.add (
76
76
[&](sycl::handler &h) {
@@ -86,18 +86,14 @@ int main() {
86
86
auto executable_graph = g.finalize (q.get_context ());
87
87
88
88
// Using shortcut for executing a graph of commands
89
- q.exec_graph (executable_graph).wait ();
89
+ q.ext_oneapi_graph (executable_graph).wait ();
90
90
91
- if (*dotp != host_gold_result ()) {
92
- std::cout << " Error unexpected result!\n " ;
93
- }
91
+ assert (*dotp == host_gold_result ());
94
92
95
93
sycl::free (dotp, q);
96
94
sycl::free (x, q);
97
95
sycl::free (y, q);
98
96
sycl::free (z, q);
99
97
100
- std::cout << " done.\n " ;
101
-
102
98
return 0 ;
103
99
}
You can’t perform that action at this time.
0 commit comments