fix(l0): Fix cache properties for subdevice

total cache size calculation should use subdevice count
rather than MultiTileArchInfo to ensure correct size when subdevices
are queried

Related-to: LOCI-4217

Signed-off-by: Brandon Yates <brandon.yates@intel.com>
This commit is contained in:
Brandon Yates
2023-04-04 02:08:25 +00:00
committed by Compute-Runtime-Automation
parent 310380119a
commit 7dc4fd8dda
2 changed files with 22 additions and 11 deletions

View File

@@ -56,6 +56,8 @@
#include "level_zero/tools/source/metrics/metric.h"
#include "level_zero/tools/source/sysman/sysman.h"
#include <algorithm>
namespace NEO {
bool releaseFP64Override();
} // namespace NEO
@@ -921,7 +923,7 @@ ze_result_t DeviceImp::getCacheProperties(uint32_t *pCount, ze_device_cache_prop
}
const auto &hardwareInfo = this->getHwInfo();
uint32_t subDeviceCount = NEO::GfxCoreHelper::getSubDevicesCount(&hardwareInfo);
uint32_t subDeviceCount = std::max(this->numSubDevices, 1u);
pCacheProperties[0].cacheSize = hardwareInfo.gtSystemInfo.L3CacheSizeInKb * subDeviceCount * KB;
pCacheProperties[0].flags = 0;

View File

@@ -1056,27 +1056,36 @@ TEST_F(DeviceTest, givenDeviceCachePropertiesThenAllPropertiesAreAssigned) {
EXPECT_NE(deviceCacheProperties.cacheSize, deviceCachePropertiesBefore.cacheSize);
}
TEST_F(DeviceTest, givenDeviceWithSubDevicesWhenQueriedForCacheSizeThenValueIsMultiplied) {
using MultiSubDeviceCachePropertiesTest = Test<SingleRootMultiSubDeviceFixture>;
TEST_F(MultiSubDeviceCachePropertiesTest, 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);
res = device->getCacheProperties(&count, &deviceCacheProperties);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
EXPECT_EQ(deviceCacheProperties.cacheSize, singleRootDeviceCacheSize * numSubDevices);
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);
}
uint32_t subDeviceCount = numSubDevices;
std::vector<ze_device_handle_t> subDevices0(subDeviceCount);
res = device->getSubDevices(&subDeviceCount, subDevices0.data());
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
L0::Device *subDevice = Device::fromHandle(subDevices0[0]);
count = 0;
res = subDevice->getCacheProperties(&count, nullptr);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
EXPECT_EQ(count, 1u);
res = subDevice->getCacheProperties(&count, &deviceCacheProperties);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
EXPECT_EQ(deviceCacheProperties.cacheSize, singleRootDeviceCacheSize);
}
TEST_F(DeviceTest, givenDevicePropertiesStructureWhenDevicePropertiesCalledThenAllPropertiesAreAssigned) {