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:
parent
111b112729
commit
a15e8a9679
|
@ -64,7 +64,6 @@ ze_result_t LinuxSysmanImp::init() {
|
|||
|
||||
rootPath = NEO::getPciRootPath(myDeviceFd).value_or("");
|
||||
pSysfsAccess->getRealPath(deviceDir, gtDevicePath);
|
||||
|
||||
osInterface.getDriverModel()->as<NEO::Drm>()->cleanup();
|
||||
// Close Drm handles
|
||||
sysmanHwDeviceId->closeFileDescriptor();
|
||||
|
|
|
@ -9,8 +9,10 @@
|
|||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/helpers/gfx_core_helper.h"
|
||||
#include "shared/source/memory_manager/memory_banks.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/sysman/source/firmware_util/sysman_firmware_util.h"
|
||||
|
@ -30,20 +32,12 @@ void memoryGetTimeStamp(uint64_t ×tamp) {
|
|||
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->getSysmanDeviceImp();
|
||||
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
|
||||
pPmt = pLinuxSysmanImp->getPlatformMonitoringTechAccess(subdeviceId);
|
||||
init();
|
||||
}
|
||||
|
||||
bool LinuxMemoryImp::isMemoryModuleSupported() {
|
||||
|
@ -89,6 +83,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) {
|
||||
|
@ -170,9 +165,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) {
|
||||
|
@ -305,26 +298,15 @@ ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) {
|
|||
pFwInterface->fwGetMemoryHealthIndicator(&pState->health);
|
||||
}
|
||||
|
||||
std::vector<NEO::MemoryRegion> deviceRegions;
|
||||
auto hwDeviceId = pLinuxSysmanImp->getSysmanHwDeviceId();
|
||||
hwDeviceId->openFileDescriptor();
|
||||
auto memRegions = pDrm->getMemoryRegions();
|
||||
auto memoryInfo = pDrm->getIoctlHelper()->createMemoryInfo();
|
||||
hwDeviceId->closeFileDescriptor();
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@ class LinuxMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass {
|
|||
bool isSubdevice = false;
|
||||
uint32_t subdeviceId = 0;
|
||||
std::string physicalSizeFile;
|
||||
void init();
|
||||
};
|
||||
|
||||
} // namespace Sysman
|
||||
|
|
|
@ -19,16 +19,6 @@
|
|||
#include "drm/intel_hwconfig_types.h"
|
||||
|
||||
using namespace NEO;
|
||||
constexpr uint64_t probedSizeRegionZero = 8 * GB;
|
||||
constexpr uint64_t probedSizeRegionOne = 16 * GB;
|
||||
constexpr uint64_t probedSizeRegionTwo = 4 * GB;
|
||||
constexpr uint64_t probedSizeRegionThree = 16 * GB;
|
||||
constexpr uint64_t probedSizeRegionFour = 32 * GB;
|
||||
constexpr uint64_t unallocatedSizeRegionZero = 6 * GB;
|
||||
constexpr uint64_t unallocatedSizeRegionOne = 12 * GB;
|
||||
constexpr uint64_t unallocatedSizeRegionTwo = 25 * GB;
|
||||
constexpr uint64_t unallocatedSizeRegionThree = 3 * GB;
|
||||
constexpr uint64_t unallocatedSizeRegionFour = 4 * GB;
|
||||
|
||||
constexpr uint16_t vF0VfidIndex = 88;
|
||||
constexpr uint16_t vF0Hbm0ReadIndex = 92;
|
||||
|
@ -214,29 +204,6 @@ struct MockMemoryNeoDrm : public NEO::Drm {
|
|||
bool mockReturnEmptyRegions = false;
|
||||
MockMemoryNeoDrm(RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<MockSysmanHwDeviceIdDrm>(mockFd, ""), rootDeviceEnvironment) {}
|
||||
|
||||
std::vector<uint8_t> getMemoryRegions() override {
|
||||
if (mockReturnEmptyRegions == true) {
|
||||
return {};
|
||||
}
|
||||
|
||||
uint32_t regionCount = 3;
|
||||
uint32_t allocSize = sizeof(drm_i915_query_memory_regions) + regionCount * sizeof(drm_i915_memory_region_info);
|
||||
auto regions = std::vector<uint8_t>(allocSize, 0);
|
||||
drm_i915_query_memory_regions *memRegions = reinterpret_cast<drm_i915_query_memory_regions *>(regions.data());
|
||||
memRegions->regions[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
memRegions->regions[0].probed_size = probedSizeRegionZero;
|
||||
memRegions->regions[0].unallocated_size = unallocatedSizeRegionZero;
|
||||
memRegions->regions[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
memRegions->regions[1].probed_size = probedSizeRegionOne;
|
||||
memRegions->regions[1].unallocated_size = unallocatedSizeRegionOne;
|
||||
memRegions->regions[2].region = {I915_MEMORY_CLASS_DEVICE, 1};
|
||||
memRegions->regions[2].probed_size = probedSizeRegionFour;
|
||||
memRegions->regions[2].unallocated_size = unallocatedSizeRegionFour;
|
||||
memRegions->num_regions = 3;
|
||||
|
||||
return regions;
|
||||
}
|
||||
|
||||
void setMemoryType(uint32_t memory) {
|
||||
mockMemoryType = memory;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#include "shared/source/os_interface/driver_info.h"
|
||||
#include "shared/test/common/mocks/linux/mock_ioctl_helper.h"
|
||||
#include "shared/test/common/test_macros/hw_test.h"
|
||||
|
||||
#include "level_zero/sysman/source/linux/pmt/sysman_pmt_xml_offsets.h"
|
||||
|
@ -51,7 +52,7 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
|
|||
pFsAccessOriginal = pLinuxSysmanImp->pFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
|
||||
pDrm->setMemoryType(INTEL_HWCONFIG_MEMORY_TYPE_HBM2e);
|
||||
pDrm->ioctlHelper = static_cast<std::unique_ptr<NEO::IoctlHelper>>(std::make_unique<IoctlHelperPrelim20>(*pDrm));
|
||||
pDrm->ioctlHelper = static_cast<std::unique_ptr<NEO::IoctlHelper>>(std::make_unique<NEO::MockIoctlHelper>(*pDrm));
|
||||
|
||||
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
|
||||
pmtMapOriginal = pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject;
|
||||
|
@ -329,8 +330,8 @@ TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZetSysmanMemo
|
|||
|
||||
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(state.health, ZES_MEM_HEALTH_OK);
|
||||
EXPECT_EQ(state.size, probedSizeRegionOne);
|
||||
EXPECT_EQ(state.free, unallocatedSizeRegionOne);
|
||||
EXPECT_EQ(state.size, NEO::probedSizeRegionOne);
|
||||
EXPECT_EQ(state.free, NEO::unallocatedSizeRegionOne);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -709,18 +710,6 @@ TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZesSysmanMemo
|
|||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZetSysmanMemoryGetStateAndIfGetMemoryRegionsFailsThenErrorIsReturned) {
|
||||
setLocalSupportedAndReinit(true);
|
||||
|
||||
pDrm->mockReturnEmptyRegions = 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(SysmanMultiDeviceFixture, GivenValidDevicePointerWhenGettingMemoryPropertiesThenValidMemoryPropertiesRetrieved) {
|
||||
zes_mem_properties_t properties = {};
|
||||
ze_bool_t isSubdevice = pLinuxSysmanImp->getSubDeviceCount() == 0 ? false : true;
|
||||
|
@ -748,7 +737,7 @@ class SysmanMultiDeviceMemoryFixture : public SysmanMultiDeviceFixture {
|
|||
pSysfsAccess = std::make_unique<MockMemorySysfsAccess>();
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
|
||||
pDrm = new MockMemoryNeoDrm(const_cast<NEO::RootDeviceEnvironment &>(pSysmanDeviceImp->getRootDeviceEnvironment()));
|
||||
pDrm->ioctlHelper = static_cast<std::unique_ptr<NEO::IoctlHelper>>(std::make_unique<IoctlHelperPrelim20>(*pDrm));
|
||||
pDrm->ioctlHelper = static_cast<std::unique_ptr<NEO::IoctlHelper>>(std::make_unique<NEO::MockIoctlHelper>(*pDrm));
|
||||
auto &osInterface = pSysmanDeviceImp->getRootDeviceEnvironment().osInterface;
|
||||
osInterface->setDriverModel(std::unique_ptr<MockMemoryNeoDrm>(pDrm));
|
||||
|
||||
|
@ -823,15 +812,15 @@ TEST_F(SysmanMultiDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZetSysma
|
|||
ze_result_t result = zesMemoryGetState(handles[0], &state1);
|
||||
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(state1.health, ZES_MEM_HEALTH_OK);
|
||||
EXPECT_EQ(state1.size, probedSizeRegionOne);
|
||||
EXPECT_EQ(state1.free, unallocatedSizeRegionOne);
|
||||
EXPECT_EQ(state1.size, NEO::probedSizeRegionOne);
|
||||
EXPECT_EQ(state1.free, NEO::unallocatedSizeRegionOne);
|
||||
|
||||
zes_mem_state_t state2;
|
||||
result = zesMemoryGetState(handles[1], &state2);
|
||||
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(state2.health, ZES_MEM_HEALTH_OK);
|
||||
EXPECT_EQ(state2.size, probedSizeRegionFour);
|
||||
EXPECT_EQ(state2.free, unallocatedSizeRegionFour);
|
||||
EXPECT_EQ(state2.size, NEO::probedSizeRegionFour);
|
||||
EXPECT_EQ(state2.free, NEO::unallocatedSizeRegionFour);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
|
|
|
@ -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 ×tamp) {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ class LinuxMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass {
|
|||
bool isSubdevice = false;
|
||||
uint32_t subdeviceId = 0;
|
||||
std::string physicalSizeFile;
|
||||
void init();
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
|
|
|
@ -19,16 +19,6 @@
|
|||
#include "drm/intel_hwconfig_types.h"
|
||||
|
||||
using namespace NEO;
|
||||
constexpr uint64_t probedSizeRegionZero = 8 * GB;
|
||||
constexpr uint64_t probedSizeRegionOne = 16 * GB;
|
||||
constexpr uint64_t probedSizeRegionTwo = 4 * GB;
|
||||
constexpr uint64_t probedSizeRegionThree = 16 * GB;
|
||||
constexpr uint64_t probedSizeRegionFour = 32 * GB;
|
||||
constexpr uint64_t unallocatedSizeRegionZero = 6 * GB;
|
||||
constexpr uint64_t unallocatedSizeRegionOne = 12 * GB;
|
||||
constexpr uint64_t unallocatedSizeRegionTwo = 25 * GB;
|
||||
constexpr uint64_t unallocatedSizeRegionThree = 3 * GB;
|
||||
constexpr uint64_t unallocatedSizeRegionFour = 4 * GB;
|
||||
|
||||
constexpr uint16_t vF0VfidIndex = 88;
|
||||
constexpr uint16_t vF0Hbm0ReadIndex = 92;
|
||||
|
@ -218,29 +208,6 @@ struct MockMemoryNeoDrm : public Drm {
|
|||
bool mockReturnEmptyRegions = false;
|
||||
MockMemoryNeoDrm(RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceIdDrm>(mockFd, ""), rootDeviceEnvironment) {}
|
||||
|
||||
std::vector<uint8_t> getMemoryRegions() override {
|
||||
if (mockReturnEmptyRegions == true) {
|
||||
return {};
|
||||
}
|
||||
|
||||
uint32_t regionCount = 3;
|
||||
uint32_t allocSize = sizeof(drm_i915_query_memory_regions) + regionCount * sizeof(drm_i915_memory_region_info);
|
||||
auto regions = std::vector<uint8_t>(allocSize, 0);
|
||||
drm_i915_query_memory_regions *memRegions = reinterpret_cast<drm_i915_query_memory_regions *>(regions.data());
|
||||
memRegions->regions[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
memRegions->regions[0].probed_size = probedSizeRegionZero;
|
||||
memRegions->regions[0].unallocated_size = unallocatedSizeRegionZero;
|
||||
memRegions->regions[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
memRegions->regions[1].probed_size = probedSizeRegionOne;
|
||||
memRegions->regions[1].unallocated_size = unallocatedSizeRegionOne;
|
||||
memRegions->regions[2].region = {I915_MEMORY_CLASS_DEVICE, 1};
|
||||
memRegions->regions[2].probed_size = probedSizeRegionFour;
|
||||
memRegions->regions[2].unallocated_size = unallocatedSizeRegionFour;
|
||||
memRegions->num_regions = 3;
|
||||
|
||||
return regions;
|
||||
}
|
||||
|
||||
void setMemoryType(uint32_t memory) {
|
||||
mockMemoryType = memory;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#include "shared/source/os_interface/driver_info.h"
|
||||
#include "shared/test/common/mocks/linux/mock_ioctl_helper.h"
|
||||
|
||||
#include "level_zero/tools/source/sysman/linux/pmt/pmt_xml_offsets.h"
|
||||
#include "level_zero/tools/source/sysman/memory/linux/os_memory_imp_prelim.h"
|
||||
|
@ -61,7 +62,7 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
|
|||
pFsAccessOriginal = pLinuxSysmanImp->pFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
|
||||
pDrm->setMemoryType(INTEL_HWCONFIG_MEMORY_TYPE_HBM2e);
|
||||
pDrm->ioctlHelper = static_cast<std::unique_ptr<NEO::IoctlHelper>>(std::make_unique<IoctlHelperPrelim20>(*pDrm));
|
||||
pDrm->ioctlHelper = static_cast<std::unique_ptr<NEO::IoctlHelper>>(std::make_unique<NEO::MockIoctlHelper>(*pDrm));
|
||||
|
||||
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
|
||||
uint32_t subDeviceCount = 0;
|
||||
|
@ -371,8 +372,8 @@ TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZetSysmanMemo
|
|||
|
||||
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(state.health, ZES_MEM_HEALTH_OK);
|
||||
EXPECT_EQ(state.size, probedSizeRegionOne);
|
||||
EXPECT_EQ(state.free, unallocatedSizeRegionOne);
|
||||
EXPECT_EQ(state.size, NEO::probedSizeRegionOne);
|
||||
EXPECT_EQ(state.free, NEO::unallocatedSizeRegionOne);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -822,18 +823,6 @@ TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZesSysmanMemo
|
|||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZetSysmanMemoryGetStateAndIfGetMemoryRegionsFailsThenErrorIsReturned) {
|
||||
setLocalSupportedAndReinit(true);
|
||||
|
||||
pDrm->mockReturnEmptyRegions = 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(SysmanMultiDeviceFixture, GivenValidDevicePointerWhenGettingMemoryPropertiesThenValidMemoryPropertiesRetrieved) {
|
||||
zes_mem_properties_t properties = {};
|
||||
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
||||
|
@ -871,7 +860,7 @@ class SysmanMultiDeviceMemoryFixture : public SysmanMultiDeviceFixture {
|
|||
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<IoctlHelperPrelim20>(*pDrm));
|
||||
pDrm->ioctlHelper = static_cast<std::unique_ptr<NEO::IoctlHelper>>(std::make_unique<NEO::MockIoctlHelper>(*pDrm));
|
||||
|
||||
pSysmanDevice = device->getSysmanHandle();
|
||||
pSysmanDeviceImp = static_cast<SysmanDeviceImp *>(pSysmanDevice);
|
||||
|
@ -992,15 +981,15 @@ TEST_F(SysmanMultiDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZetSysma
|
|||
ze_result_t result = zesMemoryGetState(handles[0], &state1);
|
||||
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(state1.health, ZES_MEM_HEALTH_OK);
|
||||
EXPECT_EQ(state1.size, probedSizeRegionOne);
|
||||
EXPECT_EQ(state1.free, unallocatedSizeRegionOne);
|
||||
EXPECT_EQ(state1.size, NEO::probedSizeRegionOne);
|
||||
EXPECT_EQ(state1.free, NEO::unallocatedSizeRegionOne);
|
||||
|
||||
zes_mem_state_t state2;
|
||||
result = zesMemoryGetState(handles[1], &state2);
|
||||
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(state2.health, ZES_MEM_HEALTH_OK);
|
||||
EXPECT_EQ(state2.size, probedSizeRegionFour);
|
||||
EXPECT_EQ(state2.free, unallocatedSizeRegionFour);
|
||||
EXPECT_EQ(state2.size, NEO::probedSizeRegionFour);
|
||||
EXPECT_EQ(state2.free, NEO::unallocatedSizeRegionFour);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
|
|
|
@ -387,6 +387,10 @@ std::string IoctlHelper::getFileForMaxMemoryFrequencyOfSubDevice(int subDeviceId
|
|||
return "/gt/gt" + std::to_string(subDeviceId) + "/mem_RP0_freq_mhz";
|
||||
}
|
||||
|
||||
std::string IoctlHelper::getFileForMemoryAddrRange(int subDeviceId) const {
|
||||
return "gt/gt" + std::to_string(subDeviceId) + "/addr_range";
|
||||
}
|
||||
|
||||
bool IoctlHelper::checkIfIoctlReinvokeRequired(int error, DrmIoctl ioctlRequest) const {
|
||||
return (error == EINTR || error == EAGAIN || error == EBUSY || error == -EBUSY);
|
||||
}
|
||||
|
|
|
@ -142,6 +142,7 @@ class IoctlHelper {
|
|||
virtual std::string getFileForMaxGpuFrequency() const;
|
||||
virtual std::string getFileForMaxGpuFrequencyOfSubDevice(int subDeviceId) const;
|
||||
virtual std::string getFileForMaxMemoryFrequencyOfSubDevice(int subDeviceId) const;
|
||||
virtual std::string getFileForMemoryAddrRange(int subdeviceId) const;
|
||||
virtual bool getFabricLatency(uint32_t fabricId, uint32_t &latency, uint32_t &bandwidth) = 0;
|
||||
virtual bool isWaitBeforeBindRequired(bool bind) const = 0;
|
||||
virtual void *pciBarrierMmap() { return nullptr; };
|
||||
|
|
|
@ -1356,6 +1356,10 @@ std::string IoctlHelperXe::getFileForMaxMemoryFrequencyOfSubDevice(int subDevice
|
|||
return "/device/gt" + std::to_string(subDeviceId) + "/freq_rp0";
|
||||
}
|
||||
|
||||
std::string IoctlHelperXe::getFileForMemoryAddrRange(int subDeviceId) const {
|
||||
return "device/tile" + std::to_string(subDeviceId) + "/addr_range";
|
||||
}
|
||||
|
||||
struct drm_xe_engine_class_instance *
|
||||
IoctlHelperXe::xeFindMatchingEngine(uint16_t engineClass, uint16_t engineInstance) {
|
||||
for (auto &engine : allEngines) {
|
||||
|
|
|
@ -96,6 +96,7 @@ class IoctlHelperXe : public IoctlHelper {
|
|||
std::string getFileForMaxGpuFrequency() const override;
|
||||
std::string getFileForMaxGpuFrequencyOfSubDevice(int subDeviceId) const override;
|
||||
std::string getFileForMaxMemoryFrequencyOfSubDevice(int subDeviceId) const override;
|
||||
std::string getFileForMemoryAddrRange(int subdeviceId) const override;
|
||||
bool getFabricLatency(uint32_t fabricId, uint32_t &latency, uint32_t &bandwidth) override;
|
||||
bool isWaitBeforeBindRequired(bool bind) const override;
|
||||
std::unique_ptr<EngineInfo> createEngineInfo(bool isSysmanEnabled) override;
|
||||
|
|
|
@ -6,12 +6,23 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/helpers/constants.h"
|
||||
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
|
||||
#include "drm/i915_drm.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
constexpr uint64_t probedSizeRegionZero = 8 * GB;
|
||||
constexpr uint64_t probedSizeRegionOne = 16 * GB;
|
||||
constexpr uint64_t probedSizeRegionFour = 32 * GB;
|
||||
constexpr uint64_t unallocatedSizeRegionZero = 6 * GB;
|
||||
constexpr uint64_t unallocatedSizeRegionOne = 12 * GB;
|
||||
constexpr uint64_t unallocatedSizeRegionFour = 4 * GB;
|
||||
|
||||
class MockIoctlHelper : public IoctlHelperPrelim20 {
|
||||
public:
|
||||
using IoctlHelperPrelim20::IoctlHelperPrelim20;
|
||||
|
@ -20,6 +31,9 @@ class MockIoctlHelper : public IoctlHelperPrelim20 {
|
|||
};
|
||||
|
||||
int getDrmParamValue(DrmParam drmParam) const override {
|
||||
if (drmParam == DrmParam::MemoryClassSystem || drmParam == DrmParam::MemoryClassDevice) {
|
||||
return IoctlHelperPrelim20::getDrmParamValue(drmParam);
|
||||
}
|
||||
return drmParamValue;
|
||||
}
|
||||
int vmBind(const VmBindParams &vmBindParams) override {
|
||||
|
@ -41,6 +55,23 @@ class MockIoctlHelper : public IoctlHelperPrelim20 {
|
|||
return IoctlHelperPrelim20::isWaitBeforeBindRequired(bind);
|
||||
}
|
||||
|
||||
std::unique_ptr<MemoryInfo> createMemoryInfo() override {
|
||||
|
||||
std::vector<MemoryRegion> regionInfo(3);
|
||||
regionInfo[0].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[0].probedSize = probedSizeRegionZero;
|
||||
regionInfo[0].unallocatedSize = unallocatedSizeRegionZero;
|
||||
regionInfo[1].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0};
|
||||
regionInfo[1].probedSize = probedSizeRegionOne;
|
||||
regionInfo[1].unallocatedSize = unallocatedSizeRegionOne;
|
||||
regionInfo[2].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 1};
|
||||
regionInfo[2].probedSize = probedSizeRegionFour;
|
||||
regionInfo[2].unallocatedSize = unallocatedSizeRegionFour;
|
||||
|
||||
std::unique_ptr<MemoryInfo> memoryInfo = std::make_unique<MemoryInfo>(regionInfo, drm);
|
||||
return memoryInfo;
|
||||
}
|
||||
|
||||
unsigned int ioctlRequestValue = 1234u;
|
||||
int drmParamValue = 1234;
|
||||
std::optional<bool> failBind{};
|
||||
|
|
|
@ -1563,6 +1563,13 @@ TEST(IoctlHelperTest, whenGettingFileNameForFrequencyFilesThenProperStringIsRetu
|
|||
EXPECT_STREQ("/gt/gt1/mem_RP0_freq_mhz", ioctlHelper->getFileForMaxMemoryFrequencyOfSubDevice(1).c_str());
|
||||
}
|
||||
|
||||
TEST(IoctlHelperTest, whenGettingFileNameForMemoryAddrRangeThenProperStringIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
auto ioctlHelper = drm.getIoctlHelper();
|
||||
EXPECT_STREQ("gt/gt0/addr_range", ioctlHelper->getFileForMemoryAddrRange(0).c_str());
|
||||
}
|
||||
|
||||
TEST(DistanceInfoTest, givenDistanceInfosWhenAssignRegionsFromDistancesThenCorrectRegionsSet) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
|
|
@ -494,6 +494,13 @@ TEST(IoctlHelperXeTest, whenGettingFileNamesForFrequencyThenProperStringIsReturn
|
|||
EXPECT_STREQ("/device/gt1/freq_rp0", ioctlHelper->getFileForMaxMemoryFrequencyOfSubDevice(1).c_str());
|
||||
}
|
||||
|
||||
TEST(IoctlHelperXeTest, whenGettingFileNameForMemoryAddrRangeThenProperStringIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
auto ioctlHelper = std::make_unique<IoctlHelperXe>(drm);
|
||||
EXPECT_STREQ("device/tile0/addr_range", ioctlHelper->getFileForMemoryAddrRange(0).c_str());
|
||||
}
|
||||
|
||||
inline constexpr int testValueVmId = 0x5764;
|
||||
inline constexpr int testValueMapOff = 0x7788;
|
||||
inline constexpr int testValuePrime = 0x4321;
|
||||
|
|
Loading…
Reference in New Issue