From 9382328709721a57521b589d283b22997261e241 Mon Sep 17 00:00:00 2001 From: Chris Perkins Date: Thu, 11 Aug 2022 09:10:24 -0700 Subject: [PATCH 1/7] deprecation warnings added. checkpoint --- sycl/include/sycl/device.hpp | 2 ++ sycl/include/sycl/device_selector.hpp | 23 ++++++++++++++----- sycl/include/sycl/platform.hpp | 2 ++ sycl/include/sycl/queue.hpp | 8 +++++++ sycl/test/extensions/inline_asm.cpp | 2 +- sycl/test/warnings/sycl_2020_deprecations.cpp | 3 +++ 6 files changed, 33 insertions(+), 7 deletions(-) diff --git a/sycl/include/sycl/device.hpp b/sycl/include/sycl/device.hpp index 4c66109256f4..876d76b89905 100644 --- a/sycl/include/sycl/device.hpp +++ b/sycl/include/sycl/device.hpp @@ -61,6 +61,8 @@ class __SYCL_EXPORT device { /// by the DeviceSelector provided. /// /// \param DeviceSelector SYCL 1.2.1 device_selector to be used (see 4.6.1.1). + __SYCL2020_DEPRECATED("Use Callable device selectors instead of deprecated " + "device_selector subclasses.") explicit device(const device_selector &DeviceSelector); #if __cplusplus >= 201703L diff --git a/sycl/include/sycl/device_selector.hpp b/sycl/include/sycl/device_selector.hpp index 2565ae18e7be..33ae26f642f4 100644 --- a/sycl/include/sycl/device_selector.hpp +++ b/sycl/include/sycl/device_selector.hpp @@ -31,7 +31,8 @@ class filter_selector; /// \sa device /// /// \ingroup sycl_api_dev_sel -class __SYCL_EXPORT device_selector { +class __SYCL_EXPORT __SYCL2020_DEPRECATED( + "Use Callable instead to select device.") device_selector { public: virtual ~device_selector() = default; @@ -46,7 +47,9 @@ class __SYCL_EXPORT device_selector { /// \sa device /// /// \ingroup sycl_api_dev_sel -class __SYCL_EXPORT default_selector : public device_selector { +class __SYCL_EXPORT __SYCL2020_DEPRECATED( + "Use the callable sycl::default_selector_v instead.") default_selector + : public device_selector { public: int operator()(const device &dev) const override; }; @@ -56,7 +59,9 @@ class __SYCL_EXPORT default_selector : public device_selector { /// \sa device /// /// \ingroup sycl_api_dev_sel -class __SYCL_EXPORT gpu_selector : public device_selector { +class __SYCL_EXPORT __SYCL2020_DEPRECATED( + "Use the callable sycl::gpu_selector_v instead.") gpu_selector + : public device_selector { public: int operator()(const device &dev) const override; }; @@ -66,7 +71,9 @@ class __SYCL_EXPORT gpu_selector : public device_selector { /// \sa device /// /// \ingroup sycl_api_dev_sel -class __SYCL_EXPORT cpu_selector : public device_selector { +class __SYCL_EXPORT __SYCL2020_DEPRECATED( + "Use the callable sycl::cpu_selector_v instead.") cpu_selector + : public device_selector { public: int operator()(const device &dev) const override; }; @@ -76,7 +83,9 @@ class __SYCL_EXPORT cpu_selector : public device_selector { /// \sa device /// /// \ingroup sycl_api_dev_sel -class __SYCL_EXPORT accelerator_selector : public device_selector { +class __SYCL_EXPORT +__SYCL2020_DEPRECATED("Use the callable sycl::accelerator_selector_v instead.") + accelerator_selector : public device_selector { public: int operator()(const device &dev) const override; }; @@ -86,7 +95,9 @@ class __SYCL_EXPORT accelerator_selector : public device_selector { /// \sa device /// /// \ingroup sycl_api_dev_sel -class __SYCL_EXPORT host_selector : public device_selector { +class __SYCL_EXPORT +__SYCL2020_DEPRECATED("Use a callable function instead.") host_selector + : public device_selector { public: int operator()(const device &dev) const override; }; diff --git a/sycl/include/sycl/platform.hpp b/sycl/include/sycl/platform.hpp index 94265450e66b..1af13e1f585a 100644 --- a/sycl/include/sycl/platform.hpp +++ b/sycl/include/sycl/platform.hpp @@ -64,6 +64,8 @@ class __SYCL_EXPORT platform { /// provided device selector. /// /// \param DeviceSelector is an instance of a SYCL 1.2.1 device_selector + __SYCL2020_DEPRECATED("Use Callable device selectors instead of deprecated " + "device_selector subclasses.") explicit platform(const device_selector &DeviceSelector); #if __cplusplus >= 201703L diff --git a/sycl/include/sycl/queue.hpp b/sycl/include/sycl/queue.hpp index e5f7510d20c4..4cc6ca84be42 100644 --- a/sycl/include/sycl/queue.hpp +++ b/sycl/include/sycl/queue.hpp @@ -163,6 +163,8 @@ class __SYCL_EXPORT queue { /// /// \param DeviceSelector is an instance of a SYCL 1.2.1 device_selector. /// \param PropList is a list of properties for queue construction. + __SYCL2020_DEPRECATED("Use Callable device selectors instead of deprecated " + "device_selector subclasses.") queue(const device_selector &DeviceSelector, const property_list &PropList = {}) : queue(DeviceSelector.select_device(), async_handler{}, PropList) {} @@ -173,6 +175,8 @@ class __SYCL_EXPORT queue { /// \param DeviceSelector is an instance of SYCL 1.2.1 device_selector. /// \param AsyncHandler is a SYCL asynchronous exception handler. /// \param PropList is a list of properties for queue construction. + __SYCL2020_DEPRECATED("Use Callable device selectors instead of deprecated " + "device_selector subclasses.") queue(const device_selector &DeviceSelector, const async_handler &AsyncHandler, const property_list &PropList = {}) : queue(DeviceSelector.select_device(), AsyncHandler, PropList) {} @@ -199,6 +203,8 @@ class __SYCL_EXPORT queue { /// \param SyclContext is an instance of SYCL context. /// \param DeviceSelector is an instance of SYCL device selector. /// \param PropList is a list of properties for queue construction. + __SYCL2020_DEPRECATED("Use Callable device selectors instead of deprecated " + "device_selector subclasses.") queue(const context &SyclContext, const device_selector &DeviceSelector, const property_list &PropList = {}); @@ -210,6 +216,8 @@ class __SYCL_EXPORT queue { /// \param DeviceSelector is an instance of SYCL device selector. /// \param AsyncHandler is a SYCL asynchronous exception handler. /// \param PropList is a list of properties for queue construction. + __SYCL2020_DEPRECATED("Use Callable device selectors instead of deprecated " + "device_selector subclasses.") queue(const context &SyclContext, const device_selector &DeviceSelector, const async_handler &AsyncHandler, const property_list &PropList = {}); diff --git a/sycl/test/extensions/inline_asm.cpp b/sycl/test/extensions/inline_asm.cpp index 7bfda5712612..63e1bb3759a7 100644 --- a/sycl/test/extensions/inline_asm.cpp +++ b/sycl/test/extensions/inline_asm.cpp @@ -31,7 +31,7 @@ int main() { sycl::buffer BufB(DataB, DEFAULT_PROBLEM_SIZE); sycl::buffer BufC(DataC, DEFAULT_PROBLEM_SIZE); - sycl::queue deviceQueue(sycl::gpu_selector{}, AsyncHandler); + sycl::queue deviceQueue(sycl::gpu_selector_v, AsyncHandler); deviceQueue.submit([&](sycl::handler &cgh) { auto A = BufA.get_access(cgh); diff --git a/sycl/test/warnings/sycl_2020_deprecations.cpp b/sycl/test/warnings/sycl_2020_deprecations.cpp index bbd3ea323e8e..e2527ea372f0 100644 --- a/sycl/test/warnings/sycl_2020_deprecations.cpp +++ b/sycl/test/warnings/sycl_2020_deprecations.cpp @@ -197,5 +197,8 @@ int main() { // expected-warning@+1{{'get_linear_id' is deprecated: use sycl::group::get_group_linear_id() instead}} group.get_linear_id(); + // expected-warning@+1{{'default_selector' is deprecated: Use the callable sycl::default_selector_v instead.}} + default_selector ds{}; + return 0; } From f6db9fcabbd589c5b35b4ae6ac7e7808b6b58195 Mon Sep 17 00:00:00 2001 From: Chris Perkins Date: Thu, 11 Aug 2022 15:09:28 -0700 Subject: [PATCH 2/7] doc and test changes --- sycl/doc/GetStartedGuide.md | 64 ++++++++----------- sycl/doc/MultiTileCardWithLevelZero.md | 4 +- sycl/doc/design/GlobalObjectsInRuntime.md | 2 +- .../sycl_ext_intel_esimd.md | 2 +- .../sycl_ext_oneapi_max_work_group_query.md | 2 +- .../atomic_zero_dimension_accessor.cpp | 2 +- sycl/test/scheduler/ReleaseResourcesTest.cpp | 4 +- sycl/test/warnings/sycl_2020_deprecations.cpp | 12 +++- sycl/unittests/assert/assert.cpp | 10 +-- sycl/unittests/buffer/BufferLocation.cpp | 2 +- 10 files changed, 49 insertions(+), 55 deletions(-) diff --git a/sycl/doc/GetStartedGuide.md b/sycl/doc/GetStartedGuide.md index 3c393e796b3f..6bda75c76030 100644 --- a/sycl/doc/GetStartedGuide.md +++ b/sycl/doc/GetStartedGuide.md @@ -704,49 +704,38 @@ SYCL_BE=PI_CUDA ./simple-sycl-app-cuda.exe ``` **NOTE**: DPC++/SYCL developers can specify SYCL device for execution using -device selectors (e.g. `sycl::cpu_selector`, `sycl::gpu_selector`, +device selectors (e.g. `sycl::cpu_selector_v`, `sycl::gpu_selector_v`, [Intel FPGA selector(s)](extensions/supported/sycl_ext_intel_fpga_device_selector.md)) as explained in following section [Code the program for a specific GPU](#code-the-program-for-a-specific-gpu). ### Code the program for a specific GPU -To specify OpenCL device SYCL provides the abstract `sycl::device_selector` -class which the can be used to define how the runtime should select the best -device. +To assist in finding a specific OpenCL device out of all that may be available, a "device selector" may be used. A "device selector" is a ranking function that will give an integer ranking value to all the +devices on the system. It can be passed to `sycl::queue`, `sycl::device` and `sycl::platform` constructors. The highest ranking device is then selected. SYCL has built-in device selectors for selecting a generic GPU, CPU, or accelerator device, as well as one for a default device. Additionally, +a user can define their own as function, lambda, or functor class. Device selectors returning negative values will "reject" a device ensuring it is not selected, but values 0 or higher will be selected by the highest score with ties resolved by an internal algorithm (see Section 4.6.1 of the SYCL 2020 specification) -The method `sycl::device_selector::operator()` of the SYCL -`sycl::device_selector` is an abstract member function which takes a -reference to a SYCL device and returns an integer score. This abstract member -function can be implemented in a derived class to provide a logic for selecting -a SYCL device. SYCL runtime uses the device for with the highest score is -returned. Such object can be passed to `sycl::queue` and `sycl::device` -constructors. - -The example below illustrates how to use `sycl::device_selector` to create +The example below illustrates how to use a device selector to create device and queue objects bound to Intel GPU device: ```c++ #include int main() { - class NEOGPUDeviceSelector : public sycl::device_selector { - public: - int operator()(const sycl::device &Device) const override { - using namespace sycl::info; - const std::string DeviceName = Device.get_info(); - const std::string DeviceVendor = Device.get_info(); + auto NEOGPUDeviceSelectorLambda = [](const sycl::device &Device){ + using namespace sycl::info; - return Device.is_gpu() && (DeviceName.find("HD Graphics NEO") != std::string::npos); - } + const std::string DeviceName = Device.get_info(); + const std::string DeviceVendor = Device.get_info(); + bool match = Device.is_gpu() && (DeviceName.find("HD Graphics NEO") != std::string::npos); + return match ? 1 : -1; }; - NEOGPUDeviceSelector Selector; try { - sycl::queue Queue(Selector); - sycl::device Device(Selector); - } catch (sycl::invalid_parameter_error &E) { + sycl::queue Queue(NEOGPUDeviceSelectorLambda); + sycl::device Device(NEOGPUDeviceSelectorLambda); + } catch (sycl::exception &E) { std::cout << E.what() << std::endl; } } @@ -757,19 +746,18 @@ The device selector below selects an NVIDIA device only, and won't execute if there is none. ```c++ -class CUDASelector : public sycl::device_selector { - public: - int operator()(const sycl::device &Device) const override { - using namespace sycl::info; - const std::string DriverVersion = Device.get_info(); - - if (Device.is_gpu() && (DriverVersion.find("CUDA") != std::string::npos)) { - std::cout << " CUDA device found " << std::endl; - return 1; - }; - return -1; - } -}; + +int CUDASelector(const sycl::device &Device) { + using namespace sycl::info; + const std::string DriverVersion = Device.get_info(); + + if (Device.is_gpu() && (DriverVersion.find("CUDA") != std::string::npos)) { + std::cout << " CUDA device found " << std::endl; + return 1; + }; + return -1; +} + ``` ### Using the DPC++ toolchain on CUDA platforms diff --git a/sycl/doc/MultiTileCardWithLevelZero.md b/sycl/doc/MultiTileCardWithLevelZero.md index 797191240419..551be4e004e6 100644 --- a/sycl/doc/MultiTileCardWithLevelZero.md +++ b/sycl/doc/MultiTileCardWithLevelZero.md @@ -143,7 +143,7 @@ try { ``` C++ try { // The queue is attached to the root-device, driver distributes to sub-devices, if any. - auto D = device(gpu_selector{}); + auto D = device(gpu_selector_v); auto Q = queue(D); Q.submit([&](handler& cgh) {...}); } @@ -155,7 +155,7 @@ try { - Example: ``` C++ try { - auto P = platform(gpu_selector{}); + auto P = platform(gpu_selector_v); auto RootDevices = P.get_devices(); auto C = context(RootDevices); for (auto &D : RootDevices) { diff --git a/sycl/doc/design/GlobalObjectsInRuntime.md b/sycl/doc/design/GlobalObjectsInRuntime.md index 0815738e8082..96a9b8fdb05e 100644 --- a/sycl/doc/design/GlobalObjectsInRuntime.md +++ b/sycl/doc/design/GlobalObjectsInRuntime.md @@ -22,7 +22,7 @@ like in example below: sycl::queue Queue; int main() { - Queue = sycl::queue{sycl::default_selector{}.select_device()}; + Queue = sycl::queue{sycl::default_selector_v}; return 0; } diff --git a/sycl/doc/extensions/experimental/sycl_ext_intel_esimd/sycl_ext_intel_esimd.md b/sycl/doc/extensions/experimental/sycl_ext_intel_esimd/sycl_ext_intel_esimd.md index b0e8fe0e36f2..e0e8fdb0c8cb 100644 --- a/sycl/doc/extensions/experimental/sycl_ext_intel_esimd/sycl_ext_intel_esimd.md +++ b/sycl/doc/extensions/experimental/sycl_ext_intel_esimd/sycl_ext_intel_esimd.md @@ -660,7 +660,7 @@ int main(void) { int err_cnt = 0; try { - queue q(gpu_selector{}, createExceptionHandler()); + queue q(gpu_selector_v, createExceptionHandler()); auto dev = q.get_device(); std::cout << "Running on " << dev.get_info() << "\n"; diff --git a/sycl/doc/extensions/experimental/sycl_ext_oneapi_max_work_group_query.md b/sycl/doc/extensions/experimental/sycl_ext_oneapi_max_work_group_query.md index 19435c44f4b0..005a163dd31e 100644 --- a/sycl/doc/extensions/experimental/sycl_ext_oneapi_max_work_group_query.md +++ b/sycl/doc/extensions/experimental/sycl_ext_oneapi_max_work_group_query.md @@ -34,7 +34,7 @@ As encouraged by the SYCL specification, a feature-test macro, `SYCL_EXT_ONEAPI_ ## Examples ```c++ -sycl::device gpu = sycl::device{sycl::gpu_selector{}}; +sycl::device gpu = sycl::device{sycl::gpu_selector_v}; std::cout << gpu.get_info() << '\n'; #ifdef SYCL_EXT_ONEAPI_MAX_WORK_GROUP_QUERY diff --git a/sycl/test/basic_tests/accessor/atomic_zero_dimension_accessor.cpp b/sycl/test/basic_tests/accessor/atomic_zero_dimension_accessor.cpp index 6e03fcff0822..d87818135aef 100644 --- a/sycl/test/basic_tests/accessor/atomic_zero_dimension_accessor.cpp +++ b/sycl/test/basic_tests/accessor/atomic_zero_dimension_accessor.cpp @@ -19,7 +19,7 @@ void store(atomic_t foo, int value) { foo.store(value); } int main(int argc, char *argv[]) { - queue q(default_selector{}); + queue q(default_selector_v); // Accessor with dimensionality 0. { diff --git a/sycl/test/scheduler/ReleaseResourcesTest.cpp b/sycl/test/scheduler/ReleaseResourcesTest.cpp index ffed076bccc6..94eb3c56ea97 100644 --- a/sycl/test/scheduler/ReleaseResourcesTest.cpp +++ b/sycl/test/scheduler/ReleaseResourcesTest.cpp @@ -20,12 +20,10 @@ int main() { // Checks creating of the second host accessor while first one is alive. try { - sycl::default_selector device_selector; - sycl::range<1> BufSize{1}; sycl::buffer Buf(BufSize); - TestQueue Queue(device_selector); + TestQueue Queue(sycl::default_selector_v); Queue.submit([&](sycl::handler &CGH) { auto BufAcc = Buf.get_access(CGH); diff --git a/sycl/test/warnings/sycl_2020_deprecations.cpp b/sycl/test/warnings/sycl_2020_deprecations.cpp index e2527ea372f0..b003e1fe1a8d 100644 --- a/sycl/test/warnings/sycl_2020_deprecations.cpp +++ b/sycl/test/warnings/sycl_2020_deprecations.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx %fsycl-host-only -fsyntax-only -sycl-std=2020 -Xclang -verify -Xclang -verify-ignore-unexpected=note %s -o %t.out +// RUN: %clangxx %fsycl-host-only -fsyntax-only -ferror-limit=100 -sycl-std=2020 -Xclang -verify -Xclang -verify-ignore-unexpected=note %s -o %t.out #include #include @@ -198,7 +198,15 @@ int main() { group.get_linear_id(); // expected-warning@+1{{'default_selector' is deprecated: Use the callable sycl::default_selector_v instead.}} - default_selector ds{}; + sycl::default_selector ds{}; + // expected-warning@+1{{'cpu_selector' is deprecated: Use the callable sycl::cpu_selector_v instead.}} + sycl::cpu_selector cs{}; + // expected-warning@+1{{'gpu_selector' is deprecated: Use the callable sycl::gpu_selector_v instead.}} + sycl::gpu_selector gs{}; + // expected-warning@+1{{'accelerator_selector' is deprecated: Use the callable sycl::accelerator_selector_v instead.}} + sycl::accelerator_selector as{}; + // expected-warning@+1{{'host_selector' is deprecated: Use a callable function instead.}} + sycl::host_selector hs{}; return 0; } diff --git a/sycl/unittests/assert/assert.cpp b/sycl/unittests/assert/assert.cpp index db78c5dcd375..f4a0514438d5 100644 --- a/sycl/unittests/assert/assert.cpp +++ b/sycl/unittests/assert/assert.cpp @@ -438,7 +438,7 @@ void ChildProcess(int StdErrFD) { exit(1); } - sycl::platform Plt{sycl::default_selector()}; + sycl::platform Plt{sycl::default_selector_v}; sycl::unittest::PiMock Mock{Plt}; @@ -516,7 +516,7 @@ void ParentProcess(int ChildPID, int ChildStdErrFD) { TEST(Assert, TestPositive) { // Preliminary checks { - sycl::platform Plt{sycl::default_selector()}; + sycl::platform Plt{sycl::default_selector_v}; if (Plt.is_host()) { printf("Test is not supported on host, skipping\n"); return; @@ -572,7 +572,7 @@ TEST(Assert, TestAssertServiceKernelHidden) { } TEST(Assert, TestInteropKernelNegative) { - sycl::platform Plt{sycl::default_selector()}; + sycl::platform Plt{sycl::default_selector_v}; if (Plt.is_host()) { printf("Test is not supported on host, skipping\n"); @@ -610,7 +610,7 @@ TEST(Assert, TestInteropKernelNegative) { } TEST(Assert, TestInteropKernelFromProgramNegative) { - sycl::platform Plt{sycl::default_selector()}; + sycl::platform Plt{sycl::default_selector_v}; if (Plt.is_host()) { printf("Test is not supported on host, skipping\n"); @@ -649,7 +649,7 @@ TEST(Assert, TestInteropKernelFromProgramNegative) { } TEST(Assert, TestKernelFromSourceNegative) { - sycl::platform Plt{sycl::default_selector()}; + sycl::platform Plt{sycl::default_selector_v}; if (Plt.is_host()) { printf("Test is not supported on host, skipping\n"); diff --git a/sycl/unittests/buffer/BufferLocation.cpp b/sycl/unittests/buffer/BufferLocation.cpp index 965e2404c743..c5cc43e81c8a 100644 --- a/sycl/unittests/buffer/BufferLocation.cpp +++ b/sycl/unittests/buffer/BufferLocation.cpp @@ -69,7 +69,7 @@ static pi_result redefinedDeviceGetInfo(pi_device device, class BufferTest : public ::testing::Test { public: - BufferTest() : Plt{sycl::default_selector()} {} + BufferTest() : Plt{sycl::default_selector_v} {} protected: void SetUp() override { From 1521dbbd248eee2cf82862982b2c52567039ceb2 Mon Sep 17 00:00:00 2001 From: Chris Perkins Date: Mon, 15 Aug 2022 11:19:09 -0700 Subject: [PATCH 3/7] test revert --- sycl/test/scheduler/ReleaseResourcesTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/test/scheduler/ReleaseResourcesTest.cpp b/sycl/test/scheduler/ReleaseResourcesTest.cpp index 94eb3c56ea97..383879553924 100644 --- a/sycl/test/scheduler/ReleaseResourcesTest.cpp +++ b/sycl/test/scheduler/ReleaseResourcesTest.cpp @@ -23,7 +23,7 @@ int main() { sycl::range<1> BufSize{1}; sycl::buffer Buf(BufSize); - TestQueue Queue(sycl::default_selector_v); + TestQueue Queue(sycl::default_selector{}); Queue.submit([&](sycl::handler &CGH) { auto BufAcc = Buf.get_access(CGH); From e72b4d520f3aea9355a5ca92570c824cbe93d9d5 Mon Sep 17 00:00:00 2001 From: Chris Perkins Date: Wed, 17 Aug 2022 17:29:09 -0700 Subject: [PATCH 4/7] remove outdated OpenCL ref from doc Signed-off-by: Chris Perkins --- sycl/doc/GetStartedGuide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/doc/GetStartedGuide.md b/sycl/doc/GetStartedGuide.md index 6bda75c76030..11e2cb77f748 100644 --- a/sycl/doc/GetStartedGuide.md +++ b/sycl/doc/GetStartedGuide.md @@ -711,7 +711,7 @@ GPU](#code-the-program-for-a-specific-gpu). ### Code the program for a specific GPU -To assist in finding a specific OpenCL device out of all that may be available, a "device selector" may be used. A "device selector" is a ranking function that will give an integer ranking value to all the +To assist in finding a specific SYCL compatible device out of all that may be available, a "device selector" may be used. A "device selector" is a ranking function that will give an integer ranking value to all the devices on the system. It can be passed to `sycl::queue`, `sycl::device` and `sycl::platform` constructors. The highest ranking device is then selected. SYCL has built-in device selectors for selecting a generic GPU, CPU, or accelerator device, as well as one for a default device. Additionally, a user can define their own as function, lambda, or functor class. Device selectors returning negative values will "reject" a device ensuring it is not selected, but values 0 or higher will be selected by the highest score with ties resolved by an internal algorithm (see Section 4.6.1 of the SYCL 2020 specification) From d07d8dad0f4a2ce7d0b7345d48eb082d7a3d18ea Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Wed, 24 Aug 2022 08:28:13 -0700 Subject: [PATCH 5/7] Review comments Signed-off-by: Larsen, Steffen --- sycl/doc/GetStartedGuide.md | 6 +++--- sycl/doc/MultiTileCardWithLevelZero.md | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/sycl/doc/GetStartedGuide.md b/sycl/doc/GetStartedGuide.md index 11e2cb77f748..edb35ba296f7 100644 --- a/sycl/doc/GetStartedGuide.md +++ b/sycl/doc/GetStartedGuide.md @@ -723,7 +723,7 @@ device and queue objects bound to Intel GPU device: int main() { - auto NEOGPUDeviceSelectorLambda = [](const sycl::device &Device){ + auto NEOGPUDeviceSelector = [](const sycl::device &Device){ using namespace sycl::info; const std::string DeviceName = Device.get_info(); @@ -733,8 +733,8 @@ int main() { }; try { - sycl::queue Queue(NEOGPUDeviceSelectorLambda); - sycl::device Device(NEOGPUDeviceSelectorLambda); + sycl::queue Queue(NEOGPUDeviceSelector); + sycl::device Device(NEOGPUDeviceSelector); } catch (sycl::exception &E) { std::cout << E.what() << std::endl; } diff --git a/sycl/doc/MultiTileCardWithLevelZero.md b/sycl/doc/MultiTileCardWithLevelZero.md index 551be4e004e6..1b1178588378 100644 --- a/sycl/doc/MultiTileCardWithLevelZero.md +++ b/sycl/doc/MultiTileCardWithLevelZero.md @@ -143,8 +143,7 @@ try { ``` C++ try { // The queue is attached to the root-device, driver distributes to sub-devices, if any. - auto D = device(gpu_selector_v); - auto Q = queue(D); + auto Q = queue(gpu_selector_v); Q.submit([&](handler& cgh) {...}); } ``` From ef344c24025b9b3ab51e606e8b23414c6fdd7cbc Mon Sep 17 00:00:00 2001 From: Chris Perkins Date: Thu, 1 Sep 2022 10:46:38 -0700 Subject: [PATCH 6/7] reviewer feedback --- sycl/doc/GetStartedGuide.md | 1 - 1 file changed, 1 deletion(-) diff --git a/sycl/doc/GetStartedGuide.md b/sycl/doc/GetStartedGuide.md index c8d63014d166..fd2666f8d101 100644 --- a/sycl/doc/GetStartedGuide.md +++ b/sycl/doc/GetStartedGuide.md @@ -756,7 +756,6 @@ int main() { using namespace sycl::info; const std::string DeviceName = Device.get_info(); - const std::string DeviceVendor = Device.get_info(); bool match = Device.is_gpu() && (DeviceName.find("HD Graphics NEO") != std::string::npos); return match ? 1 : -1; }; From b132a7411ce0fb09ee8d6940b9d4c8043d4caa56 Mon Sep 17 00:00:00 2001 From: Chris Perkins Date: Wed, 7 Sep 2022 11:38:00 -0700 Subject: [PATCH 7/7] reviewer feedback Signed-off-by: Chris Perkins --- sycl/doc/GetStartedGuide.md | 20 +++++++++++++------ sycl/test/scheduler/ReleaseResourcesTest.cpp | 4 +++- sycl/test/warnings/sycl_2020_deprecations.cpp | 10 +++++----- sycl/unittests/assert/assert.cpp | 8 ++++---- sycl/unittests/buffer/BufferLocation.cpp | 2 +- 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/sycl/doc/GetStartedGuide.md b/sycl/doc/GetStartedGuide.md index fd2666f8d101..76154c27f277 100644 --- a/sycl/doc/GetStartedGuide.md +++ b/sycl/doc/GetStartedGuide.md @@ -740,12 +740,20 @@ the CMake. ### Code the program for a specific GPU -To assist in finding a specific SYCL compatible device out of all that may be available, a "device selector" may be used. A "device selector" is a ranking function that will give an integer ranking value to all the -devices on the system. It can be passed to `sycl::queue`, `sycl::device` and `sycl::platform` constructors. The highest ranking device is then selected. SYCL has built-in device selectors for selecting a generic GPU, CPU, or accelerator device, as well as one for a default device. Additionally, -a user can define their own as function, lambda, or functor class. Device selectors returning negative values will "reject" a device ensuring it is not selected, but values 0 or higher will be selected by the highest score with ties resolved by an internal algorithm (see Section 4.6.1 of the SYCL 2020 specification) - -The example below illustrates how to use a device selector to create -device and queue objects bound to Intel GPU device: +To assist in finding a specific SYCL compatible device out of all that may be +available, a "device selector" may be used. A "device selector" is a ranking +function (C++ Callable) that will give an integer ranking value to all the +devices on the system. It can be passed to `sycl::queue`, `sycl::device` and +`sycl::platform` constructors. The highest ranking device is then selected. SYCL +has built-in device selectors for selecting a generic GPU, CPU, or accelerator +device, as well as one for a default device. Additionally, a user can define +their own as function, lambda, or functor class. Device selectors returning +negative values will "reject" a device ensuring it is not selected, but values 0 +or higher will be selected by the highest score with ties resolved by an +internal algorithm (see Section 4.6.1 of the SYCL 2020 specification) + +The example below illustrates how to use a device selector to create device and +queue objects bound to Intel GPU device: ```c++ #include diff --git a/sycl/test/scheduler/ReleaseResourcesTest.cpp b/sycl/test/scheduler/ReleaseResourcesTest.cpp index 383879553924..ffed076bccc6 100644 --- a/sycl/test/scheduler/ReleaseResourcesTest.cpp +++ b/sycl/test/scheduler/ReleaseResourcesTest.cpp @@ -20,10 +20,12 @@ int main() { // Checks creating of the second host accessor while first one is alive. try { + sycl::default_selector device_selector; + sycl::range<1> BufSize{1}; sycl::buffer Buf(BufSize); - TestQueue Queue(sycl::default_selector{}); + TestQueue Queue(device_selector); Queue.submit([&](sycl::handler &CGH) { auto BufAcc = Buf.get_access(CGH); diff --git a/sycl/test/warnings/sycl_2020_deprecations.cpp b/sycl/test/warnings/sycl_2020_deprecations.cpp index 58da6bd4c596..91e33a7d8197 100644 --- a/sycl/test/warnings/sycl_2020_deprecations.cpp +++ b/sycl/test/warnings/sycl_2020_deprecations.cpp @@ -195,15 +195,15 @@ int main() { group.get_linear_id(); // expected-warning@+1{{'default_selector' is deprecated: Use the callable sycl::default_selector_v instead.}} - sycl::default_selector ds{}; + sycl::default_selector ds; // expected-warning@+1{{'cpu_selector' is deprecated: Use the callable sycl::cpu_selector_v instead.}} - sycl::cpu_selector cs{}; + sycl::cpu_selector cs; // expected-warning@+1{{'gpu_selector' is deprecated: Use the callable sycl::gpu_selector_v instead.}} - sycl::gpu_selector gs{}; + sycl::gpu_selector gs; // expected-warning@+1{{'accelerator_selector' is deprecated: Use the callable sycl::accelerator_selector_v instead.}} - sycl::accelerator_selector as{}; + sycl::accelerator_selector as; // expected-warning@+1{{'host_selector' is deprecated: Use a callable function instead.}} - sycl::host_selector hs{}; + sycl::host_selector hs; // expected-warning@+2{{'local' is deprecated: use `local_accessor` instead}} Queue.submit([&](sycl::handler &CGH) { diff --git a/sycl/unittests/assert/assert.cpp b/sycl/unittests/assert/assert.cpp index a96db1c77f9e..ef295d985f2d 100644 --- a/sycl/unittests/assert/assert.cpp +++ b/sycl/unittests/assert/assert.cpp @@ -438,7 +438,7 @@ void ChildProcess(int StdErrFD) { exit(1); } - sycl::platform Plt{sycl::default_selector_v}; + sycl::platform Plt; sycl::unittest::PiMock Mock{Plt}; @@ -516,7 +516,7 @@ void ParentProcess(int ChildPID, int ChildStdErrFD) { TEST(Assert, TestPositive) { // Preliminary checks { - sycl::platform Plt{sycl::default_selector_v}; + sycl::platform Plt; if (Plt.is_host()) { printf("Test is not supported on host, skipping\n"); return; @@ -572,7 +572,7 @@ TEST(Assert, TestAssertServiceKernelHidden) { } TEST(Assert, TestInteropKernelNegative) { - sycl::platform Plt{sycl::default_selector_v}; + sycl::platform Plt; if (Plt.is_host()) { printf("Test is not supported on host, skipping\n"); @@ -610,7 +610,7 @@ TEST(Assert, TestInteropKernelNegative) { } TEST(Assert, TestInteropKernelFromProgramNegative) { - sycl::platform Plt{sycl::default_selector_v}; + sycl::platform Plt; if (Plt.is_host()) { printf("Test is not supported on host, skipping\n"); diff --git a/sycl/unittests/buffer/BufferLocation.cpp b/sycl/unittests/buffer/BufferLocation.cpp index e555b9cb48b5..4c63cada7a2a 100644 --- a/sycl/unittests/buffer/BufferLocation.cpp +++ b/sycl/unittests/buffer/BufferLocation.cpp @@ -71,7 +71,7 @@ static pi_result redefinedDeviceGetInfo(pi_device device, class BufferTest : public ::testing::Test { public: - BufferTest() : Plt{sycl::default_selector_v} {} + BufferTest() {} protected: void SetUp() override {