Skip to content

Commit ccd477e

Browse files
steffenlarsenAlexeySachkov
authored andcommitted
[SYCL] Remove host run and dependencies from SYCL/DeprecatedFeatures tests (intel#1201)
This commit removes the host run and any assumptions and operations related to the host device from the tests in SYCL/DeprecatedFeatures. Co-authored-by: Sachkov, Alexey <[email protected]> Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 60e711b commit ccd477e

File tree

5 files changed

+105
-128
lines changed

5 files changed

+105
-128
lines changed

SYCL/DeprecatedFeatures/deprecated.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// RUN: %clangxx -D__SYCL_INTERNAL_API -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
22
// RUN: %CPU_RUN_PLACEHOLDER %t.out
33
// RUN: %GPU_RUN_PLACEHOLDER %t.out
4-
// RUN: %HOST_RUN_PLACEHOLDER %t.out
54
// RUN: %ACC_RUN_PLACEHOLDER %t.out
65

76
//==------------- deprecated.cpp - SYCL 2020 deprecation test --------------==//

SYCL/DeprecatedFeatures/kernel_interop.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ using namespace sycl;
2626

2727
int main() {
2828
queue Queue;
29-
if (Queue.is_host())
30-
return 0;
31-
3229
context Context = Queue.get_context();
3330

3431
cl_context ClContext = Context.get();

SYCL/DeprecatedFeatures/platform.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -D__SYCL_INTERNAL_API %s -o %t.out
2-
// RUN: env SYCL_DEVICE_FILTER=host,%sycl_be %t.out
2+
// RUN: env SYCL_DEVICE_FILTER=%sycl_be %t.out
33
//==--------------- platform.cpp - SYCL platform test ----------------------==//
44
//
55
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
@@ -18,12 +18,9 @@ int main() {
1818
int i = 1;
1919
std::vector<platform> openclPlatforms;
2020
for (const auto &plt : platform::get_platforms()) {
21-
std::cout << "Platform " << i++
22-
<< " is available: " << ((plt.is_host()) ? "host: " : "OpenCL: ")
23-
<< std::hex
24-
<< ((plt.is_host() || plt.get_backend() != sycl::backend::opencl)
25-
? nullptr
26-
: plt.get())
21+
std::cout << "Platform " << i++ << " is available: OpenCL: " << std::hex
22+
<< ((plt.get_backend() != sycl::backend::opencl) ? nullptr
23+
: plt.get())
2724
<< std::endl;
2825
}
2926

@@ -36,9 +33,7 @@ int main() {
3633
size_t hash = std::hash<platform>()(Platform);
3734
platform MovedPlatform(std::move(Platform));
3835
assert(hash == std::hash<platform>()(MovedPlatform));
39-
assert(platformA.is_host() == MovedPlatform.is_host());
40-
if (!platformA.is_host() &&
41-
platformA.get_backend() == sycl::backend::opencl) {
36+
if (platformA.get_backend() == sycl::backend::opencl) {
4237
assert(MovedPlatform.get() != nullptr);
4338
}
4439
}
@@ -49,9 +44,7 @@ int main() {
4944
platform WillMovedPlatform(platformB);
5045
WillMovedPlatform = std::move(Platform);
5146
assert(hash == std::hash<platform>()(WillMovedPlatform));
52-
assert(platformA.is_host() == WillMovedPlatform.is_host());
53-
if (!platformA.is_host() &&
54-
platformA.get_backend() == sycl::backend::opencl) {
47+
if (platformA.get_backend() == sycl::backend::opencl) {
5548
assert(WillMovedPlatform.get() != nullptr);
5649
}
5750
}
@@ -63,7 +56,6 @@ int main() {
6356
assert(hash == std::hash<platform>()(Platform));
6457
assert(hash == std::hash<platform>()(PlatformCopy));
6558
assert(Platform == PlatformCopy);
66-
assert(Platform.is_host() == PlatformCopy.is_host());
6759
}
6860
{
6961
std::cout << "copy assignment operator" << std::endl;
@@ -74,6 +66,5 @@ int main() {
7466
assert(hash == std::hash<platform>()(Platform));
7567
assert(hash == std::hash<platform>()(WillPlatformCopy));
7668
assert(Platform == WillPlatformCopy);
77-
assert(Platform.is_host() == WillPlatformCopy.is_host());
7869
}
7970
}

SYCL/DeprecatedFeatures/queue_old_interop.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@
1717
using namespace sycl;
1818

1919
std::string get_type(const device &dev) {
20-
return ((dev.is_host()) ? "host"
21-
: (dev.is_gpu() ? "OpenCL.GPU" : "OpenCL.CPU"));
20+
return dev.is_gpu() ? "OpenCL.GPU" : "OpenCL.CPU";
2221
}
2322

2423
void print_queue_info(const queue &q) {
2524
std::cout << "ID=" << std::hex
26-
<< ((q.get_device().is_host() ||
27-
q.get_context().get_platform().get_backend() !=
28-
sycl::backend::opencl)
25+
<< ((q.get_context().get_platform().get_backend() !=
26+
sycl::backend::opencl)
2927
? nullptr
3028
: q.get())
3129
<< std::endl;
@@ -51,9 +49,7 @@ int main() {
5149
size_t hash = std::hash<queue>()(Queue);
5250
queue MovedQueue(std::move(Queue));
5351
assert(hash == std::hash<queue>()(MovedQueue));
54-
assert(deviceA.is_host() == MovedQueue.is_host());
55-
if (!deviceA.is_host() &&
56-
deviceA.get_platform().get_backend() == sycl::backend::opencl) {
52+
if (deviceA.get_platform().get_backend() == sycl::backend::opencl) {
5753
assert(MovedQueue.get() != nullptr);
5854
}
5955
}
@@ -64,9 +60,7 @@ int main() {
6460
queue WillMovedQueue(deviceB);
6561
WillMovedQueue = std::move(Queue);
6662
assert(hash == std::hash<queue>()(WillMovedQueue));
67-
assert(deviceA.is_host() == WillMovedQueue.is_host());
68-
if (!deviceA.is_host() &&
69-
deviceA.get_platform().get_backend() == sycl::backend::opencl) {
63+
if (deviceA.get_platform().get_backend() == sycl::backend::opencl) {
7064
assert(WillMovedQueue.get() != nullptr);
7165
}
7266
}
@@ -78,7 +72,6 @@ int main() {
7872
assert(hash == std::hash<queue>()(Queue));
7973
assert(hash == std::hash<queue>()(QueueCopy));
8074
assert(Queue == QueueCopy);
81-
assert(Queue.is_host() == QueueCopy.is_host());
8275
}
8376
{
8477
std::cout << "copy assignment operator" << std::endl;
@@ -89,7 +82,6 @@ int main() {
8982
assert(hash == std::hash<queue>()(Queue));
9083
assert(hash == std::hash<queue>()(WillQueueCopy));
9184
assert(Queue == WillQueueCopy);
92-
assert(Queue.is_host() == WillQueueCopy.is_host());
9385
}
9486

9587
{

SYCL/DeprecatedFeatures/set_arg_interop.cpp

Lines changed: 94 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -13,111 +13,109 @@ using namespace sycl;
1313

1414
int main() {
1515
queue Queue;
16-
if (!Queue.is_host()) {
17-
context Context = Queue.get_context();
18-
19-
cl_context ClContext = Context.get();
20-
21-
const size_t CountSources = 3;
22-
const char *Sources[CountSources] = {
23-
"kernel void foo1(global float* Array, global int* Value) { *Array = "
24-
"42; *Value = 1; }\n",
25-
"kernel void foo2(global float* Array) { int id = get_global_id(0); "
26-
"Array[id] = id; }\n",
27-
"kernel void foo3(global float* Array, local float* LocalArray) { "
28-
"(void)LocalArray; (void)Array; }\n",
29-
};
30-
31-
cl_int Err;
32-
cl_program ClProgram = clCreateProgramWithSource(ClContext, CountSources,
33-
Sources, nullptr, &Err);
34-
assert(Err == CL_SUCCESS);
35-
36-
Err = clBuildProgram(ClProgram, 0, nullptr, nullptr, nullptr, nullptr);
37-
assert(Err == CL_SUCCESS);
38-
39-
cl_kernel FirstCLKernel = clCreateKernel(ClProgram, "foo1", &Err);
40-
assert(Err == CL_SUCCESS);
41-
42-
cl_kernel SecondCLKernel = clCreateKernel(ClProgram, "foo2", &Err);
43-
assert(Err == CL_SUCCESS);
44-
45-
cl_kernel ThirdCLKernel = clCreateKernel(ClProgram, "foo3", &Err);
46-
assert(Err == CL_SUCCESS);
47-
48-
const size_t Count = 100;
49-
float Array[Count];
50-
51-
kernel FirstKernel(FirstCLKernel, Context);
52-
kernel SecondKernel(SecondCLKernel, Context);
53-
kernel ThirdKernel(ThirdCLKernel, Context);
54-
int Value;
55-
{
56-
buffer<float, 1> FirstBuffer(Array, range<1>(1));
57-
buffer<int, 1> SecondBuffer(&Value, range<1>(1));
58-
Queue.submit([&](handler &CGH) {
59-
CGH.set_arg(0, FirstBuffer.get_access<access::mode::write>(CGH));
60-
CGH.set_arg(1, SecondBuffer.get_access<access::mode::write>(CGH));
61-
CGH.single_task(FirstKernel);
62-
});
63-
}
64-
Queue.wait_and_throw();
16+
context Context = Queue.get_context();
17+
18+
cl_context ClContext = Context.get();
19+
20+
const size_t CountSources = 3;
21+
const char *Sources[CountSources] = {
22+
"kernel void foo1(global float* Array, global int* Value) { *Array = "
23+
"42; *Value = 1; }\n",
24+
"kernel void foo2(global float* Array) { int id = get_global_id(0); "
25+
"Array[id] = id; }\n",
26+
"kernel void foo3(global float* Array, local float* LocalArray) { "
27+
"(void)LocalArray; (void)Array; }\n",
28+
};
29+
30+
cl_int Err;
31+
cl_program ClProgram = clCreateProgramWithSource(ClContext, CountSources,
32+
Sources, nullptr, &Err);
33+
assert(Err == CL_SUCCESS);
34+
35+
Err = clBuildProgram(ClProgram, 0, nullptr, nullptr, nullptr, nullptr);
36+
assert(Err == CL_SUCCESS);
37+
38+
cl_kernel FirstCLKernel = clCreateKernel(ClProgram, "foo1", &Err);
39+
assert(Err == CL_SUCCESS);
40+
41+
cl_kernel SecondCLKernel = clCreateKernel(ClProgram, "foo2", &Err);
42+
assert(Err == CL_SUCCESS);
43+
44+
cl_kernel ThirdCLKernel = clCreateKernel(ClProgram, "foo3", &Err);
45+
assert(Err == CL_SUCCESS);
46+
47+
const size_t Count = 100;
48+
float Array[Count];
49+
50+
kernel FirstKernel(FirstCLKernel, Context);
51+
kernel SecondKernel(SecondCLKernel, Context);
52+
kernel ThirdKernel(ThirdCLKernel, Context);
53+
int Value;
54+
{
55+
buffer<float, 1> FirstBuffer(Array, range<1>(1));
56+
buffer<int, 1> SecondBuffer(&Value, range<1>(1));
57+
Queue.submit([&](handler &CGH) {
58+
CGH.set_arg(0, FirstBuffer.get_access<access::mode::write>(CGH));
59+
CGH.set_arg(1, SecondBuffer.get_access<access::mode::write>(CGH));
60+
CGH.single_task(FirstKernel);
61+
});
62+
}
63+
Queue.wait_and_throw();
64+
65+
assert(Array[0] == 42);
66+
assert(Value == 1);
67+
68+
{
69+
buffer<float, 1> FirstBuffer(Array, range<1>(Count));
70+
Queue.submit([&](handler &CGH) {
71+
auto Acc = FirstBuffer.get_access<access::mode::read_write>(CGH);
72+
CGH.set_arg(0, FirstBuffer.get_access<access::mode::read_write>(CGH));
73+
CGH.parallel_for(range<1>{Count}, SecondKernel);
74+
});
75+
}
76+
Queue.wait_and_throw();
77+
78+
for (size_t I = 0; I < Count; ++I) {
79+
assert(Array[I] == I);
80+
}
6581

66-
assert(Array[0] == 42);
67-
assert(Value == 1);
82+
{
83+
auto dev = Queue.get_device();
84+
auto ctxt = Queue.get_context();
85+
if (dev.get_info<info::device::usm_shared_allocations>()) {
86+
float *data =
87+
static_cast<float *>(malloc_shared(Count * sizeof(float), dev, ctxt));
6888

69-
{
70-
buffer<float, 1> FirstBuffer(Array, range<1>(Count));
7189
Queue.submit([&](handler &CGH) {
72-
auto Acc = FirstBuffer.get_access<access::mode::read_write>(CGH);
73-
CGH.set_arg(0, FirstBuffer.get_access<access::mode::read_write>(CGH));
90+
CGH.set_arg(0, data);
7491
CGH.parallel_for(range<1>{Count}, SecondKernel);
7592
});
76-
}
77-
Queue.wait_and_throw();
93+
Queue.wait_and_throw();
7894

79-
for (size_t I = 0; I < Count; ++I) {
80-
assert(Array[I] == I);
81-
}
82-
83-
{
84-
auto dev = Queue.get_device();
85-
auto ctxt = Queue.get_context();
86-
if (dev.get_info<info::device::usm_shared_allocations>()) {
87-
float *data = static_cast<float *>(
88-
malloc_shared(Count * sizeof(float), dev, ctxt));
89-
90-
Queue.submit([&](handler &CGH) {
91-
CGH.set_arg(0, data);
92-
CGH.parallel_for(range<1>{Count}, SecondKernel);
93-
});
94-
Queue.wait_and_throw();
95-
96-
for (size_t I = 0; I < Count; ++I) {
97-
assert(data[I] == I);
98-
}
99-
free(data, ctxt);
95+
for (size_t I = 0; I < Count; ++I) {
96+
assert(data[I] == I);
10097
}
98+
free(data, ctxt);
10199
}
100+
}
102101

103-
{
104-
buffer<float, 1> FirstBuffer(Array, range<1>(Count));
105-
Queue.submit([&](handler &CGH) {
106-
auto Acc = FirstBuffer.get_access<access::mode::read_write>(CGH);
107-
CGH.set_arg(0, FirstBuffer.get_access<access::mode::read_write>(CGH));
108-
CGH.set_arg(1, sycl::accessor<float, 1, sycl::access::mode::read_write,
109-
sycl::access::target::local>(
110-
sycl::range<1>(Count), CGH));
111-
CGH.parallel_for(range<1>{Count}, ThirdKernel);
112-
});
113-
}
114-
Queue.wait_and_throw();
115-
116-
clReleaseContext(ClContext);
117-
clReleaseKernel(FirstCLKernel);
118-
clReleaseKernel(SecondCLKernel);
119-
clReleaseKernel(ThirdCLKernel);
120-
clReleaseProgram(ClProgram);
102+
{
103+
buffer<float, 1> FirstBuffer(Array, range<1>(Count));
104+
Queue.submit([&](handler &CGH) {
105+
auto Acc = FirstBuffer.get_access<access::mode::read_write>(CGH);
106+
CGH.set_arg(0, FirstBuffer.get_access<access::mode::read_write>(CGH));
107+
CGH.set_arg(1, sycl::accessor<float, 1, sycl::access::mode::read_write,
108+
sycl::access::target::local>(
109+
sycl::range<1>(Count), CGH));
110+
CGH.parallel_for(range<1>{Count}, ThirdKernel);
111+
});
121112
}
113+
Queue.wait_and_throw();
114+
115+
clReleaseContext(ClContext);
116+
clReleaseKernel(FirstCLKernel);
117+
clReleaseKernel(SecondCLKernel);
118+
clReleaseKernel(ThirdCLKernel);
119+
clReleaseProgram(ClProgram);
122120
return 0;
123121
}

0 commit comments

Comments
 (0)