mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
fix: Merge Prelim & Nonprelim code for Legacy Sysman Memory module
Related-To: NEO-14004 Signed-off-by: Pratik Bari <pratik.bari@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
b987877712
commit
e91480c673
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2023 Intel Corporation
|
* Copyright (C) 2022-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
#include "level_zero/tools/source/sysman/events/events_imp.h"
|
#include "level_zero/tools/source/sysman/events/events_imp.h"
|
||||||
#include "level_zero/tools/source/sysman/linux/os_sysman_driver_imp.h"
|
#include "level_zero/tools/source/sysman/linux/os_sysman_driver_imp.h"
|
||||||
#include "level_zero/tools/source/sysman/linux/os_sysman_imp.h"
|
#include "level_zero/tools/source/sysman/linux/os_sysman_imp.h"
|
||||||
#include "level_zero/tools/source/sysman/memory/linux/os_memory_imp_prelim.h"
|
#include "level_zero/tools/source/sysman/memory/linux/os_memory_imp.h"
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2020-2024 Intel Corporation
|
# Copyright (C) 2020-2025 Intel Corporation
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
#
|
#
|
||||||
@@ -8,26 +8,7 @@ if(UNIX)
|
|||||||
target_sources(${L0_STATIC_LIB_NAME}
|
target_sources(${L0_STATIC_LIB_NAME}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_imp.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_imp.h
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NEO_ENABLE_I915_PRELIM_DETECTION)
|
|
||||||
target_sources(${L0_STATIC_LIB_NAME}
|
|
||||||
PRIVATE
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_imp_prelim.cpp
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_imp_prelim.h
|
|
||||||
)
|
|
||||||
elseif(SUPPORT_DG1 AND "${BRANCH_TYPE}" STREQUAL "")
|
|
||||||
target_sources(${L0_STATIC_LIB_NAME}
|
|
||||||
PRIVATE
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_imp.h
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_imp_dg1.cpp
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
target_sources(${L0_STATIC_LIB_NAME}
|
|
||||||
PRIVATE
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_imp.h
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_imp.cpp
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2020-2023 Intel Corporation
|
* Copyright (C) 2022-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -7,38 +7,368 @@
|
|||||||
|
|
||||||
#include "level_zero/tools/source/sysman/memory/linux/os_memory_imp.h"
|
#include "level_zero/tools/source/sysman/memory/linux/os_memory_imp.h"
|
||||||
|
|
||||||
#include "shared/source/memory_manager/memory_manager.h"
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||||
|
#include "shared/source/device/device.h"
|
||||||
|
#include "shared/source/helpers/hw_info.h"
|
||||||
|
#include "shared/source/memory_manager/memory_banks.h"
|
||||||
|
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
||||||
|
#include "shared/source/os_interface/linux/memory_info.h"
|
||||||
|
#include "shared/source/os_interface/linux/system_info.h"
|
||||||
|
|
||||||
#include "level_zero/core/source/driver/driver_handle.h"
|
#include "level_zero/core/source/driver/driver_handle.h"
|
||||||
|
#include "level_zero/tools/source/sysman/firmware_util/firmware_util.h"
|
||||||
#include "level_zero/tools/source/sysman/linux/os_sysman_imp.h"
|
#include "level_zero/tools/source/sysman/linux/os_sysman_imp.h"
|
||||||
|
#include "level_zero/tools/source/sysman/sysman_const.h"
|
||||||
|
|
||||||
|
#include "igfxfmid.h"
|
||||||
|
|
||||||
namespace L0 {
|
namespace L0 {
|
||||||
|
|
||||||
LinuxMemoryImp::LinuxMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) : isSubdevice(onSubdevice), subdeviceId(subdeviceId) {
|
const std::string LinuxMemoryImp::deviceMemoryHealth("device_memory_health");
|
||||||
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
|
|
||||||
pDevice = pLinuxSysmanImp->getDeviceHandle();
|
void memoryGetTimeStamp(uint64_t ×tamp) {
|
||||||
|
std::chrono::time_point<std::chrono::steady_clock> ts = std::chrono::steady_clock::now();
|
||||||
|
timestamp = std::chrono::duration_cast<std::chrono::microseconds>(ts.time_since_epoch()).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LinuxMemoryImp::init() {
|
||||||
|
if (isSubdevice) {
|
||||||
|
const std::string baseDir = "gt/gt" + std::to_string(subdeviceId) + "/";
|
||||||
|
physicalSizeFile = baseDir + "addr_range";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LinuxMemoryImp::LinuxMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) : isSubdevice(onSubdevice), subdeviceId(subdeviceId) {
|
||||||
|
pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
|
||||||
|
pDrm = &pLinuxSysmanImp->getDrm();
|
||||||
|
pDevice = pLinuxSysmanImp->getDeviceHandle();
|
||||||
|
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
|
||||||
|
pPmt = pLinuxSysmanImp->getPlatformMonitoringTechAccess(subdeviceId);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
bool LinuxMemoryImp::isMemoryModuleSupported() {
|
bool LinuxMemoryImp::isMemoryModuleSupported() {
|
||||||
return pDevice->getDriverHandle()->getMemoryManager()->isLocalMemorySupported(pDevice->getRootDeviceIndex());
|
return pDevice->getDriverHandle()->getMemoryManager()->isLocalMemorySupported(pDevice->getRootDeviceIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
ze_result_t LinuxMemoryImp::getProperties(zes_mem_properties_t *pProperties) {
|
ze_result_t LinuxMemoryImp::getProperties(zes_mem_properties_t *pProperties) {
|
||||||
pProperties->type = ZES_MEM_TYPE_DDR;
|
pProperties->type = ZES_MEM_TYPE_DDR;
|
||||||
|
pProperties->numChannels = -1;
|
||||||
|
if (pDrm->querySystemInfo()) {
|
||||||
|
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:
|
||||||
|
pProperties->type = ZES_MEM_TYPE_HBM;
|
||||||
|
break;
|
||||||
|
case NEO::DeviceBlobConstants::MemoryType::lpddr4:
|
||||||
|
pProperties->type = ZES_MEM_TYPE_LPDDR4;
|
||||||
|
break;
|
||||||
|
case NEO::DeviceBlobConstants::MemoryType::lpddr5:
|
||||||
|
pProperties->type = ZES_MEM_TYPE_LPDDR5;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
pProperties->type = ZES_MEM_TYPE_DDR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
pProperties->location = ZES_MEM_LOC_DEVICE;
|
pProperties->location = ZES_MEM_LOC_DEVICE;
|
||||||
pProperties->onSubdevice = isSubdevice;
|
pProperties->onSubdevice = isSubdevice;
|
||||||
pProperties->subdeviceId = subdeviceId;
|
pProperties->subdeviceId = subdeviceId;
|
||||||
pProperties->busWidth = -1;
|
pProperties->busWidth = memoryBusWidth; // Hardcode
|
||||||
pProperties->numChannels = -1;
|
|
||||||
pProperties->physicalSize = 0;
|
pProperties->physicalSize = 0;
|
||||||
|
if (isSubdevice) {
|
||||||
|
std::string memval;
|
||||||
|
ze_result_t result = pSysfsAccess->read(physicalSizeFile, memval);
|
||||||
|
uint64_t intval = strtoull(memval.c_str(), nullptr, 16);
|
||||||
|
if (ZE_RESULT_SUCCESS != result) {
|
||||||
|
pProperties->physicalSize = 0u;
|
||||||
|
} else {
|
||||||
|
pProperties->physicalSize = intval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ZE_RESULT_SUCCESS;
|
return ZE_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ze_result_t LinuxMemoryImp::getVFIDString(std::string &vfID) {
|
||||||
|
uint32_t vf0VfIdVal = 0;
|
||||||
|
std::string key = "VF0_VFID";
|
||||||
|
auto result = pPmt->readValue(key, vf0VfIdVal);
|
||||||
|
if (result != ZE_RESULT_SUCCESS) {
|
||||||
|
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for VF0_VFID is returning error:0x%x \n", __FUNCTION__, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t vf1VfIdVal = 0;
|
||||||
|
key = "VF1_VFID";
|
||||||
|
result = pPmt->readValue(key, vf1VfIdVal);
|
||||||
|
if (result != ZE_RESULT_SUCCESS) {
|
||||||
|
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for VF1_VFID is returning error:0x%x \n", __FUNCTION__, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// At any point of time only one VF(virtual function) could be active and thus would
|
||||||
|
// read greater than zero val. If both VF0 and VF1 are reading 0 or both are reading
|
||||||
|
// greater than 0, then we would be confused in taking the decision of correct VF.
|
||||||
|
// Lets assume and report this as a error condition
|
||||||
|
if (((vf0VfIdVal == 0) && (vf1VfIdVal == 0)) ||
|
||||||
|
((vf0VfIdVal > 0) && (vf1VfIdVal > 0))) {
|
||||||
|
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s() VF0 returning 0x%x and VF1 returning 0x%x as both should not be the same \n", __FUNCTION__, vf0VfIdVal, vf1VfIdVal);
|
||||||
|
return ZE_RESULT_ERROR_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vf0VfIdVal > 0) {
|
||||||
|
vfID = "VF0";
|
||||||
|
}
|
||||||
|
if (vf1VfIdVal > 0) {
|
||||||
|
vfID = "VF1";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t LinuxMemoryImp::readMcChannelCounters(uint64_t &readCounters, uint64_t &writeCounters) {
|
||||||
|
// For DG2 there are 8 memory instances each memory instance has 2 channels there are total 16 MC Channels
|
||||||
|
uint32_t numMcChannels = 16u;
|
||||||
|
ze_result_t result = ZE_RESULT_ERROR_UNKNOWN;
|
||||||
|
std::vector<std::string> nameOfCounters{"IDI_READS", "IDI_WRITES", "DISPLAY_VC1_READS"};
|
||||||
|
std::vector<uint64_t> counterValues(3, 0); // Will store the values of counters metioned in nameOfCounters
|
||||||
|
for (uint64_t counterIndex = 0; counterIndex < nameOfCounters.size(); counterIndex++) {
|
||||||
|
for (uint32_t mcChannelIndex = 0; mcChannelIndex < numMcChannels; mcChannelIndex++) {
|
||||||
|
uint64_t val = 0;
|
||||||
|
std::string readCounterKey = nameOfCounters[counterIndex] + "[" + std::to_string(mcChannelIndex) + "]";
|
||||||
|
result = pPmt->readValue(readCounterKey, val);
|
||||||
|
if (result != ZE_RESULT_SUCCESS) {
|
||||||
|
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for readCounterKey returning error:0x%x \n", __FUNCTION__, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
counterValues[counterIndex] += val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// PMT counters returns number of transactions that have occured and each tranaction is of 64 bytes
|
||||||
|
// Multiplying 32(tranaction size) with number of transactions gives the total reads or writes in bytes
|
||||||
|
constexpr uint64_t transactionSize = 32;
|
||||||
|
readCounters = (counterValues[0] + counterValues[2]) * transactionSize; // Read counters are summation of total IDI_READS and DISPLAY_VC1_READS
|
||||||
|
writeCounters = (counterValues[1]) * transactionSize; // Write counters are summation of IDI_WRITES
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinuxMemoryImp::getHbmFrequency(PRODUCT_FAMILY productFamily, unsigned short stepping, uint64_t &hbmFrequency) {
|
||||||
|
hbmFrequency = 0;
|
||||||
|
if (productFamily == IGFX_PVC) {
|
||||||
|
if (stepping >= REVISION_B) {
|
||||||
|
const std::string baseDir = "gt/gt" + std::to_string(subdeviceId) + "/";
|
||||||
|
// Calculating bandwidth based on HBM max frequency
|
||||||
|
const std::string hbmRP0FreqFile = baseDir + "mem_RP0_freq_mhz";
|
||||||
|
uint64_t hbmFreqValue = 0;
|
||||||
|
ze_result_t result = pSysfsAccess->read(hbmRP0FreqFile, hbmFreqValue);
|
||||||
|
if (ZE_RESULT_SUCCESS == result) {
|
||||||
|
hbmFrequency = hbmFreqValue * 1000 * 1000; // Converting MHz value to Hz
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (stepping == REVISION_A0) {
|
||||||
|
// For IGFX_PVC REV A0 HBM frequency would be 3.2 GT/s = 3.2 * 1000 * 1000 * 1000 T/s = 3200000000 T/s
|
||||||
|
hbmFrequency = 3.2 * gigaUnitTransferToUnitTransfer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t LinuxMemoryImp::getBandwidthForDg2(zes_mem_bandwidth_t *pBandwidth) {
|
||||||
|
pBandwidth->readCounter = 0;
|
||||||
|
pBandwidth->writeCounter = 0;
|
||||||
|
pBandwidth->timestamp = 0;
|
||||||
|
pBandwidth->maxBandwidth = 0;
|
||||||
|
ze_result_t result = readMcChannelCounters(pBandwidth->readCounter, pBandwidth->writeCounter);
|
||||||
|
if (result != ZE_RESULT_SUCCESS) {
|
||||||
|
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readMcChannelCounters returning error:0x%x \n", __FUNCTION__, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
pBandwidth->maxBandwidth = 0u;
|
||||||
|
const std::string maxBwFile = "prelim_lmem_max_bw_Mbps";
|
||||||
|
uint64_t maxBw = 0;
|
||||||
|
result = pSysfsAccess->read(maxBwFile, maxBw);
|
||||||
|
if (result != ZE_RESULT_SUCCESS) {
|
||||||
|
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():pSysfsAccess->read returning error:0x%x \n", __FUNCTION__, result);
|
||||||
|
}
|
||||||
|
pBandwidth->maxBandwidth = maxBw * mbpsToBytesPerSecond;
|
||||||
|
pBandwidth->timestamp = SysmanDevice::getSysmanTimestamp();
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t LinuxMemoryImp::getHbmBandwidth(uint32_t numHbmModules, zes_mem_bandwidth_t *pBandwidth) {
|
||||||
|
pBandwidth->readCounter = 0;
|
||||||
|
pBandwidth->writeCounter = 0;
|
||||||
|
pBandwidth->timestamp = 0;
|
||||||
|
pBandwidth->maxBandwidth = 0;
|
||||||
|
ze_result_t result = ZE_RESULT_ERROR_UNKNOWN;
|
||||||
|
std::string vfId = "";
|
||||||
|
result = getVFIDString(vfId);
|
||||||
|
if (result != ZE_RESULT_SUCCESS) {
|
||||||
|
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():getVFIDString returning error:0x%x while retriving VFID string \n", __FUNCTION__, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
auto &hwInfo = pDevice->getNEODevice()->getHardwareInfo();
|
||||||
|
auto productFamily = hwInfo.platform.eProductFamily;
|
||||||
|
auto &productHelper = pDevice->getNEODevice()->getProductHelper();
|
||||||
|
auto stepping = productHelper.getSteppingFromHwRevId(hwInfo);
|
||||||
|
for (auto hbmModuleIndex = 0u; hbmModuleIndex < numHbmModules; hbmModuleIndex++) {
|
||||||
|
uint32_t counterValue = 0;
|
||||||
|
// To read counters from VFID 0 and HBM module 0, key would be: VF0_HBM0_READ
|
||||||
|
std::string readCounterKey = vfId + "_HBM" + std::to_string(hbmModuleIndex) + "_READ";
|
||||||
|
result = pPmt->readValue(readCounterKey, counterValue);
|
||||||
|
if (result != ZE_RESULT_SUCCESS) {
|
||||||
|
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for readCounterKey returning error:0x%x \n", __FUNCTION__, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
pBandwidth->readCounter += counterValue;
|
||||||
|
|
||||||
|
counterValue = 0;
|
||||||
|
// To write counters to VFID 0 and HBM module 0, key would be: VF0_HBM0_Write
|
||||||
|
std::string writeCounterKey = vfId + "_HBM" + std::to_string(hbmModuleIndex) + "_WRITE";
|
||||||
|
result = pPmt->readValue(writeCounterKey, counterValue);
|
||||||
|
if (result != ZE_RESULT_SUCCESS) {
|
||||||
|
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for writeCounterKey returning error:0x%x \n", __FUNCTION__, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
pBandwidth->writeCounter += counterValue;
|
||||||
|
}
|
||||||
|
constexpr uint64_t transactionSize = 32;
|
||||||
|
pBandwidth->readCounter = pBandwidth->readCounter * transactionSize;
|
||||||
|
pBandwidth->writeCounter = pBandwidth->writeCounter * transactionSize;
|
||||||
|
pBandwidth->timestamp = SysmanDevice::getSysmanTimestamp();
|
||||||
|
|
||||||
|
uint64_t hbmFrequency = 0;
|
||||||
|
getHbmFrequency(productFamily, stepping, hbmFrequency);
|
||||||
|
|
||||||
|
pBandwidth->maxBandwidth = memoryBusWidth * hbmFrequency * numHbmModules; // Value in bytes/secs
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t LinuxMemoryImp::getHbmBandwidthPVC(uint32_t numHbmModules, zes_mem_bandwidth_t *pBandwidth) {
|
||||||
|
std::string guid = pPmt->getGuid();
|
||||||
|
if (guid != guid64BitMemoryCounters) {
|
||||||
|
return getHbmBandwidth(numHbmModules, pBandwidth);
|
||||||
|
}
|
||||||
|
pBandwidth->readCounter = 0;
|
||||||
|
pBandwidth->writeCounter = 0;
|
||||||
|
pBandwidth->timestamp = 0;
|
||||||
|
pBandwidth->maxBandwidth = 0;
|
||||||
|
ze_result_t result = ZE_RESULT_ERROR_UNKNOWN;
|
||||||
|
std::string vfId = "";
|
||||||
|
result = getVFIDString(vfId);
|
||||||
|
if (result != ZE_RESULT_SUCCESS) {
|
||||||
|
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():getVFIDString returning error:0x%x while retriving VFID string \n", __FUNCTION__, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
auto &hwInfo = pDevice->getNEODevice()->getHardwareInfo();
|
||||||
|
auto productFamily = hwInfo.platform.eProductFamily;
|
||||||
|
auto &productHelper = pDevice->getNEODevice()->getProductHelper();
|
||||||
|
auto stepping = productHelper.getSteppingFromHwRevId(hwInfo);
|
||||||
|
|
||||||
|
uint32_t readCounterL = 0;
|
||||||
|
std::string readCounterKey = vfId + "_HBM_READ_L";
|
||||||
|
result = pPmt->readValue(readCounterKey, readCounterL);
|
||||||
|
if (result != ZE_RESULT_SUCCESS) {
|
||||||
|
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for readCounterL returning error:0x%x \n", __FUNCTION__, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t readCounterH = 0;
|
||||||
|
readCounterKey = vfId + "_HBM_READ_H";
|
||||||
|
result = pPmt->readValue(readCounterKey, readCounterH);
|
||||||
|
if (result != ZE_RESULT_SUCCESS) {
|
||||||
|
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for readCounterH returning error:0x%x \n", __FUNCTION__, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr uint64_t transactionSize = 32;
|
||||||
|
pBandwidth->readCounter = readCounterH;
|
||||||
|
pBandwidth->readCounter = (pBandwidth->readCounter << 32) | static_cast<uint64_t>(readCounterL);
|
||||||
|
pBandwidth->readCounter = (pBandwidth->readCounter * transactionSize);
|
||||||
|
|
||||||
|
uint32_t writeCounterL = 0;
|
||||||
|
std::string writeCounterKey = vfId + "_HBM_WRITE_L";
|
||||||
|
result = pPmt->readValue(writeCounterKey, writeCounterL);
|
||||||
|
if (result != ZE_RESULT_SUCCESS) {
|
||||||
|
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for writeCounterL returning error:0x%x \n", __FUNCTION__, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t writeCounterH = 0;
|
||||||
|
writeCounterKey = vfId + "_HBM_WRITE_H";
|
||||||
|
result = pPmt->readValue(writeCounterKey, writeCounterH);
|
||||||
|
if (result != ZE_RESULT_SUCCESS) {
|
||||||
|
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for writeCounterH returning error:0x%x \n", __FUNCTION__, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
pBandwidth->writeCounter = writeCounterH;
|
||||||
|
pBandwidth->writeCounter = (pBandwidth->writeCounter << 32) | static_cast<uint64_t>(writeCounterL);
|
||||||
|
pBandwidth->writeCounter = (pBandwidth->writeCounter * transactionSize);
|
||||||
|
|
||||||
|
uint64_t timeStampVal = 0;
|
||||||
|
memoryGetTimeStamp(timeStampVal);
|
||||||
|
pBandwidth->timestamp = timeStampVal;
|
||||||
|
|
||||||
|
uint64_t hbmFrequency = 0;
|
||||||
|
getHbmFrequency(productFamily, stepping, hbmFrequency);
|
||||||
|
|
||||||
|
pBandwidth->maxBandwidth = memoryBusWidth * hbmFrequency * numHbmModules; // Value in bytes/secs
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
ze_result_t LinuxMemoryImp::getBandwidth(zes_mem_bandwidth_t *pBandwidth) {
|
ze_result_t LinuxMemoryImp::getBandwidth(zes_mem_bandwidth_t *pBandwidth) {
|
||||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
if (pPmt == nullptr) {
|
||||||
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||||
|
}
|
||||||
|
ze_result_t result = ZE_RESULT_ERROR_UNKNOWN;
|
||||||
|
auto &hwInfo = pDevice->getNEODevice()->getHardwareInfo();
|
||||||
|
auto productFamily = hwInfo.platform.eProductFamily;
|
||||||
|
uint32_t numHbmModules = 0u;
|
||||||
|
switch (productFamily) {
|
||||||
|
case IGFX_DG2:
|
||||||
|
result = getBandwidthForDg2(pBandwidth);
|
||||||
|
break;
|
||||||
|
case IGFX_PVC:
|
||||||
|
numHbmModules = 4u;
|
||||||
|
result = getHbmBandwidthPVC(numHbmModules, pBandwidth);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) {
|
ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) {
|
||||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
ze_result_t status = ZE_RESULT_SUCCESS;
|
||||||
|
pState->health = ZES_MEM_HEALTH_UNKNOWN;
|
||||||
|
FirmwareUtil *pFwInterface = pLinuxSysmanImp->getFwUtilInterface();
|
||||||
|
auto productFamily = SysmanDeviceImp::getProductFamily(pDevice);
|
||||||
|
if ((pFwInterface != nullptr) && (IGFX_PVC == productFamily)) {
|
||||||
|
pFwInterface->fwGetMemoryHealthIndicator(&pState->health);
|
||||||
|
}
|
||||||
|
auto memoryInfo = pDrm->getIoctlHelper()->createMemoryInfo();
|
||||||
|
if (memoryInfo != nullptr) {
|
||||||
|
auto region = memoryInfo->getMemoryRegion(MemoryBanks::getBankForLocalMemory(subdeviceId));
|
||||||
|
pState->free = region.unallocatedSize;
|
||||||
|
pState->size = region.probedSize;
|
||||||
|
} else {
|
||||||
|
pState->free = 0;
|
||||||
|
pState->size = 0;
|
||||||
|
status = ZE_RESULT_ERROR_UNKNOWN;
|
||||||
|
if (errno == ENODEV) {
|
||||||
|
status = ZE_RESULT_ERROR_DEVICE_LOST;
|
||||||
|
}
|
||||||
|
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr,
|
||||||
|
"Error@ %s():createMemoryInfo failed errno:%d \n", __FUNCTION__, errno);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<OsMemory> OsMemory::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
|
std::unique_ptr<OsMemory> OsMemory::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2020-2023 Intel Corporation
|
* Copyright (C) 2022-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -11,11 +11,14 @@
|
|||||||
|
|
||||||
#include "level_zero/tools/source/sysman/memory/os_memory.h"
|
#include "level_zero/tools/source/sysman/memory/os_memory.h"
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
namespace L0 {
|
namespace L0 {
|
||||||
|
|
||||||
class SysfsAccess;
|
class SysfsAccess;
|
||||||
struct Device;
|
struct Device;
|
||||||
|
class PlatformMonitoringTech;
|
||||||
|
class LinuxSysmanImp;
|
||||||
class LinuxMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass {
|
class LinuxMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass {
|
||||||
public:
|
public:
|
||||||
ze_result_t getProperties(zes_mem_properties_t *pProperties) override;
|
ze_result_t getProperties(zes_mem_properties_t *pProperties) override;
|
||||||
@@ -28,11 +31,25 @@ class LinuxMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass {
|
|||||||
~LinuxMemoryImp() override = default;
|
~LinuxMemoryImp() override = default;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
L0::LinuxSysmanImp *pLinuxSysmanImp = nullptr;
|
||||||
|
SysfsAccess *pSysfsAccess = nullptr;
|
||||||
NEO::Drm *pDrm = nullptr;
|
NEO::Drm *pDrm = nullptr;
|
||||||
Device *pDevice = nullptr;
|
Device *pDevice = nullptr;
|
||||||
|
PlatformMonitoringTech *pPmt = nullptr;
|
||||||
|
void getHbmFrequency(PRODUCT_FAMILY productFamily, unsigned short stepping, uint64_t &hbmFrequency);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
ze_result_t readMcChannelCounters(uint64_t &readCounters, uint64_t &writeCounters);
|
||||||
|
ze_result_t getVFIDString(std::string &vfID);
|
||||||
|
ze_result_t getBandwidthForDg2(zes_mem_bandwidth_t *pBandwidth);
|
||||||
|
ze_result_t getHbmBandwidth(uint32_t numHbmModules, zes_mem_bandwidth_t *pBandwidth);
|
||||||
|
ze_result_t getHbmBandwidthPVC(uint32_t numHbmModules, zes_mem_bandwidth_t *pBandwidth);
|
||||||
|
ze_result_t getHbmBandwidthEx(uint32_t numHbmModules, uint32_t counterMaxValue, uint64_t *pReadCounters, uint64_t *pWriteCounters, uint64_t *pMaxBandwidth, uint64_t timeout);
|
||||||
|
void init();
|
||||||
|
static const std::string deviceMemoryHealth;
|
||||||
bool isSubdevice = false;
|
bool isSubdevice = false;
|
||||||
uint32_t subdeviceId = 0;
|
uint32_t subdeviceId = 0;
|
||||||
|
std::string physicalSizeFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2020-2023 Intel Corporation
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: MIT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "shared/source/memory_manager/memory_manager.h"
|
|
||||||
#include "shared/source/os_interface/linux/i915.h"
|
|
||||||
#include "shared/source/os_interface/linux/memory_info.h"
|
|
||||||
|
|
||||||
#include "level_zero/core/source/driver/driver_handle_imp.h"
|
|
||||||
#include "level_zero/tools/source/sysman/linux/os_sysman_imp.h"
|
|
||||||
#include "level_zero/tools/source/sysman/memory/linux/os_memory_imp.h"
|
|
||||||
|
|
||||||
namespace L0 {
|
|
||||||
|
|
||||||
LinuxMemoryImp::LinuxMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) : isSubdevice(onSubdevice), subdeviceId(subdeviceId) {
|
|
||||||
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
|
|
||||||
pDrm = &pLinuxSysmanImp->getDrm();
|
|
||||||
pDevice = pLinuxSysmanImp->getDeviceHandle();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LinuxMemoryImp::isMemoryModuleSupported() {
|
|
||||||
return pDevice->getDriverHandle()->getMemoryManager()->isLocalMemorySupported(pDevice->getRootDeviceIndex());
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t LinuxMemoryImp::getProperties(zes_mem_properties_t *pProperties) {
|
|
||||||
pProperties->location = ZES_MEM_LOC_DEVICE;
|
|
||||||
pProperties->type = ZES_MEM_TYPE_DDR;
|
|
||||||
pProperties->onSubdevice = isSubdevice;
|
|
||||||
pProperties->subdeviceId = subdeviceId;
|
|
||||||
pProperties->busWidth = -1;
|
|
||||||
pProperties->numChannels = -1;
|
|
||||||
pProperties->physicalSize = 0;
|
|
||||||
|
|
||||||
return ZE_RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t LinuxMemoryImp::getBandwidth(zes_mem_bandwidth_t *pBandwidth) {
|
|
||||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) {
|
|
||||||
std::vector<NEO::MemoryRegion> deviceRegions;
|
|
||||||
if (pDrm->queryMemoryInfo() == false) {
|
|
||||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto memoryInfo = pDrm->getMemoryInfo();
|
|
||||||
if (!memoryInfo) {
|
|
||||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
|
||||||
}
|
|
||||||
for (auto region : memoryInfo->getDrmRegionInfos()) {
|
|
||||||
if (region.region.memoryClass == drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE) {
|
|
||||||
deviceRegions.push_back(region);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pState->free = deviceRegions[subdeviceId].unallocatedSize;
|
|
||||||
pState->size = deviceRegions[subdeviceId].probedSize;
|
|
||||||
pState->health = ZES_MEM_HEALTH_OK;
|
|
||||||
return ZE_RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<OsMemory> OsMemory::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
|
|
||||||
std::unique_ptr<LinuxMemoryImp> pLinuxMemoryImp = std::make_unique<LinuxMemoryImp>(pOsSysman, onSubdevice, subdeviceId);
|
|
||||||
return pLinuxMemoryImp;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace L0
|
|
||||||
@@ -1,381 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2022-2024 Intel Corporation
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: MIT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "level_zero/tools/source/sysman/memory/linux/os_memory_imp_prelim.h"
|
|
||||||
|
|
||||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
|
||||||
#include "shared/source/device/device.h"
|
|
||||||
#include "shared/source/helpers/hw_info.h"
|
|
||||||
#include "shared/source/memory_manager/memory_banks.h"
|
|
||||||
#include "shared/source/memory_manager/memory_manager.h"
|
|
||||||
#include "shared/source/os_interface/linux/i915.h"
|
|
||||||
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
|
||||||
#include "shared/source/os_interface/linux/memory_info.h"
|
|
||||||
#include "shared/source/os_interface/linux/system_info.h"
|
|
||||||
|
|
||||||
#include "level_zero/core/source/driver/driver_handle.h"
|
|
||||||
#include "level_zero/tools/source/sysman/firmware_util/firmware_util.h"
|
|
||||||
#include "level_zero/tools/source/sysman/linux/os_sysman_imp.h"
|
|
||||||
#include "level_zero/tools/source/sysman/sysman_const.h"
|
|
||||||
|
|
||||||
#include "igfxfmid.h"
|
|
||||||
|
|
||||||
namespace L0 {
|
|
||||||
|
|
||||||
const std::string LinuxMemoryImp::deviceMemoryHealth("device_memory_health");
|
|
||||||
|
|
||||||
void memoryGetTimeStamp(uint64_t ×tamp) {
|
|
||||||
std::chrono::time_point<std::chrono::steady_clock> ts = std::chrono::steady_clock::now();
|
|
||||||
timestamp = std::chrono::duration_cast<std::chrono::microseconds>(ts.time_since_epoch()).count();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LinuxMemoryImp::init() {
|
|
||||||
if (isSubdevice) {
|
|
||||||
const std::string baseDir = "gt/gt" + std::to_string(subdeviceId) + "/";
|
|
||||||
physicalSizeFile = baseDir + "addr_range";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LinuxMemoryImp::LinuxMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) : isSubdevice(onSubdevice), subdeviceId(subdeviceId) {
|
|
||||||
pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
|
|
||||||
pDrm = &pLinuxSysmanImp->getDrm();
|
|
||||||
pDevice = pLinuxSysmanImp->getDeviceHandle();
|
|
||||||
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
|
|
||||||
pPmt = pLinuxSysmanImp->getPlatformMonitoringTechAccess(subdeviceId);
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LinuxMemoryImp::isMemoryModuleSupported() {
|
|
||||||
return pDevice->getDriverHandle()->getMemoryManager()->isLocalMemorySupported(pDevice->getRootDeviceIndex());
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t LinuxMemoryImp::getProperties(zes_mem_properties_t *pProperties) {
|
|
||||||
pProperties->type = ZES_MEM_TYPE_DDR;
|
|
||||||
pProperties->numChannels = -1;
|
|
||||||
if (pDrm->querySystemInfo()) {
|
|
||||||
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:
|
|
||||||
pProperties->type = ZES_MEM_TYPE_HBM;
|
|
||||||
break;
|
|
||||||
case NEO::DeviceBlobConstants::MemoryType::lpddr4:
|
|
||||||
pProperties->type = ZES_MEM_TYPE_LPDDR4;
|
|
||||||
break;
|
|
||||||
case NEO::DeviceBlobConstants::MemoryType::lpddr5:
|
|
||||||
pProperties->type = ZES_MEM_TYPE_LPDDR5;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
pProperties->type = ZES_MEM_TYPE_DDR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pProperties->location = ZES_MEM_LOC_DEVICE;
|
|
||||||
pProperties->onSubdevice = isSubdevice;
|
|
||||||
pProperties->subdeviceId = subdeviceId;
|
|
||||||
pProperties->busWidth = memoryBusWidth; // Hardcode
|
|
||||||
|
|
||||||
pProperties->physicalSize = 0;
|
|
||||||
if (isSubdevice) {
|
|
||||||
std::string memval;
|
|
||||||
ze_result_t result = pSysfsAccess->read(physicalSizeFile, memval);
|
|
||||||
uint64_t intval = strtoull(memval.c_str(), nullptr, 16);
|
|
||||||
if (ZE_RESULT_SUCCESS != result) {
|
|
||||||
pProperties->physicalSize = 0u;
|
|
||||||
} else {
|
|
||||||
pProperties->physicalSize = intval;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ZE_RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t LinuxMemoryImp::getVFIDString(std::string &vfID) {
|
|
||||||
uint32_t vf0VfIdVal = 0;
|
|
||||||
std::string key = "VF0_VFID";
|
|
||||||
auto result = pPmt->readValue(key, vf0VfIdVal);
|
|
||||||
if (result != ZE_RESULT_SUCCESS) {
|
|
||||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for VF0_VFID is returning error:0x%x \n", __FUNCTION__, result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t vf1VfIdVal = 0;
|
|
||||||
key = "VF1_VFID";
|
|
||||||
result = pPmt->readValue(key, vf1VfIdVal);
|
|
||||||
if (result != ZE_RESULT_SUCCESS) {
|
|
||||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for VF1_VFID is returning error:0x%x \n", __FUNCTION__, result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// At any point of time only one VF(virtual function) could be active and thus would
|
|
||||||
// read greater than zero val. If both VF0 and VF1 are reading 0 or both are reading
|
|
||||||
// greater than 0, then we would be confused in taking the decision of correct VF.
|
|
||||||
// Lets assume and report this as a error condition
|
|
||||||
if (((vf0VfIdVal == 0) && (vf1VfIdVal == 0)) ||
|
|
||||||
((vf0VfIdVal > 0) && (vf1VfIdVal > 0))) {
|
|
||||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s() VF0 returning 0x%x and VF1 returning 0x%x as both should not be the same \n", __FUNCTION__, vf0VfIdVal, vf1VfIdVal);
|
|
||||||
return ZE_RESULT_ERROR_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vf0VfIdVal > 0) {
|
|
||||||
vfID = "VF0";
|
|
||||||
}
|
|
||||||
if (vf1VfIdVal > 0) {
|
|
||||||
vfID = "VF1";
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t LinuxMemoryImp::readMcChannelCounters(uint64_t &readCounters, uint64_t &writeCounters) {
|
|
||||||
// For DG2 there are 8 memory instances each memory instance has 2 channels there are total 16 MC Channels
|
|
||||||
uint32_t numMcChannels = 16u;
|
|
||||||
ze_result_t result = ZE_RESULT_ERROR_UNKNOWN;
|
|
||||||
std::vector<std::string> nameOfCounters{"IDI_READS", "IDI_WRITES", "DISPLAY_VC1_READS"};
|
|
||||||
std::vector<uint64_t> counterValues(3, 0); // Will store the values of counters metioned in nameOfCounters
|
|
||||||
for (uint64_t counterIndex = 0; counterIndex < nameOfCounters.size(); counterIndex++) {
|
|
||||||
for (uint32_t mcChannelIndex = 0; mcChannelIndex < numMcChannels; mcChannelIndex++) {
|
|
||||||
uint64_t val = 0;
|
|
||||||
std::string readCounterKey = nameOfCounters[counterIndex] + "[" + std::to_string(mcChannelIndex) + "]";
|
|
||||||
result = pPmt->readValue(readCounterKey, val);
|
|
||||||
if (result != ZE_RESULT_SUCCESS) {
|
|
||||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for readCounterKey returning error:0x%x \n", __FUNCTION__, result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
counterValues[counterIndex] += val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// PMT counters returns number of transactions that have occured and each tranaction is of 64 bytes
|
|
||||||
// Multiplying 32(tranaction size) with number of transactions gives the total reads or writes in bytes
|
|
||||||
constexpr uint64_t transactionSize = 32;
|
|
||||||
readCounters = (counterValues[0] + counterValues[2]) * transactionSize; // Read counters are summation of total IDI_READS and DISPLAY_VC1_READS
|
|
||||||
writeCounters = (counterValues[1]) * transactionSize; // Write counters are summation of IDI_WRITES
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LinuxMemoryImp::getHbmFrequency(PRODUCT_FAMILY productFamily, unsigned short stepping, uint64_t &hbmFrequency) {
|
|
||||||
hbmFrequency = 0;
|
|
||||||
if (productFamily == IGFX_PVC) {
|
|
||||||
if (stepping >= REVISION_B) {
|
|
||||||
const std::string baseDir = "gt/gt" + std::to_string(subdeviceId) + "/";
|
|
||||||
// Calculating bandwidth based on HBM max frequency
|
|
||||||
const std::string hbmRP0FreqFile = baseDir + "mem_RP0_freq_mhz";
|
|
||||||
uint64_t hbmFreqValue = 0;
|
|
||||||
ze_result_t result = pSysfsAccess->read(hbmRP0FreqFile, hbmFreqValue);
|
|
||||||
if (ZE_RESULT_SUCCESS == result) {
|
|
||||||
hbmFrequency = hbmFreqValue * 1000 * 1000; // Converting MHz value to Hz
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else if (stepping == REVISION_A0) {
|
|
||||||
// For IGFX_PVC REV A0 HBM frequency would be 3.2 GT/s = 3.2 * 1000 * 1000 * 1000 T/s = 3200000000 T/s
|
|
||||||
hbmFrequency = 3.2 * gigaUnitTransferToUnitTransfer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t LinuxMemoryImp::getBandwidthForDg2(zes_mem_bandwidth_t *pBandwidth) {
|
|
||||||
pBandwidth->readCounter = 0;
|
|
||||||
pBandwidth->writeCounter = 0;
|
|
||||||
pBandwidth->timestamp = 0;
|
|
||||||
pBandwidth->maxBandwidth = 0;
|
|
||||||
ze_result_t result = readMcChannelCounters(pBandwidth->readCounter, pBandwidth->writeCounter);
|
|
||||||
if (result != ZE_RESULT_SUCCESS) {
|
|
||||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readMcChannelCounters returning error:0x%x \n", __FUNCTION__, result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
pBandwidth->maxBandwidth = 0u;
|
|
||||||
const std::string maxBwFile = "prelim_lmem_max_bw_Mbps";
|
|
||||||
uint64_t maxBw = 0;
|
|
||||||
result = pSysfsAccess->read(maxBwFile, maxBw);
|
|
||||||
if (result != ZE_RESULT_SUCCESS) {
|
|
||||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():pSysfsAccess->read returning error:0x%x \n", __FUNCTION__, result);
|
|
||||||
}
|
|
||||||
pBandwidth->maxBandwidth = maxBw * mbpsToBytesPerSecond;
|
|
||||||
pBandwidth->timestamp = SysmanDevice::getSysmanTimestamp();
|
|
||||||
return ZE_RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t LinuxMemoryImp::getHbmBandwidth(uint32_t numHbmModules, zes_mem_bandwidth_t *pBandwidth) {
|
|
||||||
pBandwidth->readCounter = 0;
|
|
||||||
pBandwidth->writeCounter = 0;
|
|
||||||
pBandwidth->timestamp = 0;
|
|
||||||
pBandwidth->maxBandwidth = 0;
|
|
||||||
ze_result_t result = ZE_RESULT_ERROR_UNKNOWN;
|
|
||||||
std::string vfId = "";
|
|
||||||
result = getVFIDString(vfId);
|
|
||||||
if (result != ZE_RESULT_SUCCESS) {
|
|
||||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():getVFIDString returning error:0x%x while retriving VFID string \n", __FUNCTION__, result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
auto &hwInfo = pDevice->getNEODevice()->getHardwareInfo();
|
|
||||||
auto productFamily = hwInfo.platform.eProductFamily;
|
|
||||||
auto &productHelper = pDevice->getNEODevice()->getProductHelper();
|
|
||||||
auto stepping = productHelper.getSteppingFromHwRevId(hwInfo);
|
|
||||||
for (auto hbmModuleIndex = 0u; hbmModuleIndex < numHbmModules; hbmModuleIndex++) {
|
|
||||||
uint32_t counterValue = 0;
|
|
||||||
// To read counters from VFID 0 and HBM module 0, key would be: VF0_HBM0_READ
|
|
||||||
std::string readCounterKey = vfId + "_HBM" + std::to_string(hbmModuleIndex) + "_READ";
|
|
||||||
result = pPmt->readValue(readCounterKey, counterValue);
|
|
||||||
if (result != ZE_RESULT_SUCCESS) {
|
|
||||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for readCounterKey returning error:0x%x \n", __FUNCTION__, result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
pBandwidth->readCounter += counterValue;
|
|
||||||
|
|
||||||
counterValue = 0;
|
|
||||||
// To write counters to VFID 0 and HBM module 0, key would be: VF0_HBM0_Write
|
|
||||||
std::string writeCounterKey = vfId + "_HBM" + std::to_string(hbmModuleIndex) + "_WRITE";
|
|
||||||
result = pPmt->readValue(writeCounterKey, counterValue);
|
|
||||||
if (result != ZE_RESULT_SUCCESS) {
|
|
||||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for writeCounterKey returning error:0x%x \n", __FUNCTION__, result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
pBandwidth->writeCounter += counterValue;
|
|
||||||
}
|
|
||||||
constexpr uint64_t transactionSize = 32;
|
|
||||||
pBandwidth->readCounter = pBandwidth->readCounter * transactionSize;
|
|
||||||
pBandwidth->writeCounter = pBandwidth->writeCounter * transactionSize;
|
|
||||||
pBandwidth->timestamp = SysmanDevice::getSysmanTimestamp();
|
|
||||||
|
|
||||||
uint64_t hbmFrequency = 0;
|
|
||||||
getHbmFrequency(productFamily, stepping, hbmFrequency);
|
|
||||||
|
|
||||||
pBandwidth->maxBandwidth = memoryBusWidth * hbmFrequency * numHbmModules; // Value in bytes/secs
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t LinuxMemoryImp::getHbmBandwidthPVC(uint32_t numHbmModules, zes_mem_bandwidth_t *pBandwidth) {
|
|
||||||
std::string guid = pPmt->getGuid();
|
|
||||||
if (guid != guid64BitMemoryCounters) {
|
|
||||||
return getHbmBandwidth(numHbmModules, pBandwidth);
|
|
||||||
}
|
|
||||||
pBandwidth->readCounter = 0;
|
|
||||||
pBandwidth->writeCounter = 0;
|
|
||||||
pBandwidth->timestamp = 0;
|
|
||||||
pBandwidth->maxBandwidth = 0;
|
|
||||||
ze_result_t result = ZE_RESULT_ERROR_UNKNOWN;
|
|
||||||
std::string vfId = "";
|
|
||||||
result = getVFIDString(vfId);
|
|
||||||
if (result != ZE_RESULT_SUCCESS) {
|
|
||||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():getVFIDString returning error:0x%x while retriving VFID string \n", __FUNCTION__, result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
auto &hwInfo = pDevice->getNEODevice()->getHardwareInfo();
|
|
||||||
auto productFamily = hwInfo.platform.eProductFamily;
|
|
||||||
auto &productHelper = pDevice->getNEODevice()->getProductHelper();
|
|
||||||
auto stepping = productHelper.getSteppingFromHwRevId(hwInfo);
|
|
||||||
|
|
||||||
uint32_t readCounterL = 0;
|
|
||||||
std::string readCounterKey = vfId + "_HBM_READ_L";
|
|
||||||
result = pPmt->readValue(readCounterKey, readCounterL);
|
|
||||||
if (result != ZE_RESULT_SUCCESS) {
|
|
||||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for readCounterL returning error:0x%x \n", __FUNCTION__, result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t readCounterH = 0;
|
|
||||||
readCounterKey = vfId + "_HBM_READ_H";
|
|
||||||
result = pPmt->readValue(readCounterKey, readCounterH);
|
|
||||||
if (result != ZE_RESULT_SUCCESS) {
|
|
||||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for readCounterH returning error:0x%x \n", __FUNCTION__, result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr uint64_t transactionSize = 32;
|
|
||||||
pBandwidth->readCounter = readCounterH;
|
|
||||||
pBandwidth->readCounter = (pBandwidth->readCounter << 32) | static_cast<uint64_t>(readCounterL);
|
|
||||||
pBandwidth->readCounter = (pBandwidth->readCounter * transactionSize);
|
|
||||||
|
|
||||||
uint32_t writeCounterL = 0;
|
|
||||||
std::string writeCounterKey = vfId + "_HBM_WRITE_L";
|
|
||||||
result = pPmt->readValue(writeCounterKey, writeCounterL);
|
|
||||||
if (result != ZE_RESULT_SUCCESS) {
|
|
||||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for writeCounterL returning error:0x%x \n", __FUNCTION__, result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t writeCounterH = 0;
|
|
||||||
writeCounterKey = vfId + "_HBM_WRITE_H";
|
|
||||||
result = pPmt->readValue(writeCounterKey, writeCounterH);
|
|
||||||
if (result != ZE_RESULT_SUCCESS) {
|
|
||||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for writeCounterH returning error:0x%x \n", __FUNCTION__, result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
pBandwidth->writeCounter = writeCounterH;
|
|
||||||
pBandwidth->writeCounter = (pBandwidth->writeCounter << 32) | static_cast<uint64_t>(writeCounterL);
|
|
||||||
pBandwidth->writeCounter = (pBandwidth->writeCounter * transactionSize);
|
|
||||||
|
|
||||||
uint64_t timeStampVal = 0;
|
|
||||||
memoryGetTimeStamp(timeStampVal);
|
|
||||||
pBandwidth->timestamp = timeStampVal;
|
|
||||||
|
|
||||||
uint64_t hbmFrequency = 0;
|
|
||||||
getHbmFrequency(productFamily, stepping, hbmFrequency);
|
|
||||||
|
|
||||||
pBandwidth->maxBandwidth = memoryBusWidth * hbmFrequency * numHbmModules; // Value in bytes/secs
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t LinuxMemoryImp::getBandwidth(zes_mem_bandwidth_t *pBandwidth) {
|
|
||||||
if (pPmt == nullptr) {
|
|
||||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
|
||||||
}
|
|
||||||
ze_result_t result = ZE_RESULT_ERROR_UNKNOWN;
|
|
||||||
auto &hwInfo = pDevice->getNEODevice()->getHardwareInfo();
|
|
||||||
auto productFamily = hwInfo.platform.eProductFamily;
|
|
||||||
uint32_t numHbmModules = 0u;
|
|
||||||
switch (productFamily) {
|
|
||||||
case IGFX_DG2:
|
|
||||||
result = getBandwidthForDg2(pBandwidth);
|
|
||||||
break;
|
|
||||||
case IGFX_PVC:
|
|
||||||
numHbmModules = 4u;
|
|
||||||
result = getHbmBandwidthPVC(numHbmModules, pBandwidth);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) {
|
|
||||||
ze_result_t status = ZE_RESULT_SUCCESS;
|
|
||||||
pState->health = ZES_MEM_HEALTH_UNKNOWN;
|
|
||||||
FirmwareUtil *pFwInterface = pLinuxSysmanImp->getFwUtilInterface();
|
|
||||||
auto productFamily = SysmanDeviceImp::getProductFamily(pDevice);
|
|
||||||
if ((pFwInterface != nullptr) && (IGFX_PVC == productFamily)) {
|
|
||||||
pFwInterface->fwGetMemoryHealthIndicator(&pState->health);
|
|
||||||
}
|
|
||||||
auto memoryInfo = pDrm->getIoctlHelper()->createMemoryInfo();
|
|
||||||
if (memoryInfo != nullptr) {
|
|
||||||
auto region = memoryInfo->getMemoryRegion(MemoryBanks::getBankForLocalMemory(subdeviceId));
|
|
||||||
pState->free = region.unallocatedSize;
|
|
||||||
pState->size = region.probedSize;
|
|
||||||
} else {
|
|
||||||
pState->free = 0;
|
|
||||||
pState->size = 0;
|
|
||||||
status = ZE_RESULT_ERROR_UNKNOWN;
|
|
||||||
if (errno == ENODEV) {
|
|
||||||
status = ZE_RESULT_ERROR_DEVICE_LOST;
|
|
||||||
}
|
|
||||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr,
|
|
||||||
"Error@ %s():createMemoryInfo failed errno:%d \n", __FUNCTION__, errno);
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<OsMemory> OsMemory::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
|
|
||||||
std::unique_ptr<LinuxMemoryImp> pLinuxMemoryImp = std::make_unique<LinuxMemoryImp>(pOsSysman, onSubdevice, subdeviceId);
|
|
||||||
return pLinuxMemoryImp;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace L0
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2022-2023 Intel Corporation
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: MIT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
|
||||||
#include "shared/source/os_interface/linux/drm_neo.h"
|
|
||||||
|
|
||||||
#include "level_zero/tools/source/sysman/memory/os_memory.h"
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
namespace L0 {
|
|
||||||
|
|
||||||
class SysfsAccess;
|
|
||||||
struct Device;
|
|
||||||
class PlatformMonitoringTech;
|
|
||||||
class LinuxSysmanImp;
|
|
||||||
class LinuxMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass {
|
|
||||||
public:
|
|
||||||
ze_result_t getProperties(zes_mem_properties_t *pProperties) override;
|
|
||||||
ze_result_t getBandwidth(zes_mem_bandwidth_t *pBandwidth) override;
|
|
||||||
ze_result_t getState(zes_mem_state_t *pState) override;
|
|
||||||
|
|
||||||
bool isMemoryModuleSupported() override;
|
|
||||||
LinuxMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId);
|
|
||||||
LinuxMemoryImp() = default;
|
|
||||||
~LinuxMemoryImp() override = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
L0::LinuxSysmanImp *pLinuxSysmanImp = nullptr;
|
|
||||||
SysfsAccess *pSysfsAccess = nullptr;
|
|
||||||
NEO::Drm *pDrm = nullptr;
|
|
||||||
Device *pDevice = nullptr;
|
|
||||||
PlatformMonitoringTech *pPmt = nullptr;
|
|
||||||
void getHbmFrequency(PRODUCT_FAMILY productFamily, unsigned short stepping, uint64_t &hbmFrequency);
|
|
||||||
|
|
||||||
private:
|
|
||||||
ze_result_t readMcChannelCounters(uint64_t &readCounters, uint64_t &writeCounters);
|
|
||||||
ze_result_t getVFIDString(std::string &vfID);
|
|
||||||
ze_result_t getBandwidthForDg2(zes_mem_bandwidth_t *pBandwidth);
|
|
||||||
ze_result_t getHbmBandwidth(uint32_t numHbmModules, zes_mem_bandwidth_t *pBandwidth);
|
|
||||||
ze_result_t getHbmBandwidthPVC(uint32_t numHbmModules, zes_mem_bandwidth_t *pBandwidth);
|
|
||||||
ze_result_t getHbmBandwidthEx(uint32_t numHbmModules, uint32_t counterMaxValue, uint64_t *pReadCounters, uint64_t *pWriteCounters, uint64_t *pMaxBandwidth, uint64_t timeout);
|
|
||||||
void init();
|
|
||||||
static const std::string deviceMemoryHealth;
|
|
||||||
bool isSubdevice = false;
|
|
||||||
uint32_t subdeviceId = 0;
|
|
||||||
std::string physicalSizeFile;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace L0
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2020-2024 Intel Corporation
|
# Copyright (C) 2020-2025 Intel Corporation
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
#
|
#
|
||||||
@@ -8,25 +8,10 @@ set(L0_TESTS_TOOLS_SYSMAN_MEMORY_LINUX
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NEO_ENABLE_I915_PRELIM_DETECTION)
|
list(APPEND L0_TESTS_TOOLS_SYSMAN_MEMORY_LINUX
|
||||||
list(APPEND L0_TESTS_TOOLS_SYSMAN_MEMORY_LINUX
|
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_memory.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_memory_prelim.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/mock_memory.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_memory_prelim.h
|
)
|
||||||
)
|
|
||||||
|
|
||||||
else()
|
|
||||||
if(SUPPORT_DG1)
|
|
||||||
list(APPEND L0_TESTS_TOOLS_SYSMAN_MEMORY_LINUX
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_memory_dg1.cpp
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_memory.h
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
list(APPEND L0_TESTS_TOOLS_SYSMAN_MEMORY_LINUX
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_memory.cpp
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_memory.h
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
target_sources(${TARGET_NAME}
|
target_sources(${TARGET_NAME}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2020-2023 Intel Corporation
|
* Copyright (C) 2021-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -7,7 +7,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "shared/source/os_interface/linux/i915.h"
|
#include "shared/source/os_interface/linux/i915.h"
|
||||||
|
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
||||||
#include "shared/source/os_interface/linux/memory_info.h"
|
#include "shared/source/os_interface/linux/memory_info.h"
|
||||||
|
#include "shared/source/os_interface/linux/system_info.h"
|
||||||
|
|
||||||
#include "level_zero/core/test/unit_tests/mocks/mock_memory_manager.h"
|
#include "level_zero/core/test/unit_tests/mocks/mock_memory_manager.h"
|
||||||
#include "level_zero/tools/source/sysman/linux/os_sysman_imp.h"
|
#include "level_zero/tools/source/sysman/linux/os_sysman_imp.h"
|
||||||
@@ -15,16 +17,189 @@
|
|||||||
#include "level_zero/tools/source/sysman/memory/memory_imp.h"
|
#include "level_zero/tools/source/sysman/memory/memory_imp.h"
|
||||||
|
|
||||||
using namespace NEO;
|
using namespace NEO;
|
||||||
constexpr uint64_t probedSizeRegionZero = 8 * MemoryConstants::gigaByte;
|
|
||||||
constexpr uint64_t probedSizeRegionOne = 16 * MemoryConstants::gigaByte;
|
constexpr uint32_t vF0HbmLRead = 16;
|
||||||
constexpr uint64_t probedSizeRegionTwo = 4 * MemoryConstants::gigaByte;
|
constexpr uint32_t vF0HbmHRead = 2;
|
||||||
constexpr uint64_t probedSizeRegionThree = 16 * MemoryConstants::gigaByte;
|
constexpr uint32_t vF0HbmLWrite = 8;
|
||||||
constexpr uint64_t unallocatedSizeRegionZero = 6 * MemoryConstants::gigaByte;
|
constexpr uint32_t vF0HbmHWrite = 2;
|
||||||
constexpr uint64_t unallocatedSizeRegionOne = 12 * MemoryConstants::gigaByte;
|
constexpr uint32_t vF1HbmLRead = 16;
|
||||||
constexpr uint64_t unallocatedSizeRegionTwo = 25 * MemoryConstants::gigaByte;
|
constexpr uint32_t vF1HbmHRead = 2;
|
||||||
constexpr uint64_t unallocatedSizeRegionThree = 3 * MemoryConstants::gigaByte;
|
constexpr uint32_t vF1HbmLWrite = 8;
|
||||||
|
constexpr uint32_t vF1HbmHWrite = 2;
|
||||||
|
constexpr uint16_t vF0VfidIndex = 88;
|
||||||
|
constexpr uint16_t vF0Hbm0ReadIndex = 92;
|
||||||
|
constexpr uint16_t vF0Hbm0WriteIndex = 96;
|
||||||
|
constexpr uint16_t vF0Hbm1ReadIndex = 104;
|
||||||
|
constexpr uint16_t vF0Hbm1WriteIndex = 108;
|
||||||
|
constexpr uint16_t vF0TimestampLIndex = 168;
|
||||||
|
constexpr uint16_t vF0TimestampHIndex = 172;
|
||||||
|
constexpr uint16_t vF1VfidIndex = 176;
|
||||||
|
constexpr uint16_t vF1Hbm0ReadIndex = 180;
|
||||||
|
constexpr uint16_t vF1Hbm0WriteIndex = 184;
|
||||||
|
constexpr uint16_t vF1Hbm1ReadIndex = 192;
|
||||||
|
constexpr uint16_t vF1Hbm1WriteIndex = 196;
|
||||||
|
constexpr uint16_t vF1TimestampLIndex = 256;
|
||||||
|
constexpr uint16_t vF1TimestampHIndex = 260;
|
||||||
|
constexpr uint16_t vF0Hbm2ReadIndex = 312;
|
||||||
|
constexpr uint16_t vF0Hbm2WriteIndex = 316;
|
||||||
|
constexpr uint16_t vF0Hbm3ReadIndex = 328;
|
||||||
|
constexpr uint16_t vF0Hbm3WriteIndex = 332;
|
||||||
|
constexpr uint16_t vF1Hbm2ReadIndex = 344;
|
||||||
|
constexpr uint16_t vF1Hbm2WriteIndex = 348;
|
||||||
|
constexpr uint16_t vF1Hbm3ReadIndex = 360;
|
||||||
|
constexpr uint16_t vF1Hbm3WriteIndex = 364;
|
||||||
|
|
||||||
|
constexpr uint8_t vF0VfidValue = 1;
|
||||||
|
constexpr uint8_t vF0Hbm0ReadValue = 92;
|
||||||
|
constexpr uint8_t vF0Hbm0WriteValue = 96;
|
||||||
|
constexpr uint8_t vF0Hbm1ReadValue = 104;
|
||||||
|
constexpr uint8_t vF0Hbm1WriteValue = 108;
|
||||||
|
constexpr uint8_t vF0TimestampLValue = 168;
|
||||||
|
constexpr uint8_t vF0TimestampHValue = 172;
|
||||||
|
constexpr uint8_t vF1VfidValue = 0;
|
||||||
|
constexpr uint8_t vF0Hbm2ReadValue = 113;
|
||||||
|
constexpr uint8_t vF0Hbm2WriteValue = 125;
|
||||||
|
constexpr uint8_t vF0Hbm3ReadValue = 135;
|
||||||
|
constexpr uint8_t vF0Hbm3WriteValue = 20;
|
||||||
|
|
||||||
|
constexpr uint8_t vF1Hbm0ReadValue = 92;
|
||||||
|
constexpr uint8_t vF1Hbm0WriteValue = 96;
|
||||||
|
constexpr uint8_t vF1Hbm1ReadValue = 104;
|
||||||
|
constexpr uint8_t vF1Hbm1WriteValue = 108;
|
||||||
|
constexpr uint8_t vF1TimestampLValue = 168;
|
||||||
|
constexpr uint8_t vF1TimestampHValue = 172;
|
||||||
|
constexpr uint8_t vF1Hbm2ReadValue = 113;
|
||||||
|
constexpr uint8_t vF1Hbm2WriteValue = 125;
|
||||||
|
constexpr uint8_t vF1Hbm3ReadValue = 135;
|
||||||
|
constexpr uint8_t vF1Hbm3WriteValue = 20;
|
||||||
|
constexpr uint64_t mockIdiReadVal = 8u;
|
||||||
|
constexpr uint64_t mockIdiWriteVal = 9u;
|
||||||
|
constexpr uint64_t mockDisplayVc1ReadVal = 10u;
|
||||||
|
constexpr uint64_t numberMcChannels = 16;
|
||||||
|
constexpr uint64_t transactionSize = 32;
|
||||||
|
|
||||||
namespace L0 {
|
namespace L0 {
|
||||||
namespace ult {
|
namespace ult {
|
||||||
|
uint32_t mockMemoryType = NEO::DeviceBlobConstants::MemoryType::hbm2e;
|
||||||
|
constexpr uint64_t hbmRP0Frequency = 4200; // in MHz
|
||||||
|
constexpr std::string_view mockPhysicalSize = "0x00000040000000";
|
||||||
|
constexpr std::string_view deviceMemoryHealth("device_memory_health");
|
||||||
|
constexpr std::string_view baseTelemSysFS("/sys/class/intel_pmt");
|
||||||
|
constexpr std::string_view realPathTelem1 = "/sys/devices/pci0000:89/0000:89:02.0/0000:86:00.0/0000:8b:02.0/0000:8e:00.1/pmt_telemetry.1.auto/intel_pmt/telem1";
|
||||||
|
constexpr std::string_view realPathTelem2 = "/sys/devices/pci0000:89/0000:89:02.0/0000:86:00.0/0000:8b:02.0/0000:8e:00.1/pmt_telemetry.1.auto/intel_pmt/telem2";
|
||||||
|
constexpr std::string_view realPathTelem3 = "/sys/devices/pci0000:89/0000:89:02.0/0000:86:00.0/0000:8b:02.0/0000:8e:00.1/pmt_telemetry.1.auto/intel_pmt/telem3";
|
||||||
|
constexpr std::string_view realPathTelem4 = "/sys/devices/pci0000:89/0000:89:02.0/0000:86:00.0/0000:8b:02.0/0000:8e:00.1/pmt_telemetry.1.auto/intel_pmt/telem4";
|
||||||
|
constexpr std::string_view realPathTelem5 = "/sys/devices/pci0000:89/0000:89:02.0/0000:86:00.0/0000:8b:02.0/0000:8e:00.1/pmt_telemetry.1.auto/intel_pmt/telem5";
|
||||||
|
constexpr std::string_view sysfsPathTelem1 = "/sys/class/intel_pmt/telem1";
|
||||||
|
constexpr std::string_view sysfsPathTelem2 = "/sys/class/intel_pmt/telem2";
|
||||||
|
constexpr std::string_view sysfsPathTelem3 = "/sys/class/intel_pmt/telem3";
|
||||||
|
constexpr std::string_view sysfsPathTelem4 = "/sys/class/intel_pmt/telem4";
|
||||||
|
constexpr std::string_view sysfsPathTelem5 = "/sys/class/intel_pmt/telem5";
|
||||||
|
|
||||||
|
struct MockMemorySysfsAccess : public SysfsAccess {
|
||||||
|
|
||||||
|
std::vector<ze_result_t> mockReadReturnStatus{};
|
||||||
|
std::vector<std::string> mockReadStringValue{};
|
||||||
|
std::vector<uint64_t> mockReadUInt64Value{};
|
||||||
|
bool isRepeated = false;
|
||||||
|
|
||||||
|
ze_result_t getVal(const std::string file, std::string &val) {
|
||||||
|
if ((file.compare("gt/gt0/addr_range") == 0) || (file.compare("gt/gt1/addr_range") == 0)) {
|
||||||
|
val = mockPhysicalSize;
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
val = "0";
|
||||||
|
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t getValError(const std::string file, std::string &val) {
|
||||||
|
val = "0";
|
||||||
|
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t getMemHealthValReturnErrorNotAvailable(const std::string file, std::string &val) {
|
||||||
|
if (file.compare(deviceMemoryHealth) == 0) {
|
||||||
|
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||||
|
}
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t getMemHealthReturnErrorUnknown(const std::string file, std::string &val) {
|
||||||
|
if (file.compare(deviceMemoryHealth) == 0) {
|
||||||
|
return ZE_RESULT_ERROR_UNKNOWN;
|
||||||
|
}
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t read(const std::string file, std::string &val) override {
|
||||||
|
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||||
|
if (!mockReadReturnStatus.empty()) {
|
||||||
|
result = mockReadReturnStatus.front();
|
||||||
|
if (!mockReadStringValue.empty()) {
|
||||||
|
val = mockReadStringValue.front();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isRepeated != true) {
|
||||||
|
mockReadReturnStatus.erase(mockReadReturnStatus.begin());
|
||||||
|
if (!mockReadStringValue.empty()) {
|
||||||
|
mockReadStringValue.erase(mockReadStringValue.begin());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file.compare(deviceMemoryHealth) == 0) {
|
||||||
|
val = "OK";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t read(const std::string file, uint64_t &val) override {
|
||||||
|
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||||
|
if (!mockReadReturnStatus.empty()) {
|
||||||
|
result = mockReadReturnStatus.front();
|
||||||
|
if (!mockReadUInt64Value.empty()) {
|
||||||
|
val = mockReadUInt64Value.front();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isRepeated != true) {
|
||||||
|
mockReadReturnStatus.erase(mockReadReturnStatus.begin());
|
||||||
|
if (!mockReadUInt64Value.empty()) {
|
||||||
|
mockReadUInt64Value.erase(mockReadUInt64Value.begin());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t getMemHealthDegraded(const std::string file, std::string &val) {
|
||||||
|
if (file.compare(deviceMemoryHealth) == 0) {
|
||||||
|
val = "REBOOT_ALARM";
|
||||||
|
}
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t getMemHealthCritical(const std::string file, std::string &val) {
|
||||||
|
if (file.compare(deviceMemoryHealth) == 0) {
|
||||||
|
val = "DEGRADED";
|
||||||
|
}
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t getMemHealthReplace(const std::string file, std::string &val) {
|
||||||
|
if (file.compare(deviceMemoryHealth) == 0) {
|
||||||
|
val = "DEGRADED_FAILED";
|
||||||
|
}
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t getMemHealthUnknown(const std::string file, std::string &val) {
|
||||||
|
if (file.compare(deviceMemoryHealth) == 0) {
|
||||||
|
val = "RANDOM";
|
||||||
|
}
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct MockMemoryManagerSysman : public MemoryManagerMock {
|
struct MockMemoryManagerSysman : public MemoryManagerMock {
|
||||||
MockMemoryManagerSysman(NEO::ExecutionEnvironment &executionEnvironment) : MemoryManagerMock(const_cast<NEO::ExecutionEnvironment &>(executionEnvironment)) {}
|
MockMemoryManagerSysman(NEO::ExecutionEnvironment &executionEnvironment) : MemoryManagerMock(const_cast<NEO::ExecutionEnvironment &>(executionEnvironment)) {}
|
||||||
@@ -32,27 +207,277 @@ struct MockMemoryManagerSysman : public MemoryManagerMock {
|
|||||||
|
|
||||||
struct MockMemoryNeoDrm : public Drm {
|
struct MockMemoryNeoDrm : public Drm {
|
||||||
using Drm::ioctlHelper;
|
using Drm::ioctlHelper;
|
||||||
using Drm::memoryInfo;
|
|
||||||
const int mockFd = 33;
|
const int mockFd = 33;
|
||||||
|
std::vector<bool> mockQuerySystemInfoReturnValue{};
|
||||||
|
bool isRepeated = false;
|
||||||
|
bool mockReturnEmptyRegions = false;
|
||||||
MockMemoryNeoDrm(RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceIdDrm>(mockFd, ""), rootDeviceEnvironment) {}
|
MockMemoryNeoDrm(RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceIdDrm>(mockFd, ""), rootDeviceEnvironment) {}
|
||||||
std::vector<bool> mockQueryMemoryInfoReturnStatus{};
|
|
||||||
bool queryMemoryInfo() override {
|
void setMemoryType(uint32_t memory) {
|
||||||
if (!mockQueryMemoryInfoReturnStatus.empty()) {
|
mockMemoryType = memory;
|
||||||
return mockQueryMemoryInfoReturnStatus.front();
|
}
|
||||||
|
|
||||||
|
std::vector<uint64_t> getMemoryRegionsReturnsEmpty() {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
bool querySystemInfo() override {
|
||||||
|
bool returnValue = true;
|
||||||
|
if (!mockQuerySystemInfoReturnValue.empty()) {
|
||||||
|
returnValue = mockQuerySystemInfoReturnValue.front();
|
||||||
|
if (isRepeated != true) {
|
||||||
|
mockQuerySystemInfoReturnValue.erase(mockQuerySystemInfoReturnValue.begin());
|
||||||
|
}
|
||||||
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<MemoryRegion> regionInfo(2);
|
uint32_t hwBlob[] = {NEO::DeviceBlobConstants::maxMemoryChannels, 1, 8, NEO::DeviceBlobConstants::memoryType, 0, mockMemoryType};
|
||||||
regionInfo[0].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_SYSTEM, 0};
|
std::vector<uint32_t> inputBlobData(reinterpret_cast<uint32_t *>(hwBlob), reinterpret_cast<uint32_t *>(ptrOffset(hwBlob, sizeof(hwBlob))));
|
||||||
regionInfo[0].probedSize = probedSizeRegionZero;
|
this->systemInfo.reset(new SystemInfo(inputBlobData));
|
||||||
regionInfo[0].unallocatedSize = unallocatedSizeRegionZero;
|
return returnValue;
|
||||||
regionInfo[1].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0};
|
|
||||||
regionInfo[1].probedSize = probedSizeRegionOne;
|
|
||||||
regionInfo[1].unallocatedSize = unallocatedSizeRegionOne;
|
|
||||||
|
|
||||||
this->memoryInfo.reset(new MemoryInfo(regionInfo, *this));
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct MockMemoryPmt : public PlatformMonitoringTech {
|
||||||
|
|
||||||
|
using PlatformMonitoringTech::guid;
|
||||||
|
using PlatformMonitoringTech::keyOffsetMap;
|
||||||
|
std::vector<ze_result_t> mockReadValueReturnStatus{};
|
||||||
|
std::vector<uint32_t> mockReadArgumentValue{};
|
||||||
|
ze_result_t mockIdiReadValueFailureReturnStatus = ZE_RESULT_SUCCESS;
|
||||||
|
ze_result_t mockIdiWriteFailureReturnStatus = ZE_RESULT_SUCCESS;
|
||||||
|
ze_result_t mockDisplayVc1ReadFailureReturnStatus = ZE_RESULT_SUCCESS;
|
||||||
|
ze_result_t mockReadTimeStampFailureReturnStatus = ZE_RESULT_SUCCESS;
|
||||||
|
bool mockVfid0Status = false;
|
||||||
|
bool mockVfid1Status = false;
|
||||||
|
bool isRepeated = false;
|
||||||
|
|
||||||
|
void setGuid(std::string_view guid) {
|
||||||
|
this->guid = guid;
|
||||||
|
}
|
||||||
|
|
||||||
|
MockMemoryPmt(FsAccess *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : PlatformMonitoringTech(pFsAccess, onSubdevice, subdeviceId) {}
|
||||||
|
ze_result_t readValue(const std::string key, uint32_t &val) override {
|
||||||
|
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||||
|
|
||||||
|
if (mockVfid0Status == true) {
|
||||||
|
return mockedReadValueWithVfid0True(key, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mockVfid1Status == true) {
|
||||||
|
return mockedReadValueWithVfid1True(key, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mockReadValueReturnStatus.empty()) {
|
||||||
|
result = mockReadValueReturnStatus.front();
|
||||||
|
if (!mockReadArgumentValue.empty()) {
|
||||||
|
val = mockReadArgumentValue.front();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isRepeated != true) {
|
||||||
|
mockReadValueReturnStatus.erase(mockReadValueReturnStatus.begin());
|
||||||
|
if (!mockReadArgumentValue.empty()) {
|
||||||
|
mockReadArgumentValue.erase(mockReadArgumentValue.begin());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t mockedReadValueWithVfid0True(const std::string key, uint32_t &val) {
|
||||||
|
if (key.compare("VF0_VFID") == 0) {
|
||||||
|
val = 1;
|
||||||
|
} else if (key.compare("VF1_VFID") == 0) {
|
||||||
|
val = 0;
|
||||||
|
} else if (key.compare("VF0_HBM0_READ") == 0) {
|
||||||
|
val = vF0Hbm0ReadValue;
|
||||||
|
} else if (key.compare("VF0_HBM0_WRITE") == 0) {
|
||||||
|
val = vF0Hbm0WriteValue;
|
||||||
|
} else if (key.compare("VF0_HBM1_READ") == 0) {
|
||||||
|
val = vF0Hbm1ReadValue;
|
||||||
|
} else if (key.compare("VF0_HBM1_WRITE") == 0) {
|
||||||
|
val = vF0Hbm1WriteValue;
|
||||||
|
} else if (key.compare("VF0_TIMESTAMP_L") == 0) {
|
||||||
|
val = vF0TimestampLValue;
|
||||||
|
} else if (key.compare("VF0_TIMESTAMP_H") == 0) {
|
||||||
|
val = vF0TimestampHValue;
|
||||||
|
} else if (key.compare("VF0_HBM2_READ") == 0) {
|
||||||
|
val = vF0Hbm2ReadValue;
|
||||||
|
} else if (key.compare("VF0_HBM2_WRITE") == 0) {
|
||||||
|
val = vF0Hbm2WriteValue;
|
||||||
|
} else if (key.compare("VF0_HBM3_READ") == 0) {
|
||||||
|
val = vF0Hbm3ReadValue;
|
||||||
|
} else if (key.compare("VF0_HBM3_WRITE") == 0) {
|
||||||
|
val = vF0Hbm3WriteValue;
|
||||||
|
} else if (key.compare("VF0_HBM_READ_L") == 0) {
|
||||||
|
val = vF0HbmLRead;
|
||||||
|
} else if (key.compare("VF0_HBM_READ_H") == 0) {
|
||||||
|
val = vF0HbmHRead;
|
||||||
|
} else if (key.compare("VF0_HBM_WRITE_L") == 0) {
|
||||||
|
val = vF0HbmLWrite;
|
||||||
|
} else if (key.compare("VF0_HBM_WRITE_H") == 0) {
|
||||||
|
val = vF0HbmHWrite;
|
||||||
|
} else {
|
||||||
|
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||||
|
}
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t mockedReadValueWithVfid1True(const std::string key, uint32_t &val) {
|
||||||
|
if (key.compare("VF0_VFID") == 0) {
|
||||||
|
val = 0;
|
||||||
|
} else if (key.compare("VF1_VFID") == 0) {
|
||||||
|
val = 1;
|
||||||
|
} else if (key.compare("VF1_HBM0_READ") == 0) {
|
||||||
|
val = vF1Hbm0ReadValue;
|
||||||
|
} else if (key.compare("VF1_HBM0_WRITE") == 0) {
|
||||||
|
val = vF1Hbm0WriteValue;
|
||||||
|
} else if (key.compare("VF1_HBM1_READ") == 0) {
|
||||||
|
val = vF1Hbm1ReadValue;
|
||||||
|
} else if (key.compare("VF1_HBM1_WRITE") == 0) {
|
||||||
|
val = vF1Hbm1WriteValue;
|
||||||
|
} else if (key.compare("VF1_TIMESTAMP_L") == 0) {
|
||||||
|
val = vF1TimestampLValue;
|
||||||
|
} else if (key.compare("VF1_TIMESTAMP_H") == 0) {
|
||||||
|
val = vF1TimestampHValue;
|
||||||
|
} else if (key.compare("VF1_HBM2_READ") == 0) {
|
||||||
|
val = vF1Hbm2ReadValue;
|
||||||
|
} else if (key.compare("VF1_HBM2_WRITE") == 0) {
|
||||||
|
val = vF1Hbm2WriteValue;
|
||||||
|
} else if (key.compare("VF1_HBM3_READ") == 0) {
|
||||||
|
val = vF1Hbm3ReadValue;
|
||||||
|
} else if (key.compare("VF1_HBM3_WRITE") == 0) {
|
||||||
|
val = vF1Hbm3WriteValue;
|
||||||
|
} else if (key.compare("VF1_HBM_READ_L") == 0) {
|
||||||
|
val = vF1HbmLRead;
|
||||||
|
} else if (key.compare("VF1_HBM_READ_H") == 0) {
|
||||||
|
val = vF1HbmHRead;
|
||||||
|
} else if (key.compare("VF1_HBM_WRITE_L") == 0) {
|
||||||
|
val = vF1HbmLWrite;
|
||||||
|
} else if (key.compare("VF1_HBM_WRITE_H") == 0) {
|
||||||
|
val = vF1HbmHWrite;
|
||||||
|
} else {
|
||||||
|
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||||
|
}
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t readValue(const std::string key, uint64_t &val) override {
|
||||||
|
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||||
|
|
||||||
|
if (mockIdiReadValueFailureReturnStatus != ZE_RESULT_SUCCESS) {
|
||||||
|
return mockIdiReadValueFailure(key, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mockIdiWriteFailureReturnStatus != ZE_RESULT_SUCCESS) {
|
||||||
|
return mockIdiWriteFailure(key, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mockDisplayVc1ReadFailureReturnStatus != ZE_RESULT_SUCCESS) {
|
||||||
|
return mockDisplayVc1ReadFailure(key, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mockReadTimeStampFailureReturnStatus != ZE_RESULT_SUCCESS) {
|
||||||
|
return mockReadTimeStampFailure(key, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key.compare("IDI_READS[0]") == 0 || key.compare("IDI_READS[1]") == 0 || key.compare("IDI_READS[2]") == 0 || key.compare("IDI_READS[3]") == 0 || key.compare("IDI_READS[4]") == 0 || key.compare("IDI_READS[5]") == 0 || key.compare("IDI_READS[6]") == 0 || key.compare("IDI_READS[7]") == 0 || key.compare("IDI_READS[8]") == 0 || key.compare("IDI_READS[9]") == 0 || key.compare("IDI_READS[10]") == 0 || key.compare("IDI_READS[11]") == 0 || key.compare("IDI_READS[12]") == 0 || key.compare("IDI_READS[13]") == 0 || key.compare("IDI_READS[14]") == 0 || key.compare("IDI_READS[15]") == 0) {
|
||||||
|
val = mockIdiReadVal;
|
||||||
|
} else if (key.compare("IDI_WRITES[0]") == 0 || key.compare("IDI_WRITES[1]") == 0 || key.compare("IDI_WRITES[2]") == 0 || key.compare("IDI_WRITES[3]") == 0 || key.compare("IDI_WRITES[4]") == 0 || key.compare("IDI_WRITES[5]") == 0 || key.compare("IDI_WRITES[6]") == 0 || key.compare("IDI_WRITES[7]") == 0 || key.compare("IDI_WRITES[8]") == 0 || key.compare("IDI_WRITES[9]") == 0 || key.compare("IDI_WRITES[10]") == 0 || key.compare("IDI_WRITES[11]") == 0 || key.compare("IDI_WRITES[12]") == 0 || key.compare("IDI_WRITES[13]") == 0 || key.compare("IDI_WRITES[14]") == 0 || key.compare("IDI_WRITES[15]") == 0) {
|
||||||
|
val = mockIdiWriteVal;
|
||||||
|
} else if (key.compare("DISPLAY_VC1_READS[0]") == 0 || key.compare("DISPLAY_VC1_READS[1]") == 0 || key.compare("DISPLAY_VC1_READS[2]") == 0 || key.compare("DISPLAY_VC1_READS[3]") == 0 || key.compare("DISPLAY_VC1_READS[4]") == 0 || key.compare("DISPLAY_VC1_READS[5]") == 0 || key.compare("DISPLAY_VC1_READS[6]") == 0 || key.compare("DISPLAY_VC1_READS[7]") == 0 || key.compare("DISPLAY_VC1_READS[8]") == 0 || key.compare("DISPLAY_VC1_READS[9]") == 0 || key.compare("DISPLAY_VC1_READS[10]") == 0 || key.compare("DISPLAY_VC1_READS[11]") == 0 || key.compare("DISPLAY_VC1_READS[12]") == 0 || key.compare("DISPLAY_VC1_READS[13]") == 0 || key.compare("DISPLAY_VC1_READS[14]") == 0 || key.compare("DISPLAY_VC1_READS[15]") == 0) {
|
||||||
|
val = mockDisplayVc1ReadVal;
|
||||||
|
} else {
|
||||||
|
result = ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t mockIdiReadValueFailure(const std::string key, uint64_t &val) {
|
||||||
|
return ZE_RESULT_ERROR_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t mockIdiWriteFailure(const std::string key, uint64_t &val) {
|
||||||
|
if (key.compare("IDI_READS[0]") == 0 || key.compare("IDI_READS[1]") == 0 || key.compare("IDI_READS[2]") == 0 || key.compare("IDI_READS[3]") == 0 || key.compare("IDI_READS[4]") == 0 || key.compare("IDI_READS[5]") == 0 || key.compare("IDI_READS[6]") == 0 || key.compare("IDI_READS[7]") == 0 || key.compare("IDI_READS[8]") == 0 || key.compare("IDI_READS[9]") == 0 || key.compare("IDI_READS[10]") == 0 || key.compare("IDI_READS[11]") == 0 || key.compare("IDI_READS[12]") == 0 || key.compare("IDI_READS[13]") == 0 || key.compare("IDI_READS[14]") == 0 || key.compare("IDI_READS[15]") == 0) {
|
||||||
|
val = mockIdiReadVal;
|
||||||
|
} else if (key.compare("IDI_WRITES[0]") == 0 || key.compare("IDI_WRITES[1]") == 0 || key.compare("IDI_WRITES[2]") == 0 || key.compare("IDI_WRITES[3]") == 0 || key.compare("IDI_WRITES[4]") == 0 || key.compare("IDI_WRITES[5]") == 0 || key.compare("IDI_WRITES[6]") == 0 || key.compare("IDI_WRITES[7]") == 0 || key.compare("IDI_WRITES[8]") == 0 || key.compare("IDI_WRITES[9]") == 0 || key.compare("IDI_WRITES[10]") == 0 || key.compare("IDI_WRITES[11]") == 0 || key.compare("IDI_WRITES[12]") == 0 || key.compare("IDI_WRITES[13]") == 0 || key.compare("IDI_WRITES[14]") == 0 || key.compare("IDI_WRITES[15]") == 0) {
|
||||||
|
return ZE_RESULT_ERROR_UNKNOWN;
|
||||||
|
}
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t mockDisplayVc1ReadFailure(const std::string key, uint64_t &val) {
|
||||||
|
if (key.compare("IDI_READS[0]") == 0 || key.compare("IDI_READS[1]") == 0 || key.compare("IDI_READS[2]") == 0 || key.compare("IDI_READS[3]") == 0 || key.compare("IDI_READS[4]") == 0 || key.compare("IDI_READS[5]") == 0 || key.compare("IDI_READS[6]") == 0 || key.compare("IDI_READS[7]") == 0 || key.compare("IDI_READS[8]") == 0 || key.compare("IDI_READS[9]") == 0 || key.compare("IDI_READS[10]") == 0 || key.compare("IDI_READS[11]") == 0 || key.compare("IDI_READS[12]") == 0 || key.compare("IDI_READS[13]") == 0 || key.compare("IDI_READS[14]") == 0 || key.compare("IDI_READS[15]") == 0) {
|
||||||
|
val = mockIdiReadVal;
|
||||||
|
} else if (key.compare("IDI_WRITES[0]") == 0 || key.compare("IDI_WRITES[1]") == 0 || key.compare("IDI_WRITES[2]") == 0 || key.compare("IDI_WRITES[3]") == 0 || key.compare("IDI_WRITES[4]") == 0 || key.compare("IDI_WRITES[5]") == 0 || key.compare("IDI_WRITES[6]") == 0 || key.compare("IDI_WRITES[7]") == 0 || key.compare("IDI_WRITES[8]") == 0 || key.compare("IDI_WRITES[9]") == 0 || key.compare("IDI_WRITES[10]") == 0 || key.compare("IDI_WRITES[11]") == 0 || key.compare("IDI_WRITES[12]") == 0 || key.compare("IDI_WRITES[13]") == 0 || key.compare("IDI_WRITES[14]") == 0 || key.compare("IDI_WRITES[15]") == 0) {
|
||||||
|
val = mockIdiWriteVal;
|
||||||
|
} else if (key.compare("DISPLAY_VC1_READS[0]") == 0 || key.compare("DISPLAY_VC1_READS[1]") == 0 || key.compare("DISPLAY_VC1_READS[2]") == 0 || key.compare("DISPLAY_VC1_READS[3]") == 0 || key.compare("DISPLAY_VC1_READS[4]") == 0 || key.compare("DISPLAY_VC1_READS[5]") == 0 || key.compare("DISPLAY_VC1_READS[6]") == 0 || key.compare("DISPLAY_VC1_READS[7]") == 0 || key.compare("DISPLAY_VC1_READS[8]") == 0 || key.compare("DISPLAY_VC1_READS[9]") == 0 || key.compare("DISPLAY_VC1_READS[10]") == 0 || key.compare("DISPLAY_VC1_READS[11]") == 0 || key.compare("DISPLAY_VC1_READS[12]") == 0 || key.compare("DISPLAY_VC1_READS[13]") == 0 || key.compare("DISPLAY_VC1_READS[14]") == 0 || key.compare("DISPLAY_VC1_READS[15]") == 0) {
|
||||||
|
return ZE_RESULT_ERROR_UNKNOWN;
|
||||||
|
}
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t mockReadTimeStampFailure(const std::string key, uint64_t &val) {
|
||||||
|
if (key.compare("IDI_READS[0]") == 0 || key.compare("IDI_READS[1]") == 0 || key.compare("IDI_READS[2]") == 0 || key.compare("IDI_READS[3]") == 0 || key.compare("IDI_READS[4]") == 0 || key.compare("IDI_READS[5]") == 0 || key.compare("IDI_READS[6]") == 0 || key.compare("IDI_READS[7]") == 0 || key.compare("IDI_READS[8]") == 0 || key.compare("IDI_READS[9]") == 0 || key.compare("IDI_READS[10]") == 0 || key.compare("IDI_READS[11]") == 0 || key.compare("IDI_READS[12]") == 0 || key.compare("IDI_READS[13]") == 0 || key.compare("IDI_READS[14]") == 0 || key.compare("IDI_READS[15]") == 0) {
|
||||||
|
val = mockIdiReadVal;
|
||||||
|
} else if (key.compare("IDI_WRITES[0]") == 0 || key.compare("IDI_WRITES[1]") == 0 || key.compare("IDI_WRITES[2]") == 0 || key.compare("IDI_WRITES[3]") == 0 || key.compare("IDI_WRITES[4]") == 0 || key.compare("IDI_WRITES[5]") == 0 || key.compare("IDI_WRITES[6]") == 0 || key.compare("IDI_WRITES[7]") == 0 || key.compare("IDI_WRITES[8]") == 0 || key.compare("IDI_WRITES[9]") == 0 || key.compare("IDI_WRITES[10]") == 0 || key.compare("IDI_WRITES[11]") == 0 || key.compare("IDI_WRITES[12]") == 0 || key.compare("IDI_WRITES[13]") == 0 || key.compare("IDI_WRITES[14]") == 0 || key.compare("IDI_WRITES[15]") == 0) {
|
||||||
|
val = mockIdiWriteVal;
|
||||||
|
} else if (key.compare("DISPLAY_VC1_READS[0]") == 0 || key.compare("DISPLAY_VC1_READS[1]") == 0 || key.compare("DISPLAY_VC1_READS[2]") == 0 || key.compare("DISPLAY_VC1_READS[3]") == 0 || key.compare("DISPLAY_VC1_READS[4]") == 0 || key.compare("DISPLAY_VC1_READS[5]") == 0 || key.compare("DISPLAY_VC1_READS[6]") == 0 || key.compare("DISPLAY_VC1_READS[7]") == 0 || key.compare("DISPLAY_VC1_READS[8]") == 0 || key.compare("DISPLAY_VC1_READS[9]") == 0 || key.compare("DISPLAY_VC1_READS[10]") == 0 || key.compare("DISPLAY_VC1_READS[11]") == 0 || key.compare("DISPLAY_VC1_READS[12]") == 0 || key.compare("DISPLAY_VC1_READS[13]") == 0 || key.compare("DISPLAY_VC1_READS[14]") == 0 || key.compare("DISPLAY_VC1_READS[15]") == 0) {
|
||||||
|
val = mockDisplayVc1ReadVal;
|
||||||
|
} else {
|
||||||
|
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||||
|
}
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MockMemoryFsAccess : public FsAccess {
|
||||||
|
ze_result_t listDirectory(const std::string directory, std::vector<std::string> &listOfTelemNodes) override {
|
||||||
|
if (directory.compare(baseTelemSysFS) == 0) {
|
||||||
|
listOfTelemNodes.push_back("telem1");
|
||||||
|
listOfTelemNodes.push_back("telem2");
|
||||||
|
listOfTelemNodes.push_back("telem3");
|
||||||
|
listOfTelemNodes.push_back("telem4");
|
||||||
|
listOfTelemNodes.push_back("telem5");
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t listDirectoryFailure(const std::string directory, std::vector<std::string> &events) {
|
||||||
|
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t getRealPath(const std::string path, std::string &buf) override {
|
||||||
|
if (path.compare(sysfsPathTelem1) == 0) {
|
||||||
|
buf = realPathTelem1;
|
||||||
|
} else if (path.compare(sysfsPathTelem2) == 0) {
|
||||||
|
buf = realPathTelem2;
|
||||||
|
} else if (path.compare(sysfsPathTelem3) == 0) {
|
||||||
|
buf = realPathTelem3;
|
||||||
|
} else if (path.compare(sysfsPathTelem4) == 0) {
|
||||||
|
buf = realPathTelem4;
|
||||||
|
} else if (path.compare(sysfsPathTelem5) == 0) {
|
||||||
|
buf = realPathTelem5;
|
||||||
|
} else {
|
||||||
|
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||||
|
}
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
ze_result_t getRealPathFailure(const std::string path, std::string &buf) {
|
||||||
|
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
MockMemoryFsAccess() = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PublicLinuxMemoryImp : public L0::LinuxMemoryImp {
|
||||||
|
public:
|
||||||
|
PublicLinuxMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) : LinuxMemoryImp(pOsSysman, onSubdevice, subdeviceId) {}
|
||||||
|
PublicLinuxMemoryImp() = default;
|
||||||
|
using LinuxMemoryImp::getHbmFrequency;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace ult
|
} // namespace ult
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|||||||
@@ -1,484 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2021-2024 Intel Corporation
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: MIT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "shared/source/os_interface/linux/i915.h"
|
|
||||||
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
|
||||||
#include "shared/source/os_interface/linux/memory_info.h"
|
|
||||||
#include "shared/source/os_interface/linux/system_info.h"
|
|
||||||
|
|
||||||
#include "level_zero/core/test/unit_tests/mocks/mock_memory_manager.h"
|
|
||||||
#include "level_zero/tools/source/sysman/linux/os_sysman_imp.h"
|
|
||||||
#include "level_zero/tools/source/sysman/memory/linux/os_memory_imp_prelim.h"
|
|
||||||
#include "level_zero/tools/source/sysman/memory/memory_imp.h"
|
|
||||||
|
|
||||||
using namespace NEO;
|
|
||||||
|
|
||||||
constexpr uint32_t vF0HbmLRead = 16;
|
|
||||||
constexpr uint32_t vF0HbmHRead = 2;
|
|
||||||
constexpr uint32_t vF0HbmLWrite = 8;
|
|
||||||
constexpr uint32_t vF0HbmHWrite = 2;
|
|
||||||
constexpr uint32_t vF1HbmLRead = 16;
|
|
||||||
constexpr uint32_t vF1HbmHRead = 2;
|
|
||||||
constexpr uint32_t vF1HbmLWrite = 8;
|
|
||||||
constexpr uint32_t vF1HbmHWrite = 2;
|
|
||||||
constexpr uint16_t vF0VfidIndex = 88;
|
|
||||||
constexpr uint16_t vF0Hbm0ReadIndex = 92;
|
|
||||||
constexpr uint16_t vF0Hbm0WriteIndex = 96;
|
|
||||||
constexpr uint16_t vF0Hbm1ReadIndex = 104;
|
|
||||||
constexpr uint16_t vF0Hbm1WriteIndex = 108;
|
|
||||||
constexpr uint16_t vF0TimestampLIndex = 168;
|
|
||||||
constexpr uint16_t vF0TimestampHIndex = 172;
|
|
||||||
constexpr uint16_t vF1VfidIndex = 176;
|
|
||||||
constexpr uint16_t vF1Hbm0ReadIndex = 180;
|
|
||||||
constexpr uint16_t vF1Hbm0WriteIndex = 184;
|
|
||||||
constexpr uint16_t vF1Hbm1ReadIndex = 192;
|
|
||||||
constexpr uint16_t vF1Hbm1WriteIndex = 196;
|
|
||||||
constexpr uint16_t vF1TimestampLIndex = 256;
|
|
||||||
constexpr uint16_t vF1TimestampHIndex = 260;
|
|
||||||
constexpr uint16_t vF0Hbm2ReadIndex = 312;
|
|
||||||
constexpr uint16_t vF0Hbm2WriteIndex = 316;
|
|
||||||
constexpr uint16_t vF0Hbm3ReadIndex = 328;
|
|
||||||
constexpr uint16_t vF0Hbm3WriteIndex = 332;
|
|
||||||
constexpr uint16_t vF1Hbm2ReadIndex = 344;
|
|
||||||
constexpr uint16_t vF1Hbm2WriteIndex = 348;
|
|
||||||
constexpr uint16_t vF1Hbm3ReadIndex = 360;
|
|
||||||
constexpr uint16_t vF1Hbm3WriteIndex = 364;
|
|
||||||
|
|
||||||
constexpr uint8_t vF0VfidValue = 1;
|
|
||||||
constexpr uint8_t vF0Hbm0ReadValue = 92;
|
|
||||||
constexpr uint8_t vF0Hbm0WriteValue = 96;
|
|
||||||
constexpr uint8_t vF0Hbm1ReadValue = 104;
|
|
||||||
constexpr uint8_t vF0Hbm1WriteValue = 108;
|
|
||||||
constexpr uint8_t vF0TimestampLValue = 168;
|
|
||||||
constexpr uint8_t vF0TimestampHValue = 172;
|
|
||||||
constexpr uint8_t vF1VfidValue = 0;
|
|
||||||
constexpr uint8_t vF0Hbm2ReadValue = 113;
|
|
||||||
constexpr uint8_t vF0Hbm2WriteValue = 125;
|
|
||||||
constexpr uint8_t vF0Hbm3ReadValue = 135;
|
|
||||||
constexpr uint8_t vF0Hbm3WriteValue = 20;
|
|
||||||
|
|
||||||
constexpr uint8_t vF1Hbm0ReadValue = 92;
|
|
||||||
constexpr uint8_t vF1Hbm0WriteValue = 96;
|
|
||||||
constexpr uint8_t vF1Hbm1ReadValue = 104;
|
|
||||||
constexpr uint8_t vF1Hbm1WriteValue = 108;
|
|
||||||
constexpr uint8_t vF1TimestampLValue = 168;
|
|
||||||
constexpr uint8_t vF1TimestampHValue = 172;
|
|
||||||
constexpr uint8_t vF1Hbm2ReadValue = 113;
|
|
||||||
constexpr uint8_t vF1Hbm2WriteValue = 125;
|
|
||||||
constexpr uint8_t vF1Hbm3ReadValue = 135;
|
|
||||||
constexpr uint8_t vF1Hbm3WriteValue = 20;
|
|
||||||
constexpr uint64_t mockIdiReadVal = 8u;
|
|
||||||
constexpr uint64_t mockIdiWriteVal = 9u;
|
|
||||||
constexpr uint64_t mockDisplayVc1ReadVal = 10u;
|
|
||||||
constexpr uint64_t numberMcChannels = 16;
|
|
||||||
constexpr uint64_t transactionSize = 32;
|
|
||||||
|
|
||||||
namespace L0 {
|
|
||||||
namespace ult {
|
|
||||||
uint32_t mockMemoryType = NEO::DeviceBlobConstants::MemoryType::hbm2e;
|
|
||||||
std::string mockPhysicalSize = "0x00000040000000";
|
|
||||||
uint64_t hbmRP0Frequency = 4200; // in MHz
|
|
||||||
const std::string deviceMemoryHealth("device_memory_health");
|
|
||||||
std::string gpuUpstreamPortPathInMemory = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0";
|
|
||||||
const std::string baseTelemSysFS("/sys/class/intel_pmt");
|
|
||||||
const std::string realPathTelem1 = "/sys/devices/pci0000:89/0000:89:02.0/0000:86:00.0/0000:8b:02.0/0000:8e:00.1/pmt_telemetry.1.auto/intel_pmt/telem1";
|
|
||||||
const std::string realPathTelem2 = "/sys/devices/pci0000:89/0000:89:02.0/0000:86:00.0/0000:8b:02.0/0000:8e:00.1/pmt_telemetry.1.auto/intel_pmt/telem2";
|
|
||||||
const std::string realPathTelem3 = "/sys/devices/pci0000:89/0000:89:02.0/0000:86:00.0/0000:8b:02.0/0000:8e:00.1/pmt_telemetry.1.auto/intel_pmt/telem3";
|
|
||||||
const std::string realPathTelem4 = "/sys/devices/pci0000:89/0000:89:02.0/0000:86:00.0/0000:8b:02.0/0000:8e:00.1/pmt_telemetry.1.auto/intel_pmt/telem4";
|
|
||||||
const std::string realPathTelem5 = "/sys/devices/pci0000:89/0000:89:02.0/0000:86:00.0/0000:8b:02.0/0000:8e:00.1/pmt_telemetry.1.auto/intel_pmt/telem5";
|
|
||||||
const std::string sysfsPahTelem1 = "/sys/class/intel_pmt/telem1";
|
|
||||||
const std::string sysfsPahTelem2 = "/sys/class/intel_pmt/telem2";
|
|
||||||
const std::string sysfsPahTelem3 = "/sys/class/intel_pmt/telem3";
|
|
||||||
const std::string sysfsPahTelem4 = "/sys/class/intel_pmt/telem4";
|
|
||||||
const std::string sysfsPahTelem5 = "/sys/class/intel_pmt/telem5";
|
|
||||||
|
|
||||||
struct MockMemorySysfsAccess : public SysfsAccess {
|
|
||||||
|
|
||||||
std::vector<ze_result_t> mockReadReturnStatus{};
|
|
||||||
std::vector<std::string> mockReadStringValue{};
|
|
||||||
std::vector<uint64_t> mockReadUInt64Value{};
|
|
||||||
bool isRepeated = false;
|
|
||||||
|
|
||||||
ze_result_t getVal(const std::string file, std::string &val) {
|
|
||||||
if ((file.compare("gt/gt0/addr_range") == 0) || (file.compare("gt/gt1/addr_range") == 0)) {
|
|
||||||
val = mockPhysicalSize;
|
|
||||||
return ZE_RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
val = "0";
|
|
||||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t getValError(const std::string file, std::string &val) {
|
|
||||||
val = "0";
|
|
||||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t getMemHealthValReturnErrorNotAvailable(const std::string file, std::string &val) {
|
|
||||||
if (file.compare(deviceMemoryHealth) == 0) {
|
|
||||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
|
||||||
}
|
|
||||||
return ZE_RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t getMemHealthReturnErrorUnknown(const std::string file, std::string &val) {
|
|
||||||
if (file.compare(deviceMemoryHealth) == 0) {
|
|
||||||
return ZE_RESULT_ERROR_UNKNOWN;
|
|
||||||
}
|
|
||||||
return ZE_RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t read(const std::string file, std::string &val) override {
|
|
||||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
|
||||||
if (!mockReadReturnStatus.empty()) {
|
|
||||||
result = mockReadReturnStatus.front();
|
|
||||||
if (!mockReadStringValue.empty()) {
|
|
||||||
val = mockReadStringValue.front();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isRepeated != true) {
|
|
||||||
mockReadReturnStatus.erase(mockReadReturnStatus.begin());
|
|
||||||
if (!mockReadStringValue.empty()) {
|
|
||||||
mockReadStringValue.erase(mockReadStringValue.begin());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (file.compare(deviceMemoryHealth) == 0) {
|
|
||||||
val = "OK";
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t read(const std::string file, uint64_t &val) override {
|
|
||||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
|
||||||
if (!mockReadReturnStatus.empty()) {
|
|
||||||
result = mockReadReturnStatus.front();
|
|
||||||
if (!mockReadUInt64Value.empty()) {
|
|
||||||
val = mockReadUInt64Value.front();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isRepeated != true) {
|
|
||||||
mockReadReturnStatus.erase(mockReadReturnStatus.begin());
|
|
||||||
if (!mockReadUInt64Value.empty()) {
|
|
||||||
mockReadUInt64Value.erase(mockReadUInt64Value.begin());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t getMemHealthDegraded(const std::string file, std::string &val) {
|
|
||||||
if (file.compare(deviceMemoryHealth) == 0) {
|
|
||||||
val = "REBOOT_ALARM";
|
|
||||||
}
|
|
||||||
return ZE_RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t getMemHealthCritical(const std::string file, std::string &val) {
|
|
||||||
if (file.compare(deviceMemoryHealth) == 0) {
|
|
||||||
val = "DEGRADED";
|
|
||||||
}
|
|
||||||
return ZE_RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t getMemHealthReplace(const std::string file, std::string &val) {
|
|
||||||
if (file.compare(deviceMemoryHealth) == 0) {
|
|
||||||
val = "DEGRADED_FAILED";
|
|
||||||
}
|
|
||||||
return ZE_RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t getMemHealthUnknown(const std::string file, std::string &val) {
|
|
||||||
if (file.compare(deviceMemoryHealth) == 0) {
|
|
||||||
val = "RANDOM";
|
|
||||||
}
|
|
||||||
return ZE_RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MockMemoryManagerSysman : public MemoryManagerMock {
|
|
||||||
MockMemoryManagerSysman(NEO::ExecutionEnvironment &executionEnvironment) : MemoryManagerMock(const_cast<NEO::ExecutionEnvironment &>(executionEnvironment)) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MockMemoryNeoDrm : public Drm {
|
|
||||||
using Drm::ioctlHelper;
|
|
||||||
const int mockFd = 33;
|
|
||||||
std::vector<bool> mockQuerySystemInfoReturnValue{};
|
|
||||||
bool isRepeated = false;
|
|
||||||
bool mockReturnEmptyRegions = false;
|
|
||||||
MockMemoryNeoDrm(RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceIdDrm>(mockFd, ""), rootDeviceEnvironment) {}
|
|
||||||
|
|
||||||
void setMemoryType(uint32_t memory) {
|
|
||||||
mockMemoryType = memory;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<uint64_t> getMemoryRegionsReturnsEmpty() {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
bool querySystemInfo() override {
|
|
||||||
bool returnValue = true;
|
|
||||||
if (!mockQuerySystemInfoReturnValue.empty()) {
|
|
||||||
returnValue = mockQuerySystemInfoReturnValue.front();
|
|
||||||
if (isRepeated != true) {
|
|
||||||
mockQuerySystemInfoReturnValue.erase(mockQuerySystemInfoReturnValue.begin());
|
|
||||||
}
|
|
||||||
return returnValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t hwBlob[] = {NEO::DeviceBlobConstants::maxMemoryChannels, 1, 8, NEO::DeviceBlobConstants::memoryType, 0, mockMemoryType};
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MockMemoryPmt : public PlatformMonitoringTech {
|
|
||||||
|
|
||||||
using PlatformMonitoringTech::guid;
|
|
||||||
using PlatformMonitoringTech::keyOffsetMap;
|
|
||||||
std::vector<ze_result_t> mockReadValueReturnStatus{};
|
|
||||||
std::vector<uint32_t> mockReadArgumentValue{};
|
|
||||||
ze_result_t mockIdiReadValueFailureReturnStatus = ZE_RESULT_SUCCESS;
|
|
||||||
ze_result_t mockIdiWriteFailureReturnStatus = ZE_RESULT_SUCCESS;
|
|
||||||
ze_result_t mockDisplayVc1ReadFailureReturnStatus = ZE_RESULT_SUCCESS;
|
|
||||||
ze_result_t mockReadTimeStampFailureReturnStatus = ZE_RESULT_SUCCESS;
|
|
||||||
bool mockVfid0Status = false;
|
|
||||||
bool mockVfid1Status = false;
|
|
||||||
bool isRepeated = false;
|
|
||||||
|
|
||||||
void setGuid(std::string_view guid) {
|
|
||||||
this->guid = guid;
|
|
||||||
}
|
|
||||||
|
|
||||||
MockMemoryPmt(FsAccess *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : PlatformMonitoringTech(pFsAccess, onSubdevice, subdeviceId) {}
|
|
||||||
ze_result_t readValue(const std::string key, uint32_t &val) override {
|
|
||||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
|
||||||
|
|
||||||
if (mockVfid0Status == true) {
|
|
||||||
return mockedReadValueWithVfid0True(key, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mockVfid1Status == true) {
|
|
||||||
return mockedReadValueWithVfid1True(key, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mockReadValueReturnStatus.empty()) {
|
|
||||||
result = mockReadValueReturnStatus.front();
|
|
||||||
if (!mockReadArgumentValue.empty()) {
|
|
||||||
val = mockReadArgumentValue.front();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isRepeated != true) {
|
|
||||||
mockReadValueReturnStatus.erase(mockReadValueReturnStatus.begin());
|
|
||||||
if (!mockReadArgumentValue.empty()) {
|
|
||||||
mockReadArgumentValue.erase(mockReadArgumentValue.begin());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t mockedReadValueWithVfid0True(const std::string key, uint32_t &val) {
|
|
||||||
if (key.compare("VF0_VFID") == 0) {
|
|
||||||
val = 1;
|
|
||||||
} else if (key.compare("VF1_VFID") == 0) {
|
|
||||||
val = 0;
|
|
||||||
} else if (key.compare("VF0_HBM0_READ") == 0) {
|
|
||||||
val = vF0Hbm0ReadValue;
|
|
||||||
} else if (key.compare("VF0_HBM0_WRITE") == 0) {
|
|
||||||
val = vF0Hbm0WriteValue;
|
|
||||||
} else if (key.compare("VF0_HBM1_READ") == 0) {
|
|
||||||
val = vF0Hbm1ReadValue;
|
|
||||||
} else if (key.compare("VF0_HBM1_WRITE") == 0) {
|
|
||||||
val = vF0Hbm1WriteValue;
|
|
||||||
} else if (key.compare("VF0_TIMESTAMP_L") == 0) {
|
|
||||||
val = vF0TimestampLValue;
|
|
||||||
} else if (key.compare("VF0_TIMESTAMP_H") == 0) {
|
|
||||||
val = vF0TimestampHValue;
|
|
||||||
} else if (key.compare("VF0_HBM2_READ") == 0) {
|
|
||||||
val = vF0Hbm2ReadValue;
|
|
||||||
} else if (key.compare("VF0_HBM2_WRITE") == 0) {
|
|
||||||
val = vF0Hbm2WriteValue;
|
|
||||||
} else if (key.compare("VF0_HBM3_READ") == 0) {
|
|
||||||
val = vF0Hbm3ReadValue;
|
|
||||||
} else if (key.compare("VF0_HBM3_WRITE") == 0) {
|
|
||||||
val = vF0Hbm3WriteValue;
|
|
||||||
} else if (key.compare("VF0_HBM_READ_L") == 0) {
|
|
||||||
val = vF0HbmLRead;
|
|
||||||
} else if (key.compare("VF0_HBM_READ_H") == 0) {
|
|
||||||
val = vF0HbmHRead;
|
|
||||||
} else if (key.compare("VF0_HBM_WRITE_L") == 0) {
|
|
||||||
val = vF0HbmLWrite;
|
|
||||||
} else if (key.compare("VF0_HBM_WRITE_H") == 0) {
|
|
||||||
val = vF0HbmHWrite;
|
|
||||||
} else {
|
|
||||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
|
||||||
}
|
|
||||||
return ZE_RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t mockedReadValueWithVfid1True(const std::string key, uint32_t &val) {
|
|
||||||
if (key.compare("VF0_VFID") == 0) {
|
|
||||||
val = 0;
|
|
||||||
} else if (key.compare("VF1_VFID") == 0) {
|
|
||||||
val = 1;
|
|
||||||
} else if (key.compare("VF1_HBM0_READ") == 0) {
|
|
||||||
val = vF1Hbm0ReadValue;
|
|
||||||
} else if (key.compare("VF1_HBM0_WRITE") == 0) {
|
|
||||||
val = vF1Hbm0WriteValue;
|
|
||||||
} else if (key.compare("VF1_HBM1_READ") == 0) {
|
|
||||||
val = vF1Hbm1ReadValue;
|
|
||||||
} else if (key.compare("VF1_HBM1_WRITE") == 0) {
|
|
||||||
val = vF1Hbm1WriteValue;
|
|
||||||
} else if (key.compare("VF1_TIMESTAMP_L") == 0) {
|
|
||||||
val = vF1TimestampLValue;
|
|
||||||
} else if (key.compare("VF1_TIMESTAMP_H") == 0) {
|
|
||||||
val = vF1TimestampHValue;
|
|
||||||
} else if (key.compare("VF1_HBM2_READ") == 0) {
|
|
||||||
val = vF1Hbm2ReadValue;
|
|
||||||
} else if (key.compare("VF1_HBM2_WRITE") == 0) {
|
|
||||||
val = vF1Hbm2WriteValue;
|
|
||||||
} else if (key.compare("VF1_HBM3_READ") == 0) {
|
|
||||||
val = vF1Hbm3ReadValue;
|
|
||||||
} else if (key.compare("VF1_HBM3_WRITE") == 0) {
|
|
||||||
val = vF1Hbm3WriteValue;
|
|
||||||
} else if (key.compare("VF1_HBM_READ_L") == 0) {
|
|
||||||
val = vF1HbmLRead;
|
|
||||||
} else if (key.compare("VF1_HBM_READ_H") == 0) {
|
|
||||||
val = vF1HbmHRead;
|
|
||||||
} else if (key.compare("VF1_HBM_WRITE_L") == 0) {
|
|
||||||
val = vF1HbmLWrite;
|
|
||||||
} else if (key.compare("VF1_HBM_WRITE_H") == 0) {
|
|
||||||
val = vF1HbmHWrite;
|
|
||||||
} else {
|
|
||||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
|
||||||
}
|
|
||||||
return ZE_RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t readValue(const std::string key, uint64_t &val) override {
|
|
||||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
|
||||||
|
|
||||||
if (mockIdiReadValueFailureReturnStatus != ZE_RESULT_SUCCESS) {
|
|
||||||
return mockIdiReadValueFailure(key, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mockIdiWriteFailureReturnStatus != ZE_RESULT_SUCCESS) {
|
|
||||||
return mockIdiWriteFailure(key, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mockDisplayVc1ReadFailureReturnStatus != ZE_RESULT_SUCCESS) {
|
|
||||||
return mockDisplayVc1ReadFailure(key, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mockReadTimeStampFailureReturnStatus != ZE_RESULT_SUCCESS) {
|
|
||||||
return mockReadTimeStampFailure(key, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key.compare("IDI_READS[0]") == 0 || key.compare("IDI_READS[1]") == 0 || key.compare("IDI_READS[2]") == 0 || key.compare("IDI_READS[3]") == 0 || key.compare("IDI_READS[4]") == 0 || key.compare("IDI_READS[5]") == 0 || key.compare("IDI_READS[6]") == 0 || key.compare("IDI_READS[7]") == 0 || key.compare("IDI_READS[8]") == 0 || key.compare("IDI_READS[9]") == 0 || key.compare("IDI_READS[10]") == 0 || key.compare("IDI_READS[11]") == 0 || key.compare("IDI_READS[12]") == 0 || key.compare("IDI_READS[13]") == 0 || key.compare("IDI_READS[14]") == 0 || key.compare("IDI_READS[15]") == 0) {
|
|
||||||
val = mockIdiReadVal;
|
|
||||||
} else if (key.compare("IDI_WRITES[0]") == 0 || key.compare("IDI_WRITES[1]") == 0 || key.compare("IDI_WRITES[2]") == 0 || key.compare("IDI_WRITES[3]") == 0 || key.compare("IDI_WRITES[4]") == 0 || key.compare("IDI_WRITES[5]") == 0 || key.compare("IDI_WRITES[6]") == 0 || key.compare("IDI_WRITES[7]") == 0 || key.compare("IDI_WRITES[8]") == 0 || key.compare("IDI_WRITES[9]") == 0 || key.compare("IDI_WRITES[10]") == 0 || key.compare("IDI_WRITES[11]") == 0 || key.compare("IDI_WRITES[12]") == 0 || key.compare("IDI_WRITES[13]") == 0 || key.compare("IDI_WRITES[14]") == 0 || key.compare("IDI_WRITES[15]") == 0) {
|
|
||||||
val = mockIdiWriteVal;
|
|
||||||
} else if (key.compare("DISPLAY_VC1_READS[0]") == 0 || key.compare("DISPLAY_VC1_READS[1]") == 0 || key.compare("DISPLAY_VC1_READS[2]") == 0 || key.compare("DISPLAY_VC1_READS[3]") == 0 || key.compare("DISPLAY_VC1_READS[4]") == 0 || key.compare("DISPLAY_VC1_READS[5]") == 0 || key.compare("DISPLAY_VC1_READS[6]") == 0 || key.compare("DISPLAY_VC1_READS[7]") == 0 || key.compare("DISPLAY_VC1_READS[8]") == 0 || key.compare("DISPLAY_VC1_READS[9]") == 0 || key.compare("DISPLAY_VC1_READS[10]") == 0 || key.compare("DISPLAY_VC1_READS[11]") == 0 || key.compare("DISPLAY_VC1_READS[12]") == 0 || key.compare("DISPLAY_VC1_READS[13]") == 0 || key.compare("DISPLAY_VC1_READS[14]") == 0 || key.compare("DISPLAY_VC1_READS[15]") == 0) {
|
|
||||||
val = mockDisplayVc1ReadVal;
|
|
||||||
} else {
|
|
||||||
result = ZE_RESULT_ERROR_NOT_AVAILABLE;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t mockIdiReadValueFailure(const std::string key, uint64_t &val) {
|
|
||||||
return ZE_RESULT_ERROR_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t mockIdiWriteFailure(const std::string key, uint64_t &val) {
|
|
||||||
if (key.compare("IDI_READS[0]") == 0 || key.compare("IDI_READS[1]") == 0 || key.compare("IDI_READS[2]") == 0 || key.compare("IDI_READS[3]") == 0 || key.compare("IDI_READS[4]") == 0 || key.compare("IDI_READS[5]") == 0 || key.compare("IDI_READS[6]") == 0 || key.compare("IDI_READS[7]") == 0 || key.compare("IDI_READS[8]") == 0 || key.compare("IDI_READS[9]") == 0 || key.compare("IDI_READS[10]") == 0 || key.compare("IDI_READS[11]") == 0 || key.compare("IDI_READS[12]") == 0 || key.compare("IDI_READS[13]") == 0 || key.compare("IDI_READS[14]") == 0 || key.compare("IDI_READS[15]") == 0) {
|
|
||||||
val = mockIdiReadVal;
|
|
||||||
} else if (key.compare("IDI_WRITES[0]") == 0 || key.compare("IDI_WRITES[1]") == 0 || key.compare("IDI_WRITES[2]") == 0 || key.compare("IDI_WRITES[3]") == 0 || key.compare("IDI_WRITES[4]") == 0 || key.compare("IDI_WRITES[5]") == 0 || key.compare("IDI_WRITES[6]") == 0 || key.compare("IDI_WRITES[7]") == 0 || key.compare("IDI_WRITES[8]") == 0 || key.compare("IDI_WRITES[9]") == 0 || key.compare("IDI_WRITES[10]") == 0 || key.compare("IDI_WRITES[11]") == 0 || key.compare("IDI_WRITES[12]") == 0 || key.compare("IDI_WRITES[13]") == 0 || key.compare("IDI_WRITES[14]") == 0 || key.compare("IDI_WRITES[15]") == 0) {
|
|
||||||
return ZE_RESULT_ERROR_UNKNOWN;
|
|
||||||
}
|
|
||||||
return ZE_RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t mockDisplayVc1ReadFailure(const std::string key, uint64_t &val) {
|
|
||||||
if (key.compare("IDI_READS[0]") == 0 || key.compare("IDI_READS[1]") == 0 || key.compare("IDI_READS[2]") == 0 || key.compare("IDI_READS[3]") == 0 || key.compare("IDI_READS[4]") == 0 || key.compare("IDI_READS[5]") == 0 || key.compare("IDI_READS[6]") == 0 || key.compare("IDI_READS[7]") == 0 || key.compare("IDI_READS[8]") == 0 || key.compare("IDI_READS[9]") == 0 || key.compare("IDI_READS[10]") == 0 || key.compare("IDI_READS[11]") == 0 || key.compare("IDI_READS[12]") == 0 || key.compare("IDI_READS[13]") == 0 || key.compare("IDI_READS[14]") == 0 || key.compare("IDI_READS[15]") == 0) {
|
|
||||||
val = mockIdiReadVal;
|
|
||||||
} else if (key.compare("IDI_WRITES[0]") == 0 || key.compare("IDI_WRITES[1]") == 0 || key.compare("IDI_WRITES[2]") == 0 || key.compare("IDI_WRITES[3]") == 0 || key.compare("IDI_WRITES[4]") == 0 || key.compare("IDI_WRITES[5]") == 0 || key.compare("IDI_WRITES[6]") == 0 || key.compare("IDI_WRITES[7]") == 0 || key.compare("IDI_WRITES[8]") == 0 || key.compare("IDI_WRITES[9]") == 0 || key.compare("IDI_WRITES[10]") == 0 || key.compare("IDI_WRITES[11]") == 0 || key.compare("IDI_WRITES[12]") == 0 || key.compare("IDI_WRITES[13]") == 0 || key.compare("IDI_WRITES[14]") == 0 || key.compare("IDI_WRITES[15]") == 0) {
|
|
||||||
val = mockIdiWriteVal;
|
|
||||||
} else if (key.compare("DISPLAY_VC1_READS[0]") == 0 || key.compare("DISPLAY_VC1_READS[1]") == 0 || key.compare("DISPLAY_VC1_READS[2]") == 0 || key.compare("DISPLAY_VC1_READS[3]") == 0 || key.compare("DISPLAY_VC1_READS[4]") == 0 || key.compare("DISPLAY_VC1_READS[5]") == 0 || key.compare("DISPLAY_VC1_READS[6]") == 0 || key.compare("DISPLAY_VC1_READS[7]") == 0 || key.compare("DISPLAY_VC1_READS[8]") == 0 || key.compare("DISPLAY_VC1_READS[9]") == 0 || key.compare("DISPLAY_VC1_READS[10]") == 0 || key.compare("DISPLAY_VC1_READS[11]") == 0 || key.compare("DISPLAY_VC1_READS[12]") == 0 || key.compare("DISPLAY_VC1_READS[13]") == 0 || key.compare("DISPLAY_VC1_READS[14]") == 0 || key.compare("DISPLAY_VC1_READS[15]") == 0) {
|
|
||||||
return ZE_RESULT_ERROR_UNKNOWN;
|
|
||||||
}
|
|
||||||
return ZE_RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t mockReadTimeStampFailure(const std::string key, uint64_t &val) {
|
|
||||||
if (key.compare("IDI_READS[0]") == 0 || key.compare("IDI_READS[1]") == 0 || key.compare("IDI_READS[2]") == 0 || key.compare("IDI_READS[3]") == 0 || key.compare("IDI_READS[4]") == 0 || key.compare("IDI_READS[5]") == 0 || key.compare("IDI_READS[6]") == 0 || key.compare("IDI_READS[7]") == 0 || key.compare("IDI_READS[8]") == 0 || key.compare("IDI_READS[9]") == 0 || key.compare("IDI_READS[10]") == 0 || key.compare("IDI_READS[11]") == 0 || key.compare("IDI_READS[12]") == 0 || key.compare("IDI_READS[13]") == 0 || key.compare("IDI_READS[14]") == 0 || key.compare("IDI_READS[15]") == 0) {
|
|
||||||
val = mockIdiReadVal;
|
|
||||||
} else if (key.compare("IDI_WRITES[0]") == 0 || key.compare("IDI_WRITES[1]") == 0 || key.compare("IDI_WRITES[2]") == 0 || key.compare("IDI_WRITES[3]") == 0 || key.compare("IDI_WRITES[4]") == 0 || key.compare("IDI_WRITES[5]") == 0 || key.compare("IDI_WRITES[6]") == 0 || key.compare("IDI_WRITES[7]") == 0 || key.compare("IDI_WRITES[8]") == 0 || key.compare("IDI_WRITES[9]") == 0 || key.compare("IDI_WRITES[10]") == 0 || key.compare("IDI_WRITES[11]") == 0 || key.compare("IDI_WRITES[12]") == 0 || key.compare("IDI_WRITES[13]") == 0 || key.compare("IDI_WRITES[14]") == 0 || key.compare("IDI_WRITES[15]") == 0) {
|
|
||||||
val = mockIdiWriteVal;
|
|
||||||
} else if (key.compare("DISPLAY_VC1_READS[0]") == 0 || key.compare("DISPLAY_VC1_READS[1]") == 0 || key.compare("DISPLAY_VC1_READS[2]") == 0 || key.compare("DISPLAY_VC1_READS[3]") == 0 || key.compare("DISPLAY_VC1_READS[4]") == 0 || key.compare("DISPLAY_VC1_READS[5]") == 0 || key.compare("DISPLAY_VC1_READS[6]") == 0 || key.compare("DISPLAY_VC1_READS[7]") == 0 || key.compare("DISPLAY_VC1_READS[8]") == 0 || key.compare("DISPLAY_VC1_READS[9]") == 0 || key.compare("DISPLAY_VC1_READS[10]") == 0 || key.compare("DISPLAY_VC1_READS[11]") == 0 || key.compare("DISPLAY_VC1_READS[12]") == 0 || key.compare("DISPLAY_VC1_READS[13]") == 0 || key.compare("DISPLAY_VC1_READS[14]") == 0 || key.compare("DISPLAY_VC1_READS[15]") == 0) {
|
|
||||||
val = mockDisplayVc1ReadVal;
|
|
||||||
} else {
|
|
||||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
|
||||||
}
|
|
||||||
return ZE_RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MockMemoryFsAccess : public FsAccess {
|
|
||||||
ze_result_t listDirectory(const std::string directory, std::vector<std::string> &listOfTelemNodes) override {
|
|
||||||
if (directory.compare(baseTelemSysFS) == 0) {
|
|
||||||
listOfTelemNodes.push_back("telem1");
|
|
||||||
listOfTelemNodes.push_back("telem2");
|
|
||||||
listOfTelemNodes.push_back("telem3");
|
|
||||||
listOfTelemNodes.push_back("telem4");
|
|
||||||
listOfTelemNodes.push_back("telem5");
|
|
||||||
return ZE_RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t listDirectoryFailure(const std::string directory, std::vector<std::string> &events) {
|
|
||||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t getRealPath(const std::string path, std::string &buf) override {
|
|
||||||
if (path.compare(sysfsPahTelem1) == 0) {
|
|
||||||
buf = realPathTelem1;
|
|
||||||
} else if (path.compare(sysfsPahTelem2) == 0) {
|
|
||||||
buf = realPathTelem2;
|
|
||||||
} else if (path.compare(sysfsPahTelem3) == 0) {
|
|
||||||
buf = realPathTelem3;
|
|
||||||
} else if (path.compare(sysfsPahTelem4) == 0) {
|
|
||||||
buf = realPathTelem4;
|
|
||||||
} else if (path.compare(sysfsPahTelem5) == 0) {
|
|
||||||
buf = realPathTelem5;
|
|
||||||
} else {
|
|
||||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
|
||||||
}
|
|
||||||
return ZE_RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
ze_result_t getRealPathFailure(const std::string path, std::string &buf) {
|
|
||||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
MockMemoryFsAccess() = default;
|
|
||||||
};
|
|
||||||
|
|
||||||
class PublicLinuxMemoryImp : public L0::LinuxMemoryImp {
|
|
||||||
public:
|
|
||||||
PublicLinuxMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) : LinuxMemoryImp(pOsSysman, onSubdevice, subdeviceId) {}
|
|
||||||
PublicLinuxMemoryImp() = default;
|
|
||||||
using LinuxMemoryImp::getHbmFrequency;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ult
|
|
||||||
} // namespace L0
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,254 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2021-2023 Intel Corporation
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: MIT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "level_zero/tools/source/sysman/sysman_imp.h"
|
|
||||||
#include "level_zero/tools/test/unit_tests/sources/sysman/linux/mock_sysman_fixture.h"
|
|
||||||
|
|
||||||
#include "mock_memory.h"
|
|
||||||
|
|
||||||
extern bool sysmanUltsEnable;
|
|
||||||
|
|
||||||
namespace L0 {
|
|
||||||
namespace ult {
|
|
||||||
|
|
||||||
constexpr uint32_t memoryHandleComponentCount = 1u;
|
|
||||||
class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
|
|
||||||
protected:
|
|
||||||
MockMemoryNeoDrm *pDrm = nullptr;
|
|
||||||
Drm *pOriginalDrm = nullptr;
|
|
||||||
|
|
||||||
void SetUp() override {
|
|
||||||
if (!sysmanUltsEnable) {
|
|
||||||
GTEST_SKIP();
|
|
||||||
}
|
|
||||||
SysmanDeviceFixture::SetUp();
|
|
||||||
|
|
||||||
pMemoryManagerOld = device->getDriverHandle()->getMemoryManager();
|
|
||||||
pMemoryManager = new MockMemoryManagerSysman(*neoDevice->getExecutionEnvironment());
|
|
||||||
pMemoryManager->localMemorySupported[0] = false;
|
|
||||||
device->getDriverHandle()->setMemoryManager(pMemoryManager);
|
|
||||||
|
|
||||||
pDrm = new MockMemoryNeoDrm(const_cast<NEO::RootDeviceEnvironment &>(neoDevice->getRootDeviceEnvironment()));
|
|
||||||
pDrm->ioctlHelper = static_cast<std::unique_ptr<NEO::IoctlHelper>>(std::make_unique<IoctlHelperUpstream>(*pDrm));
|
|
||||||
|
|
||||||
pSysmanDevice = device->getSysmanHandle();
|
|
||||||
pSysmanDeviceImp = static_cast<SysmanDeviceImp *>(pSysmanDevice);
|
|
||||||
pOsSysman = pSysmanDeviceImp->pOsSysman;
|
|
||||||
pLinuxSysmanImp = static_cast<PublicLinuxSysmanImp *>(pOsSysman);
|
|
||||||
pLinuxSysmanImp->pDrm = pDrm;
|
|
||||||
|
|
||||||
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
|
|
||||||
uint32_t subDeviceCount = 0;
|
|
||||||
std::vector<ze_device_handle_t> deviceHandles;
|
|
||||||
// We received a device handle. Check for subdevices in this device
|
|
||||||
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, nullptr);
|
|
||||||
if (subDeviceCount == 0) {
|
|
||||||
deviceHandles.resize(1, device->toHandle());
|
|
||||||
} else {
|
|
||||||
deviceHandles.resize(subDeviceCount, nullptr);
|
|
||||||
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, deviceHandles.data());
|
|
||||||
}
|
|
||||||
getMemoryHandles(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TearDown() override {
|
|
||||||
if (!sysmanUltsEnable) {
|
|
||||||
GTEST_SKIP();
|
|
||||||
}
|
|
||||||
device->getDriverHandle()->setMemoryManager(pMemoryManagerOld);
|
|
||||||
pLinuxSysmanImp->pDrm = pOriginalDrm;
|
|
||||||
if (pDrm != nullptr) {
|
|
||||||
delete pDrm;
|
|
||||||
pDrm = nullptr;
|
|
||||||
}
|
|
||||||
if (pMemoryManager != nullptr) {
|
|
||||||
delete pMemoryManager;
|
|
||||||
pMemoryManager = nullptr;
|
|
||||||
}
|
|
||||||
SysmanDeviceFixture::TearDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setLocalSupportedAndReinit(bool supported) {
|
|
||||||
pMemoryManager->localMemorySupported[0] = supported;
|
|
||||||
|
|
||||||
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
|
|
||||||
uint32_t subDeviceCount = 0;
|
|
||||||
std::vector<ze_device_handle_t> deviceHandles;
|
|
||||||
// We received a device handle. Check for subdevices in this device
|
|
||||||
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, nullptr);
|
|
||||||
if (subDeviceCount == 0) {
|
|
||||||
deviceHandles.resize(1, device->toHandle());
|
|
||||||
} else {
|
|
||||||
deviceHandles.resize(subDeviceCount, nullptr);
|
|
||||||
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, deviceHandles.data());
|
|
||||||
}
|
|
||||||
pSysmanDeviceImp->pMemoryHandleContext->init(deviceHandles);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<zes_mem_handle_t> getMemoryHandles(uint32_t count) {
|
|
||||||
std::vector<zes_mem_handle_t> handles(count, nullptr);
|
|
||||||
EXPECT_EQ(zesDeviceEnumMemoryModules(device->toHandle(), &count, handles.data()), ZE_RESULT_SUCCESS);
|
|
||||||
return handles;
|
|
||||||
}
|
|
||||||
|
|
||||||
MockMemoryManagerSysman *pMemoryManager = nullptr;
|
|
||||||
MemoryManager *pMemoryManagerOld;
|
|
||||||
};
|
|
||||||
|
|
||||||
TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesWithLocalMemorySupportThenValidCountIsReturned) {
|
|
||||||
setLocalSupportedAndReinit(true);
|
|
||||||
|
|
||||||
uint32_t count = 0;
|
|
||||||
EXPECT_EQ(zesDeviceEnumMemoryModules(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS);
|
|
||||||
EXPECT_EQ(count, memoryHandleComponentCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(SysmanDeviceMemoryFixture, GivenInvalidComponentCountWhenEnumeratingMemoryModulesWithLocalMemorySupportThenValidCountIsReturned) {
|
|
||||||
setLocalSupportedAndReinit(true);
|
|
||||||
|
|
||||||
uint32_t count = 0;
|
|
||||||
EXPECT_EQ(zesDeviceEnumMemoryModules(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS);
|
|
||||||
EXPECT_EQ(count, memoryHandleComponentCount);
|
|
||||||
|
|
||||||
count = count + 1;
|
|
||||||
EXPECT_EQ(zesDeviceEnumMemoryModules(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS);
|
|
||||||
EXPECT_EQ(count, memoryHandleComponentCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesWithLocalMemorySupportThenValidHandlesIsReturned) {
|
|
||||||
setLocalSupportedAndReinit(true);
|
|
||||||
|
|
||||||
uint32_t count = 0;
|
|
||||||
EXPECT_EQ(zesDeviceEnumMemoryModules(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS);
|
|
||||||
EXPECT_EQ(count, memoryHandleComponentCount);
|
|
||||||
|
|
||||||
std::vector<zes_mem_handle_t> handles(count, nullptr);
|
|
||||||
EXPECT_EQ(zesDeviceEnumMemoryModules(device->toHandle(), &count, handles.data()), ZE_RESULT_SUCCESS);
|
|
||||||
for (auto handle : handles) {
|
|
||||||
EXPECT_NE(handle, nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesWithNoLocalMemorySupportThenZeroCountIsReturned) {
|
|
||||||
setLocalSupportedAndReinit(false);
|
|
||||||
|
|
||||||
uint32_t count = 0;
|
|
||||||
EXPECT_EQ(zesDeviceEnumMemoryModules(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS);
|
|
||||||
EXPECT_EQ(count, 0u);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(SysmanDeviceMemoryFixture, GivenInvalidComponentCountWhenEnumeratingMemoryModulesWithNoLocalMemorySupportThenZeroCountIsReturned) {
|
|
||||||
setLocalSupportedAndReinit(false);
|
|
||||||
|
|
||||||
uint32_t count = 0;
|
|
||||||
EXPECT_EQ(zesDeviceEnumMemoryModules(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS);
|
|
||||||
EXPECT_EQ(count, 0u);
|
|
||||||
|
|
||||||
count = count + 1;
|
|
||||||
EXPECT_EQ(zesDeviceEnumMemoryModules(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS);
|
|
||||||
EXPECT_EQ(count, 0u);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesWithNoLocalMemorySupportThenValidHandlesIsReturned) {
|
|
||||||
setLocalSupportedAndReinit(false);
|
|
||||||
|
|
||||||
uint32_t count = 0;
|
|
||||||
EXPECT_EQ(zesDeviceEnumMemoryModules(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS);
|
|
||||||
EXPECT_EQ(count, 0u);
|
|
||||||
|
|
||||||
std::vector<zes_mem_handle_t> handles(count, nullptr);
|
|
||||||
EXPECT_EQ(zesDeviceEnumMemoryModules(device->toHandle(), &count, handles.data()), ZE_RESULT_SUCCESS);
|
|
||||||
for (auto handle : handles) {
|
|
||||||
EXPECT_NE(handle, nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenGettingPropertiesWithLocalMemoryThenCallSucceeds) {
|
|
||||||
setLocalSupportedAndReinit(true);
|
|
||||||
|
|
||||||
auto handles = getMemoryHandles(memoryHandleComponentCount);
|
|
||||||
|
|
||||||
for (auto handle : handles) {
|
|
||||||
zes_mem_properties_t properties;
|
|
||||||
|
|
||||||
ze_result_t result = zesMemoryGetProperties(handle, &properties);
|
|
||||||
|
|
||||||
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
|
||||||
EXPECT_EQ(properties.type, ZES_MEM_TYPE_DDR);
|
|
||||||
EXPECT_EQ(properties.location, ZES_MEM_LOC_DEVICE);
|
|
||||||
EXPECT_FALSE(properties.onSubdevice);
|
|
||||||
EXPECT_EQ(properties.subdeviceId, 0u);
|
|
||||||
EXPECT_EQ(properties.physicalSize, 0u);
|
|
||||||
EXPECT_EQ(properties.numChannels, -1);
|
|
||||||
EXPECT_EQ(properties.busWidth, -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenGettingStateThenCallSucceeds) {
|
|
||||||
setLocalSupportedAndReinit(true);
|
|
||||||
|
|
||||||
auto handles = getMemoryHandles(memoryHandleComponentCount);
|
|
||||||
|
|
||||||
for (auto handle : handles) {
|
|
||||||
zes_mem_state_t state;
|
|
||||||
ze_result_t result = zesMemoryGetState(handle, &state);
|
|
||||||
|
|
||||||
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
|
||||||
EXPECT_EQ(state.health, ZES_MEM_HEALTH_OK);
|
|
||||||
EXPECT_EQ(state.size, probedSizeRegionOne);
|
|
||||||
EXPECT_EQ(state.free, unallocatedSizeRegionOne);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleAndIfQueryMemoryInfoFailsWhenGettingStateThenErrorIsReturned) {
|
|
||||||
setLocalSupportedAndReinit(true);
|
|
||||||
pDrm->mockQueryMemoryInfoReturnStatus.push_back(false);
|
|
||||||
|
|
||||||
auto handles = getMemoryHandles(memoryHandleComponentCount);
|
|
||||||
|
|
||||||
for (auto handle : handles) {
|
|
||||||
zes_mem_state_t state;
|
|
||||||
EXPECT_EQ(zesMemoryGetState(handle, &state), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleAndIfQueryMemoryInfoAndIfMemoryInfoIsNotCorrectWhenGettingStateThenErrorIsReturned) {
|
|
||||||
setLocalSupportedAndReinit(true);
|
|
||||||
pDrm->mockQueryMemoryInfoReturnStatus.push_back(true);
|
|
||||||
|
|
||||||
auto handles = getMemoryHandles(memoryHandleComponentCount);
|
|
||||||
|
|
||||||
for (auto handle : handles) {
|
|
||||||
zes_mem_state_t state;
|
|
||||||
EXPECT_EQ(zesMemoryGetState(handle, &state), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenGettingBandwidthThenZeResultErrorUnsupportedFeatureIsReturned) {
|
|
||||||
setLocalSupportedAndReinit(true);
|
|
||||||
|
|
||||||
auto handles = getMemoryHandles(memoryHandleComponentCount);
|
|
||||||
|
|
||||||
for (auto handle : handles) {
|
|
||||||
zes_mem_bandwidth_t bandwidth;
|
|
||||||
EXPECT_EQ(zesMemoryGetBandwidth(handle, &bandwidth), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(SysmanMultiDeviceFixture, GivenValidDevicePointerWhenGettingMemoryPropertiesThenValidMemoryPropertiesRetrieved) {
|
|
||||||
zes_mem_properties_t properties = {};
|
|
||||||
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
|
||||||
ze_bool_t isSubDevice = deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE;
|
|
||||||
Device::fromHandle(device)->getProperties(&deviceProperties);
|
|
||||||
std::unique_ptr<LinuxMemoryImp> pLinuxMemoryImp = std::make_unique<LinuxMemoryImp>(pOsSysman, isSubDevice, deviceProperties.subdeviceId);
|
|
||||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxMemoryImp->getProperties(&properties));
|
|
||||||
EXPECT_EQ(properties.subdeviceId, deviceProperties.subdeviceId);
|
|
||||||
EXPECT_EQ(properties.onSubdevice, isSubDevice);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ult
|
|
||||||
} // namespace L0
|
|
||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user