diff --git a/SYCL/DeprecatedFeatures/deprecated.cpp b/SYCL/DeprecatedFeatures/deprecated.cpp index 582dc50d25..434910ddf3 100644 --- a/SYCL/DeprecatedFeatures/deprecated.cpp +++ b/SYCL/DeprecatedFeatures/deprecated.cpp @@ -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 --------------==// diff --git a/SYCL/DeprecatedFeatures/kernel_interop.cpp b/SYCL/DeprecatedFeatures/kernel_interop.cpp index 9c3bcfd923..0da7668ac1 100644 --- a/SYCL/DeprecatedFeatures/kernel_interop.cpp +++ b/SYCL/DeprecatedFeatures/kernel_interop.cpp @@ -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(); diff --git a/SYCL/DeprecatedFeatures/platform.cpp b/SYCL/DeprecatedFeatures/platform.cpp index 71372eda78..b6700dfd38 100644 --- a/SYCL/DeprecatedFeatures/platform.cpp +++ b/SYCL/DeprecatedFeatures/platform.cpp @@ -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. @@ -18,12 +18,9 @@ int main() { int i = 1; std::vector 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; } @@ -36,9 +33,7 @@ int main() { size_t hash = std::hash()(Platform); platform MovedPlatform(std::move(Platform)); assert(hash == std::hash()(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); } } @@ -49,9 +44,7 @@ int main() { platform WillMovedPlatform(platformB); WillMovedPlatform = std::move(Platform); assert(hash == std::hash()(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); } } @@ -63,7 +56,6 @@ int main() { assert(hash == std::hash()(Platform)); assert(hash == std::hash()(PlatformCopy)); assert(Platform == PlatformCopy); - assert(Platform.is_host() == PlatformCopy.is_host()); } { std::cout << "copy assignment operator" << std::endl; @@ -74,6 +66,5 @@ int main() { assert(hash == std::hash()(Platform)); assert(hash == std::hash()(WillPlatformCopy)); assert(Platform == WillPlatformCopy); - assert(Platform.is_host() == WillPlatformCopy.is_host()); } } diff --git a/SYCL/DeprecatedFeatures/queue_old_interop.cpp b/SYCL/DeprecatedFeatures/queue_old_interop.cpp index a1d520ad6e..e6f0e234ec 100644 --- a/SYCL/DeprecatedFeatures/queue_old_interop.cpp +++ b/SYCL/DeprecatedFeatures/queue_old_interop.cpp @@ -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; @@ -51,9 +49,7 @@ int main() { size_t hash = std::hash()(Queue); queue MovedQueue(std::move(Queue)); assert(hash == std::hash()(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); } } @@ -64,9 +60,7 @@ int main() { queue WillMovedQueue(deviceB); WillMovedQueue = std::move(Queue); assert(hash == std::hash()(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); } } @@ -78,7 +72,6 @@ int main() { assert(hash == std::hash()(Queue)); assert(hash == std::hash()(QueueCopy)); assert(Queue == QueueCopy); - assert(Queue.is_host() == QueueCopy.is_host()); } { std::cout << "copy assignment operator" << std::endl; @@ -89,7 +82,6 @@ int main() { assert(hash == std::hash()(Queue)); assert(hash == std::hash()(WillQueueCopy)); assert(Queue == WillQueueCopy); - assert(Queue.is_host() == WillQueueCopy.is_host()); } { diff --git a/SYCL/DeprecatedFeatures/set_arg_interop.cpp b/SYCL/DeprecatedFeatures/set_arg_interop.cpp index e18804b682..853ead8161 100644 --- a/SYCL/DeprecatedFeatures/set_arg_interop.cpp +++ b/SYCL/DeprecatedFeatures/set_arg_interop.cpp @@ -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 FirstBuffer(Array, range<1>(1)); - buffer SecondBuffer(&Value, range<1>(1)); - Queue.submit([&](handler &CGH) { - CGH.set_arg(0, FirstBuffer.get_access(CGH)); - CGH.set_arg(1, SecondBuffer.get_access(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 FirstBuffer(Array, range<1>(1)); + buffer SecondBuffer(&Value, range<1>(1)); + Queue.submit([&](handler &CGH) { + CGH.set_arg(0, FirstBuffer.get_access(CGH)); + CGH.set_arg(1, SecondBuffer.get_access(CGH)); + CGH.single_task(FirstKernel); + }); + } + Queue.wait_and_throw(); + + assert(Array[0] == 42); + assert(Value == 1); + + { + buffer FirstBuffer(Array, range<1>(Count)); + Queue.submit([&](handler &CGH) { + auto Acc = FirstBuffer.get_access(CGH); + CGH.set_arg(0, FirstBuffer.get_access(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()) { + float *data = + static_cast(malloc_shared(Count * sizeof(float), dev, ctxt)); - { - buffer FirstBuffer(Array, range<1>(Count)); Queue.submit([&](handler &CGH) { - auto Acc = FirstBuffer.get_access(CGH); - CGH.set_arg(0, FirstBuffer.get_access(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()) { - float *data = static_cast( - 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 FirstBuffer(Array, range<1>(Count)); - Queue.submit([&](handler &CGH) { - auto Acc = FirstBuffer.get_access(CGH); - CGH.set_arg(0, FirstBuffer.get_access(CGH)); - CGH.set_arg(1, sycl::accessor( - 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 FirstBuffer(Array, range<1>(Count)); + Queue.submit([&](handler &CGH) { + auto Acc = FirstBuffer.get_access(CGH); + CGH.set_arg(0, FirstBuffer.get_access(CGH)); + CGH.set_arg(1, sycl::accessor( + 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; }