diff --git a/sycl/include/sycl/device.hpp b/sycl/include/sycl/device.hpp index a14545de7e2df..98f446a4e0fba 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,15 @@ 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 + // TODO: consider rewriting the filter_selector class to be used with the new + // device(const DeviceSelector &deviceSelector) constructor. + /// Constructs a SYCL device instance using the device selected + /// by the DeviceSelector provided. + /// + /// \param DeviceSelector filter_selector to be used (see sycl_ext_oneapi_filter_selector). + explicit device(const ext::oneapi::filter_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..85004e50f9ee4 100644 --- a/sycl/include/sycl/device_selector.hpp +++ b/sycl/include/sycl/device_selector.hpp @@ -29,14 +29,16 @@ namespace ext::oneapi { class filter_selector; } // namespace ext::oneapi +#ifndef __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. /// /// \sa device /// /// \ingroup sycl_api_dev_sel -class __SYCL_EXPORT __SYCL2020_DEPRECATED( - "Use SYCL 2020 callable device selectors instead.") device_selector { +class __SYCL_EXPORT +__SYCL2020_DEPRECATED("Use SYCL 2020 callable device selectors instead.") + device_selector { public: virtual ~device_selector() = default; @@ -45,17 +47,26 @@ class __SYCL_EXPORT __SYCL2020_DEPRECATED( virtual int operator()(const device &device) const = 0; }; +#endif // __INTEL_PREVIEW_BREAKING_CHANGES /// The default selector chooses the first available SYCL device. /// /// \sa device /// /// \ingroup sycl_api_dev_sel -class __SYCL_EXPORT __SYCL2020_DEPRECATED( - "Use the callable sycl::default_selector_v instead.") default_selector - : public device_selector { +class __SYCL_EXPORT +__SYCL2020_DEPRECATED("Use the callable sycl::default_selector_v instead.") + default_selector +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES + : public device_selector +#endif // __INTEL_PREVIEW_BREAKING_CHANGES +{ public: +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES int operator()(const device &dev) const override; +#else + int operator()(const device &dev) const; +#endif // __INTEL_PREVIEW_BREAKING_CHANGES }; /// Selects any SYCL GPU device. @@ -63,11 +74,19 @@ class __SYCL_EXPORT __SYCL2020_DEPRECATED( /// \sa device /// /// \ingroup sycl_api_dev_sel -class __SYCL_EXPORT __SYCL2020_DEPRECATED( - "Use the callable sycl::gpu_selector_v instead.") gpu_selector - : public device_selector { +class __SYCL_EXPORT +__SYCL2020_DEPRECATED("Use the callable sycl::gpu_selector_v instead.") + gpu_selector +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES + : public device_selector +#endif // __INTEL_PREVIEW_BREAKING_CHANGES +{ public: +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES int operator()(const device &dev) const override; +#else + int operator()(const device &dev) const; +#endif // __INTEL_PREVIEW_BREAKING_CHANGES }; /// Selects any SYCL CPU device. @@ -75,11 +94,19 @@ class __SYCL_EXPORT __SYCL2020_DEPRECATED( /// \sa device /// /// \ingroup sycl_api_dev_sel -class __SYCL_EXPORT __SYCL2020_DEPRECATED( - "Use the callable sycl::cpu_selector_v instead.") cpu_selector - : public device_selector { +class __SYCL_EXPORT +__SYCL2020_DEPRECATED("Use the callable sycl::cpu_selector_v instead.") + cpu_selector +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES + : public device_selector +#endif // __INTEL_PREVIEW_BREAKING_CHANGES +{ public: +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES int operator()(const device &dev) const override; +#else + int operator()(const device &dev) const; +#endif // __INTEL_PREVIEW_BREAKING_CHANGES }; /// Selects any SYCL accelerator device. @@ -89,9 +116,17 @@ 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 +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES + : public device_selector +#endif // __INTEL_PREVIEW_BREAKING_CHANGES +{ public: +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES int operator()(const device &dev) const override; +#else + int operator()(const device &dev) const; +#endif // __INTEL_PREVIEW_BREAKING_CHANGES }; // -------------- SYCL 2020 @@ -122,13 +157,21 @@ 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 (deprecated & will be removed +// soon). // See [FilterSelector not Callable] in device_selector.cpp template -using EnableIfSYCL2020DeviceSelectorInvocable = std::enable_if_t< - std::is_invocable_r_v && - !std::is_base_of_v && - !std::is_base_of_v>; +using EnableIfSYCL2020DeviceSelectorInvocable = +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES + std::enable_if_t< + std::is_invocable_r_v && + !std::is_base_of_v && + !std::is_base_of_v>; +#else + 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..0c2d7e4cc5d9e 100644 --- a/sycl/include/sycl/ext/oneapi/filter_selector.hpp +++ b/sycl/include/sycl/ext/oneapi/filter_selector.hpp @@ -10,7 +10,9 @@ #include // for __SYCL_EXPORT #include // for device +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES #include // for device_selector +#endif // __INTEL_PREVIEW_BREAKING_CHANGES #include // for shared_ptr #include // for string @@ -22,7 +24,6 @@ inline namespace _V1 { // Forward declarations class device; -class device_selector; #ifdef __SYCL_INTERNAL_API namespace ONEAPI { class filter_selector; @@ -34,13 +35,26 @@ namespace detail { class filter_selector_impl; } // namespace detail -class __SYCL_EXPORT filter_selector : public device_selector { +class __SYCL_EXPORT filter_selector +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES + : public device_selector +#endif // __INTEL_PREVIEW_BREAKING_CHANGES +{ public: + virtual ~filter_selector() = default; filter_selector(const std::string &filter) : filter_selector(sycl::detail::string_view{filter}) {} +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES int operator()(const device &dev) const override; +#else + virtual int operator()(const device &dev) const; +#endif // __INTEL_PREVIEW_BREAKING_CHANGES void reset() const; +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES device select_device() const override; +#else + virtual device select_device() const; +#endif // __INTEL_PREVIEW_BREAKING_CHANGES #ifdef __SYCL_INTERNAL_API friend class sycl::ONEAPI::filter_selector; #endif 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/device.cpp b/sycl/source/device.cpp index 16d6d13b7664b..89350d3c1a98f 100644 --- a/sycl/source/device.cpp +++ b/sycl/source/device.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -61,9 +62,15 @@ device::device(cl_device_id DeviceId) { __SYCL_OCL_CALL(clRetainDevice, DeviceId); } +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES device::device(const device_selector &deviceSelector) { *this = deviceSelector.select_device(); } +#else +device::device(const ext::oneapi::filter_selector &deviceSelector) { + *this = deviceSelector.select_device(); +} +#endif // __INTEL_PREVIEW_BREAKING_CHANGES std::vector device::get_devices(info::device_type deviceType) { std::vector devices; diff --git a/sycl/source/device_selector.cpp b/sycl/source/device_selector.cpp index 47ea8c69fda7b..47e31056f68f6 100644 --- a/sycl/source/device_selector.cpp +++ b/sycl/source/device_selector.cpp @@ -249,9 +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 { return detail::select_device([&](const device &dev) { return (*this)(dev); }); } +#endif // __INTEL_PREVIEW_BREAKING_CHANGES int default_selector::operator()(const device &dev) const { return default_selector_v(dev); @@ -294,7 +296,8 @@ device filter_selector::select_device() const { std::lock_guard Guard( sycl::detail::GlobalHandler::instance().getFilterMutex()); - device Result = device_selector::select_device(); + device Result = sycl::detail::select_device( + [&](const device &dev) { return (*this)(dev); }); reset(); diff --git a/sycl/source/platform.cpp b/sycl/source/platform.cpp index d6d4f90f493e2..ff7ae04e2ee7c 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 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 c69e8902224ab..3053fc249a096 100644 --- a/sycl/test-e2e/Adapters/level_zero/interop-buffer.cpp +++ b/sycl/test-e2e/Adapters/level_zero/interop-buffer.cpp @@ -22,9 +22,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/test/abi/abi_crossing_type_traits.cpp b/sycl/test/abi/abi_crossing_type_traits.cpp index a904bd66e0bc4..98aa926705eb7 100644 --- a/sycl/test/abi/abi_crossing_type_traits.cpp +++ b/sycl/test/abi/abi_crossing_type_traits.cpp @@ -63,7 +63,9 @@ int main() { check_type_traits, true, true, true>(); check_type_traits(); check_type_traits(); +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES check_type_traits(); +#endif return 0; } diff --git a/sycl/test/abi/symbol_size_alignment.cpp b/sycl/test/abi/symbol_size_alignment.cpp index 40018f719c982..8f88403cd7de5 100644 --- a/sycl/test/abi/symbol_size_alignment.cpp +++ b/sycl/test/abi/symbol_size_alignment.cpp @@ -50,7 +50,9 @@ int main() { check(); check(); check(); +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES check(); +#endif check(); check(); check(); diff --git a/sycl/test/abi/vtable.cpp b/sycl/test/abi/vtable.cpp index f1ff7e02f1900..35b43cf55e760 100644 --- a/sycl/test/abi/vtable.cpp +++ b/sycl/test/abi/vtable.cpp @@ -31,6 +31,7 @@ void foo(sycl::detail::SYCLMemObjAllocator &Allocator) { // CHECK-NEXT: 7 | std::size_t sycl::detail::SYCLMemObjAllocator::getValueSize() const [pure] // CHECK-NEXT: 8 | void sycl::detail::SYCLMemObjAllocator::setAlignment(std::size_t) [pure] +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES void foo(sycl::device_selector &DeviceSelector) { (void)DeviceSelector.select_device(); } @@ -42,3 +43,4 @@ void foo(sycl::device_selector &DeviceSelector) { // CHECK-NEXT: 3 | sycl::device_selector::~device_selector() [deleting] // CHECK-NEXT: 4 | device sycl::device_selector::select_device() const // CHECK-NEXT: 5 | int sycl::device_selector::operator()(const device &) const [pure] +#endif diff --git a/sycl/test/check_device_code/abi/user_mangling.cpp b/sycl/test/check_device_code/abi/user_mangling.cpp index 69004b3e616d1..8e52770f24be6 100644 --- a/sycl/test/check_device_code/abi/user_mangling.cpp +++ b/sycl/test/check_device_code/abi/user_mangling.cpp @@ -70,8 +70,10 @@ void device_evt(sycl::device_event) {} // CHK-HOST: define dso_local void @_Z5eventN4sycl3_V15eventE({{.*}}) void event(sycl::event) {} +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES // CHK-HOST: define dso_local void @_Z15device_selectorRN4sycl3_V115device_selectorE({{.*}}) void device_selector(sycl::device_selector&) {} +#endif // CHK-HOST: define dso_local void @_Z7handlerRN4sycl3_V17handlerE({{.*}}) void handler(sycl::handler&) {} diff --git a/sycl/test/helpers.hpp b/sycl/test/helpers.hpp index 02fc14817151e..497565c203095 100644 --- a/sycl/test/helpers.hpp +++ b/sycl/test/helpers.hpp @@ -54,7 +54,8 @@ std::ostream &operator<<(std::ostream &Out, class TestQueue : public sycl::queue { public: - TestQueue(const sycl::device_selector &DevSelector, + template + TestQueue(const DeviceSelector &DevSelector, const sycl::property_list &PropList = {}) : sycl::queue( DevSelector, diff --git a/sycl/test/invoke_simd/invoke_simd.cpp b/sycl/test/invoke_simd/invoke_simd.cpp index a7d3e11983ebb..66c4e16f08021 100644 --- a/sycl/test/invoke_simd/invoke_simd.cpp +++ b/sycl/test/invoke_simd/invoke_simd.cpp @@ -45,9 +45,10 @@ ESIMD_CALLEE(float *A, esimd::simd b, int i) SYCL_ESIMD_FUNCTION { float SPMD_CALLEE(float *A, float b, int i) { return A[i] + b; } -class ESIMDSelector : public device_selector { +class ESIMDSelector { +public: // Require GPU device - virtual int operator()(const device &device) const { + int operator()(const device &device) const { if (const char *dev_filter = getenv("ONEAPI_DEVICE_SELECTOR")) { std::string filter_string(dev_filter); if (filter_string.find("gpu") != std::string::npos) diff --git a/sycl/test/warnings/sycl_2020_deprecations.cpp b/sycl/test/warnings/sycl_2020_deprecations.cpp index 30b41ea194772..962ac4d847120 100644 --- a/sycl/test/warnings/sycl_2020_deprecations.cpp +++ b/sycl/test/warnings/sycl_2020_deprecations.cpp @@ -165,6 +165,7 @@ int main() { // expected-warning@+1{{'accelerator_selector' is deprecated: Use the callable sycl::accelerator_selector_v instead.}} sycl::accelerator_selector as; +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES // expected-warning@+1{{Use SYCL 2020 callable device selectors instead.}} class user_defined_device_selector : public sycl::device_selector { public: @@ -240,6 +241,7 @@ int main() { 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 udq4{ctx, uds, ah}; +#endif Queue.submit([&](sycl::handler &CGH) { // expected-warning@+1{{'local' is deprecated: use `local_accessor` instead}} diff --git a/sycl/tools/sycl-ls/sycl-ls.cpp b/sycl/tools/sycl-ls/sycl-ls.cpp index 82c957afc45ed..cc518d9b2bf44 100644 --- a/sycl/tools/sycl-ls/sycl-ls.cpp +++ b/sycl/tools/sycl-ls/sycl-ls.cpp @@ -56,12 +56,12 @@ bool DiscardFilters; std::vector FilterEnvVars; // Trivial custom selector that selects a device of the given type. -class custom_selector : public device_selector { +class custom_selector { info::device_type MType; public: custom_selector(info::device_type Type) : MType(Type) {} - int operator()(const device &Dev) const override { + int operator()(const device &Dev) const { return Dev.get_info() == MType ? 1 : -1; } }; @@ -215,7 +215,8 @@ static void printDeviceInfo(const device &Device, bool Verbose, } } -static void printSelectorChoice(const device_selector &Selector, +template +static void printSelectorChoice(const SelectorT &Selector, const std::string &Prepend) { try { const auto &Device = device(Selector);