feature: Added changes for Porting Memory API with XE driver

The Memory Info object is used in the getState function for memory.
Some of the ULTS in the memory modules has been modified.
A function to return the sysfs nodes for the Memory address range has
been added in the IoctlHelper class corresponding to the XE and i915
driver.

Related-To: LOCI-4397

Signed-off-by: Bari, Pratik <pratik.bari@intel.com>
This commit is contained in:
Bari, Pratik
2023-05-25 07:15:14 +00:00
committed by Compute-Runtime-Automation
parent 111b112729
commit a15e8a9679
16 changed files with 89 additions and 161 deletions

View File

@@ -10,9 +10,11 @@
#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"
@@ -32,20 +34,12 @@ void memoryGetTimeStamp(uint64_t &timestamp) {
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() {
@@ -85,6 +79,7 @@ ze_result_t LinuxMemoryImp::getProperties(zes_mem_properties_t *pProperties) {
pProperties->physicalSize = 0;
if (isSubdevice) {
std::string memval;
physicalSizeFile = pDrm->getIoctlHelper()->getFileForMemoryAddrRange(subdeviceId);
ze_result_t result = pSysfsAccess->read(physicalSizeFile, memval);
uint64_t intval = strtoull(memval.c_str(), nullptr, 16);
if (ZE_RESULT_SUCCESS != result) {
@@ -166,9 +161,7 @@ void LinuxMemoryImp::getHbmFrequency(PRODUCT_FAMILY productFamily, unsigned shor
hbmFrequency = 2.8 * gigaUnitTransferToUnitTransfer;
} else 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";
const std::string hbmRP0FreqFile = pDrm->getIoctlHelper()->getFileForMaxMemoryFrequencyOfSubDevice(subdeviceId);
uint64_t hbmFreqValue = 0;
ze_result_t result = pSysfsAccess->read(hbmRP0FreqFile, hbmFreqValue);
if (ZE_RESULT_SUCCESS == result) {
@@ -391,22 +384,11 @@ ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) {
pFwInterface->fwGetMemoryHealthIndicator(&pState->health);
}
std::vector<NEO::MemoryRegion> deviceRegions;
auto memRegions = pDrm->getMemoryRegions();
if (memRegions.empty()) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
auto regions = pDrm->getIoctlHelper()->translateToMemoryRegions(memRegions);
for (auto region : regions) {
if (region.region.memoryClass == drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE) {
deviceRegions.push_back(region);
}
}
auto memoryInfo = pDrm->getIoctlHelper()->createMemoryInfo();
auto region = memoryInfo->getMemoryRegion(MemoryBanks::getBankForLocalMemory(subdeviceId));
UNRECOVERABLE_IF(deviceRegions.size() <= subdeviceId);
pState->free = deviceRegions[subdeviceId].unallocatedSize;
pState->size = deviceRegions[subdeviceId].probedSize;
pState->free = region.unallocatedSize;
pState->size = region.probedSize;
return ZE_RESULT_SUCCESS;
}

View File

@@ -49,7 +49,6 @@ class LinuxMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass {
bool isSubdevice = false;
uint32_t subdeviceId = 0;
std::string physicalSizeFile;
void init();
};
} // namespace L0