Skip to content

Commit 86dc914

Browse files
[NFCI][SYCL] Change get_device_info_impl to operate on device_impl (#18125)
Previously, it used `DeviceImplPtr` (`std::shared_ptr<device_impl>`) but that isn't necessary and was preventing a future change to initialzie device aspects when creating `device_impl` object. Also, searching for a correct `std::shared_ptr` via `getOrMakeDeviceImpl` (e.g., in `device_impl::get_info`) is just wasteful.
1 parent 0b81e21 commit 86dc914

File tree

3 files changed

+187
-189
lines changed

3 files changed

+187
-189
lines changed

sycl/source/detail/allowlist.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,18 +428,20 @@ void applyAllowList(std::vector<ur_device_handle_t> &UrDevices,
428428
}
429429
// get DeviceVendorId value and put it to DeviceDesc
430430
uint32_t DeviceVendorIdUInt =
431-
sycl::detail::get_device_info<info::device::vendor_id>(DeviceImpl);
431+
sycl::detail::get_device_info<info::device::vendor_id>(
432+
*DeviceImpl.get());
432433
std::stringstream DeviceVendorIdHexStringStream;
433434
DeviceVendorIdHexStringStream << "0x" << std::hex << DeviceVendorIdUInt;
434435
const auto &DeviceVendorIdValue = DeviceVendorIdHexStringStream.str();
435436
DeviceDesc[DeviceVendorIdKeyName] = DeviceVendorIdValue;
436437
// get DriverVersion value and put it to DeviceDesc
437438
const std::string &DriverVersionValue =
438-
sycl::detail::get_device_info<info::device::driver_version>(DeviceImpl);
439+
sycl::detail::get_device_info<info::device::driver_version>(
440+
*DeviceImpl.get());
439441
DeviceDesc[DriverVersionKeyName] = DriverVersionValue;
440442
// get DeviceName value and put it to DeviceDesc
441443
const std::string &DeviceNameValue =
442-
sycl::detail::get_device_info<info::device::name>(DeviceImpl);
444+
sycl::detail::get_device_info<info::device::name>(*DeviceImpl.get());
443445
DeviceDesc[DeviceNameKeyName] = DeviceNameValue;
444446

445447
// check if we can allow device with such device description DeviceDesc

sycl/source/detail/device_impl.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ platform device_impl::get_platform() const {
109109

110110
template <typename Param>
111111
typename Param::return_type device_impl::get_info() const {
112-
return get_device_info<Param>(
113-
MPlatform->getOrMakeDeviceImpl(MDevice, MPlatform));
112+
return get_device_info<Param>(*this);
114113
}
115114
// Explicitly instantiate all device info traits
116115
#define __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, PiCode) \
@@ -401,17 +400,17 @@ bool device_impl::has(aspect Aspect) const {
401400
case aspect::ext_oneapi_cuda_cluster_group:
402401
return get_info<info::device::ext_oneapi_cuda_cluster_group>();
403402
case aspect::usm_atomic_host_allocations:
404-
return (get_device_info_impl<ur_device_usm_access_capability_flags_t,
405-
info::device::usm_host_allocations>::
406-
get(MPlatform->getDeviceImpl(MDevice)) &
407-
UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_CONCURRENT_ACCESS);
403+
return (
404+
get_device_info_impl<ur_device_usm_access_capability_flags_t,
405+
info::device::usm_host_allocations>::get(*this) &
406+
UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_CONCURRENT_ACCESS);
408407
case aspect::usm_shared_allocations:
409408
return get_info<info::device::usm_shared_allocations>();
410409
case aspect::usm_atomic_shared_allocations:
411-
return (get_device_info_impl<ur_device_usm_access_capability_flags_t,
412-
info::device::usm_shared_allocations>::
413-
get(MPlatform->getDeviceImpl(MDevice)) &
414-
UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_CONCURRENT_ACCESS);
410+
return (
411+
get_device_info_impl<ur_device_usm_access_capability_flags_t,
412+
info::device::usm_shared_allocations>::get(*this) &
413+
UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ATOMIC_CONCURRENT_ACCESS);
415414
case aspect::usm_restricted_shared_allocations:
416415
return get_info<info::device::usm_restricted_shared_allocations>();
417416
case aspect::usm_system_allocations:

0 commit comments

Comments
 (0)