diff --git a/sycl/include/sycl/device.hpp b/sycl/include/sycl/device.hpp index a14545de7e2df..66fcc179c25c0 100644 --- a/sycl/include/sycl/device.hpp +++ b/sycl/include/sycl/device.hpp @@ -77,6 +77,7 @@ class __SYCL_STANDALONE_DEBUG __SYCL_EXPORT device { explicit device(cl_device_id DeviceId); #endif +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES /// Constructs a SYCL device instance using the device selected /// by the DeviceSelector provided. /// @@ -84,6 +85,13 @@ class __SYCL_STANDALONE_DEBUG __SYCL_EXPORT device { __SYCL2020_DEPRECATED("SYCL 1.2.1 device selectors are deprecated. Please " "use SYCL 2020 device selectors instead.") explicit device(const device_selector &DeviceSelector); +#else + /// Constructs a SYCL device instance using the device selected + /// by the DeviceSelector provided. + /// + /// \param DeviceSelector SYCL 1.2.1 device_selector to be used (see 4.6.1.1). + explicit device(const sycl::detail::device_selector &DeviceSelector); +#endif // __INTEL_PREVIEW_BREAKING_CHANGES /// Constructs a SYCL device instance using the device /// identified by the device selector provided. diff --git a/sycl/include/sycl/device_selector.hpp b/sycl/include/sycl/device_selector.hpp index cc00cf63e6edb..e4f0f0c7ce402 100644 --- a/sycl/include/sycl/device_selector.hpp +++ b/sycl/include/sycl/device_selector.hpp @@ -29,6 +29,13 @@ namespace ext::oneapi { class filter_selector; } // namespace ext::oneapi +#ifdef __INTEL_PREVIEW_BREAKING_CHANGES +// device_selector has been removed in SYCL 2020. Moved it to detail:: to keep +// support for legacy selectors while making it invisible to users. +// TODO: remove __SYCL2020_DEPRECATED during the ABI-breaking window. +namespace detail { +#endif // __INTEL_PREVIEW_BREAKING_CHANGES + /// The SYCL 1.2.1 device_selector class provides ability to choose the /// best SYCL device based on heuristics specified by the user. /// @@ -46,6 +53,10 @@ class __SYCL_EXPORT __SYCL2020_DEPRECATED( virtual int operator()(const device &device) const = 0; }; +#ifdef __INTEL_PREVIEW_BREAKING_CHANGES +} // namespace detail +#endif // __INTEL_PREVIEW_BREAKING_CHANGES + /// The default selector chooses the first available SYCL device. /// /// \sa device @@ -53,7 +64,11 @@ class __SYCL_EXPORT __SYCL2020_DEPRECATED( /// \ingroup sycl_api_dev_sel class __SYCL_EXPORT __SYCL2020_DEPRECATED( "Use the callable sycl::default_selector_v instead.") default_selector +#ifdef __INTEL_PREVIEW_BREAKING_CHANGES + : public detail::device_selector { +#else : public device_selector { +#endif // __INTEL_PREVIEW_BREAKING_CHANGES public: int operator()(const device &dev) const override; }; @@ -65,7 +80,11 @@ class __SYCL_EXPORT __SYCL2020_DEPRECATED( /// \ingroup sycl_api_dev_sel class __SYCL_EXPORT __SYCL2020_DEPRECATED( "Use the callable sycl::gpu_selector_v instead.") gpu_selector +#ifdef __INTEL_PREVIEW_BREAKING_CHANGES + : public detail::device_selector { +#else : public device_selector { +#endif // __INTEL_PREVIEW_BREAKING_CHANGES public: int operator()(const device &dev) const override; }; @@ -77,7 +96,11 @@ class __SYCL_EXPORT __SYCL2020_DEPRECATED( /// \ingroup sycl_api_dev_sel class __SYCL_EXPORT __SYCL2020_DEPRECATED( "Use the callable sycl::cpu_selector_v instead.") cpu_selector +#ifdef __INTEL_PREVIEW_BREAKING_CHANGES + : public detail::device_selector { +#else : public device_selector { +#endif // __INTEL_PREVIEW_BREAKING_CHANGES public: int operator()(const device &dev) const override; }; @@ -89,7 +112,12 @@ class __SYCL_EXPORT __SYCL2020_DEPRECATED( /// \ingroup sycl_api_dev_sel class __SYCL_EXPORT __SYCL2020_DEPRECATED("Use the callable sycl::accelerator_selector_v instead.") - accelerator_selector : public device_selector { + accelerator_selector : +#ifdef __INTEL_PREVIEW_BREAKING_CHANGES + public detail::device_selector { +#else + public device_selector { +#endif // __INTEL_PREVIEW_BREAKING_CHANGES public: int operator()(const device &dev) const override; }; @@ -122,13 +150,22 @@ void fill_aspect_vector(std::vector &V, FirstT F, OtherTs... O) { // Enable if DeviceSelector callable has matching signature, but // 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. +// if descended from SYCL 1.2.1 device_selector. // See [FilterSelector not Callable] in device_selector.cpp template +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES using EnableIfSYCL2020DeviceSelectorInvocable = std::enable_if_t< std::is_invocable_r_v && !std::is_base_of_v && !std::is_base_of_v>; +#else +// TODO: Remove "or if descended from SYCL 1.2.1 device_selector" from the +// comment above during the ABI-breaking window. Users can no longer inherit +// from device_selector. +using EnableIfSYCL2020DeviceSelectorInvocable = std::enable_if_t< + std::is_invocable_r_v && + !std::is_base_of_v>; +#endif // __INTEL_PREVIEW_BREAKING_CHANGES __SYCL_EXPORT device select_device(const DSelectorInvocableType &DeviceSelectorInvocable); diff --git a/sycl/include/sycl/ext/oneapi/filter_selector.hpp b/sycl/include/sycl/ext/oneapi/filter_selector.hpp index f1846ede65d3b..7966f82eb9f5c 100644 --- a/sycl/include/sycl/ext/oneapi/filter_selector.hpp +++ b/sycl/include/sycl/ext/oneapi/filter_selector.hpp @@ -22,7 +22,6 @@ inline namespace _V1 { // Forward declarations class device; -class device_selector; #ifdef __SYCL_INTERNAL_API namespace ONEAPI { class filter_selector; @@ -34,7 +33,11 @@ namespace detail { class filter_selector_impl; } // namespace detail +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES class __SYCL_EXPORT filter_selector : public device_selector { +#else +class __SYCL_EXPORT filter_selector : public sycl::detail::device_selector { +#endif // __INTEL_PREVIEW_BREAKING_CHANGES public: filter_selector(const std::string &filter) : filter_selector(sycl::detail::string_view{filter}) {} diff --git a/sycl/include/sycl/platform.hpp b/sycl/include/sycl/platform.hpp index 0ff059e43e2fe..1fe716eefefff 100644 --- a/sycl/include/sycl/platform.hpp +++ b/sycl/include/sycl/platform.hpp @@ -85,6 +85,7 @@ class __SYCL_EXPORT platform : public detail::OwnerLessBase { explicit platform(cl_platform_id PlatformId); #endif +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES /// Constructs a SYCL platform instance using a device_selector. /// /// One of the SYCL devices that is associated with the constructed SYCL @@ -95,6 +96,7 @@ class __SYCL_EXPORT platform : public detail::OwnerLessBase { __SYCL2020_DEPRECATED("SYCL 1.2.1 device selectors are deprecated. Please " "use SYCL 2020 device selectors instead.") explicit platform(const device_selector &DeviceSelector); +#endif // __INTEL_PREVIEW_BREAKING_CHANGES /// Constructs a SYCL platform instance using the platform of the device /// identified by the device selector provided. diff --git a/sycl/include/sycl/queue.hpp b/sycl/include/sycl/queue.hpp index e795491c06073..f177deaa70bca 100644 --- a/sycl/include/sycl/queue.hpp +++ b/sycl/include/sycl/queue.hpp @@ -273,6 +273,7 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase { : queue(syclContext, detail::select_device(deviceSelector, syclContext), AsyncHandler, propList) {} +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES /// Constructs a SYCL queue instance using the device returned by the /// DeviceSelector provided. /// @@ -296,6 +297,7 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase { queue(const device_selector &DeviceSelector, const async_handler &AsyncHandler, const property_list &PropList = {}) : queue(DeviceSelector.select_device(), AsyncHandler, PropList) {} +#endif // __INTEL_PREVIEW_BREAKING_CHANGES /// Constructs a SYCL queue instance using the device provided. /// @@ -313,6 +315,7 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase { explicit queue(const device &SyclDevice, const async_handler &AsyncHandler, const property_list &PropList = {}); +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES /// Constructs a SYCL queue instance that is associated with the context /// provided, using the device returned by the device selector. /// @@ -336,6 +339,7 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase { "use SYCL 2020 device selectors instead.") queue(const context &SyclContext, const device_selector &DeviceSelector, const async_handler &AsyncHandler, const property_list &PropList = {}); +#endif // __INTEL_PREVIEW_BREAKING_CHANGES /// Constructs a SYCL queue associated with the given context, device /// and optional properties list. diff --git a/sycl/source/detail/platform_impl.hpp b/sycl/source/detail/platform_impl.hpp index e402f6ee146b6..c113f8c808d55 100644 --- a/sycl/source/detail/platform_impl.hpp +++ b/sycl/source/detail/platform_impl.hpp @@ -23,7 +23,6 @@ namespace sycl { inline namespace _V1 { // Forward declaration -class device_selector; class device; namespace detail { diff --git a/sycl/source/device.cpp b/sycl/source/device.cpp index 16d6d13b7664b..97b61f62a5b1e 100644 --- a/sycl/source/device.cpp +++ b/sycl/source/device.cpp @@ -61,7 +61,11 @@ device::device(cl_device_id DeviceId) { __SYCL_OCL_CALL(clRetainDevice, DeviceId); } +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES device::device(const device_selector &deviceSelector) { +#else +device::device(const sycl::detail::device_selector &deviceSelector) { +#endif // __INTEL_PREVIEW_BREAKING_CHANGES *this = deviceSelector.select_device(); } diff --git a/sycl/source/device_selector.cpp b/sycl/source/device_selector.cpp index 47ea8c69fda7b..45168534205da 100644 --- a/sycl/source/device_selector.cpp +++ b/sycl/source/device_selector.cpp @@ -249,7 +249,11 @@ aspect_selector(const std::vector &RequireList, // SYCL 1.2.1 device_selector class and sub-classes +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES device device_selector::select_device() const { +#else +device detail::device_selector::select_device() const { +#endif // __INTEL_PREVIEW_BREAKING_CHANGES return detail::select_device([&](const device &dev) { return (*this)(dev); }); } @@ -294,7 +298,12 @@ device filter_selector::select_device() const { std::lock_guard Guard( sycl::detail::GlobalHandler::instance().getFilterMutex()); - device Result = device_selector::select_device(); + device Result = +#ifdef __INTEL_PREVIEW_BREAKING_CHANGES + sycl::detail::device_selector::select_device(); +#else + sycl::device_selector::select_device(); +#endif reset(); diff --git a/sycl/source/platform.cpp b/sycl/source/platform.cpp index d6d4f90f493e2..cb5879852e8f4 100644 --- a/sycl/source/platform.cpp +++ b/sycl/source/platform.cpp @@ -37,9 +37,11 @@ platform::platform(cl_platform_id PlatformId) { // protected constructor for internal use platform::platform(const device &Device) { *this = Device.get_platform(); } +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES platform::platform(const device_selector &dev_selector) { *this = dev_selector.select_device().get_platform(); } +#endif // __INTEL_PREVIEW_BREAKING_CHANGES cl_platform_id platform::get() const { return impl->get(); } diff --git a/sycl/source/queue.cpp b/sycl/source/queue.cpp index 58a26407f6416..ae9a3be1e2530 100644 --- a/sycl/source/queue.cpp +++ b/sycl/source/queue.cpp @@ -20,6 +20,7 @@ namespace sycl { inline namespace _V1 { +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES queue::queue(const context &SyclContext, const device_selector &DeviceSelector, const async_handler &AsyncHandler, const property_list &PropList) { const std::vector Devs = SyclContext.get_devices(); @@ -34,6 +35,7 @@ queue::queue(const context &SyclContext, const device_selector &DeviceSelector, *detail::getSyclObjImpl(SyclContext), AsyncHandler, PropList); } +#endif // __INTEL_PREVIEW_BREAKING_CHANGES queue::queue(const context &SyclContext, const device &SyclDevice, const async_handler &AsyncHandler, const property_list &PropList) { @@ -48,11 +50,13 @@ queue::queue(const device &SyclDevice, const async_handler &AsyncHandler, AsyncHandler, PropList); } +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES queue::queue(const context &SyclContext, const device_selector &deviceSelector, const property_list &PropList) : queue(SyclContext, deviceSelector, detail::getSyclObjImpl(SyclContext)->get_async_handler(), PropList) {} +#endif // __INTEL_PREVIEW_BREAKING_CHANGES queue::queue(const context &SyclContext, const device &SyclDevice, const property_list &PropList) diff --git a/sycl/test-e2e/Adapters/level_zero/interop-buffer.cpp b/sycl/test-e2e/Adapters/level_zero/interop-buffer.cpp index dd25811cb7815..2e6188ca57615 100644 --- a/sycl/test-e2e/Adapters/level_zero/interop-buffer.cpp +++ b/sycl/test-e2e/Adapters/level_zero/interop-buffer.cpp @@ -20,9 +20,9 @@ using namespace sycl; -class DiscreteSelector : public sycl::device_selector { +class DiscreteSelector { public: - int operator()(const sycl::device &Device) const final { + int operator()(const sycl::device &Device) const { if (!Device.is_gpu() || Device.get_backend() != backend::ext_oneapi_level_zero) return -1; diff --git a/sycl/unittests/buffer/SubbufferLargeSize.cpp b/sycl/unittests/buffer/SubbufferLargeSize.cpp index f924084b93a32..05018330f6681 100644 --- a/sycl/unittests/buffer/SubbufferLargeSize.cpp +++ b/sycl/unittests/buffer/SubbufferLargeSize.cpp @@ -40,7 +40,7 @@ class LargeBufferSizeTest : public ::testing::Test { TEST_F(LargeBufferSizeTest, MoreThan32bit) { sycl::context Context{Plt}; - sycl::queue Queue{Context, sycl::accelerator_selector{}}; + sycl::queue Queue{Context, sycl::accelerator_selector_v }; using DataType = double; const size_t IndexStart = 16;