fix: Read appropriate entry for HBM channels

Related-To: NEO-11949

Signed-off-by: Bellekallu Rajkiran <bellekallu.rajkiran@intel.com>
This commit is contained in:
Bellekallu Rajkiran 2024-08-08 08:37:08 +00:00 committed by Compute-Runtime-Automation
parent abbc08bb67
commit be4570fe10
7 changed files with 60 additions and 3 deletions

View File

@ -52,11 +52,11 @@ ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryProperties(zes_mem_prope
if (status) {
auto memSystemInfo = pDrm->getSystemInfo();
if (memSystemInfo != nullptr) {
pProperties->numChannels = memSystemInfo->getMaxMemoryChannels();
auto memType = memSystemInfo->getMemoryType();
switch (memType) {
case NEO::DeviceBlobConstants::MemoryType::hbm2e:
case NEO::DeviceBlobConstants::MemoryType::hbm2:
case NEO::DeviceBlobConstants::MemoryType::hbm3:
pProperties->type = ZES_MEM_TYPE_HBM;
break;
case NEO::DeviceBlobConstants::MemoryType::lpddr4:
@ -69,6 +69,12 @@ ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryProperties(zes_mem_prope
pProperties->type = ZES_MEM_TYPE_DDR;
break;
}
if (pProperties->type == ZES_MEM_TYPE_HBM) {
pProperties->numChannels = memSystemInfo->getNumHbmStacksPerTile() * memSystemInfo->getNumChannlesPerHbmStack();
} else {
pProperties->numChannels = memSystemInfo->getMaxMemoryChannels();
}
}
}

View File

@ -121,7 +121,10 @@ struct MockMemoryNeoDrm : public NEO::Drm {
return returnValue;
}
uint32_t hwBlob[] = {NEO::DeviceBlobConstants::maxMemoryChannels, 1, 8, NEO::DeviceBlobConstants::memoryType, 0, mockMemoryType};
constexpr uint32_t numHbmStacksPerTile = 2;
constexpr uint32_t numChannelsPerHbmStack = 4;
uint32_t hwBlob[] = {NEO::DeviceBlobConstants::maxMemoryChannels, 1, 8, NEO::DeviceBlobConstants::memoryType, 1, mockMemoryType, NEO::DeviceBlobConstants::numHbmStacksPerTile, 1, numHbmStacksPerTile, NEO::DeviceBlobConstants::numChannelsPerHbmStack, 1, numChannelsPerHbmStack};
std::vector<uint32_t> inputBlobData(reinterpret_cast<uint32_t *>(hwBlob), reinterpret_cast<uint32_t *>(ptrOffset(hwBlob, sizeof(hwBlob))));
this->systemInfo.reset(new SystemInfo(inputBlobData));
return returnValue;

View File

@ -921,6 +921,33 @@ TEST(SysmanProductHelperTest, GivenInvalidProductFamilyWhenCallingProductHelperC
EXPECT_EQ(nullptr, pSysmanProductHelper);
}
using IsNotDG1 = IsNotWithinProducts<IGFX_DG1, IGFX_DG1>;
HWTEST2_F(SysmanProductHelperMemoryTest, GivenSysmanProductHelperInstanceWhenCallingGetMemoryPropertiesThenVerifyCallSucceeds, IsNotDG1) {
pDrm->setMemoryType(NEO::DeviceBlobConstants::MemoryType::hbm3);
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
zes_mem_properties_t properties = {};
bool isSubdevice = true;
uint32_t subDeviceId = 0;
auto pSysmanKmdInterface = new MockSysmanKmdInterfacePrelim(pLinuxSysmanImp->getSysmanProductHelper());
MockMemorySysFsAccessInterface *pSysfsAccess = new MockMemorySysFsAccessInterface();
pLinuxSysmanImp->pSysmanKmdInterface.reset(pSysmanKmdInterface);
pSysmanKmdInterface->pSysfsAccess.reset(pSysfsAccess);
pSysfsAccess->mockReadStringValue.push_back(mockPhysicalSize);
pSysfsAccess->mockReadReturnStatus.push_back(ZE_RESULT_SUCCESS);
pSysfsAccess->isRepeated = true;
ze_result_t result = pSysmanProductHelper->getMemoryProperties(&properties, pLinuxSysmanImp, pDrm, pLinuxSysmanImp->getSysmanKmdInterface(), subDeviceId, isSubdevice);
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
EXPECT_EQ(properties.type, ZES_MEM_TYPE_HBM);
EXPECT_EQ(properties.location, ZES_MEM_LOC_DEVICE);
EXPECT_EQ(properties.subdeviceId, 0u);
EXPECT_EQ(properties.physicalSize, strtoull(mockPhysicalSize.c_str(), nullptr, 16));
EXPECT_EQ(properties.numChannels, numMemoryChannels);
EXPECT_EQ(properties.busWidth, memoryBusWidth);
}
} // namespace ult
} // namespace Sysman
} // namespace L0

