diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index 1a2faac5589e1..d5abb4feed9d8 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -761,6 +761,12 @@ pi_result _pi_device::initialize(int SubSubDeviceOrdinal, (ZeDevice, &Count, Properties.data())); }; + ZeDeviceMemoryAccessProperties.Compute = + [ZeDevice](ze_device_memory_access_properties_t &Properties) { + ZE_CALL_NOCHECK(zeDeviceGetMemoryAccessProperties, + (ZeDevice, &Properties)); + }; + ZeDeviceCacheProperties.Compute = [ZeDevice](ze_device_cache_properties_t &Properties) { // TODO: Since v1.0 there can be multiple cache properties. @@ -2672,14 +2678,33 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName, case PI_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT: case PI_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT: case PI_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT: { - pi_uint64 Supported = 0; - // TODO[1.0]: how to query for USM support now? - if (true) { - // TODO: Use ze_memory_access_capabilities_t - Supported = PI_USM_ACCESS | PI_USM_ATOMIC_ACCESS | - PI_USM_CONCURRENT_ACCESS | PI_USM_CONCURRENT_ATOMIC_ACCESS; - } - return ReturnValue(Supported); + auto MapCaps = [](const ze_memory_access_cap_flags_t &ZeCapabilities) { + pi_uint64 Capabilities = 0; + if (ZeCapabilities & ZE_MEMORY_ACCESS_CAP_FLAG_RW) + Capabilities |= PI_USM_ACCESS; + if (ZeCapabilities & ZE_MEMORY_ACCESS_CAP_FLAG_ATOMIC) + Capabilities |= PI_USM_ATOMIC_ACCESS; + if (ZeCapabilities & ZE_MEMORY_ACCESS_CAP_FLAG_CONCURRENT) + Capabilities |= PI_USM_CONCURRENT_ACCESS; + if (ZeCapabilities & ZE_MEMORY_ACCESS_CAP_FLAG_CONCURRENT_ATOMIC) + Capabilities |= PI_USM_CONCURRENT_ATOMIC_ACCESS; + return Capabilities; + }; + auto &Props = Device->ZeDeviceMemoryAccessProperties; + switch (ParamName) { + case PI_DEVICE_INFO_USM_HOST_SUPPORT: + return ReturnValue(MapCaps(Props->hostAllocCapabilities)); + case PI_DEVICE_INFO_USM_DEVICE_SUPPORT: + return ReturnValue(MapCaps(Props->deviceAllocCapabilities)); + case PI_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT: + return ReturnValue(MapCaps(Props->sharedSingleDeviceAllocCapabilities)); + case PI_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT: + return ReturnValue(MapCaps(Props->sharedCrossDeviceAllocCapabilities)); + case PI_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT: + return ReturnValue(MapCaps(Props->sharedSystemAllocCapabilities)); + default: + die("piDeviceGetInfo: enexpected ParamName."); + } } // intel extensions for GPU information diff --git a/sycl/plugins/level_zero/pi_level_zero.hpp b/sycl/plugins/level_zero/pi_level_zero.hpp index 2892bd52febeb..b99163f619bae 100644 --- a/sycl/plugins/level_zero/pi_level_zero.hpp +++ b/sycl/plugins/level_zero/pi_level_zero.hpp @@ -139,6 +139,10 @@ template <> ze_structure_type_t getZeStructureType() { return ZE_STRUCTURE_TYPE_DEVICE_MEMORY_PROPERTIES; } +template <> +ze_structure_type_t getZeStructureType() { + return ZE_STRUCTURE_TYPE_DEVICE_MEMORY_ACCESS_PROPERTIES; +} template <> ze_structure_type_t getZeStructureType() { return ZE_STRUCTURE_TYPE_MODULE_PROPERTIES; } @@ -384,6 +388,8 @@ struct _pi_device : _pi_object { ZeCache> ZeDeviceModuleProperties; ZeCache>> ZeDeviceMemoryProperties; + ZeCache> + ZeDeviceMemoryAccessProperties; ZeCache> ZeDeviceCacheProperties; }; diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index 69dec907448dc..243ca75b5f808 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -262,7 +262,7 @@ bool device_impl::has(aspect Aspect) const { (get_device_info< pi_usm_capabilities, info::device::usm_host_allocations>::get(MDevice, getPlugin()) & - PI_USM_ATOMIC_ACCESS); + PI_USM_CONCURRENT_ATOMIC_ACCESS); case aspect::usm_shared_allocations: return get_info(); case aspect::usm_atomic_shared_allocations: @@ -271,7 +271,7 @@ bool device_impl::has(aspect Aspect) const { pi_usm_capabilities, info::device::usm_shared_allocations>::get(MDevice, getPlugin()) & - PI_USM_ATOMIC_ACCESS); + PI_USM_CONCURRENT_ATOMIC_ACCESS); case aspect::usm_restricted_shared_allocations: return get_info(); case aspect::usm_system_allocations: