Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL] Fix deprecation of device selectors #6965

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
7 changes: 4 additions & 3 deletions sycl/include/sycl/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 DeviceSelector,
typename = detail::EnableIfDeviceSelectorInvocable<DeviceSelector>>
typename =
detail::EnableIfSYCL2020DeviceSelectorInvocable<DeviceSelector>>
explicit device(const DeviceSelector &deviceSelector)
: device(detail::select_device(deviceSelector)) {}
#endif
Expand Down
10 changes: 6 additions & 4 deletions sycl/include/sycl/device_selector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -120,12 +120,14 @@ using DSelectorInvocableType = std::function<int(const sycl::device &)>;
#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 <typename DeviceSelector>
using EnableIfDeviceSelectorInvocable = std::enable_if_t<
using EnableIfSYCL2020DeviceSelectorInvocable = std::enable_if_t<
std::is_invocable_r_v<int, DeviceSelector &, const device &> &&
!std::is_base_of_v<ext::oneapi::filter_selector, DeviceSelector>>;
!std::is_base_of_v<ext::oneapi::filter_selector, DeviceSelector> &&
!std::is_base_of_v<device_selector, DeviceSelector>>;
#endif

__SYCL_EXPORT device
Expand Down
7 changes: 4 additions & 3 deletions sycl/include/sycl/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 DeviceSelector,
typename = detail::EnableIfDeviceSelectorInvocable<DeviceSelector>>
typename =
detail::EnableIfSYCL2020DeviceSelectorInvocable<DeviceSelector>>
explicit platform(const DeviceSelector &deviceSelector)
: platform(detail::select_device(deviceSelector)) {}
#endif
Expand Down
28 changes: 16 additions & 12 deletions sycl/include/sycl/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 DeviceSelector,
typename = detail::EnableIfDeviceSelectorInvocable<DeviceSelector>>
typename =
detail::EnableIfSYCL2020DeviceSelectorInvocable<DeviceSelector>>
explicit queue(const DeviceSelector &deviceSelector,
const async_handler &AsyncHandler,
const property_list &PropList = {})
Expand All @@ -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 DeviceSelector,
typename = detail::EnableIfDeviceSelectorInvocable<DeviceSelector>>
typename =
detail::EnableIfSYCL2020DeviceSelectorInvocable<DeviceSelector>>
explicit queue(const DeviceSelector &deviceSelector,
const property_list &PropList = {})
: queue(detail::select_device(deviceSelector), async_handler{},
Expand All @@ -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 DeviceSelector,
typename = detail::EnableIfDeviceSelectorInvocable<DeviceSelector>>
typename =
detail::EnableIfSYCL2020DeviceSelectorInvocable<DeviceSelector>>
explicit queue(const context &syclContext,
const DeviceSelector &deviceSelector,
const property_list &propList = {})
Expand All @@ -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 DeviceSelector,
typename = detail::EnableIfDeviceSelectorInvocable<DeviceSelector>>
typename =
detail::EnableIfSYCL2020DeviceSelectorInvocable<DeviceSelector>>
explicit queue(const context &syclContext,
const DeviceSelector &deviceSelector,
const async_handler &AsyncHandler,
Expand All @@ -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) {}
Expand All @@ -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) {}
Expand All @@ -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 = {});

Expand All @@ -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 = {});

Expand Down
90 changes: 89 additions & 1 deletion sycl/test/warnings/sycl_2020_deprecations.cpp
Original file line number Diff line number Diff line change
@@ -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 <CL/sycl.hpp>
#include <sycl/ext/intel/experimental/online_compiler.hpp>
Expand Down Expand Up @@ -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<int, 1, sycl::access::mode::read_write, sycl::target::local>
Expand Down