Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

[SYCL] Remove host run and dependencies from SYCL/DeprecatedFeatures tests #1201

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion SYCL/DeprecatedFeatures/deprecated.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// RUN: %clangxx -D__SYCL_INTERNAL_API -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// RUN: %HOST_RUN_PLACEHOLDER %t.out
// RUN: %ACC_RUN_PLACEHOLDER %t.out

//==------------- deprecated.cpp - SYCL 2020 deprecation test --------------==//
Expand Down
3 changes: 0 additions & 3 deletions SYCL/DeprecatedFeatures/kernel_interop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ using namespace sycl;

int main() {
queue Queue;
if (Queue.is_host())
return 0;

context Context = Queue.get_context();

cl_context ClContext = Context.get();
Expand Down
21 changes: 6 additions & 15 deletions SYCL/DeprecatedFeatures/platform.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -D__SYCL_INTERNAL_API %s -o %t.out
// RUN: env SYCL_DEVICE_FILTER=host,%sycl_be %t.out
// RUN: env SYCL_DEVICE_FILTER=%sycl_be %t.out
//==--------------- platform.cpp - SYCL platform test ----------------------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
Expand All @@ -18,12 +18,9 @@ int main() {
int i = 1;
std::vector<platform> openclPlatforms;
for (const auto &plt : platform::get_platforms()) {
std::cout << "Platform " << i++
<< " is available: " << ((plt.is_host()) ? "host: " : "OpenCL: ")
<< std::hex
<< ((plt.is_host() || plt.get_backend() != sycl::backend::opencl)
? nullptr
: plt.get())
std::cout << "Platform " << i++ << " is available: OpenCL: " << std::hex
<< ((plt.get_backend() != sycl::backend::opencl) ? nullptr
: plt.get())
<< std::endl;
}

Expand All @@ -36,9 +33,7 @@ int main() {
size_t hash = std::hash<platform>()(Platform);
platform MovedPlatform(std::move(Platform));
assert(hash == std::hash<platform>()(MovedPlatform));
assert(platformA.is_host() == MovedPlatform.is_host());
if (!platformA.is_host() &&
platformA.get_backend() == sycl::backend::opencl) {
if (platformA.get_backend() == sycl::backend::opencl) {
assert(MovedPlatform.get() != nullptr);
}
}
Expand All @@ -49,9 +44,7 @@ int main() {
platform WillMovedPlatform(platformB);
WillMovedPlatform = std::move(Platform);
assert(hash == std::hash<platform>()(WillMovedPlatform));
assert(platformA.is_host() == WillMovedPlatform.is_host());
if (!platformA.is_host() &&
platformA.get_backend() == sycl::backend::opencl) {
if (platformA.get_backend() == sycl::backend::opencl) {
assert(WillMovedPlatform.get() != nullptr);
}
}
Expand All @@ -63,7 +56,6 @@ int main() {
assert(hash == std::hash<platform>()(Platform));
assert(hash == std::hash<platform>()(PlatformCopy));
assert(Platform == PlatformCopy);
assert(Platform.is_host() == PlatformCopy.is_host());
}
{
std::cout << "copy assignment operator" << std::endl;
Expand All @@ -74,6 +66,5 @@ int main() {
assert(hash == std::hash<platform>()(Platform));
assert(hash == std::hash<platform>()(WillPlatformCopy));
assert(Platform == WillPlatformCopy);
assert(Platform.is_host() == WillPlatformCopy.is_host());
}
}
18 changes: 5 additions & 13 deletions SYCL/DeprecatedFeatures/queue_old_interop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
using namespace sycl;

std::string get_type(const device &dev) {
return ((dev.is_host()) ? "host"
: (dev.is_gpu() ? "OpenCL.GPU" : "OpenCL.CPU"));
return dev.is_gpu() ? "OpenCL.GPU" : "OpenCL.CPU";
}

void print_queue_info(const queue &q) {
std::cout << "ID=" << std::hex
<< ((q.get_device().is_host() ||
q.get_context().get_platform().get_backend() !=
sycl::backend::opencl)
<< ((q.get_context().get_platform().get_backend() !=
sycl::backend::opencl)
? nullptr
: q.get())
<< std::endl;
Expand All @@ -51,9 +49,7 @@ int main() {
size_t hash = std::hash<queue>()(Queue);
queue MovedQueue(std::move(Queue));
assert(hash == std::hash<queue>()(MovedQueue));
assert(deviceA.is_host() == MovedQueue.is_host());
if (!deviceA.is_host() &&
deviceA.get_platform().get_backend() == sycl::backend::opencl) {
if (deviceA.get_platform().get_backend() == sycl::backend::opencl) {
assert(MovedQueue.get() != nullptr);
}
}
Expand All @@ -64,9 +60,7 @@ int main() {
queue WillMovedQueue(deviceB);
WillMovedQueue = std::move(Queue);
assert(hash == std::hash<queue>()(WillMovedQueue));
assert(deviceA.is_host() == WillMovedQueue.is_host());
if (!deviceA.is_host() &&
deviceA.get_platform().get_backend() == sycl::backend::opencl) {
if (deviceA.get_platform().get_backend() == sycl::backend::opencl) {
assert(WillMovedQueue.get() != nullptr);
}
}
Expand All @@ -78,7 +72,6 @@ int main() {
assert(hash == std::hash<queue>()(Queue));
assert(hash == std::hash<queue>()(QueueCopy));
assert(Queue == QueueCopy);
assert(Queue.is_host() == QueueCopy.is_host());
}
{
std::cout << "copy assignment operator" << std::endl;
Expand All @@ -89,7 +82,6 @@ int main() {
assert(hash == std::hash<queue>()(Queue));
assert(hash == std::hash<queue>()(WillQueueCopy));
assert(Queue == WillQueueCopy);
assert(Queue.is_host() == WillQueueCopy.is_host());
}

{
Expand Down
190 changes: 94 additions & 96 deletions SYCL/DeprecatedFeatures/set_arg_interop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,111 +13,109 @@ using namespace sycl;

int main() {
queue Queue;
if (!Queue.is_host()) {
context Context = Queue.get_context();

cl_context ClContext = Context.get();

const size_t CountSources = 3;
const char *Sources[CountSources] = {
"kernel void foo1(global float* Array, global int* Value) { *Array = "
"42; *Value = 1; }\n",
"kernel void foo2(global float* Array) { int id = get_global_id(0); "
"Array[id] = id; }\n",
"kernel void foo3(global float* Array, local float* LocalArray) { "
"(void)LocalArray; (void)Array; }\n",
};

cl_int Err;
cl_program ClProgram = clCreateProgramWithSource(ClContext, CountSources,
Sources, nullptr, &Err);
assert(Err == CL_SUCCESS);

Err = clBuildProgram(ClProgram, 0, nullptr, nullptr, nullptr, nullptr);
assert(Err == CL_SUCCESS);

cl_kernel FirstCLKernel = clCreateKernel(ClProgram, "foo1", &Err);
assert(Err == CL_SUCCESS);

cl_kernel SecondCLKernel = clCreateKernel(ClProgram, "foo2", &Err);
assert(Err == CL_SUCCESS);

cl_kernel ThirdCLKernel = clCreateKernel(ClProgram, "foo3", &Err);
assert(Err == CL_SUCCESS);

const size_t Count = 100;
float Array[Count];

kernel FirstKernel(FirstCLKernel, Context);
kernel SecondKernel(SecondCLKernel, Context);
kernel ThirdKernel(ThirdCLKernel, Context);
int Value;
{
buffer<float, 1> FirstBuffer(Array, range<1>(1));
buffer<int, 1> SecondBuffer(&Value, range<1>(1));
Queue.submit([&](handler &CGH) {
CGH.set_arg(0, FirstBuffer.get_access<access::mode::write>(CGH));
CGH.set_arg(1, SecondBuffer.get_access<access::mode::write>(CGH));
CGH.single_task(FirstKernel);
});
}
Queue.wait_and_throw();
context Context = Queue.get_context();

cl_context ClContext = Context.get();

const size_t CountSources = 3;
const char *Sources[CountSources] = {
"kernel void foo1(global float* Array, global int* Value) { *Array = "
"42; *Value = 1; }\n",
"kernel void foo2(global float* Array) { int id = get_global_id(0); "
"Array[id] = id; }\n",
"kernel void foo3(global float* Array, local float* LocalArray) { "
"(void)LocalArray; (void)Array; }\n",
};

cl_int Err;
cl_program ClProgram = clCreateProgramWithSource(ClContext, CountSources,
Sources, nullptr, &Err);
assert(Err == CL_SUCCESS);

Err = clBuildProgram(ClProgram, 0, nullptr, nullptr, nullptr, nullptr);
assert(Err == CL_SUCCESS);

cl_kernel FirstCLKernel = clCreateKernel(ClProgram, "foo1", &Err);
assert(Err == CL_SUCCESS);

cl_kernel SecondCLKernel = clCreateKernel(ClProgram, "foo2", &Err);
assert(Err == CL_SUCCESS);

cl_kernel ThirdCLKernel = clCreateKernel(ClProgram, "foo3", &Err);
assert(Err == CL_SUCCESS);

const size_t Count = 100;
float Array[Count];

kernel FirstKernel(FirstCLKernel, Context);
kernel SecondKernel(SecondCLKernel, Context);
kernel ThirdKernel(ThirdCLKernel, Context);
int Value;
{
buffer<float, 1> FirstBuffer(Array, range<1>(1));
buffer<int, 1> SecondBuffer(&Value, range<1>(1));
Queue.submit([&](handler &CGH) {
CGH.set_arg(0, FirstBuffer.get_access<access::mode::write>(CGH));
CGH.set_arg(1, SecondBuffer.get_access<access::mode::write>(CGH));
CGH.single_task(FirstKernel);
});
}
Queue.wait_and_throw();

assert(Array[0] == 42);
assert(Value == 1);

{
buffer<float, 1> FirstBuffer(Array, range<1>(Count));
Queue.submit([&](handler &CGH) {
auto Acc = FirstBuffer.get_access<access::mode::read_write>(CGH);
CGH.set_arg(0, FirstBuffer.get_access<access::mode::read_write>(CGH));
CGH.parallel_for(range<1>{Count}, SecondKernel);
});
}
Queue.wait_and_throw();

for (size_t I = 0; I < Count; ++I) {
assert(Array[I] == I);
}

assert(Array[0] == 42);
assert(Value == 1);
{
auto dev = Queue.get_device();
auto ctxt = Queue.get_context();
if (dev.get_info<info::device::usm_shared_allocations>()) {
float *data =
static_cast<float *>(malloc_shared(Count * sizeof(float), dev, ctxt));

{
buffer<float, 1> FirstBuffer(Array, range<1>(Count));
Queue.submit([&](handler &CGH) {
auto Acc = FirstBuffer.get_access<access::mode::read_write>(CGH);
CGH.set_arg(0, FirstBuffer.get_access<access::mode::read_write>(CGH));
CGH.set_arg(0, data);
CGH.parallel_for(range<1>{Count}, SecondKernel);
});
}
Queue.wait_and_throw();
Queue.wait_and_throw();

for (size_t I = 0; I < Count; ++I) {
assert(Array[I] == I);
}

{
auto dev = Queue.get_device();
auto ctxt = Queue.get_context();
if (dev.get_info<info::device::usm_shared_allocations>()) {
float *data = static_cast<float *>(
malloc_shared(Count * sizeof(float), dev, ctxt));

Queue.submit([&](handler &CGH) {
CGH.set_arg(0, data);
CGH.parallel_for(range<1>{Count}, SecondKernel);
});
Queue.wait_and_throw();

for (size_t I = 0; I < Count; ++I) {
assert(data[I] == I);
}
free(data, ctxt);
for (size_t I = 0; I < Count; ++I) {
assert(data[I] == I);
}
free(data, ctxt);
}
}

{
buffer<float, 1> FirstBuffer(Array, range<1>(Count));
Queue.submit([&](handler &CGH) {
auto Acc = FirstBuffer.get_access<access::mode::read_write>(CGH);
CGH.set_arg(0, FirstBuffer.get_access<access::mode::read_write>(CGH));
CGH.set_arg(1, sycl::accessor<float, 1, sycl::access::mode::read_write,
sycl::access::target::local>(
sycl::range<1>(Count), CGH));
CGH.parallel_for(range<1>{Count}, ThirdKernel);
});
}
Queue.wait_and_throw();

clReleaseContext(ClContext);
clReleaseKernel(FirstCLKernel);
clReleaseKernel(SecondCLKernel);
clReleaseKernel(ThirdCLKernel);
clReleaseProgram(ClProgram);
{
buffer<float, 1> FirstBuffer(Array, range<1>(Count));
Queue.submit([&](handler &CGH) {
auto Acc = FirstBuffer.get_access<access::mode::read_write>(CGH);
CGH.set_arg(0, FirstBuffer.get_access<access::mode::read_write>(CGH));
CGH.set_arg(1, sycl::accessor<float, 1, sycl::access::mode::read_write,
sycl::access::target::local>(
sycl::range<1>(Count), CGH));
CGH.parallel_for(range<1>{Count}, ThirdKernel);
});
}
Queue.wait_and_throw();

clReleaseContext(ClContext);
clReleaseKernel(FirstCLKernel);
clReleaseKernel(SecondCLKernel);
clReleaseKernel(ThirdCLKernel);
clReleaseProgram(ClProgram);
return 0;
}