diff --git a/sycl/include/sycl/device.hpp b/sycl/include/sycl/device.hpp index 0ca1e98e11f37..686d7e730edc4 100644 --- a/sycl/include/sycl/device.hpp +++ b/sycl/include/sycl/device.hpp @@ -61,8 +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.") + __SYCL2020_DEPRECATED("SYCL 1.2.1 device selectors are deprecated. Please " + "use SYCL 2020 device selectors instead.") explicit device(const device_selector &DeviceSelector); #if __cplusplus >= 201703L @@ -71,7 +71,8 @@ class __SYCL_EXPORT device { /// \param DeviceSelector is SYCL 2020 Device Selector, a simple callable that /// takes a device and returns an int template > + typename = + detail::EnableIfSYCL2020DeviceSelectorInvocable> explicit device(const DeviceSelector &deviceSelector) : device(detail::select_device(deviceSelector)) {} #endif diff --git a/sycl/include/sycl/device_selector.hpp b/sycl/include/sycl/device_selector.hpp index ef27a83eb52b8..170345d15d309 100644 --- a/sycl/include/sycl/device_selector.hpp +++ b/sycl/include/sycl/device_selector.hpp @@ -32,7 +32,7 @@ class filter_selector; /// /// \ingroup sycl_api_dev_sel class __SYCL_EXPORT __SYCL2020_DEPRECATED( - "Use Callable instead to select device.") device_selector { + "Use SYCL 2020 callable device selectors instead.") device_selector { public: virtual ~device_selector() = default; @@ -120,12 +120,14 @@ using DSelectorInvocableType = std::function; #if __cplusplus >= 201703L // Enable if DeviceSelector callable has matching signature, but -// exclude if descended from filter_selector which is not purely callable. +// exclude if descended from filter_selector which is not purely callable or +// if descended from it is descended from SYCL 1.2.1 device_selector. // See [FilterSelector not Callable] in device_selector.cpp template -using EnableIfDeviceSelectorInvocable = std::enable_if_t< +using EnableIfSYCL2020DeviceSelectorInvocable = std::enable_if_t< std::is_invocable_r_v && - !std::is_base_of_v>; + !std::is_base_of_v && + !std::is_base_of_v>; #endif __SYCL_EXPORT device diff --git a/sycl/include/sycl/platform.hpp b/sycl/include/sycl/platform.hpp index 85de7409ceb7a..4b07626eeb385 100644 --- a/sycl/include/sycl/platform.hpp +++ b/sycl/include/sycl/platform.hpp @@ -64,8 +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.") + __SYCL2020_DEPRECATED("SYCL 1.2.1 device selectors are deprecated. Please " + "use SYCL 2020 device selectors instead.") explicit platform(const device_selector &DeviceSelector); #if __cplusplus >= 201703L @@ -74,7 +74,8 @@ class __SYCL_EXPORT platform { /// \param DeviceSelector is SYCL 2020 Device Selector, a simple callable that /// takes a device and returns an int template > + typename = + detail::EnableIfSYCL2020DeviceSelectorInvocable> explicit platform(const DeviceSelector &deviceSelector) : platform(detail::select_device(deviceSelector)) {} #endif diff --git a/sycl/include/sycl/queue.hpp b/sycl/include/sycl/queue.hpp index fd2cf7736dc3a..6289836e99b01 100644 --- a/sycl/include/sycl/queue.hpp +++ b/sycl/include/sycl/queue.hpp @@ -108,7 +108,8 @@ class __SYCL_EXPORT queue { /// \param AsyncHandler is a SYCL asynchronous exception handler. /// \param PropList is a list of properties for queue construction. template > + typename = + detail::EnableIfSYCL2020DeviceSelectorInvocable> explicit queue(const DeviceSelector &deviceSelector, const async_handler &AsyncHandler, const property_list &PropList = {}) @@ -120,7 +121,8 @@ class __SYCL_EXPORT queue { /// takes a device and returns an int /// \param PropList is a list of properties for queue construction. template > + typename = + detail::EnableIfSYCL2020DeviceSelectorInvocable> explicit queue(const DeviceSelector &deviceSelector, const property_list &PropList = {}) : queue(detail::select_device(deviceSelector), async_handler{}, @@ -133,7 +135,8 @@ class __SYCL_EXPORT queue { /// takes a device and returns an int /// \param PropList is a list of properties for queue construction. template > + typename = + detail::EnableIfSYCL2020DeviceSelectorInvocable> explicit queue(const context &syclContext, const DeviceSelector &deviceSelector, const property_list &propList = {}) @@ -148,7 +151,8 @@ class __SYCL_EXPORT queue { /// \param AsyncHandler is a SYCL asynchronous exception handler. /// \param PropList is a list of properties for queue construction. template > + typename = + detail::EnableIfSYCL2020DeviceSelectorInvocable> explicit queue(const context &syclContext, const DeviceSelector &deviceSelector, const async_handler &AsyncHandler, @@ -163,8 +167,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.") + __SYCL2020_DEPRECATED("SYCL 1.2.1 device selectors are deprecated. Please " + "use SYCL 2020 device selectors instead.") queue(const device_selector &DeviceSelector, const property_list &PropList = {}) : queue(DeviceSelector.select_device(), async_handler{}, PropList) {} @@ -175,8 +179,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.") + __SYCL2020_DEPRECATED("SYCL 1.2.1 device selectors are deprecated. Please " + "use SYCL 2020 device selectors instead.") queue(const device_selector &DeviceSelector, const async_handler &AsyncHandler, const property_list &PropList = {}) : queue(DeviceSelector.select_device(), AsyncHandler, PropList) {} @@ -203,8 +207,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.") + __SYCL2020_DEPRECATED("SYCL 1.2.1 device selectors are deprecated. Please " + "use SYCL 2020 device selectors instead.") queue(const context &SyclContext, const device_selector &DeviceSelector, const property_list &PropList = {}); @@ -216,8 +220,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.") + __SYCL2020_DEPRECATED("SYCL 1.2.1 device selectors are deprecated. Please " + "use SYCL 2020 device selectors instead.") queue(const context &SyclContext, const device_selector &DeviceSelector, const async_handler &AsyncHandler, const property_list &PropList = {}); diff --git a/sycl/test/warnings/sycl_2020_deprecations.cpp b/sycl/test/warnings/sycl_2020_deprecations.cpp index e1f3d12177d60..a3f2600ea673a 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 -ferror-limit=100 -sycl-std=2020 -Xclang -verify -Xclang -verify-ignore-unexpected=note %s -o %t.out +// RUN: %clangxx %fsycl-host-only -fsyntax-only -ferror-limit=0 -sycl-std=2020 -Xclang -verify -Xclang -verify-ignore-unexpected=note %s -o %t.out #include #include @@ -205,6 +205,94 @@ int main() { // expected-warning@+1{{'host_selector' is deprecated: Host device is no longer supported.}} sycl::host_selector hs; + // expected-warning@+1{{Use SYCL 2020 callable device selectors instead.}} + class user_defined_device_selector : public sycl::device_selector { + public: + int operator()(const sycl::device &) const override { return 100; } + } uds; + + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::device dd{ds}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::device cd{cs}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::device gd{gs}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::device ad{as}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::device hd{hs}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::device udd{uds}; + + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::platform dp{ds}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::platform cp{cs}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::platform gp{gs}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::platform ap{as}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::platform hp{hs}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::platform udp{uds}; + + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue dq1{ds}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue cq1{cs}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue gq1{gs}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue aq1{as}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue hq1{hs}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue udq1{uds}; + + sycl::context ctx; + + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue dq2{ctx, ds}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue cq2{ctx, cs}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue gq2{ctx, gs}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue aq2{ctx, as}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue hq2{ctx, hs}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue udq2{ctx, uds}; + + auto ah = [](sycl::exception_list) {}; + + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue dq3{ds, ah}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue cq3{cs, ah}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue gq3{gs, ah}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue aq3{as, ah}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue hq3{hs, ah}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue udq3{uds, ah}; + + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue dq4{ctx, ds, ah}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue cq4{ctx, cs, ah}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue gq4{ctx, gs, ah}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue aq4{ctx, as, ah}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue hq4{ctx, hs, ah}; + // expected-warning@+1{{SYCL 1.2.1 device selectors are deprecated. Please use SYCL 2020 device selectors instead.}} + sycl::queue udq4{ctx, uds, ah}; + // expected-warning@+2{{'local' is deprecated: use `local_accessor` instead}} Queue.submit([&](sycl::handler &CGH) { sycl::accessor