mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-10 15:12:56 +08:00
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:
committed by
Compute-Runtime-Automation
parent
111b112729
commit
a15e8a9679
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user