21 inline namespace _V1 {
28 "No device of forced type.");
36 auto Plugin = sycl::detail::ur::getPlugin<backend::opencl>();
39 ur_device_handle_t Device;
40 Plugin->call(urDeviceCreateWithNativeHandle,
41 detail::ur::cast<ur_native_handle_t>(DeviceId),
42 Plugin->getUrPlatforms()[0],
nullptr, &Device);
45 impl = Platform->getOrMakeDeviceImpl(Device, Platform);
46 Plugin->call(urDeviceRetain, impl->getHandleRef());
50 *
this = deviceSelector.select_device();
54 std::vector<device> devices;
59 for (
const auto &plt : thePlatforms) {
61 backend platformBackend = plt.get_backend();
65 std::vector<device> found_devices(plt.get_devices(deviceType));
66 if (!found_devices.empty())
67 devices.insert(devices.end(), found_devices.begin(), found_devices.end());
73 cl_device_id
device::get()
const {
return impl->get(); }
83 template <info::partition_property prop>
85 return impl->create_sub_devices(ComputeUnits);
88 template __SYCL_EXPORT std::vector<device>
89 device::create_sub_devices<info::partition_property::partition_equally>(
90 size_t ComputeUnits)
const;
92 template <info::partition_property prop>
95 return impl->create_sub_devices(Counts);
98 template __SYCL_EXPORT std::vector<device>
99 device::create_sub_devices<info::partition_property::partition_by_counts>(
100 const std::vector<size_t> &Counts)
const;
102 template <info::partition_property prop>
105 return impl->create_sub_devices(AffinityDomain);
112 template <info::partition_property prop>
114 return impl->create_sub_devices();
121 return impl->has_extension(ext_name.data());
124 template <
typename Param>
125 detail::ABINeutralT_t<typename detail::is_device_info_desc<Param>::return_type>
126 device::get_info_impl()
const {
133 device::get_info_impl<info::device::parent_device>()
const {
138 if (impl->isRootDevice())
140 "No parent for device because it is not a subdevice");
142 return impl->template get_info<info::device::parent_device>();
146 __SYCL_EXPORT std::vector<sycl::aspect>
147 device::get_info_impl<info::device::aspects>()
const {
148 std::vector<sycl::aspect> DeviceAspects{
149 #define __SYCL_ASPECT(ASPECT, ID) aspect::ASPECT,
150 #include <sycl/info/aspects.def>
154 auto UnsupportedAspects =
155 std::remove_if(DeviceAspects.begin(), DeviceAspects.end(),
156 [&](aspect Aspect) { return !impl->has(Aspect); });
158 DeviceAspects.erase(UnsupportedAspects, DeviceAspects.end());
160 return DeviceAspects;
164 __SYCL_EXPORT
bool device::get_info_impl<info::device::image_support>()
const {
167 return impl->template get_info<info::device::image_support>();
170 #define __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, PiCode) \
171 template __SYCL_EXPORT detail::ABINeutralT_t<ReturnT> \
172 device::get_info_impl<info::device::Desc>() const;
174 #define __SYCL_PARAM_TRAITS_SPEC_SPECIALIZED(DescType, Desc, ReturnT, PiCode)
176 #include <sycl/info/device_traits.def>
177 #undef __SYCL_PARAM_TRAITS_SPEC_SPECIALIZED
178 #undef __SYCL_PARAM_TRAITS_SPEC
180 #define __SYCL_PARAM_TRAITS_SPEC(Namespace, DescType, Desc, ReturnT, PiCode) \
181 template __SYCL_EXPORT detail::ABINeutralT_t<ReturnT> \
182 device::get_info_impl<Namespace::info::DescType::Desc>() const;
184 #include <sycl/info/ext_codeplay_device_traits.def>
185 #include <sycl/info/ext_intel_device_traits.def>
186 #include <sycl/info/ext_oneapi_device_traits.def>
187 #undef __SYCL_PARAM_TRAITS_SPEC
189 template <
typename Param>
190 typename detail::is_backend_info_desc<Param>::return_type
192 return impl->get_backend_info<Param>();
195 #define __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, Picode) \
196 template __SYCL_EXPORT ReturnT \
197 device::get_backend_info<info::DescType::Desc>() const;
199 #include <sycl/info/sycl_backend_traits.def>
201 #undef __SYCL_PARAM_TRAITS_SPEC
205 ur_native_handle_t device::getNative()
const {
return impl->getNative(); }
207 bool device::has(aspect Aspect)
const {
return impl->has(Aspect); }
210 ur_device_handle_t Device = impl->getHandleRef();
211 ur_device_handle_t Peer = peer.impl->getHandleRef();
212 if (Device != Peer) {
213 auto Plugin = impl->getPlugin();
214 Plugin->call(urUsmP2PEnablePeerAccessExp, Device, Peer);
219 ur_device_handle_t Device = impl->getHandleRef();
220 ur_device_handle_t Peer = peer.impl->getHandleRef();
221 if (Device != Peer) {
222 auto Plugin = impl->getPlugin();
223 Plugin->call(urUsmP2PDisablePeerAccessExp, Device, Peer);
229 ur_device_handle_t Device = impl->getHandleRef();
230 ur_device_handle_t Peer = peer.impl->getHandleRef();
232 if (Device == Peer) {
239 ur_exp_peer_info_t UrAttr = [&]() {
242 return UR_EXP_PEER_INFO_UR_PEER_ACCESS_SUPPORTED;
244 return UR_EXP_PEER_INFO_UR_PEER_ATOMICS_SUPPORTED;
247 "Unrecognized peer access attribute.");
249 auto Plugin = impl->getPlugin();
250 Plugin->call(urUsmP2PPeerAccessGetInfoExp, Device, Peer, UrAttr,
sizeof(
int),
251 &value, &returnSize);
258 return impl->extOneapiArchitectureIs(arch);
263 return impl->extOneapiArchitectureIs(category);
269 return impl->extOneapiCanCompile(Language);
273 ur_device_handle_t Device = impl->getHandleRef();
274 auto Plugin = impl->getPlugin();
275 uint32_t ipVersion = 0;
277 Plugin->call_nocheck(urDeviceGetInfo, Device, UR_DEVICE_INFO_IP_VERSION,
278 sizeof(uint32_t), &ipVersion,
nullptr);
279 if (res != UR_RESULT_SUCCESS)
283 Feature.
data(), ipVersion);
288 ur_device_handle_t Device = impl->getHandleRef();
289 auto Plugin = impl->getPlugin();
290 uint32_t ipVersion = 0;
292 Plugin->call_nocheck(urDeviceGetInfo, Device, UR_DEVICE_INFO_IP_VERSION,
293 sizeof(uint32_t), &ipVersion,
nullptr);
294 if (res != UR_RESULT_SUCCESS)
304 ur_device_handle_t Device = impl->getHandleRef();
305 auto Plugin = impl->getPlugin();
306 uint32_t ipVersion = 0;
308 Plugin->call_nocheck(urDeviceGetInfo, Device, UR_DEVICE_INFO_IP_VERSION,
309 sizeof(uint32_t), &ipVersion,
nullptr);
310 if (res != UR_RESULT_SUCCESS)
314 Name.
data(), VersionPtr, ipVersion);
318 ur_device_handle_t Device = impl->getHandleRef();
319 auto Plugin = impl->getPlugin();
320 uint32_t ipVersion = 0;
322 Plugin->call_nocheck(urDeviceGetInfo, Device, UR_DEVICE_INFO_IP_VERSION,
323 sizeof(uint32_t), &ipVersion,
nullptr);
324 if (res != UR_RESULT_SUCCESS)
static const char * get()
bool backendCompatible(backend Backend)
const char * data() const noexcept
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
bool ext_oneapi_supports_cl_extension(const std::string &name, ext::oneapi::experimental::cl_version *version=nullptr) const
If the device supports kernel bundles using the OpenCL extension identified by name and if version is...
bool ext_oneapi_can_access_peer(const device &peer, ext::oneapi::peer_access value=ext::oneapi::peer_access::access_supported)
detail::is_backend_info_desc< Param >::return_type get_backend_info() const
Queries this SYCL device for SYCL backend-specific information.
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 ext_oneapi_can_compile(ext::oneapi::experimental::source_language Language)
kernel_compiler extension
backend get_backend() const noexcept
Returns the backend associated with this device.
bool ext_oneapi_architecture_is(ext::oneapi::experimental::architecture arch)
Indicates if the SYCL device architecture equals to the one passed to the function.
bool ext_oneapi_supports_cl_c_version(const ext::oneapi::experimental::cl_version &Version) const
Indicates if the device supports kernel bundles written in a particular OpenCL C version.
bool is_cpu() const
Get instance of device.
bool ext_oneapi_supports_cl_c_feature(const std::string &Feature)
Indicates if the device supports a given feature when compiling the OpenCL C language.
std::vector< device > create_sub_devices() const
Partition device into sub devices.
void ext_oneapi_enable_peer_access(const device &peer)
void ext_oneapi_disable_peer_access(const device &peer)
std::string ext_oneapi_cl_profile() const
Retrieve the OpenCl Device Profile.
device()
Constructs a SYCL device instance using the default device.
platform get_platform() const
Get associated SYCL platform.
bool has(aspect Aspect) const __SYCL_WARN_IMAGE_ASPECT(Aspect)
Indicates if the SYCL device has the given feature.
constexpr tuple_element< I, tuple< Types... > >::type & get(sycl::detail::tuple< Types... > &Arg) noexcept
auto convert_to_abi_neutral(ParamT &&Info)
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_by_affinity_domain
@ ext_intel_partition_by_cslice
partition_affinity_domain
int default_selector_v(const device &dev)
std::error_code make_error_code(sycl::errc E) noexcept
Constructs an error code using e and sycl_category()
_Abi const simd< _Tp, _Abi > & noexcept
C++ utilities for Unified Runtime integration.