mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
feature(sysman): Add support for Memory properties & state for iGPU's in Linux
Related-To: NEO-14198 Signed-off-by: Shreyas Kunder <shreyas.kunder@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
ff00896801
commit
e1eae6a3e5
@@ -17,6 +17,7 @@
|
||||
#include "level_zero/sysman/source/shared/firmware_util/sysman_firmware_util.h"
|
||||
#include "level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface.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/zes_os_sysman_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
@@ -35,6 +36,22 @@ ze_result_t LinuxMemoryImp::getBandwidth(zes_mem_bandwidth_t *pBandwidth) {
|
||||
ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) {
|
||||
ze_result_t status = ZE_RESULT_SUCCESS;
|
||||
pState->health = ZES_MEM_HEALTH_UNKNOWN;
|
||||
|
||||
if (pLinuxSysmanImp->getHardwareInfo().capabilityTable.isIntegratedDevice) {
|
||||
const std::string memFreeKey = "MemFree";
|
||||
const std::string memAvailableKey = "MemAvailable";
|
||||
auto memInfoValues = readMemInfoValues(&pLinuxSysmanImp->getFsAccess(), {memFreeKey, memAvailableKey});
|
||||
if (memInfoValues.find(memFreeKey) != memInfoValues.end() && memInfoValues.find(memAvailableKey) != memInfoValues.end()) {
|
||||
pState->free = memInfoValues[memFreeKey] * 1024;
|
||||
pState->size = memInfoValues[memAvailableKey] * 1024;
|
||||
} else {
|
||||
pState->free = 0;
|
||||
pState->size = 0;
|
||||
status = ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
FirmwareUtil *pFwInterface = pLinuxSysmanImp->getFwUtilInterface();
|
||||
auto pSysmanProductHelper = pLinuxSysmanImp->getSysmanProductHelper();
|
||||
pSysmanProductHelper->getMemoryHealthIndicator(pFwInterface, &pState->health);
|
||||
@@ -60,6 +77,35 @@ ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) {
|
||||
return status;
|
||||
}
|
||||
|
||||
std::map<std::string, uint64_t> LinuxMemoryImp::readMemInfoValues(FsAccessInterface *pFsAccess, const std::vector<std::string> &keys) {
|
||||
std::map<std::string, uint64_t> result = {};
|
||||
const std::string memInfoFile = "/proc/meminfo";
|
||||
std::vector<std::string> memInfo{};
|
||||
|
||||
if (pFsAccess->read(memInfoFile, memInfo) == ZE_RESULT_SUCCESS) {
|
||||
for (const auto &line : memInfo) {
|
||||
std::istringstream lineStream(line);
|
||||
std::string label = "";
|
||||
std::string unit = "";
|
||||
uint64_t value = 0;
|
||||
|
||||
lineStream >> label >> value >> unit;
|
||||
|
||||
if (!label.empty() && label.back() == ':') {
|
||||
label.pop_back();
|
||||
}
|
||||
|
||||
if (std::find(keys.begin(), keys.end(), label) != keys.end()) {
|
||||
result[label] = value;
|
||||
if (result.size() == keys.size()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
LinuxMemoryImp::LinuxMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) : isSubdevice(onSubdevice), subdeviceId(subdeviceId) {
|
||||
pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
|
||||
pDrm = pLinuxSysmanImp->getDrm();
|
||||
@@ -69,6 +115,9 @@ LinuxMemoryImp::LinuxMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint3
|
||||
|
||||
bool LinuxMemoryImp::isMemoryModuleSupported() {
|
||||
auto &gfxCoreHelper = pDevice->getRootDeviceEnvironment().getHelper<NEO::GfxCoreHelper>();
|
||||
if (pLinuxSysmanImp->getHardwareInfo().capabilityTable.isIntegratedDevice) {
|
||||
return true;
|
||||
}
|
||||
return gfxCoreHelper.getEnableLocalMemory(pDevice->getHardwareInfo());
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
|
||||
#include "level_zero/sysman/source/api/memory/sysman_os_memory.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace NEO {
|
||||
class Drm;
|
||||
@@ -22,12 +24,14 @@ namespace Sysman {
|
||||
class LinuxSysmanImp;
|
||||
class SysmanKmdInterface;
|
||||
struct SysmanDeviceImp;
|
||||
class FsAccessInterface;
|
||||
|
||||
class LinuxMemoryImp : public OsMemory, NEO::NonCopyableAndNonMovableClass {
|
||||
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;
|
||||
static std::map<std::string, uint64_t> readMemInfoValues(FsAccessInterface *pFsAccess, const std::vector<std::string> &keys);
|
||||
bool isMemoryModuleSupported() override;
|
||||
LinuxMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId);
|
||||
LinuxMemoryImp() = default;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
#include "shared/source/os_interface/linux/system_info.h"
|
||||
|
||||
#include "level_zero/sysman/source/api/memory/linux/sysman_os_memory_imp.h"
|
||||
#include "level_zero/sysman/source/api/ras/linux/ras_util/sysman_ras_util.h"
|
||||
#include "level_zero/sysman/source/shared/firmware_util/sysman_firmware_util.h"
|
||||
#include "level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface.h"
|
||||
@@ -37,8 +38,13 @@ void SysmanProductHelperHw<gfxProduct>::getFrequencyStepSize(double *pStepSize)
|
||||
template <PRODUCT_FAMILY gfxProduct>
|
||||
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();
|
||||
bool isIntegratedDevice = pLinuxSysmanImp->getHardwareInfo().capabilityTable.isIntegratedDevice;
|
||||
|
||||
pProperties->location = ZES_MEM_LOC_DEVICE;
|
||||
if (isIntegratedDevice) {
|
||||
pProperties->location = ZES_MEM_LOC_SYSTEM;
|
||||
} else {
|
||||
pProperties->location = ZES_MEM_LOC_DEVICE;
|
||||
}
|
||||
pProperties->type = ZES_MEM_TYPE_DDR;
|
||||
pProperties->onSubdevice = isSubdevice;
|
||||
pProperties->subdeviceId = subDeviceId;
|
||||
@@ -84,7 +90,17 @@ ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryProperties(zes_mem_prope
|
||||
pProperties->busWidth = memoryBusWidth;
|
||||
pProperties->physicalSize = 0;
|
||||
|
||||
if (pSysmanKmdInterface->isPhysicalMemorySizeSupported() == true) {
|
||||
if (isIntegratedDevice) {
|
||||
pProperties->busWidth = -1;
|
||||
pProperties->numChannels = -1;
|
||||
pProperties->type = ZES_MEM_TYPE_FORCE_UINT32;
|
||||
|
||||
const std::string memTotalKey = "MemTotal";
|
||||
auto memInfoValues = LinuxMemoryImp::readMemInfoValues(&pLinuxSysmanImp->getFsAccess(), {memTotalKey});
|
||||
if (memInfoValues.find(memTotalKey) != memInfoValues.end()) {
|
||||
pProperties->physicalSize = memInfoValues[memTotalKey] * 1024;
|
||||
}
|
||||
} else if (pSysmanKmdInterface->isPhysicalMemorySizeSupported() == true) {
|
||||
if (isSubdevice) {
|
||||
std::string memval;
|
||||
std::string physicalSizeFile = pSysmanKmdInterface->getSysfsFilePathForPhysicalMemorySize(subDeviceId);
|
||||
|
||||
Reference in New Issue
Block a user