Skip to content

Commit 4d83925

Browse files
againullbader
authored andcommitted
[SYCL] Improve SYCL stream lit test
* Remove workaround with explicit specifying of stream_manipulator namespace. * Provide namespace for sqrt, otherwise sqrt function from global namespace is used on Windows. Signed-off-by: Artur Gainullin <[email protected]>
1 parent b10bdbb commit 4d83925

File tree

1 file changed

+61
-67
lines changed

1 file changed

+61
-67
lines changed

sycl/test/basic_tests/stream.cpp

Lines changed: 61 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <cassert>
2020

2121
using namespace cl::sycl;
22-
using sm = stream_manipulator;
2322

2423
int main() {
2524
{
@@ -53,11 +52,6 @@ int main() {
5352
CGH.single_task<class DummyTask2>([=]() {});
5453
});
5554

56-
// TODO: support cl::sycl::endl. According to specitification endl should be
57-
// constant global variable in cl::sycl which is initialized with
58-
// strean_manipulator::endl. This approach doesn't currently work,
59-
// variable is not initialized in the kernel code, it contains some garbage
60-
// value.
6155
Queue.submit([&](handler &CGH) {
6256
stream Out(1024, 80, CGH);
6357
CGH.single_task<class integral>([=]() {
@@ -70,23 +64,23 @@ int main() {
7064
// CHECK-NEXT: a
7165

7266
// Boolean type
73-
Out << true << sm::endl;
74-
Out << false << sm::endl;
67+
Out << true << endl;
68+
Out << false << endl;
7569
// CHECK-NEXT: true
7670
// CHECK-NEXT: false
7771

7872
// Integral types
79-
Out << static_cast<unsigned char>(123) << sm::endl;
80-
Out << static_cast<signed char>(-123) << sm::endl;
81-
Out << static_cast<short>(2344) << sm::endl;
82-
Out << static_cast<signed short>(-2344) << sm::endl;
83-
Out << 3454 << sm::endl;
84-
Out << -3454 << sm::endl;
85-
Out << 3454U << sm::endl;
86-
Out << 3454L << sm::endl;
87-
Out << 12345678901245UL << sm::endl;
88-
Out << -12345678901245LL << sm::endl;
89-
Out << 12345678901245ULL << sm::endl;
73+
Out << static_cast<unsigned char>(123) << endl;
74+
Out << static_cast<signed char>(-123) << endl;
75+
Out << static_cast<short>(2344) << endl;
76+
Out << static_cast<signed short>(-2344) << endl;
77+
Out << 3454 << endl;
78+
Out << -3454 << endl;
79+
Out << 3454U << endl;
80+
Out << 3454L << endl;
81+
Out << 12345678901245UL << endl;
82+
Out << -12345678901245LL << endl;
83+
Out << 12345678901245ULL << endl;
9084
// CHECK-NEXT: 123
9185
// CHECK-NEXT: -123
9286
// CHECK-NEXT: 2344
@@ -100,17 +94,17 @@ int main() {
10094
// CHECK-NEXT: 12345678901245
10195

10296
// Floating point types
103-
Out << 33.4f << sm::endl;
104-
Out << 5.2 << sm::endl;
105-
Out << -33.4f << sm::endl;
106-
Out << -5.2 << sm::endl;
107-
Out << 0.0003 << sm::endl;
108-
Out << -1.0 / 0.0 << sm::endl;
109-
Out << 1.0 / 0.0 << sm::endl;
110-
Out << cl::sycl::sqrt(-1.0) << sm::endl;
111-
Out << -1.0f / 0.0f << sm::endl;
112-
Out << 1.0f / 0.0f << sm::endl;
113-
Out << sqrt(-1.0f) << sm::endl;
97+
Out << 33.4f << endl;
98+
Out << 5.2 << endl;
99+
Out << -33.4f << endl;
100+
Out << -5.2 << endl;
101+
Out << 0.0003 << endl;
102+
Out << -1.0 / 0.0 << endl;
103+
Out << 1.0 / 0.0 << endl;
104+
Out << cl::sycl::sqrt(-1.0) << endl;
105+
Out << -1.0f / 0.0f << endl;
106+
Out << 1.0f / 0.0f << endl;
107+
Out << cl::sycl::sqrt(-1.0f) << endl;
114108
// CHECK-NEXT: 33.4
115109
// CHECK-NEXT: 5.2
116110
// CHECK-NEXT: -33.4
@@ -124,69 +118,69 @@ int main() {
124118
// CHECK-NEXT: nan
125119

126120
// Manipulators for integral types
127-
Out << sm::dec << 0213 << sm::endl;
128-
Out << sm::dec << 0x213A << sm::endl;
129-
Out << sm::oct << 139 << sm::endl;
130-
Out << sm::hex << 8506 << sm::endl;
121+
Out << dec << 0213 << endl;
122+
Out << dec << 0x213A << endl;
123+
Out << oct << 139 << endl;
124+
Out << hex << 8506 << endl;
131125
// CHECK-NEXT: 139
132126
// CHECK-NEXT: 8506
133127
// CHECK-NEXT: 213
134128
// CHECK-NEXT: 213a
135129

136-
Out << sm::oct << sm::showbase << 8506 << ' ' << sm::noshowbase << 8506
137-
<< sm::endl;
138-
Out << sm::hex << sm::showbase << 8506 << ' ' << sm::noshowbase << 8506
139-
<< sm::endl;
140-
Out << sm::dec << sm::showbase << 8506 << ' ' << sm::noshowbase << 8506
141-
<< sm::endl;
130+
Out << oct << showbase << 8506 << ' ' << noshowbase << 8506
131+
<< endl;
132+
Out << hex << showbase << 8506 << ' ' << noshowbase << 8506
133+
<< endl;
134+
Out << dec << showbase << 8506 << ' ' << noshowbase << 8506
135+
<< endl;
142136
// CHECK-NEXT: 020472 20472
143137
// CHECK-NEXT: 0x213a 213a
144138
// CHECK-NEXT: 8506 8506
145139

146-
Out << sm::dec << sm::showpos << 234 << ' ' << sm::noshowpos << 234
147-
<< sm::endl;
148-
Out << sm::hex << sm::showpos << 234 << ' ' << sm::noshowpos << 234
149-
<< sm::endl;
150-
Out << sm::oct << sm::showpos << 234 << ' ' << sm::noshowpos << 234
151-
<< sm::endl;
140+
Out << dec << showpos << 234 << ' ' << noshowpos << 234
141+
<< endl;
142+
Out << hex << showpos << 234 << ' ' << noshowpos << 234
143+
<< endl;
144+
Out << oct << showpos << 234 << ' ' << noshowpos << 234
145+
<< endl;
152146
// CHECK-NEXT: +234 234
153147
// CHECK-NEXT: ea ea
154148
// CHECK-NEXT: 352 352
155149

156-
Out << sm::hex << sm::showpos << -1 << ' ' << sm::noshowpos << -1
157-
<< sm::endl;
158-
Out << sm::oct << sm::showpos << -1 << ' ' << sm::noshowpos << -1
159-
<< sm::endl;
160-
Out << sm::dec << sm::showpos << -1 << ' ' << sm::noshowpos << -1
161-
<< sm::endl;
150+
Out << hex << showpos << -1 << ' ' << noshowpos << -1
151+
<< endl;
152+
Out << oct << showpos << -1 << ' ' << noshowpos << -1
153+
<< endl;
154+
Out << dec << showpos << -1 << ' ' << noshowpos << -1
155+
<< endl;
162156
// CHECK-NEXT: ffffffff ffffffff
163157
// CHECK-NEXT: 37777777777 37777777777
164158
// CHECK-NEXT: -1 -1
165159

166160
// Pointers
167161
int a = 5;
168162
int *Ptr = &a;
169-
Out << Ptr << sm::endl;
163+
Out << Ptr << endl;
170164
const int *const ConstPtr = &a;
171-
Out << ConstPtr << sm::endl;
165+
Out << ConstPtr << endl;
172166
auto multiPtr = private_ptr<int>(Ptr);
173-
Out << multiPtr << sm::endl;
167+
Out << multiPtr << endl;
174168
// CHECK-NEXT: 0x{{[0-9a-fA-F]*$}}
175169
// CHECK-NEXT: 0x{{[0-9a-fA-F]*$}}
176170
// CHECK-NEXT: 0x{{[0-9a-fA-F]*$}}
177171

178172
// Vectors
179173
vec<int, 1> f1(545);
180-
Out << f1 << sm::endl;
174+
Out << f1 << endl;
181175
vec<int, 2> f2(545, 645);
182-
Out << f2 << sm::endl;
176+
Out << f2 << endl;
183177
vec<int, 3> f3(545, 645, 771);
184-
Out << f3 << sm::endl;
178+
Out << f3 << endl;
185179
vec<int, 4> f4(542325, 645, 771, 1024);
186-
Out << sm::hex << sm::showbase << f4 << sm::endl;
187-
Out << sm::dec << f4 << sm::endl;
180+
Out << hex << showbase << f4 << endl;
181+
Out << dec << f4 << endl;
188182
vec<float, 4> f5(542.3f, 645.3f, 771.6f, 1024.2f);
189-
Out << f5 << sm::endl;
183+
Out << f5 << endl;
190184
// CHECK-NEXT: 545
191185
// CHECK-NEXT: 545, 645
192186
// CHECK-NEXT: 545, 645, 771
@@ -195,15 +189,15 @@ int main() {
195189
// CHECK-NEXT: 542.3, 645.3, 771.6, 1024.2
196190

197191
// Swizzles
198-
Out << f4.xyzw() << sm::endl;
192+
Out << f4.xyzw() << endl;
199193
// CHECK-NEXT: 542325, 645, 771, 1024
200194

201195
// SYCL types
202-
Out << id<3>(11, 12, 13) << sm::endl;
203-
Out << range<3>(11, 12, 13) << sm::endl;
196+
Out << id<3>(11, 12, 13) << endl;
197+
Out << range<3>(11, 12, 13) << endl;
204198
Out << cl::sycl::nd_range<3>(cl::sycl::range<3>(2, 4, 1),
205199
cl::sycl::range<3>(1, 2, 1))
206-
<< sm::endl;
200+
<< endl;
207201
// CHECK-NEXT: {11, 12, 13}
208202
// CHECK-NEXT: {11, 12, 13}
209203
// CHECK-NEXT: nd_range(global_range: {2, 4, 1}, local_range: {1, 2, 1}, offset: {0, 0, 0})
@@ -237,7 +231,7 @@ int main() {
237231
[=](nd_item<3> item) {
238232
if (item.get_global_id(0) == 1 && item.get_global_id(1) == 2 &&
239233
item.get_global_id(2) == 3)
240-
Out << item << sm::endl;
234+
Out << item << endl;
241235
});
242236
});
243237
Queue.wait();
@@ -248,7 +242,7 @@ int main() {
248242
CGH.parallel_for_work_group<class stream_h_item>(
249243
range<3>(1, 1, 1), range<3>(1, 1, 1), [=](group<3> Group) {
250244
Group.parallel_for_work_item(
251-
[&](h_item<3> Item) { Out << Item << sm::endl; });
245+
[&](h_item<3> Item) { Out << Item << endl; });
252246
});
253247
});
254248
// CHECK-NEXT: h_item(

0 commit comments

Comments
 (0)