mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-27 07:44:16 +08:00
fix(sysman): Use CPU timestamp instead of PMT timestamp for Memory Bandwidth
Related-To: NEO-15385 Signed-off-by: Anvesh Bakwad <anvesh.bakwad@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
f8a2070c86
commit
3fa6089097
@@ -782,27 +782,6 @@ static ze_result_t getMemoryMaxBandwidth(const std::map<std::string, uint64_t> &
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static ze_result_t getMemoryBandwidthTimestamp(const std::map<std::string, uint64_t> &keyOffsetMap, std::unordered_map<std::string, std::string> &keyTelemInfoMap,
|
||||
zes_mem_bandwidth_t *pBandwidth) {
|
||||
uint32_t timeStampH = 0;
|
||||
uint32_t timeStampL = 0;
|
||||
pBandwidth->timestamp = 0;
|
||||
|
||||
std::string key = "GDDR_TELEM_CAPTURE_TIMESTAMP_UPPER";
|
||||
if (!PlatformMonitoringTech::readValue(keyOffsetMap, keyTelemInfoMap[key], key, 0, timeStampH)) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
key = "GDDR_TELEM_CAPTURE_TIMESTAMP_LOWER";
|
||||
if (!PlatformMonitoringTech::readValue(keyOffsetMap, keyTelemInfoMap[key], key, 0, timeStampL)) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
pBandwidth->timestamp = packInto64Bit(timeStampH, timeStampL) * milliSecsToMicroSecs;
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static ze_result_t getCounterValues(const std::vector<std::pair<const std::string, const std::string>> ®isterList, const std::string &keyPrefix,
|
||||
const std::map<std::string, uint64_t> &keyOffsetMap, std::unordered_map<std::string, std::string> &keyTelemInfoMap, uint64_t &totalCounter) {
|
||||
for (const auto ®Pair : registerList) {
|
||||
@@ -927,16 +906,14 @@ ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryBandwidth(zes_mem_bandwi
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
// Get Timestamp Values
|
||||
if (ZE_RESULT_SUCCESS != getMemoryBandwidthTimestamp(keyOffsetMap, keyTelemInfoMap, pBandwidth)) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
// Get Max Bandwidth
|
||||
if (ZE_RESULT_SUCCESS != getMemoryMaxBandwidth(keyOffsetMap, keyTelemInfoMap, pBandwidth)) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
// Get Timestamp
|
||||
pBandwidth->timestamp = SysmanDevice::getSysmanTimestamp();
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -875,21 +875,8 @@ ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryBandWidth(zes_mem_bandwi
|
||||
// PMT reports maxBandwidth in units of 100 MBps (decimal). Need to convert it into Bytes/sec, unit to be returned by sysman.
|
||||
pBandwidth->maxBandwidth = static_cast<uint64_t>(maxBandwidth) * megaBytesToBytes * 100;
|
||||
|
||||
// timestamp calculation
|
||||
uint32_t timeStampL = 0;
|
||||
uint32_t timeStampH = 0;
|
||||
|
||||
status = pPmt->readValue("GDDR_TELEM_CAPTURE_TIMESTAMP_UPPER", timeStampH);
|
||||
if (status != ZE_RESULT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
status = pPmt->readValue("GDDR_TELEM_CAPTURE_TIMESTAMP_LOWER", timeStampL);
|
||||
if (status != ZE_RESULT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
// timestamp from PMT is in milli seconds
|
||||
pBandwidth->timestamp = packInto64Bit(timeStampH, timeStampL) * milliSecsToMicroSecs;
|
||||
// Get timestamp
|
||||
pBandwidth->timestamp = SysmanDevice::getSysmanTimestamp();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1019,23 +1019,17 @@ HWTEST2_F(SysmanProductHelperMemoryTest, GivenSysmanProductHelperInstanceWhenCal
|
||||
memcpy(buf, validOobmsmGuid.data(), count);
|
||||
} else if (fd == 6) {
|
||||
switch (offset) {
|
||||
case 368:
|
||||
case 376:
|
||||
count = (readFailCount == 2) ? -1 : sizeof(uint32_t);
|
||||
break;
|
||||
case 372:
|
||||
case 380:
|
||||
count = (readFailCount == 3) ? -1 : sizeof(uint32_t);
|
||||
break;
|
||||
case 376:
|
||||
case 392:
|
||||
count = (readFailCount == 4) ? -1 : sizeof(uint32_t);
|
||||
break;
|
||||
case 380:
|
||||
count = (readFailCount == 5) ? -1 : sizeof(uint32_t);
|
||||
break;
|
||||
case 392:
|
||||
count = (readFailCount == 6) ? -1 : sizeof(uint32_t);
|
||||
break;
|
||||
case 396:
|
||||
count = (readFailCount == 7) ? -1 : sizeof(uint32_t);
|
||||
count = (readFailCount == 5) ? -1 : sizeof(uint32_t);
|
||||
break;
|
||||
case 3688:
|
||||
memcpy(buf, &mockMsuBitMask, count);
|
||||
@@ -1053,7 +1047,7 @@ HWTEST2_F(SysmanProductHelperMemoryTest, GivenSysmanProductHelperInstanceWhenCal
|
||||
uint32_t subdeviceId = 0;
|
||||
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
|
||||
zes_mem_bandwidth_t memBandwidth;
|
||||
while (readFailCount <= 7) {
|
||||
while (readFailCount <= 5) {
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, pSysmanProductHelper->getMemoryBandwidth(&memBandwidth, pLinuxSysmanImp, subdeviceId));
|
||||
readFailCount++;
|
||||
}
|
||||
@@ -1099,8 +1093,6 @@ HWTEST2_F(SysmanProductHelperMemoryTest, GivenSysmanProductHelperInstanceWhenCal
|
||||
static uint32_t writeCounterLower32Bit = 0xa;
|
||||
static uint32_t writeCounterUpper64Bit = 0xf;
|
||||
static uint32_t writeCounterLower64Bit = 0xb;
|
||||
static uint32_t timeStampUpper = 0xab;
|
||||
static uint32_t timeStampLower = 0xcd;
|
||||
static uint32_t vramBandwidth = 0x6abc0000;
|
||||
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsReadlink)> mockReadLink(&NEO::SysCalls::sysCallsReadlink, &mockReadLinkSuccess);
|
||||
@@ -1119,12 +1111,6 @@ HWTEST2_F(SysmanProductHelperMemoryTest, GivenSysmanProductHelperInstanceWhenCal
|
||||
memcpy(buf, validOobmsmGuid.data(), count);
|
||||
} else if (fd == 6) {
|
||||
switch (offset) {
|
||||
case 368:
|
||||
memcpy(buf, &timeStampLower, count);
|
||||
break;
|
||||
case 372:
|
||||
memcpy(buf, &timeStampUpper, count);
|
||||
break;
|
||||
case 376:
|
||||
memcpy(buf, &readCounterUpper32Bit, count);
|
||||
break;
|
||||
@@ -1181,13 +1167,12 @@ HWTEST2_F(SysmanProductHelperMemoryTest, GivenSysmanProductHelperInstanceWhenCal
|
||||
uint64_t outputWriteCounter64Bit = packInto64Bit(writeCounterUpper64Bit, writeCounterLower64Bit) * 64;
|
||||
EXPECT_EQ((outputWriteCounter32Bit + outputWriteCounter64Bit), memBandwidth.writeCounter);
|
||||
|
||||
uint64_t outputTimestamp = packInto64Bit(timeStampUpper, timeStampLower) * milliSecsToMicroSecs;
|
||||
EXPECT_EQ(outputTimestamp, memBandwidth.timestamp);
|
||||
|
||||
uint64_t outputMaxBandwidth = vramBandwidth;
|
||||
outputMaxBandwidth = outputMaxBandwidth >> 16;
|
||||
outputMaxBandwidth = static_cast<uint64_t>(outputMaxBandwidth) * megaBytesToBytes * 100;
|
||||
EXPECT_EQ(outputMaxBandwidth, memBandwidth.maxBandwidth);
|
||||
|
||||
EXPECT_GT(memBandwidth.timestamp, 0u);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
|
||||
@@ -118,14 +118,6 @@ HWTEST2_F(SysmanDeviceMemoryHelperFixture, GivenValidMemoryHandleWhenGettingBand
|
||||
*lpBytesReturned = 8;
|
||||
*static_cast<uint32_t *>(lpOutBuffer) = 131072;
|
||||
return true;
|
||||
case 92:
|
||||
*lpBytesReturned = 8;
|
||||
*static_cast<uint32_t *>(lpOutBuffer) = mockMemoryBandwidthTimestamp;
|
||||
return true;
|
||||
case 93:
|
||||
*lpBytesReturned = 8;
|
||||
*static_cast<uint32_t *>(lpOutBuffer) = 0;
|
||||
return true;
|
||||
default:
|
||||
*lpBytesReturned = 8;
|
||||
if (readRequest->offset % 2 == 0) {
|
||||
@@ -147,12 +139,12 @@ HWTEST2_F(SysmanDeviceMemoryHelperFixture, GivenValidMemoryHandleWhenGettingBand
|
||||
EXPECT_EQ(bandwidth.maxBandwidth, static_cast<uint64_t>(mockMemoryMaxBandwidth * megaBytesToBytes * 100));
|
||||
EXPECT_EQ(bandwidth.readCounter, (6 * mockPmtBandWidthVariableBackupValue * 32) + (6 * mockPmtBandWidthVariableBackupValue * 64));
|
||||
EXPECT_EQ(bandwidth.writeCounter, (4 * mockPmtBandWidthVariableBackupValue * 32) + (4 * mockPmtBandWidthVariableBackupValue * 64));
|
||||
EXPECT_EQ(bandwidth.timestamp, mockMemoryBandwidthTimestamp * milliSecsToMicroSecs);
|
||||
EXPECT_GT(bandwidth.timestamp, 0u);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(SysmanDeviceMemoryHelperFixture, GivenValidMemoryHandleWhenGettingBandwidthCoveringNegativePathsThenCallFails, IsBMG) {
|
||||
static uint32_t count = 8;
|
||||
static uint32_t count = 6;
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCreateFile)> psysCallsCreateFile(&NEO::SysCalls::sysCallsCreateFile, [](LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) -> HANDLE {
|
||||
return reinterpret_cast<HANDLE>(static_cast<uintptr_t>(0x7));
|
||||
});
|
||||
@@ -167,30 +159,22 @@ HWTEST2_F(SysmanDeviceMemoryHelperFixture, GivenValidMemoryHandleWhenGettingBand
|
||||
*lpBytesReturned = 8;
|
||||
*static_cast<uint32_t *>(lpOutBuffer) = 131072;
|
||||
return count == 2 ? false : true;
|
||||
case 92:
|
||||
*lpBytesReturned = 8;
|
||||
*static_cast<uint32_t *>(lpOutBuffer) = 1230000;
|
||||
return count == 4 ? false : true;
|
||||
case 93:
|
||||
*lpBytesReturned = 8;
|
||||
*static_cast<uint32_t *>(lpOutBuffer) = 0;
|
||||
return count == 3 ? false : true;
|
||||
case 94:
|
||||
*lpBytesReturned = 8;
|
||||
*static_cast<uint32_t *>(lpOutBuffer) = 0;
|
||||
return count == 5 ? false : true;
|
||||
return count == 3 ? false : true;
|
||||
case 95:
|
||||
*lpBytesReturned = 8;
|
||||
*static_cast<uint32_t *>(lpOutBuffer) = 10000000;
|
||||
return count == 6 ? false : true;
|
||||
return count == 4 ? false : true;
|
||||
case 110:
|
||||
*lpBytesReturned = 8;
|
||||
*static_cast<uint32_t *>(lpOutBuffer) = 0;
|
||||
return count == 7 ? false : true;
|
||||
return count == 5 ? false : true;
|
||||
case 111:
|
||||
*lpBytesReturned = 8;
|
||||
*static_cast<uint32_t *>(lpOutBuffer) = 10000000;
|
||||
return count == 8 ? false : true;
|
||||
return count == 6 ? false : true;
|
||||
default:
|
||||
*lpBytesReturned = 8;
|
||||
if (readRequest->offset % 2 == 0) {
|
||||
|
||||
Reference in New Issue
Block a user