-
Notifications
You must be signed in to change notification settings - Fork 746
Expand file tree
/
Copy pathout.cpp
More file actions
75 lines (69 loc) · 1.85 KB
/
out.cpp
File metadata and controls
75 lines (69 loc) · 1.85 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//==============================================================
// Copyright © 2022 Intel Corporation
//
// SPDX-License-Identifier: MIT
// =============================================================
#include <sycl/sycl.hpp>
void out1() {
constexpr int N = 16;
sycl::queue q;
q.submit([&](auto &cgh) {
sycl::stream str(8192, 1024, cgh);
cgh.parallel_for(N, [=](sycl::item<1> it) {
int id = it[0];
/* Send the identifier to a stream to be printed on the console */
str << "ID=" << id << sycl::endl;
});
}).wait();
} // end out1
void out2() {
sycl::queue q;
q.submit([&](auto &cgh) {
sycl::stream str(8192, 4, cgh);
cgh.parallel_for(1, [=](sycl::item<1>) {
str << "ABC" << sycl::endl; // Print statement 1
str << "ABCDEFG" << sycl::endl; // Print statement 2
});
}).wait();
} // end out2
void out3() {
sycl::queue q;
q.submit([&](auto &cgh) {
sycl::stream str(8192, 10, cgh);
cgh.parallel_for(1, [=](sycl::item<1>) {
str << "ABC" << sycl::endl; // Print statement 1
str << "ABCDEFG" << sycl::endl; // Print statement 2
});
}).wait();
} // end out3
void out4() {
sycl::queue q;
q.submit([&](auto &cgh) {
sycl::stream str(8192, 1024, cgh);
cgh.parallel_for(sycl::nd_range<1>(32, 4), [=](sycl::nd_item<1> it) {
int id = it.get_global_id();
str << "ID=" << id << sycl::endl;
});
}).wait();
} // end out4
void out5() {
int *m = NULL;
sycl::queue q;
q.submit([&](auto &cgh) {
sycl::stream str(8192, 1024, cgh);
cgh.parallel_for(sycl::nd_range<1>(32, 4), [=](sycl::nd_item<1> it) {
int id = it.get_global_id();
str << "ID=" << id << sycl::endl;
if (id == 31)
*m = id;
});
}).wait();
} // end out5
int main() {
out1();
out2();
out3();
out4();
out5();
return 0;
}