fix: Add coverage for all memory types in L0 API

Related-To: NEO-12807
Signed-off-by: Krzysztof Sprzaczkowski <krzysztof.sprzaczkowski@intel.com>
This commit is contained in:
Krzysztof Sprzaczkowski
2025-05-20 14:26:03 +00:00
committed by Compute-Runtime-Automation
parent 88820a414f
commit b0db130df8
2 changed files with 49 additions and 9 deletions

View File

@@ -718,10 +718,26 @@ ze_result_t DeviceImp::getPciProperties(ze_pci_ext_properties_t *pPciProperties)
return ZE_RESULT_SUCCESS;
}
const char *DeviceImp::getDeviceMemoryName() {
constexpr std::array<uint32_t, 4> hbmTypeIds = {2, 3, 5, 8};
static const std::map<uint32_t, const char *> memoryTypeNames = {
{0, "DDR"},
{1, "DDR"},
{2, "HBM"},
{3, "HBM"},
{4, "DDR"},
{5, "HBM"},
{6, "DDR"},
{7, "DDR"},
{8, "HBM"},
{9, "HBM"},
};
return std::find(hbmTypeIds.begin(), hbmTypeIds.end(), getHwInfo().gtSystemInfo.MemoryType) != hbmTypeIds.end() ? "HBM" : "DDR";
const char *DeviceImp::getDeviceMemoryName() {
auto it = memoryTypeNames.find(getHwInfo().gtSystemInfo.MemoryType);
if (it != memoryTypeNames.end()) {
return it->second;
}
UNRECOVERABLE_IF(true);
return "unknown memory type";
}
ze_result_t DeviceImp::getMemoryProperties(uint32_t *pCount, ze_device_memory_properties_t *pMemProperties) {
@@ -762,14 +778,20 @@ ze_result_t DeviceImp::getMemoryProperties(uint32_t *pCount, ze_device_memory_pr
auto extendedProperties = reinterpret_cast<ze_device_memory_ext_properties_t *>(pNext);
// GT_MEMORY_TYPES map to ze_device_memory_ext_type_t
const std::array<ze_device_memory_ext_type_t, 5> sysInfoMemType = {
const std::array<ze_device_memory_ext_type_t, 10> sysInfoMemType = {
ZE_DEVICE_MEMORY_EXT_TYPE_LPDDR4,
ZE_DEVICE_MEMORY_EXT_TYPE_LPDDR5,
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
ZE_DEVICE_MEMORY_EXT_TYPE_GDDR6,
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
ZE_DEVICE_MEMORY_EXT_TYPE_DDR5,
ZE_DEVICE_MEMORY_EXT_TYPE_GDDR7,
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
};
UNRECOVERABLE_IF(hwInfo.gtSystemInfo.MemoryType >= sizeof(sysInfoMemType));
extendedProperties->type = sysInfoMemType[hwInfo.gtSystemInfo.MemoryType];
uint32_t enabledSubDeviceCount = 1;

View File

@@ -384,12 +384,12 @@ TEST(L0DeviceTest, whenCallingGetDeviceMemoryNameThenCorrectTypeIsReturned) {
auto &sysInfo = device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo()->gtSystemInfo;
for (uint32_t i = 0; i < 11; i++) {
for (uint32_t i = 0; i < 10; i++) {
sysInfo.MemoryType = i;
EXPECT_EQ(ZE_RESULT_SUCCESS, device->getMemoryProperties(&count, &memProperties));
if (i == 2 || i == 3 || i == 5 || i == 8) {
if (i == 2 || i == 3 || i == 5 || i == 8 || i == 9) {
EXPECT_STREQ("HBM", memProperties.name);
} else {
EXPECT_STREQ("DDR", memProperties.name);
@@ -2103,17 +2103,23 @@ HWTEST2_F(DeviceGetMemoryTests, whenCallingGetMemoryPropertiesForMemoryExtProper
res = device->getMemoryProperties(&count, &memProperties);
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
EXPECT_EQ(1u, count);
const std::array<ze_device_memory_ext_type_t, 5> sysInfoMemType = {
const std::array<ze_device_memory_ext_type_t, 10> sysInfoMemType = {
ZE_DEVICE_MEMORY_EXT_TYPE_LPDDR4,
ZE_DEVICE_MEMORY_EXT_TYPE_LPDDR5,
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
ZE_DEVICE_MEMORY_EXT_TYPE_GDDR6,
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
ZE_DEVICE_MEMORY_EXT_TYPE_DDR5,
ZE_DEVICE_MEMORY_EXT_TYPE_GDDR7,
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
};
auto &hwInfo = device->getHwInfo();
auto bandwidthPerNanoSecond = productHelper.getDeviceMemoryMaxBandWidthInBytesPerSecond(hwInfo, nullptr, 0) / 1000000000;
UNRECOVERABLE_IF(hwInfo.gtSystemInfo.MemoryType >= sizeof(sysInfoMemType));
EXPECT_EQ(memExtProperties.type, sysInfoMemType[hwInfo.gtSystemInfo.MemoryType]);
EXPECT_EQ(memExtProperties.physicalSize, productHelper.getDeviceMemoryPhysicalSizeInBytes(nullptr, 0));
EXPECT_EQ(memExtProperties.readBandwidth, bandwidthPerNanoSecond);
@@ -2141,17 +2147,23 @@ HWTEST2_F(DeviceGetMemoryTests, whenCallingGetMemoryPropertiesWith2LevelsOfPnext
res = device->getMemoryProperties(&count, &memProperties);
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
EXPECT_EQ(1u, count);
const std::array<ze_device_memory_ext_type_t, 5> sysInfoMemType = {
const std::array<ze_device_memory_ext_type_t, 10> sysInfoMemType = {
ZE_DEVICE_MEMORY_EXT_TYPE_LPDDR4,
ZE_DEVICE_MEMORY_EXT_TYPE_LPDDR5,
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
ZE_DEVICE_MEMORY_EXT_TYPE_GDDR6,
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
ZE_DEVICE_MEMORY_EXT_TYPE_DDR5,
ZE_DEVICE_MEMORY_EXT_TYPE_GDDR7,
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
};
auto &hwInfo = device->getHwInfo();
auto bandwidthPerNanoSecond = productHelper.getDeviceMemoryMaxBandWidthInBytesPerSecond(hwInfo, nullptr, 0) / 1000000000;
UNRECOVERABLE_IF(hwInfo.gtSystemInfo.MemoryType >= sizeof(sysInfoMemType));
EXPECT_EQ(memExtProperties.type, sysInfoMemType[hwInfo.gtSystemInfo.MemoryType]);
EXPECT_EQ(memExtProperties.physicalSize, productHelper.getDeviceMemoryPhysicalSizeInBytes(nullptr, 0));
EXPECT_EQ(memExtProperties.readBandwidth, bandwidthPerNanoSecond);
@@ -2588,16 +2600,22 @@ HWTEST2_F(MultipleDevicesEnabledImplicitScalingTest, GivenImplicitScalingEnabled
res = device->getMemoryProperties(&count, &memProperties);
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
EXPECT_EQ(1u, count);
const std::array<ze_device_memory_ext_type_t, 5> sysInfoMemType = {
const std::array<ze_device_memory_ext_type_t, 10> sysInfoMemType = {
ZE_DEVICE_MEMORY_EXT_TYPE_LPDDR4,
ZE_DEVICE_MEMORY_EXT_TYPE_LPDDR5,
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
ZE_DEVICE_MEMORY_EXT_TYPE_GDDR6,
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
ZE_DEVICE_MEMORY_EXT_TYPE_DDR5,
ZE_DEVICE_MEMORY_EXT_TYPE_GDDR7,
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
};
auto bandwidthPerNanoSecond = raii.mockProductHelper->getDeviceMemoryMaxBandWidthInBytesPerSecond(device->getHwInfo(), nullptr, 0) / 1000000000;
UNRECOVERABLE_IF(hwInfo.gtSystemInfo.MemoryType >= sizeof(sysInfoMemType));
EXPECT_EQ(memExtProperties.type, sysInfoMemType[hwInfo.gtSystemInfo.MemoryType]);
EXPECT_EQ(memExtProperties.physicalSize, raii.mockProductHelper->getDeviceMemoryPhysicalSizeInBytes(nullptr, 0) * numSubDevices);
EXPECT_EQ(memExtProperties.readBandwidth, bandwidthPerNanoSecond * numSubDevices);