24 if (t == info::device_type::all) {
26 }
else if (ft != info::device_type::all && t != ft) {
27 throw sycl::invalid_parameter_error(
"No device of forced type.",
28 PI_ERROR_INVALID_OPERATION);
39 auto Plugin = detail::RT::getPlugin<backend::opencl>();
41 detail::pi::cast<pi_native_handle>(DeviceId),
nullptr, &Device);
44 impl = Platform->getOrMakeDeviceImpl(Device, Platform);
49 *
this = deviceSelector.select_device();
53 std::vector<device> devices;
60 for (
const auto &plt : thePlatforms) {
63 backend platformBackend = plt.get_backend();
69 std::vector<device> found_devices(plt.get_devices(deviceType));
70 if (!found_devices.empty())
71 devices.insert(devices.end(), found_devices.begin(), found_devices.end());
77 cl_device_id
device::get()
const {
return impl->get(); }
79 bool device::is_host()
const {
80 bool IsHost = impl->is_host();
81 assert(!IsHost &&
"device::is_host should not be called in implementation.");
93 template <info::partition_property prop>
95 return impl->create_sub_devices(ComputeUnits);
98 template __SYCL_EXPORT std::vector<device>
99 device::create_sub_devices<info::partition_property::partition_equally>(
100 size_t ComputeUnits)
const;
102 template <info::partition_property prop>
105 return impl->create_sub_devices(Counts);
108 template __SYCL_EXPORT std::vector<device>
109 device::create_sub_devices<info::partition_property::partition_by_counts>(
110 const std::vector<size_t> &Counts)
const;
112 template <info::partition_property prop>
115 return impl->create_sub_devices(AffinityDomain);
122 template <info::partition_property prop>
124 return impl->create_sub_devices();
131 return impl->has_extension(extension_name);
134 template <
typename Param>
137 return impl->template get_info<Param>();
142 __SYCL_EXPORT
device device::get_info<info::device::parent_device>()
const {
147 if (impl->isRootDevice())
148 throw invalid_object_error(
149 "No parent for device because it is not a subdevice",
150 PI_ERROR_INVALID_DEVICE);
152 return impl->template get_info<info::device::parent_device>();
156 __SYCL_EXPORT std::vector<sycl::aspect>
157 device::get_info<info::device::aspects>()
const {
158 std::vector<sycl::aspect> DeviceAspects{
159 #define __SYCL_ASPECT(ASPECT, ID) aspect::ASPECT,
160 #include <sycl/info/aspects.def>
164 auto UnsupportedAspects = std::remove_if(
165 DeviceAspects.begin(), DeviceAspects.end(), [&](aspect Aspect) {
167 return !impl->has(Aspect);
168 } catch (
const runtime_error &ex) {
169 if (ex.get_cl_code() == PI_ERROR_INVALID_DEVICE)
175 DeviceAspects.erase(UnsupportedAspects, DeviceAspects.end());
177 return DeviceAspects;
180 #define __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, PiCode) \
181 template __SYCL_EXPORT ReturnT device::get_info<info::device::Desc>() const;
183 #define __SYCL_PARAM_TRAITS_SPEC_SPECIALIZED(DescType, Desc, ReturnT, PiCode)
185 #include <sycl/info/device_traits.def>
186 #undef __SYCL_PARAM_TRAITS_SPEC_SPECIALIZED
187 #undef __SYCL_PARAM_TRAITS_SPEC
189 #define __SYCL_PARAM_TRAITS_SPEC(Namespace, DescType, Desc, ReturnT, PiCode) \
190 template __SYCL_EXPORT ReturnT \
191 device::get_info<Namespace::info::DescType::Desc>() const;
193 #include <sycl/info/ext_codeplay_device_traits.def>
194 #include <sycl/info/ext_intel_device_traits.def>
195 #include <sycl/info/ext_oneapi_device_traits.def>
196 #undef __SYCL_PARAM_TRAITS_SPEC
202 bool device::has(aspect Aspect)
const {
return impl->has(Aspect); }