From 19c655076c9d7ce28a54e6f7ab2f58a762dd6cc1 Mon Sep 17 00:00:00 2001 From: Krzysztof Gibala Date: Tue, 24 Jan 2023 10:11:10 +0000 Subject: [PATCH] fix(l0): adjust getCacheProperties Use L3CacheSizeInKb value for cacheSize calculation Resolves: NEO-7655 Signed-off-by: Krzysztof Gibala --- level_zero/core/source/device/device_imp.cpp | 3 ++- .../unit_tests/sources/device/test_device.cpp | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index 5121cf24c3..5fbfc7a7c5 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -910,7 +910,8 @@ ze_result_t DeviceImp::getCacheProperties(uint32_t *pCount, ze_device_cache_prop } const auto &hardwareInfo = this->getHwInfo(); - pCacheProperties[0].cacheSize = hardwareInfo.gtSystemInfo.L3BankCount * 128 * KB; + uint32_t subDeviceCount = NEO::GfxCoreHelper::getSubDevicesCount(&hardwareInfo); + pCacheProperties[0].cacheSize = hardwareInfo.gtSystemInfo.L3CacheSizeInKb * subDeviceCount * KB; pCacheProperties[0].flags = 0; if (pCacheProperties->pNext) { diff --git a/level_zero/core/test/unit_tests/sources/device/test_device.cpp b/level_zero/core/test/unit_tests/sources/device/test_device.cpp index c25ea8f34e..3f4626c3df 100644 --- a/level_zero/core/test/unit_tests/sources/device/test_device.cpp +++ b/level_zero/core/test/unit_tests/sources/device/test_device.cpp @@ -1058,6 +1058,29 @@ TEST_F(DeviceTest, givenDeviceCachePropertiesThenAllPropertiesAreAssigned) { EXPECT_NE(deviceCacheProperties.cacheSize, deviceCachePropertiesBefore.cacheSize); } +TEST_F(DeviceTest, givenDeviceWithSubDevicesWhenQueriedForCacheSizeThenValueIsMultiplied) { + ze_device_cache_properties_t deviceCacheProperties = {}; + + auto rootDeviceIndex = device->getNEODevice()->getRootDeviceIndex(); + auto &hwInfo = *device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->getMutableHardwareInfo(); + auto singleRootDeviceCacheSize = hwInfo.gtSystemInfo.L3CacheSizeInKb * KB; + + hwInfo.gtSystemInfo.L3BankCount = 0u; + hwInfo.gtSystemInfo.MultiTileArchInfo.IsValid = true; + + uint32_t count = 0; + ze_result_t res = device->getCacheProperties(&count, nullptr); + EXPECT_EQ(ZE_RESULT_SUCCESS, res); + EXPECT_EQ(count, 1u); + + for (uint32_t subDevicesCount : {1, 2, 3}) { + hwInfo.gtSystemInfo.MultiTileArchInfo.TileCount = subDevicesCount; + res = device->getCacheProperties(&count, &deviceCacheProperties); + EXPECT_EQ(ZE_RESULT_SUCCESS, res); + EXPECT_EQ(deviceCacheProperties.cacheSize, singleRootDeviceCacheSize * subDevicesCount); + } +} + TEST_F(DeviceTest, givenDevicePropertiesStructureWhenDevicePropertiesCalledThenAllPropertiesAreAssigned) { ze_device_properties_t deviceProperties, devicePropertiesBefore; deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};