Skip to content
Closed
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
8 changes: 8 additions & 0 deletions sycl/include/sycl/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,21 @@ 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.
///
/// \param DeviceSelector SYCL 1.2.1 device_selector to be used (see 4.6.1.1).
__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.
Expand Down
41 changes: 39 additions & 2 deletions sycl/include/sycl/device_selector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand All @@ -46,14 +53,22 @@ 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
///
/// \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;
};
Expand All @@ -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;
};
Expand All @@ -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;
};
Expand All @@ -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;
};
Expand Down Expand Up @@ -122,13 +150,22 @@ void fill_aspect_vector(std::vector<aspect> &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 <typename DeviceSelector>
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
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<device_selector, DeviceSelector>>;
#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<int, DeviceSelector &, const device &> &&
!std::is_base_of_v<ext::oneapi::filter_selector, DeviceSelector>>;
#endif // __INTEL_PREVIEW_BREAKING_CHANGES

__SYCL_EXPORT device
select_device(const DSelectorInvocableType &DeviceSelectorInvocable);
Expand Down
5 changes: 4 additions & 1 deletion sycl/include/sycl/ext/oneapi/filter_selector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ inline namespace _V1 {

// Forward declarations
class device;
class device_selector;

@KornevNikita KornevNikita Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note - redundant FD. The filter_selector class uses device_selector as a base class and therefore needs #include.

#ifdef __SYCL_INTERNAL_API
namespace ONEAPI {
class filter_selector;
Expand All @@ -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}) {}
Expand Down
2 changes: 2 additions & 0 deletions sycl/include/sycl/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class __SYCL_EXPORT platform : public detail::OwnerLessBase<platform> {
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
Expand All @@ -95,6 +96,7 @@ class __SYCL_EXPORT platform : public detail::OwnerLessBase<platform> {
__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.
Expand Down
4 changes: 4 additions & 0 deletions sycl/include/sycl/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
: 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.
///
Expand All @@ -296,6 +297,7 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
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.
///
Expand All @@ -313,6 +315,7 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
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.
///
Expand All @@ -336,6 +339,7 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
"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.
Expand Down
1 change: 0 additions & 1 deletion sycl/source/detail/platform_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ namespace sycl {
inline namespace _V1 {

// Forward declaration
class device_selector;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note - redundant FD, not used in this file.

class device;

namespace detail {
Expand Down
4 changes: 4 additions & 0 deletions sycl/source/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
11 changes: 10 additions & 1 deletion sycl/source/device_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,11 @@ aspect_selector(const std::vector<aspect> &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); });
}

Expand Down Expand Up @@ -294,7 +298,12 @@ device filter_selector::select_device() const {
std::lock_guard<std::mutex> 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();

Expand Down
2 changes: 2 additions & 0 deletions sycl/source/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }

Expand Down
4 changes: 4 additions & 0 deletions sycl/source/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<device> Devs = SyclContext.get_devices();
Expand All @@ -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) {
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions sycl/test-e2e/Adapters/level_zero/interop-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion sycl/unittests/buffer/SubbufferLargeSize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading