20 inline namespace _V1 {
26 throw sycl::invalid_parameter_error(
"No device of forced type.",
27 PI_ERROR_INVALID_OPERATION);
38 auto Plugin = sycl::detail::pi::getPlugin<backend::opencl>();
40 detail::pi::cast<pi_native_handle>(DeviceId),
nullptr, &Device);
43 impl = Platform->getOrMakeDeviceImpl(Device, Platform);
48 *
this = deviceSelector.select_device();
52 std::vector<device> devices;
57 for (
const auto &plt : thePlatforms) {
59 backend platformBackend = plt.get_backend();
63 std::vector<device> found_devices(plt.get_devices(deviceType));
64 if (!found_devices.empty())
65 devices.insert(devices.end(), found_devices.begin(), found_devices.end());
71 cl_device_id
device::get()
const {
return impl->get(); }
73 bool device::is_host()
const {
74 bool IsHost = impl->is_host();
75 assert(!IsHost &&
"device::is_host should not be called in implementation.");
87 template <info::partition_property prop>
89 return impl->create_sub_devices(ComputeUnits);
92 template __SYCL_EXPORT std::vector<device>
93 device::create_sub_devices<info::partition_property::partition_equally>(
94 size_t ComputeUnits)
const;
96 template <info::partition_property prop>
99 return impl->create_sub_devices(Counts);
102 template __SYCL_EXPORT std::vector<device>
103 device::create_sub_devices<info::partition_property::partition_by_counts>(
104 const std::vector<size_t> &Counts)
const;
106 template <info::partition_property prop>
109 return impl->create_sub_devices(AffinityDomain);
116 template <info::partition_property prop>
118 return impl->create_sub_devices();
125 return impl->has_extension(extension_name);
128 template <
typename Param>
130 device::get_info_impl()
const {
137 device::get_info_impl<info::device::parent_device>()
const {
142 if (impl->isRootDevice())
143 throw invalid_object_error(
144 "No parent for device because it is not a subdevice",
145 PI_ERROR_INVALID_DEVICE);
147 return impl->template get_info<info::device::parent_device>();
151 __SYCL_EXPORT std::vector<sycl::aspect>
152 device::get_info_impl<info::device::aspects>()
const {
153 std::vector<sycl::aspect> DeviceAspects{
154 #define __SYCL_ASPECT(ASPECT, ID) aspect::ASPECT,
155 #include <sycl/info/aspects.def>
159 auto UnsupportedAspects = std::remove_if(
160 DeviceAspects.begin(), DeviceAspects.end(), [&](aspect Aspect) {
162 return !impl->has(Aspect);
163 } catch (
const runtime_error &ex) {
164 if (ex.get_cl_code() == PI_ERROR_INVALID_DEVICE)
170 DeviceAspects.erase(UnsupportedAspects, DeviceAspects.end());
172 return DeviceAspects;
176 __SYCL_EXPORT
bool device::get_info_impl<info::device::image_support>()
const {
179 return impl->template get_info<info::device::image_support>();
182 #define __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, PiCode) \
183 template __SYCL_EXPORT detail::ABINeutralT_t<ReturnT> \
184 device::get_info_impl<info::device::Desc>() const;
186 #define __SYCL_PARAM_TRAITS_SPEC_SPECIALIZED(DescType, Desc, ReturnT, PiCode)
188 #include <sycl/info/device_traits.def>
189 #undef __SYCL_PARAM_TRAITS_SPEC_SPECIALIZED
190 #undef __SYCL_PARAM_TRAITS_SPEC
192 #define __SYCL_PARAM_TRAITS_SPEC(Namespace, DescType, Desc, ReturnT, PiCode) \
193 template __SYCL_EXPORT detail::ABINeutralT_t<ReturnT> \
194 device::get_info_impl<Namespace::info::DescType::Desc>() const;
196 #include <sycl/info/ext_codeplay_device_traits.def>
197 #include <sycl/info/ext_intel_device_traits.def>
198 #include <sycl/info/ext_oneapi_device_traits.def>
199 #undef __SYCL_PARAM_TRAITS_SPEC
201 template <
typename Param>
202 typename detail::is_backend_info_desc<Param>::return_type
203 device::get_backend_info()
const {
204 return impl->get_backend_info<Param>();
207 #define __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, Picode) \
208 template __SYCL_EXPORT ReturnT \
209 device::get_backend_info<info::DescType::Desc>() const;
211 #include <sycl/info/sycl_backend_traits.def>
213 #undef __SYCL_PARAM_TRAITS_SPEC
219 bool device::has(aspect Aspect)
const {
return impl->has(Aspect); }
221 void device::ext_oneapi_enable_peer_access(
const device &peer) {
224 if (Device != Peer) {
225 auto Plugin = impl->getPlugin();
230 void device::ext_oneapi_disable_peer_access(
const device &peer) {
233 if (Device != Peer) {
234 auto Plugin = impl->getPlugin();
239 bool device::ext_oneapi_can_access_peer(
const device &peer,
244 if (Device == Peer) {
253 case ext::oneapi::peer_access::access_supported:
255 case ext::oneapi::peer_access::atomics_supported:
259 "Unrecognized peer access attribute.");
261 auto Plugin = impl->getPlugin();
263 Device, Peer, PiAttr,
sizeof(int), &value, &returnSize);
268 bool device::ext_oneapi_architecture_is(
270 return impl->extOneapiArchitectureIs(arch);
273 bool device::ext_oneapi_architecture_is(
275 return impl->extOneapiArchitectureIs(category);
279 bool device::ext_oneapi_can_compile(
281 return impl->extOneapiCanCompile(Language);
284 bool device::ext_oneapi_supports_cl_c_feature(
const std::string &Feature) {
286 auto Plugin = impl->getPlugin();
287 uint32_t ipVersion = 0;
290 &ipVersion,
nullptr);
291 if (res != PI_SUCCESS)
298 bool device::ext_oneapi_supports_cl_c_version(
301 auto Plugin = impl->getPlugin();
302 uint32_t ipVersion = 0;
305 &ipVersion,
nullptr);
306 if (res != PI_SUCCESS)
313 bool device::ext_oneapi_supports_cl_extension(
314 const std::string &Name,
317 auto Plugin = impl->getPlugin();
318 uint32_t ipVersion = 0;
321 &ipVersion,
nullptr);
322 if (res != PI_SUCCESS)
326 Name, VersionPtr, ipVersion);
329 std::string device::ext_oneapi_cl_profile()
const {
331 auto Plugin = impl->getPlugin();
332 uint32_t ipVersion = 0;
335 &ipVersion,
nullptr);
336 if (res != PI_SUCCESS)
static const char * get()
bool backendCompatible(backend Backend)
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
bool is_accelerator() const
Check if device is an accelerator device.
bool is_gpu() const
Check if device is a GPU device.
bool has_extension(const std::string &extension_name) const
Check SYCL extension support by device.
static std::vector< device > get_devices(info::device_type deviceType=info::device_type::all)
Query available SYCL devices.
bool is_cpu() const
Check if device is a CPU device.
std::vector< device > create_sub_devices() const
Partition device into sub devices.
device()
Constructs a SYCL device instance using the default device.
platform get_platform() const
Get associated SYCL platform.
class __SYCL2020_DEPRECATED("Host device is no longer supported.") host_selector int default_selector_v(const device &dev)
Selects SYCL host device.
constexpr tuple_element< I, tuple< Types... > >::type & get(sycl::detail::tuple< Types... > &Arg) noexcept
auto convert_to_abi_neutral(ParamT &&Info)
typename ABINeutralT< T >::type ABINeutralT_t
void force_type(info::device_type &t, const info::device_type &ft)
bool OpenCLC_Feature_Available(const std::string &Feature, uint32_t IPVersion)
bool OpenCLC_Supports_Extension(const std::string &Name, ext::oneapi::experimental::cl_version *VersionPtr, uint32_t IPVersion)
bool OpenCLC_Supports_Version(const ext::oneapi::experimental::cl_version &Version, uint32_t IPVersion)
std::string OpenCLC_Profile(uint32_t IPVersion)
partition_affinity_domain
@ partition_by_affinity_domain
@ ext_intel_partition_by_cslice
std::error_code make_error_code(sycl::errc E) noexcept
Constructs an error code using e and sycl_category()
pi_result piextDisablePeerAccess(pi_device command_device, pi_device peer_device)
pi_result piextEnablePeerAccess(pi_device command_device, pi_device peer_device)
uintptr_t pi_native_handle
@ PI_EXT_ONEAPI_DEVICE_INFO_IP_VERSION
pi_result piDeviceGetInfo(pi_device device, pi_device_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
Returns requested info for provided native device Return PI_DEVICE_INFO_EXTENSION_DEVICELIB_ASSERT fo...
pi_result piextDeviceCreateWithNativeHandle(pi_native_handle nativeHandle, pi_platform platform, pi_device *device)
Creates PI device object from a native handle.
pi_result piDeviceRetain(pi_device device)
pi_result piextPeerAccessGetInfo(pi_device command_device, pi_device peer_device, pi_peer_attr attr, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
@ PI_PEER_ACCESS_SUPPORTED
returns a uint32_t: 1 if P2P Access is supported otherwise P2P Access is not supported.
@ PI_PEER_ATOMICS_SUPPORTED
returns a uint32_t: 1 if Atomic operations are supported over the P2P link, otherwise such operations...
_Abi const simd< _Tp, _Abi > & noexcept