19 device_impl::device_impl()
20 : MIsHostDevice(true), MPlatform(
platform_impl::getHostPlatformImpl()),
22 MIsAssertFailSupported(true) {}
26 :
device_impl(InteropDeviceHandle, nullptr, nullptr, Plugin) {}
39 : MDevice(
Device), MIsHostDevice(false) {
41 bool InteroperabilityConstructor =
false;
43 assert(InteropDeviceHandle);
48 InteropDeviceHandle,
nullptr, &MDevice);
49 InteroperabilityConstructor =
true;
61 if (!InteroperabilityConstructor) {
74 MIsAssertFailSupported =
89 auto SupportedDomains = get_info<info::device::partition_affinity_domains>();
90 return std::find(SupportedDomains.begin(), SupportedDomains.end(),
91 AffinityDomain) != SupportedDomains.end();
96 throw invalid_object_error(
97 "This instance of device doesn't support OpenCL interoperability.",
98 PI_ERROR_INVALID_DEVICE);
102 return pi::cast<cl_device_id>(
getNative());
106 return createSyclObjFromImpl<platform>(MPlatform);
114 std::string AllExtensionNames =
117 return (AllExtensionNames.find(ExtensionName) != std::string::npos);
121 auto SupportedProperties = get_info<info::device::partition_properties>();
122 return std::find(SupportedProperties.begin(), SupportedProperties.end(),
123 Prop) != SupportedProperties.end();
128 size_t SubDevicesCount)
const {
130 std::vector<RT::PiDevice> SubDevices(SubDevicesCount);
134 MDevice, Properties, SubDevicesCount, SubDevices.data(),
135 &ReturnedSubDevices);
136 if (ReturnedSubDevices != SubDevicesCount) {
139 "Could not partition to the specified number of sub-devices");
145 std::vector<device> res;
148 device sycl_device = detail::createSyclObjFromImpl<device>(
149 MPlatform->getOrMakeDeviceImpl(a_pi_device, MPlatform));
150 res.push_back(sycl_device);
160 "Partitioning to subdevices of the host device is not implemented yet",
161 PI_ERROR_INVALID_DEVICE);
164 throw cl::sycl::feature_not_supported();
168 auto MaxComputeUnits = get_info<info::device::max_compute_units>();
169 if (ComputeUnits > MaxComputeUnits)
171 "Total counts exceed max compute units");
173 size_t SubDevicesCount = MaxComputeUnits / ComputeUnits;
186 "Partitioning to subdevices of the host device is not implemented yet",
187 PI_ERROR_INVALID_DEVICE);
190 throw cl::sycl::feature_not_supported();
194 std::vector<pi_device_partition_property> Properties(P, P + 3);
197 auto It = Properties.begin() + 1;
198 size_t TotalCounts = 0;
199 size_t NonZeroCounts = 0;
200 for (
auto Count : Counts) {
201 TotalCounts += Count;
202 NonZeroCounts += (Count != 0) ? 1 : 0;
203 It = Properties.insert(It, Count);
210 if (NonZeroCounts > get_info<info::device::partition_max_sub_devices>())
212 "Total non-zero counts exceed max sub-devices");
218 if (TotalCounts > get_info<info::device::max_compute_units>())
220 "Total counts exceed max compute units");
231 "Partitioning to subdevices of the host device is not implemented yet",
232 PI_ERROR_INVALID_DEVICE);
237 throw cl::sycl::feature_not_supported();
246 MDevice, Properties, 0,
nullptr, &SubDevicesCount);
261 size_t return_size = 0;
280 return get_info<info::device::ext_oneapi_bfloat16>();
281 case aspect::int64_base_atomics:
283 case aspect::int64_extended_atomics:
286 return get_info<info::device::atomic64>();
288 return get_info<info::device::image_support>();
290 return get_info<info::device::is_compiler_available>();
292 return get_info<info::device::is_linker_available>();
294 return get_info<info::device::queue_profiling>();
296 return get_info<info::device::usm_device_allocations>();
298 return get_info<info::device::usm_host_allocations>();
306 return get_info<info::device::usm_shared_allocations>();
315 return get_info<info::device::usm_restricted_shared_allocations>();
317 return get_info<info::device::usm_system_allocations>();
325 &device_type, &return_size) == PI_SUCCESS;
330 &return_size) == PI_SUCCESS;
334 &device_type, &return_size) == PI_SUCCESS;
339 &return_size) == PI_SUCCESS;
344 &return_size) == PI_SUCCESS;
349 &return_size) == PI_SUCCESS;
353 if (Result != PI_SUCCESS) {
357 assert(return_size <= 16);
358 unsigned char UUID[16];
362 nullptr) == PI_SUCCESS;
368 return get_info<info::device::ext_oneapi_srgb>();
372 int async_barrier_supported;
373 bool call_successful =
376 &async_barrier_supported,
nullptr) == PI_SUCCESS;
377 return call_successful && async_barrier_supported;
380 throw runtime_error(
"This device aspect has not been implemented yet.",
381 PI_ERROR_INVALID_DEVICE);
386 static std::shared_ptr<device_impl> HostImpl =
387 std::make_shared<device_impl>();
393 return MIsAssertFailSupported;
397 std::call_once(MDeviceNameFlag,
398 [
this]() { MDeviceName = get_info<info::device::name>(); });