View File

@ -67,6 +67,12 @@ void SystemInfo::parseDeviceBlob(const std::vector<uint32_t> &inputData) {
if (DeviceBlobConstants::slmSizePerSs == data[i]) {
slmSizePerDss = std::max(data[i + 2], slmSizePerDss);
}
if (DeviceBlobConstants::numHbmStacksPerTile == data[i]) {
numHbmStacksPerTile = data[i + 2];
}
if (DeviceBlobConstants::numChannelsPerHbmStack == data[i]) {
numChannelsPerHbmStack = data[i + 2];
}
/* Skip to next attribute */
auto blobLength = 2 + data[i + 1];
i += blobLength;

View File

@ -27,13 +27,16 @@ constexpr uint32_t slmSizePerDss = 65;
constexpr uint32_t maxSubSlicesSupported = 70;
constexpr uint32_t maxEuPerSubSlice = 71;
constexpr uint32_t slmSizePerSs = 73;
constexpr uint32_t numHbmStacksPerTile = 74;
constexpr uint32_t numChannelsPerHbmStack = 75;
enum MemoryType {
lpddr4,
lpddr5,
hbm2,
hbm2e,
gddr6
gddr6,
hbm3
};
} // namespace DeviceBlobConstants
@ -54,6 +57,8 @@ struct SystemInfo {
uint32_t getL3BankSizeInKb() const { return l3BankSizeInKb; }
uint32_t getSlmSizePerDss() const { return slmSizePerDss; }
uint32_t getCsrSizeInMb() const { return csrSizeInMb; }
uint32_t getNumHbmStacksPerTile() const { return numHbmStacksPerTile; }
uint32_t getNumChannlesPerHbmStack() const { return numChannelsPerHbmStack; }
void checkSysInfoMismatch(HardwareInfo *hwInfo);
@ -71,6 +76,8 @@ struct SystemInfo {
uint32_t l3BankSizeInKb = 0;
uint32_t slmSizePerDss = 0;
uint32_t csrSizeInMb = 0;
uint32_t numHbmStacksPerTile = 0;
uint32_t numChannelsPerHbmStack = 0;
};
} // namespace NEO

View File

@ -52,6 +52,12 @@ static constexpr uint32_t dummyDeviceBlobData[] = {
NEO::DeviceBlobConstants::csrSizeInMb,
1,
0x25,
NEO::DeviceBlobConstants::numHbmStacksPerTile,
1,
0x04,
NEO::DeviceBlobConstants::numChannelsPerHbmStack,
1,
0x08,
};
const std::vector<uint32_t> inputBlobData(reinterpret_cast<const uint32_t *>(dummyDeviceBlobData),

View File

@ -180,6 +180,8 @@ TEST(DrmSystemInfoTest, givenSystemInfoCreatedFromDeviceBlobWhenQueryingSpecific
EXPECT_EQ(0x2Du, systemInfo.getL3BankSizeInKb());
EXPECT_EQ(0x24u, systemInfo.getSlmSizePerDss());
EXPECT_EQ(0x25u, systemInfo.getCsrSizeInMb());
EXPECT_EQ(0x04u, systemInfo.getNumHbmStacksPerTile());
EXPECT_EQ(0x08u, systemInfo.getNumChannlesPerHbmStack());
}
TEST(DrmSystemInfoTest, givenSystemInfoCreatedFromDeviceBlobAndDifferentMaxSubSlicesAndMaxDSSThenQueryReturnsTheMaxValue) {