Skip to content

Commit 5074ba7

Browse files
authored
[UR][L0] Support for Device Cacheline Size Query (#19155)
Signed-off-by: Neil R. Spruit <[email protected]>
1 parent a5bf268 commit 5074ba7

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

unified-runtime/source/adapters/level_zero/common.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,10 @@ template <> zes_structure_type_t getZesStructureType<zes_freq_properties_t>() {
345345
template <> zes_structure_type_t getZesStructureType<zes_power_properties_t>() {
346346
return ZES_STRUCTURE_TYPE_POWER_PROPERTIES;
347347
}
348+
template <>
349+
ze_structure_type_t getZeStructureType<ze_device_cache_line_size_ext_t>() {
350+
return ZE_STRUCTURE_TYPE_DEVICE_CACHELINE_SIZE_EXT;
351+
}
348352

349353
#ifdef ZE_INTEL_DEVICE_BLOCK_ARRAY_EXP_NAME
350354
template <>

unified-runtime/source/adapters/level_zero/device.cpp

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,9 +567,13 @@ ur_result_t urDeviceGetInfo(
567567
case UR_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE:
568568
return ReturnValue(UR_DEVICE_MEM_CACHE_TYPE_READ_WRITE_CACHE);
569569
case UR_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE:
570-
return ReturnValue(
571-
// TODO[1.0]: how to query cache line-size?
572-
uint32_t{1});
570+
if (Device->Platform->zeDriverExtensionMap.count(
571+
ZE_CACHELINE_SIZE_EXT_NAME)) {
572+
return ReturnValue(uint32_t{static_cast<uint32_t>(
573+
Device->ZeDeviceCacheLinePropertiesExt->cacheLineSize)});
574+
} else {
575+
return ReturnValue(uint32_t{1});
576+
}
573577
case UR_DEVICE_INFO_GLOBAL_MEM_CACHE_SIZE:
574578
return ReturnValue(uint64_t{Device->ZeDeviceCacheProperties->cacheSize});
575579
case UR_DEVICE_INFO_IP_VERSION:
@@ -1856,6 +1860,28 @@ ur_result_t ur_device_handle_t_::initialize(int SubSubDeviceOrdinal,
18561860
(ZeDevice, &Count, &Properties));
18571861
};
18581862

1863+
if (this->Platform->zeDriverExtensionMap.count(ZE_CACHELINE_SIZE_EXT_NAME)) {
1864+
ZeDeviceCacheLinePropertiesExt.Compute =
1865+
[ZeDevice](ze_device_cache_line_size_ext_t &Properties) {
1866+
// TODO: Since v1.0 there can be multiple cache properties.
1867+
// For now remember the first one, if any.
1868+
uint32_t Count = 0;
1869+
ZE_CALL_NOCHECK(zeDeviceGetCacheProperties,
1870+
(ZeDevice, &Count, nullptr));
1871+
if (Count > 0)
1872+
Count = 1;
1873+
ze_device_cache_properties_t P;
1874+
P.stype = ZE_STRUCTURE_TYPE_DEVICE_CACHE_PROPERTIES;
1875+
P.pNext = &Properties;
1876+
ZE_CALL_NOCHECK(zeDeviceGetCacheProperties, (ZeDevice, &Count, &P));
1877+
if (Properties.cacheLineSize == 0) {
1878+
// If cache line size is not set, use the default value.
1879+
Properties.cacheLineSize =
1880+
1; // Default cache line size property value.
1881+
}
1882+
};
1883+
}
1884+
18591885
ZeDeviceMutableCmdListsProperties.Compute =
18601886
[ZeDevice](
18611887
ZeStruct<ze_mutable_command_list_exp_properties_t> &Properties) {

unified-runtime/source/adapters/level_zero/device.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ struct ur_device_handle_t_ : ur_object {
223223
ZeCache<ZeStruct<ze_device_memory_access_properties_t>>
224224
ZeDeviceMemoryAccessProperties;
225225
ZeCache<ZeStruct<ze_device_cache_properties_t>> ZeDeviceCacheProperties;
226+
ZeCache<ZeStruct<ze_device_cache_line_size_ext_t>>
227+
ZeDeviceCacheLinePropertiesExt;
226228
ZeCache<ZeStruct<ze_device_ip_version_ext_t>> ZeDeviceIpVersionExt;
227229
ZeCache<struct ze_global_memsize> ZeGlobalMemSize;
228230
ZeCache<ZeStruct<ze_mutable_command_list_exp_properties_t>>

0 commit comments

Comments
 (0)