Skip to content

Commit f8037ba

Browse files
alexeyvoronov-intelromanovvlad
authored andcommitted
[SYCL][NFC] Refactoring of built-in functions' tests.
Removed I/O. Replace namespace cl::sycl to s for the tests. Signed-off-by: Alexey Voronov <[email protected]>
1 parent 4e3a49a commit f8037ba

10 files changed

+1001
-1108
lines changed

sycl/test/built-ins/scalar_common.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,24 @@
66

77
#include <CL/sycl.hpp>
88

9-
#include <array>
109
#include <cassert>
1110

12-
using namespace cl::sycl;
11+
namespace s = cl::sycl;
1312

1413
int main() {
1514
// max
1615
{
17-
cl::sycl::cl_float r{0};
16+
s::cl_float r{ 0 };
1817
{
19-
buffer<cl::sycl::cl_float, 1> BufR(&r, range<1>(1));
20-
queue myQueue;
21-
myQueue.submit([&](handler &cgh) {
22-
auto AccR = BufR.get_access<access::mode::write>(cgh);
18+
s::buffer<s::cl_float, 1> BufR(&r, s::range<1>(1));
19+
s::queue myQueue;
20+
myQueue.submit([&](s::handler &cgh) {
21+
auto AccR = BufR.get_access<s::access::mode::write>(cgh);
2322
cgh.single_task<class maxF1F1>([=]() {
24-
AccR[0] =
25-
cl::sycl::max(cl::sycl::cl_float{0.5f}, cl::sycl::cl_float{2.3f});
23+
AccR[0] = s::max(s::cl_float{ 0.5f }, s::cl_float{ 2.3f });
2624
});
2725
});
2826
}
29-
std::cout << "r " << r << std::endl;
3027
assert(r == 2.3f);
3128
}
3229

sycl/test/built-ins/scalar_geometric.cpp

Lines changed: 50 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -6,128 +6,121 @@
66

77
#include <CL/sycl.hpp>
88

9-
#include <array>
109
#include <cassert>
1110

12-
using namespace cl::sycl;
11+
namespace s = cl::sycl;
1312

1413
int main() {
1514
// dot
1615
{
17-
cl::sycl::cl_float r{0};
16+
s::cl_float r{ 0 };
1817
{
19-
buffer<cl::sycl::cl_float, 1> BufR(&r, range<1>(1));
20-
queue myQueue;
21-
myQueue.submit([&](handler &cgh) {
22-
auto AccR = BufR.get_access<access::mode::write>(cgh);
18+
s::buffer<s::cl_float, 1> BufR(&r, s::range<1>(1));
19+
s::queue myQueue;
20+
myQueue.submit([&](s::handler &cgh) {
21+
auto AccR = BufR.get_access<s::access::mode::write>(cgh);
2322
cgh.single_task<class dotF1F1>([=]() {
24-
AccR[0] =
25-
cl::sycl::dot(cl::sycl::cl_float{0.5}, cl::sycl::cl_float{1.6});
23+
AccR[0] = s::dot(s::cl_float{ 0.5 }, s::cl_float{ 1.6 });
2624
});
2725
});
2826
}
29-
std::cout << "r " << r << std::endl;
3027
assert(r == 0.8f);
3128
}
3229

3330
// distance
3431
{
35-
cl::sycl::cl_float r{0};
32+
s::cl_float r{ 0 };
3633
{
37-
buffer<cl::sycl::cl_float, 1> BufR(&r, range<1>(1));
38-
queue myQueue;
39-
myQueue.submit([&](handler &cgh) {
40-
auto AccR = BufR.get_access<access::mode::write>(cgh);
34+
s::buffer<s::cl_float, 1> BufR(&r, s::range<1>(1));
35+
s::queue myQueue;
36+
myQueue.submit([&](s::handler &cgh) {
37+
auto AccR = BufR.get_access<s::access::mode::write>(cgh);
4138
cgh.single_task<class distanceF1>([=]() {
42-
AccR[0] = cl::sycl::distance(cl::sycl::cl_float{1.f},
43-
cl::sycl::cl_float{3.f});
39+
AccR[0] = s::distance(s::cl_float{ 1.f }, s::cl_float{ 3.f });
4440
});
4541
});
4642
}
47-
std::cout << "r " << r << std::endl;
4843
assert(r == 2.f);
4944
}
5045

5146
// length
5247
{
53-
cl::sycl::cl_float r{0};
48+
s::cl_float r{ 0 };
5449
{
55-
buffer<cl::sycl::cl_float, 1> BufR(&r, range<1>(1));
56-
queue myQueue;
57-
myQueue.submit([&](handler &cgh) {
58-
auto AccR = BufR.get_access<access::mode::write>(cgh);
59-
cgh.single_task<class lengthF1>(
60-
[=]() { AccR[0] = cl::sycl::length(cl::sycl::cl_float{1.f}); });
50+
s::buffer<s::cl_float, 1> BufR(&r, s::range<1>(1));
51+
s::queue myQueue;
52+
myQueue.submit([&](s::handler &cgh) {
53+
auto AccR = BufR.get_access<s::access::mode::write>(cgh);
54+
cgh.single_task<class lengthF1>([=]() {
55+
AccR[0] = s::length(s::cl_float{ 1.f });
56+
});
6157
});
6258
}
63-
std::cout << "r " << r << std::endl;
6459
assert(r == 1.f);
6560
}
61+
6662
// normalize
6763
{
68-
cl::sycl::cl_float r{0};
64+
s::cl_float r{ 0 };
6965
{
70-
buffer<cl::sycl::cl_float, 1> BufR(&r, range<1>(1));
71-
queue myQueue;
72-
myQueue.submit([&](handler &cgh) {
73-
auto AccR = BufR.get_access<access::mode::write>(cgh);
74-
cgh.single_task<class normalizeF1>(
75-
[=]() { AccR[0] = cl::sycl::normalize(cl::sycl::cl_float{2.f}); });
66+
s::buffer<s::cl_float, 1> BufR(&r, s::range<1>(1));
67+
s::queue myQueue;
68+
myQueue.submit([&](s::handler &cgh) {
69+
auto AccR = BufR.get_access<s::access::mode::write>(cgh);
70+
cgh.single_task<class normalizeF1>([=]() {
71+
AccR[0] = s::normalize(s::cl_float{ 2.f });
72+
});
7673
});
7774
}
78-
79-
std::cout << "r " << r << std::endl;
8075
assert(r == 1.f);
8176
}
8277

8378
// fast_distance
8479
{
85-
cl::sycl::cl_float r{0};
80+
s::cl_float r{ 0 };
8681
{
87-
buffer<cl::sycl::cl_float, 1> BufR(&r, range<1>(1));
88-
queue myQueue;
89-
myQueue.submit([&](handler &cgh) {
90-
auto AccR = BufR.get_access<access::mode::write>(cgh);
82+
s::buffer<s::cl_float, 1> BufR(&r, s::range<1>(1));
83+
s::queue myQueue;
84+
myQueue.submit([&](s::handler &cgh) {
85+
auto AccR = BufR.get_access<s::access::mode::write>(cgh);
9186
cgh.single_task<class fast_distanceF1>([=]() {
92-
AccR[0] = cl::sycl::fast_distance(cl::sycl::cl_float{1.f},
93-
cl::sycl::cl_float{3.f});
87+
AccR[0] = s::fast_distance(s::cl_float{ 1.f }, s::cl_float{ 3.f });
9488
});
9589
});
9690
}
97-
std::cout << "r " << r << std::endl;
9891
assert(r == 2.f);
9992
}
93+
10094
// fast_length
10195
{
102-
cl::sycl::cl_float r{0};
96+
s::cl_float r{ 0 };
10397
{
104-
buffer<cl::sycl::cl_float, 1> BufR(&r, range<1>(1));
105-
queue myQueue;
106-
myQueue.submit([&](handler &cgh) {
107-
auto AccR = BufR.get_access<access::mode::write>(cgh);
98+
s::buffer<s::cl_float, 1> BufR(&r, s::range<1>(1));
99+
s::queue myQueue;
100+
myQueue.submit([&](s::handler &cgh) {
101+
auto AccR = BufR.get_access<s::access::mode::write>(cgh);
108102
cgh.single_task<class fast_lengthF1>([=]() {
109-
AccR[0] = cl::sycl::fast_length(cl::sycl::cl_float{2.f});
103+
AccR[0] = s::fast_length(s::cl_float{ 2.f });
110104
});
111105
});
112106
}
113-
std::cout << "r " << r << std::endl;
114107
assert(r == 2.f);
115108
}
109+
116110
// fast_normalize
117111
{
118-
cl::sycl::cl_float r{0};
112+
s::cl_float r{ 0 };
119113
{
120-
buffer<cl::sycl::cl_float, 1> BufR(&r, range<1>(1));
121-
queue myQueue;
122-
myQueue.submit([&](handler &cgh) {
123-
auto AccR = BufR.get_access<access::mode::write>(cgh);
114+
s::buffer<s::cl_float, 1> BufR(&r, s::range<1>(1));
115+
s::queue myQueue;
116+
myQueue.submit([&](s::handler &cgh) {
117+
auto AccR = BufR.get_access<s::access::mode::write>(cgh);
124118
cgh.single_task<class fast_normalizeF1>([=]() {
125-
AccR[0] = cl::sycl::fast_normalize(cl::sycl::cl_float{2.f});
119+
AccR[0] = s::fast_normalize(s::cl_float{ 2.f });
126120
});
127121
});
128122
}
129123

130-
std::cout << "r " << r << std::endl;
131124
assert(r == 1.f);
132125
}
133126

0 commit comments

Comments
 (0)