mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
feature(sysman): Add Sysman Product Helper in Prelim File for Memory
Related-To: NEO-8662 Signed-off-by: Bari, Pratik <pratik.bari@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
138f22f684
commit
baf11d06ca
@@ -16,6 +16,7 @@
|
||||
#include "shared/source/os_interface/linux/system_info.h"
|
||||
|
||||
#include "level_zero/sysman/source/shared/firmware_util/sysman_firmware_util.h"
|
||||
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_kmd_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
@@ -28,316 +29,18 @@ namespace Sysman {
|
||||
|
||||
const std::string LinuxMemoryImp::deviceMemoryHealth("device_memory_health");
|
||||
|
||||
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->getSysmanDeviceImp();
|
||||
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
|
||||
pPmt = pLinuxSysmanImp->getPlatformMonitoringTechAccess(subdeviceId);
|
||||
pSysmanKmdInterface = pLinuxSysmanImp->getSysmanKmdInterface();
|
||||
}
|
||||
|
||||
bool LinuxMemoryImp::isMemoryModuleSupported() {
|
||||
auto &gfxCoreHelper = pDevice->getRootDeviceEnvironment().getHelper<NEO::GfxCoreHelper>();
|
||||
return gfxCoreHelper.getEnableLocalMemory(pDevice->getHardwareInfo());
|
||||
}
|
||||
|
||||
ze_result_t LinuxMemoryImp::getProperties(zes_mem_properties_t *pProperties) {
|
||||
pProperties->type = ZES_MEM_TYPE_DDR;
|
||||
pProperties->numChannels = -1;
|
||||
|
||||
bool status = false;
|
||||
{
|
||||
auto hwDeviceId = pLinuxSysmanImp->getSysmanHwDeviceIdInstance();
|
||||
status = pDrm->querySystemInfo();
|
||||
}
|
||||
|
||||
if (status) {
|
||||
auto memSystemInfo = pDrm->getSystemInfo();
|
||||
if (memSystemInfo != nullptr) {
|
||||
pProperties->numChannels = memSystemInfo->getMaxMemoryChannels();
|
||||
auto memType = memSystemInfo->getMemoryType();
|
||||
switch (memType) {
|
||||
case NEO::DeviceBlobConstants::MemoryType::hbm2e:
|
||||
case NEO::DeviceBlobConstants::MemoryType::hbm2:
|
||||
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;
|
||||
physicalSizeFile = pSysmanKmdInterface->getSysfsFilePathForPhysicalMemorySize(subdeviceId);
|
||||
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 hbmRP0FreqFile = pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameMaxMemoryFrequency, subdeviceId, true);
|
||||
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::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->getHardwareInfo();
|
||||
auto productFamily = hwInfo.platform.eProductFamily;
|
||||
auto &productHelper = pDevice->getRootDeviceEnvironment().getHelper<NEO::ProductHelper>();
|
||||
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);
|
||||
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::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->getHardwareInfo();
|
||||
auto productFamily = hwInfo.platform.eProductFamily;
|
||||
auto &productHelper = pDevice->getRootDeviceEnvironment().getHelper<NEO::ProductHelper>();
|
||||
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;
|
||||
return result;
|
||||
auto pSysmanProductHelper = pLinuxSysmanImp->getSysmanProductHelper();
|
||||
return pSysmanProductHelper->getMemoryProperties(pProperties, pLinuxSysmanImp, pDrm, pSysmanKmdInterface, subdeviceId, isSubdevice);
|
||||
}
|
||||
|
||||
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->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;
|
||||
|
||||
auto pSysmanProductHelper = pLinuxSysmanImp->getSysmanProductHelper();
|
||||
return pSysmanProductHelper->getMemoryBandwidth(pBandwidth, pPmt, pDevice, pSysmanKmdInterface, subdeviceId);
|
||||
}
|
||||
|
||||
ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) {
|
||||
@@ -371,6 +74,19 @@ ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) {
|
||||
return status;
|
||||
}
|
||||
|
||||
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->getSysmanDeviceImp();
|
||||
pPmt = pLinuxSysmanImp->getPlatformMonitoringTechAccess(subdeviceId);
|
||||
pSysmanKmdInterface = pLinuxSysmanImp->getSysmanKmdInterface();
|
||||
}
|
||||
|
||||
bool LinuxMemoryImp::isMemoryModuleSupported() {
|
||||
auto &gfxCoreHelper = pDevice->getRootDeviceEnvironment().getHelper<NEO::GfxCoreHelper>();
|
||||
return gfxCoreHelper.getEnableLocalMemory(pDevice->getHardwareInfo());
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -41,14 +41,8 @@ class LinuxMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass {
|
||||
SysmanDeviceImp *pDevice = nullptr;
|
||||
PlatformMonitoringTech *pPmt = nullptr;
|
||||
SysmanKmdInterface *pSysmanKmdInterface = 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 getHbmBandwidthPVC(uint32_t numHbmModules, zes_mem_bandwidth_t *pBandwidth);
|
||||
ze_result_t getHbmBandwidth(uint32_t numHbmModules, zes_mem_bandwidth_t *pBandwidth);
|
||||
static const std::string deviceMemoryHealth;
|
||||
bool isSubdevice = false;
|
||||
uint32_t subdeviceId = 0;
|
||||
|
||||
@@ -25,7 +25,7 @@ class FsAccessInterface;
|
||||
|
||||
class PlatformMonitoringTech : NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
PlatformMonitoringTech() = delete;
|
||||
PlatformMonitoringTech() = default;
|
||||
PlatformMonitoringTech(FsAccessInterface *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId);
|
||||
virtual ~PlatformMonitoringTech();
|
||||
|
||||
|
||||
@@ -106,6 +106,18 @@ RasInterfaceType SysmanProductHelperHw<gfxProduct>::getGtRasUtilInterface() {
|
||||
return RasInterfaceType::pmu;
|
||||
}
|
||||
|
||||
template <>
|
||||
ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryProperties(zes_mem_properties_t *pProperties, LinuxSysmanImp *pLinuxSysmanImp, NEO::Drm *pDrm, SysmanKmdInterface *pSysmanKmdInterface, uint32_t subDeviceId, bool isSubdevice) {
|
||||
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;
|
||||
}
|
||||
|
||||
template class SysmanProductHelperHw<gfxProduct>;
|
||||
|
||||
} // namespace Sysman
|
||||
|
||||
@@ -14,12 +14,19 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace NEO {
|
||||
class Drm;
|
||||
}
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
|
||||
struct SysmanDeviceImp;
|
||||
class SysmanProductHelper;
|
||||
class LinuxSysmanImp;
|
||||
class PlatformMonitoringTech;
|
||||
class SysmanKmdInterface;
|
||||
|
||||
enum class RasInterfaceType;
|
||||
|
||||
using SysmanProductHelperCreateFunctionType = std::unique_ptr<SysmanProductHelper> (*)();
|
||||
@@ -40,8 +47,8 @@ class SysmanProductHelper {
|
||||
virtual void getFrequencyStepSize(double *pStepSize) = 0;
|
||||
|
||||
// Memory
|
||||
virtual ze_result_t getMemoryProperties(zes_mem_properties_t *pProperties, const LinuxSysmanImp *pLinuxSysmanImp) = 0;
|
||||
virtual ze_result_t getMemoryBandwidth(zes_mem_bandwidth_t *pBandwidth, const LinuxSysmanImp *pLinuxSysmanImp) = 0;
|
||||
virtual ze_result_t getMemoryProperties(zes_mem_properties_t *pProperties, LinuxSysmanImp *pLinuxSysmanImp, NEO::Drm *pDrm, SysmanKmdInterface *pSysmanKmdInterface, uint32_t subDeviceId, bool isSubdevice) = 0;
|
||||
virtual ze_result_t getMemoryBandwidth(zes_mem_bandwidth_t *pBandwidth, PlatformMonitoringTech *pPmt, SysmanDeviceImp *pDevice, SysmanKmdInterface *pSysmanKmdInterface, uint32_t subdeviceId) = 0;
|
||||
|
||||
// Performance
|
||||
virtual void getMediaPerformanceFactorMultiplier(const double performanceFactor, double *pMultiplier) = 0;
|
||||
|
||||
@@ -26,8 +26,8 @@ class SysmanProductHelperHw : public SysmanProductHelper {
|
||||
void getFrequencyStepSize(double *pStepSize) override;
|
||||
|
||||
// Memory
|
||||
ze_result_t getMemoryProperties(zes_mem_properties_t *pProperties, const LinuxSysmanImp *pLinuxSysmanImp) override;
|
||||
ze_result_t getMemoryBandwidth(zes_mem_bandwidth_t *pBandwidth, const LinuxSysmanImp *pLinuxSysmanImp) override;
|
||||
ze_result_t getMemoryProperties(zes_mem_properties_t *pProperties, LinuxSysmanImp *pLinuxSysmanImp, NEO::Drm *pDrm, SysmanKmdInterface *pSysmanKmdInterface, uint32_t subDeviceId, bool isSubdevice) override;
|
||||
ze_result_t getMemoryBandwidth(zes_mem_bandwidth_t *pBandwidth, PlatformMonitoringTech *pPmt, SysmanDeviceImp *pDevice, SysmanKmdInterface *pSysmanKmdInterface, uint32_t subdeviceId) override;
|
||||
|
||||
// Performance
|
||||
void getMediaPerformanceFactorMultiplier(const double performanceFactor, double *pMultiplier) override;
|
||||
|
||||
@@ -5,10 +5,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/linux/drm_neo.h"
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
#include "shared/source/os_interface/linux/system_info.h"
|
||||
|
||||
#include "level_zero/sysman/source/api/ras/linux/ras_util/sysman_ras_util.h"
|
||||
#include "level_zero/sysman/source/shared/linux/pmt/sysman_pmt.h"
|
||||
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
|
||||
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_kmd_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
#include "level_zero/sysman/source/sysman_const.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -22,12 +29,65 @@ void SysmanProductHelperHw<gfxProduct>::getFrequencyStepSize(double *pStepSize)
|
||||
}
|
||||
|
||||
template <PRODUCT_FAMILY gfxProduct>
|
||||
ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryProperties(zes_mem_properties_t *pProperties, const LinuxSysmanImp *pLinuxSysmanImp) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryProperties(zes_mem_properties_t *pProperties, LinuxSysmanImp *pLinuxSysmanImp, NEO::Drm *pDrm, SysmanKmdInterface *pSysmanKmdInterface, uint32_t subDeviceId, bool isSubdevice) {
|
||||
auto pSysFsAccess = pSysmanKmdInterface->getSysFsAccess();
|
||||
|
||||
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;
|
||||
|
||||
auto hwDeviceId = pLinuxSysmanImp->getSysmanHwDeviceIdInstance();
|
||||
auto status = pDrm->querySystemInfo();
|
||||
|
||||
if (status) {
|
||||
auto memSystemInfo = pDrm->getSystemInfo();
|
||||
if (memSystemInfo != nullptr) {
|
||||
pProperties->numChannels = memSystemInfo->getMaxMemoryChannels();
|
||||
auto memType = memSystemInfo->getMemoryType();
|
||||
switch (memType) {
|
||||
case NEO::DeviceBlobConstants::MemoryType::hbm2e:
|
||||
case NEO::DeviceBlobConstants::MemoryType::hbm2:
|
||||
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->busWidth = memoryBusWidth;
|
||||
pProperties->physicalSize = 0;
|
||||
|
||||
if (pSysmanKmdInterface->isPhysicalMemorySizeSupported() == true) {
|
||||
if (isSubdevice) {
|
||||
std::string memval;
|
||||
std::string physicalSizeFile = pSysmanKmdInterface->getSysfsFilePathForPhysicalMemorySize(subDeviceId);
|
||||
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;
|
||||
}
|
||||
|
||||
template <PRODUCT_FAMILY gfxProduct>
|
||||
ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryBandwidth(zes_mem_bandwidth_t *pBandwidth, const LinuxSysmanImp *pLinuxSysmanImp) {
|
||||
ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryBandwidth(zes_mem_bandwidth_t *pBandwidth, PlatformMonitoringTech *pPmt, SysmanDeviceImp *pDevice, SysmanKmdInterface *pSysmanKmdInterface, uint32_t subdeviceId) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,9 +15,181 @@
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
constexpr static auto gfxProduct = IGFX_PVC;
|
||||
static const uint32_t numHbmModules = 4;
|
||||
|
||||
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_xe_hp_and_later.inl"
|
||||
|
||||
void getHBMFrequency(SysmanKmdInterface *pSysmanKmdInterface, SysFsAccessInterface *pSysFsAccess, uint64_t &hbmFrequency, uint32_t subdeviceId, unsigned short stepping) {
|
||||
hbmFrequency = 0;
|
||||
if (stepping >= REVISION_B) {
|
||||
const std::string hbmRP0FreqFile = pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameMaxMemoryFrequency, subdeviceId, true);
|
||||
uint64_t hbmFreqValue = 0;
|
||||
ze_result_t result = pSysFsAccess->read(hbmRP0FreqFile, hbmFreqValue);
|
||||
if (ZE_RESULT_SUCCESS == result) {
|
||||
hbmFrequency = hbmFreqValue * 1000 * 1000;
|
||||
return;
|
||||
}
|
||||
} else if (stepping == REVISION_A0) {
|
||||
hbmFrequency = 3.2 * gigaUnitTransferToUnitTransfer;
|
||||
}
|
||||
}
|
||||
|
||||
ze_result_t getVFIDString(std::string &vfID, PlatformMonitoringTech *pPmt) {
|
||||
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;
|
||||
}
|
||||
|
||||
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 getHBMBandwidth(zes_mem_bandwidth_t *pBandwidth, PlatformMonitoringTech *pPmt, SysmanKmdInterface *pSysmanKmdInterface, SysFsAccessInterface *pSysFsAccess, uint32_t subdeviceId, unsigned short stepping) {
|
||||
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, pPmt);
|
||||
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;
|
||||
}
|
||||
|
||||
for (auto hbmModuleIndex = 0u; hbmModuleIndex < numHbmModules; hbmModuleIndex++) {
|
||||
uint32_t counterValue = 0;
|
||||
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;
|
||||
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(pSysmanKmdInterface, pSysFsAccess, hbmFrequency, subdeviceId, stepping);
|
||||
|
||||
pBandwidth->maxBandwidth = memoryBusWidth * hbmFrequency * numHbmModules;
|
||||
return result;
|
||||
}
|
||||
|
||||
ze_result_t getHBMBandwidth(zes_mem_bandwidth_t *pBandwidth, PlatformMonitoringTech *pPmt, SysmanDeviceImp *pDevice, SysmanKmdInterface *pSysmanKmdInterface, uint32_t subdeviceId) {
|
||||
auto pSysFsAccess = pSysmanKmdInterface->getSysFsAccess();
|
||||
auto &hwInfo = pDevice->getHardwareInfo();
|
||||
auto &productHelper = pDevice->getRootDeviceEnvironment().getHelper<NEO::ProductHelper>();
|
||||
auto stepping = productHelper.getSteppingFromHwRevId(hwInfo);
|
||||
|
||||
std::string guid = pPmt->getGuid();
|
||||
if (guid != guid64BitMemoryCounters) {
|
||||
return getHBMBandwidth(pBandwidth, pPmt, pSysmanKmdInterface, pSysFsAccess, subdeviceId, stepping);
|
||||
}
|
||||
|
||||
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, pPmt);
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
pBandwidth->timestamp = SysmanDevice::getSysmanTimestamp();
|
||||
|
||||
uint64_t hbmFrequency = 0;
|
||||
getHBMFrequency(pSysmanKmdInterface, pSysFsAccess, hbmFrequency, subdeviceId, stepping);
|
||||
|
||||
pBandwidth->maxBandwidth = memoryBusWidth * hbmFrequency * numHbmModules;
|
||||
return result;
|
||||
}
|
||||
|
||||
template <>
|
||||
ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryBandwidth(zes_mem_bandwidth_t *pBandwidth, PlatformMonitoringTech *pPmt, SysmanDeviceImp *pDevice, SysmanKmdInterface *pSysmanKmdInterface, uint32_t subdeviceId) {
|
||||
return getHBMBandwidth(pBandwidth, pPmt, pDevice, pSysmanKmdInterface, subdeviceId);
|
||||
}
|
||||
|
||||
template <>
|
||||
void SysmanProductHelperHw<gfxProduct>::getMediaPerformanceFactorMultiplier(const double performanceFactor, double *pMultiplier) {
|
||||
if (performanceFactor > halfOfMaxPerformanceFactor) {
|
||||
|
||||
@@ -20,6 +20,52 @@ RasInterfaceType SysmanProductHelperHw<gfxProduct>::getGtRasUtilInterface() {
|
||||
|
||||
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_xe_hp_and_later.inl"
|
||||
|
||||
ze_result_t readMcChannelCounters(PlatformMonitoringTech *pPmt, uint64_t &readCounters, uint64_t &writeCounters) {
|
||||
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);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
constexpr uint64_t transactionSize = 32;
|
||||
readCounters = (counterValues[0] + counterValues[2]) * transactionSize;
|
||||
writeCounters = (counterValues[1]) * transactionSize;
|
||||
return result;
|
||||
}
|
||||
|
||||
template <>
|
||||
ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryBandwidth(zes_mem_bandwidth_t *pBandwidth, PlatformMonitoringTech *pPmt, SysmanDeviceImp *pDevice, SysmanKmdInterface *pSysmanKmdInterface, uint32_t subdeviceId) {
|
||||
auto pSysFsAccess = pSysmanKmdInterface->getSysFsAccess();
|
||||
|
||||
pBandwidth->readCounter = 0;
|
||||
pBandwidth->writeCounter = 0;
|
||||
pBandwidth->timestamp = 0;
|
||||
pBandwidth->maxBandwidth = 0;
|
||||
ze_result_t result = readMcChannelCounters(pPmt, 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;
|
||||
pSysFsAccess->read(maxBwFile, maxBw);
|
||||
pBandwidth->maxBandwidth = maxBw * mbpsToBytesPerSecond;
|
||||
pBandwidth->timestamp = SysmanDevice::getSysmanTimestamp();
|
||||
return result;
|
||||
}
|
||||
|
||||
template class SysmanProductHelperHw<gfxProduct>;
|
||||
|
||||
} // namespace Sysman
|
||||
|
||||
@@ -136,6 +136,7 @@ class SysmanKmdInterface {
|
||||
virtual bool isDefaultFrequencyAvailable() const = 0;
|
||||
virtual bool isBoostFrequencyAvailable() const = 0;
|
||||
virtual bool isTdpFrequencyAvailable() const = 0;
|
||||
virtual bool isPhysicalMemorySizeSupported() const = 0;
|
||||
|
||||
protected:
|
||||
std::unique_ptr<FsAccessInterface> pFsAccess;
|
||||
@@ -182,6 +183,7 @@ class SysmanKmdInterfaceI915Upstream : public SysmanKmdInterface, SysmanKmdInter
|
||||
bool isDefaultFrequencyAvailable() const override { return true; }
|
||||
bool isBoostFrequencyAvailable() const override { return true; }
|
||||
bool isTdpFrequencyAvailable() const override { return true; }
|
||||
bool isPhysicalMemorySizeSupported() const override { return false; }
|
||||
|
||||
protected:
|
||||
std::map<SysfsName, valuePair> sysfsNameToFileMap;
|
||||
@@ -223,6 +225,7 @@ class SysmanKmdInterfaceI915Prelim : public SysmanKmdInterface, SysmanKmdInterfa
|
||||
bool isDefaultFrequencyAvailable() const override { return true; }
|
||||
bool isBoostFrequencyAvailable() const override { return true; }
|
||||
bool isTdpFrequencyAvailable() const override { return true; }
|
||||
bool isPhysicalMemorySizeSupported() const override { return true; }
|
||||
|
||||
protected:
|
||||
std::map<SysfsName, valuePair> sysfsNameToFileMap;
|
||||
@@ -264,6 +267,7 @@ class SysmanKmdInterfaceXe : public SysmanKmdInterface {
|
||||
bool isDefaultFrequencyAvailable() const override { return false; }
|
||||
bool isBoostFrequencyAvailable() const override { return false; }
|
||||
bool isTdpFrequencyAvailable() const override { return false; }
|
||||
bool isPhysicalMemorySizeSupported() const override { return true; }
|
||||
|
||||
protected:
|
||||
std::map<SysfsName, valuePair> sysfsNameToFileMap;
|
||||
|
||||
@@ -44,6 +44,7 @@ class PublicLinuxSysmanImp : public L0::Sysman::LinuxSysmanImp {
|
||||
using LinuxSysmanImp::pProcfsAccess;
|
||||
using LinuxSysmanImp::pSysfsAccess;
|
||||
using LinuxSysmanImp::pSysmanKmdInterface;
|
||||
using LinuxSysmanImp::pSysmanProductHelper;
|
||||
using LinuxSysmanImp::rootPath;
|
||||
};
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
#include "level_zero/sysman/source/api/memory/linux/sysman_os_memory_imp_prelim.h"
|
||||
#include "level_zero/sysman/source/api/memory/sysman_memory_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_kmd_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_hw_device_id.h"
|
||||
|
||||
@@ -85,8 +87,6 @@ namespace Sysman {
|
||||
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");
|
||||
@@ -105,37 +105,8 @@ struct MockMemorySysfsAccess : public L0::Sysman::SysFsAccessInterface {
|
||||
|
||||
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()) {
|
||||
@@ -158,52 +129,6 @@ struct MockMemorySysfsAccess : public L0::Sysman::SysFsAccessInterface {
|
||||
}
|
||||
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 MockMemoryNeoDrm : public NEO::Drm {
|
||||
@@ -262,7 +187,7 @@ struct MockMemoryPmt : public L0::Sysman::PlatformMonitoringTech {
|
||||
this->guid = guid;
|
||||
}
|
||||
|
||||
MockMemoryPmt(L0::Sysman::FsAccessInterface *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : L0::Sysman::PlatformMonitoringTech(pFsAccess, onSubdevice, subdeviceId) {}
|
||||
MockMemoryPmt() = default;
|
||||
ze_result_t readValue(const std::string key, uint32_t &val) override {
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
|
||||
@@ -437,52 +362,11 @@ struct MockMemoryPmt : public L0::Sysman::PlatformMonitoringTech {
|
||||
}
|
||||
};
|
||||
|
||||
struct MockMemoryFsAccess : public L0::Sysman::FsAccessInterface {
|
||||
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::Sysman::LinuxMemoryImp {
|
||||
class MockSysmanKmdInterfaceI915Prelim : public L0::Sysman::SysmanKmdInterfaceI915Prelim {
|
||||
public:
|
||||
PublicLinuxMemoryImp(L0::Sysman::OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) : LinuxMemoryImp(pOsSysman, onSubdevice, subdeviceId) {}
|
||||
PublicLinuxMemoryImp() = default;
|
||||
using LinuxMemoryImp::getHbmFrequency;
|
||||
using L0::Sysman::SysmanKmdInterface::pSysfsAccess;
|
||||
MockSysmanKmdInterfaceI915Prelim(const PRODUCT_FAMILY productFamily) : SysmanKmdInterfaceI915Prelim(productFamily) {}
|
||||
~MockSysmanKmdInterfaceI915Prelim() override = default;
|
||||
};
|
||||
|
||||
} // namespace ult
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,44 +5,258 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/linux/drm_neo.h"
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
#include "shared/source/os_interface/linux/system_info.h"
|
||||
|
||||
#include "level_zero/sysman/source/device/sysman_device_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/pmt/sysman_pmt.h"
|
||||
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_fixture.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_hw_device_id.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
namespace ult {
|
||||
|
||||
using SysmanProductHelperMemoryTest = SysmanDeviceFixture;
|
||||
static const uint64_t hbmRP0Frequency = 4200;
|
||||
static const uint64_t mockMaxBwDg2 = 1343616u;
|
||||
|
||||
static uint32_t mockMemoryType = NEO::DeviceBlobConstants::MemoryType::hbm2e;
|
||||
|
||||
static const uint32_t vF0HbmLRead = 16;
|
||||
static const uint32_t vF0HbmHRead = 2;
|
||||
static const uint32_t vF0HbmLWrite = 8;
|
||||
static const uint32_t vF0HbmHWrite = 2;
|
||||
|
||||
static const uint8_t vF0Hbm0ReadValue = 92;
|
||||
static const uint8_t vF0Hbm0WriteValue = 96;
|
||||
static const uint8_t vF0Hbm1ReadValue = 104;
|
||||
static const uint8_t vF0Hbm1WriteValue = 108;
|
||||
static const uint8_t vF0TimestampLValue = 168;
|
||||
static const uint8_t vF0TimestampHValue = 172;
|
||||
static const uint8_t vF0Hbm2ReadValue = 113;
|
||||
static const uint8_t vF0Hbm2WriteValue = 125;
|
||||
static const uint8_t vF0Hbm3ReadValue = 135;
|
||||
static const uint8_t vF0Hbm3WriteValue = 20;
|
||||
static const uint64_t mockIdiReadVal = 8u;
|
||||
static const uint64_t mockIdiWriteVal = 9u;
|
||||
static const uint64_t mockDisplayVc1ReadVal = 10u;
|
||||
static const uint64_t numberMcChannels = 16;
|
||||
static const uint64_t transactionSize = 32;
|
||||
|
||||
class MockDrm : public NEO::Drm {
|
||||
public:
|
||||
MockDrm(RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<MockSysmanHwDeviceIdDrm>(mockFd, ""), rootDeviceEnvironment) {}
|
||||
void resetSystemInfo() {
|
||||
systemInfo.reset(nullptr);
|
||||
}
|
||||
|
||||
void setMemoryType(uint32_t memory) {
|
||||
mockMemoryType = memory;
|
||||
}
|
||||
|
||||
bool querySystemInfo() override {
|
||||
bool returnValue = true;
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
class MockPmt : public L0::Sysman::PlatformMonitoringTech {
|
||||
public:
|
||||
using L0::Sysman::PlatformMonitoringTech::guid;
|
||||
MockPmt() = default;
|
||||
|
||||
void setGuid(std::string guid) {
|
||||
this->guid = guid;
|
||||
}
|
||||
|
||||
ze_result_t readValue(const std::string key, uint32_t &val) override {
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
|
||||
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 result;
|
||||
}
|
||||
|
||||
ze_result_t readValue(const std::string key, uint64_t &val) override {
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
class SysmanProductHelperMemoryTest : public SysmanDeviceFixture {
|
||||
protected:
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
DebugManagerStateRestore restorer;
|
||||
MockDrm *pDrm = nullptr;
|
||||
|
||||
void SetUp() override {
|
||||
debugManager.flags.EnableLocalMemory.set(1);
|
||||
SysmanDeviceFixture::SetUp();
|
||||
device = pSysmanDeviceImp;
|
||||
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
|
||||
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
|
||||
pLinuxSysmanImp->pSysmanProductHelper = std::move(pSysmanProductHelper);
|
||||
pDrm = new MockDrm(const_cast<NEO::RootDeviceEnvironment &>(pSysmanDeviceImp->getRootDeviceEnvironment()));
|
||||
auto &osInterface = pSysmanDeviceImp->getRootDeviceEnvironment().osInterface;
|
||||
osInterface->setDriverModel(std::unique_ptr<MockDrm>(pDrm));
|
||||
pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.clear();
|
||||
auto subdeviceId = 0u;
|
||||
auto subDeviceCount = pLinuxSysmanImp->getSubDeviceCount();
|
||||
do {
|
||||
auto pPmt = new MockPmt();
|
||||
pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.emplace(subdeviceId, pPmt);
|
||||
} while (++subdeviceId < subDeviceCount);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
pLinuxSysmanImp->releasePmtObject();
|
||||
SysmanDeviceFixture::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
HWTEST2_F(SysmanProductHelperMemoryTest, GivenSysmanProductHelperInstanceWhenCallingMemoryAPIsThenErrorIsReturned, IsPVC) {
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsPread)> mockPread(&NEO::SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
|
||||
std::ostringstream oStream;
|
||||
oStream << hbmRP0Frequency;
|
||||
std::string value = oStream.str();
|
||||
memcpy(buf, value.data(), count);
|
||||
return count;
|
||||
});
|
||||
|
||||
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
|
||||
zes_mem_properties_t properties;
|
||||
ze_result_t result = pSysmanProductHelper->getMemoryProperties(&properties, static_cast<const L0::Sysman::LinuxSysmanImp *>(pLinuxSysmanImp));
|
||||
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
uint64_t expectedReadCounters = 0, expectedWriteCounters = 0, expectedBandwidth = 0;
|
||||
bool isSubdevice = true;
|
||||
uint32_t subDeviceId = 0;
|
||||
ze_result_t result = pSysmanProductHelper->getMemoryProperties(&properties, pLinuxSysmanImp, pDrm, pLinuxSysmanImp->getSysmanKmdInterface(), subDeviceId, isSubdevice);
|
||||
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(properties.type, ZES_MEM_TYPE_HBM);
|
||||
EXPECT_EQ(properties.location, ZES_MEM_LOC_DEVICE);
|
||||
EXPECT_TRUE(properties.onSubdevice);
|
||||
EXPECT_EQ(properties.subdeviceId, 0u);
|
||||
EXPECT_EQ(properties.physicalSize, 0u);
|
||||
EXPECT_EQ(properties.numChannels, numMemoryChannels);
|
||||
EXPECT_EQ(properties.busWidth, memoryBusWidth);
|
||||
|
||||
auto pPmt = static_cast<MockPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(properties.subdeviceId));
|
||||
pPmt->setGuid(guid64BitMemoryCounters);
|
||||
|
||||
zes_mem_bandwidth_t bandwidth;
|
||||
result = pSysmanProductHelper->getMemoryBandwidth(&bandwidth, static_cast<const L0::Sysman::LinuxSysmanImp *>(pLinuxSysmanImp));
|
||||
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
result = pSysmanProductHelper->getMemoryBandwidth(&bandwidth, pLinuxSysmanImp->getPlatformMonitoringTechAccess(subDeviceId), pSysmanDeviceImp, pLinuxSysmanImp->getSysmanKmdInterface(), subDeviceId);
|
||||
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
expectedReadCounters |= vF0HbmHRead;
|
||||
expectedReadCounters = (expectedReadCounters << 32) | vF0HbmLRead;
|
||||
expectedReadCounters = expectedReadCounters * transactionSize;
|
||||
EXPECT_EQ(bandwidth.readCounter, expectedReadCounters);
|
||||
expectedWriteCounters |= vF0HbmHWrite;
|
||||
expectedWriteCounters = (expectedWriteCounters << 32) | vF0HbmLWrite;
|
||||
expectedWriteCounters = expectedWriteCounters * transactionSize;
|
||||
EXPECT_EQ(bandwidth.writeCounter, expectedWriteCounters);
|
||||
expectedBandwidth = 128 * hbmRP0Frequency * 1000 * 1000 * 4;
|
||||
EXPECT_EQ(bandwidth.maxBandwidth, expectedBandwidth);
|
||||
}
|
||||
|
||||
HWTEST2_F(SysmanProductHelperMemoryTest, GivenSysmanProductHelperInstanceWhenCallingMemoryAPIsThenErrorIsReturned, IsDG1) {
|
||||
HWTEST2_F(SysmanProductHelperMemoryTest, GivenSysmanProductHelperInstanceWhenCallingGetMemoryBandwidthAPIsThenErrorIsReturned, IsDG1) {
|
||||
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
|
||||
zes_mem_properties_t properties;
|
||||
ze_result_t result = pSysmanProductHelper->getMemoryProperties(&properties, static_cast<const L0::Sysman::LinuxSysmanImp *>(pLinuxSysmanImp));
|
||||
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
bool isSubdevice = true;
|
||||
uint32_t subDeviceId = 0;
|
||||
ze_result_t result = pSysmanProductHelper->getMemoryProperties(&properties, pLinuxSysmanImp, pDrm, pLinuxSysmanImp->getSysmanKmdInterface(), subDeviceId, isSubdevice);
|
||||
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(properties.type, ZES_MEM_TYPE_DDR);
|
||||
EXPECT_EQ(properties.location, ZES_MEM_LOC_DEVICE);
|
||||
EXPECT_TRUE(properties.onSubdevice);
|
||||
EXPECT_EQ(properties.subdeviceId, 0u);
|
||||
EXPECT_EQ(properties.physicalSize, 0u);
|
||||
EXPECT_EQ(properties.numChannels, -1);
|
||||
EXPECT_EQ(properties.busWidth, -1);
|
||||
zes_mem_bandwidth_t bandwidth;
|
||||
result = pSysmanProductHelper->getMemoryBandwidth(&bandwidth, static_cast<const L0::Sysman::LinuxSysmanImp *>(pLinuxSysmanImp));
|
||||
result = pSysmanProductHelper->getMemoryBandwidth(&bandwidth, pLinuxSysmanImp->getPlatformMonitoringTechAccess(subDeviceId), pSysmanDeviceImp, pLinuxSysmanImp->getSysmanKmdInterface(), subDeviceId);
|
||||
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
}
|
||||
|
||||
HWTEST2_F(SysmanProductHelperMemoryTest, GivenSysmanProductHelperInstanceWhenCallingMemoryAPIsThenErrorIsReturned, IsDG2) {
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsPread)> mockPread(&NEO::SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
|
||||
std::ostringstream oStream;
|
||||
oStream << mockMaxBwDg2;
|
||||
std::string value = oStream.str();
|
||||
memcpy(buf, value.data(), count);
|
||||
return count;
|
||||
});
|
||||
|
||||
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
|
||||
zes_mem_properties_t properties;
|
||||
ze_result_t result = pSysmanProductHelper->getMemoryProperties(&properties, static_cast<const L0::Sysman::LinuxSysmanImp *>(pLinuxSysmanImp));
|
||||
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
uint64_t expectedReadCounters = 0, expectedWriteCounters = 0, expectedBandwidth = 0;
|
||||
bool isSubdevice = true;
|
||||
uint32_t subDeviceId = 0;
|
||||
ze_result_t result = pSysmanProductHelper->getMemoryProperties(&properties, pLinuxSysmanImp, pDrm, pLinuxSysmanImp->getSysmanKmdInterface(), subDeviceId, isSubdevice);
|
||||
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(properties.location, ZES_MEM_LOC_DEVICE);
|
||||
EXPECT_TRUE(properties.onSubdevice);
|
||||
EXPECT_EQ(properties.subdeviceId, 0u);
|
||||
EXPECT_EQ(properties.physicalSize, 0u);
|
||||
EXPECT_EQ(properties.numChannels, numMemoryChannels);
|
||||
EXPECT_EQ(properties.busWidth, memoryBusWidth);
|
||||
|
||||
zes_mem_bandwidth_t bandwidth;
|
||||
result = pSysmanProductHelper->getMemoryBandwidth(&bandwidth, static_cast<const L0::Sysman::LinuxSysmanImp *>(pLinuxSysmanImp));
|
||||
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
result = pSysmanProductHelper->getMemoryBandwidth(&bandwidth, pLinuxSysmanImp->getPlatformMonitoringTechAccess(subDeviceId), pSysmanDeviceImp, pLinuxSysmanImp->getSysmanKmdInterface(), subDeviceId);
|
||||
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
expectedReadCounters = numberMcChannels * (mockIdiReadVal + mockDisplayVc1ReadVal) * transactionSize;
|
||||
EXPECT_EQ(expectedReadCounters, bandwidth.readCounter);
|
||||
expectedWriteCounters = numberMcChannels * mockIdiWriteVal * transactionSize;
|
||||
EXPECT_EQ(expectedWriteCounters, bandwidth.writeCounter);
|
||||
expectedBandwidth = mockMaxBwDg2 * mbpsToBytesPerSecond;
|
||||
EXPECT_EQ(expectedBandwidth, bandwidth.maxBandwidth);
|
||||
EXPECT_GT(bandwidth.timestamp, 0u);
|
||||
}
|
||||
|
||||
TEST(SysmanProductHelperTest, GivenInvalidProductFamilyWhenCallingProductHelperCreateThenNullPtrIsReturned) {
|
||||
|
||||
@@ -114,6 +114,11 @@ TEST_F(SysmanFixtureDeviceI915Prelim, GivenSysmanKmdInterfaceInstanceWhenCheckin
|
||||
EXPECT_TRUE(pSysmanKmdInterface->isTdpFrequencyAvailable());
|
||||
}
|
||||
|
||||
TEST_F(SysmanFixtureDeviceI915Prelim, GivenSysmanKmdInterfaceInstanceWhenCheckingPhysicalMemorySizeAvailabilityThenTrueValueIsReturned) {
|
||||
auto pSysmanKmdInterface = pLinuxSysmanImp->getSysmanKmdInterface();
|
||||
EXPECT_TRUE(pSysmanKmdInterface->isPhysicalMemorySizeSupported());
|
||||
}
|
||||
|
||||
TEST_F(SysmanFixtureDeviceI915Prelim, GivenSysmanKmdInterfaceInstanceWhenCallingGetEngineClassStringThenInvalidValueIsReturned) {
|
||||
auto pSysmanKmdInterface = pLinuxSysmanImp->getSysmanKmdInterface();
|
||||
EXPECT_EQ(std::nullopt, pSysmanKmdInterface->getEngineClassString(EngineClass::ENGINE_CLASS_COMPUTE));
|
||||
|
||||
@@ -152,6 +152,11 @@ TEST_F(SysmanFixtureDeviceI915Upstream, GivenSysmanKmdInterfaceInstanceWhenCheck
|
||||
EXPECT_TRUE(pSysmanKmdInterface->isTdpFrequencyAvailable());
|
||||
}
|
||||
|
||||
TEST_F(SysmanFixtureDeviceI915Upstream, GivenSysmanKmdInterfaceInstanceWhenCheckingPhysicalMemorySizeAvailabilityThenFalseValueIsReturned) {
|
||||
auto pSysmanKmdInterface = pLinuxSysmanImp->pSysmanKmdInterface.get();
|
||||
EXPECT_FALSE(pSysmanKmdInterface->isPhysicalMemorySizeSupported());
|
||||
}
|
||||
|
||||
TEST_F(SysmanFixtureDeviceI915Upstream, GivenSysmanKmdInterfaceInstanceWhenCallingGetNativeUnitWithProperSysfsNameThenValidValuesAreReturned) {
|
||||
auto pSysmanKmdInterface = pLinuxSysmanImp->getSysmanKmdInterface();
|
||||
EXPECT_EQ(SysmanKmdInterface::SysfsValueUnit::milliSecond, pSysmanKmdInterface->getNativeUnit(SysfsName::sysfsNameSchedulerTimeout));
|
||||
|
||||
@@ -134,6 +134,11 @@ TEST_F(SysmanFixtureDeviceXe, GivenSysmanKmdInterfaceInstanceWhenCheckingAvailab
|
||||
EXPECT_FALSE(pSysmanKmdInterface->isTdpFrequencyAvailable());
|
||||
}
|
||||
|
||||
TEST_F(SysmanFixtureDeviceXe, GivenSysmanKmdInterfaceInstanceWhenCheckingPhysicalMemorySizeAvailabilityThenTrueValueIsReturned) {
|
||||
auto pSysmanKmdInterface = pLinuxSysmanImp->pSysmanKmdInterface.get();
|
||||
EXPECT_TRUE(pSysmanKmdInterface->isPhysicalMemorySizeSupported());
|
||||
}
|
||||
|
||||
TEST_F(SysmanFixtureDeviceXe, GivenSysmanKmdInterfaceInstanceWhenCallingGetNativeUnitWithProperSysfsNameThenValidValuesAreReturned) {
|
||||
auto pSysmanKmdInterface = pLinuxSysmanImp->getSysmanKmdInterface();
|
||||
EXPECT_EQ(SysmanKmdInterface::SysfsValueUnit::microSecond, pSysmanKmdInterface->getNativeUnit(SysfsName::sysfsNameSchedulerTimeout));
|
||||
|
||||
Reference in New Issue
Block a user