mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 22:12:59 +08:00
Move MemoryInfoImpl logic to MemoryInfo
Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
f138c5f881
commit
12777bd758
@@ -5,7 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/linux/memory_info_impl.h"
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
|
||||
#include "level_zero/tools/source/sysman/memory/linux/os_memory_imp.h"
|
||||
|
||||
@@ -45,7 +45,7 @@ ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
auto memoryInfo = static_cast<NEO::MemoryInfoImpl *>(pDrm->getMemoryInfo());
|
||||
auto memoryInfo = pDrm->getMemoryInfo();
|
||||
if (!memoryInfo) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/os_interface/linux/memory_info_impl.h"
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
|
||||
#include "level_zero/core/test/unit_tests/mock.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_memory_manager.h"
|
||||
@@ -50,7 +50,7 @@ struct Mock<MemoryNeoDrm> : public MemoryNeoDrm {
|
||||
regionInfo[1].probed_size = probedSizeRegionOne;
|
||||
regionInfo[1].unallocated_size = unallocatedSizeRegionOne;
|
||||
|
||||
this->memoryInfo.reset(new MemoryInfoImpl(regionInfo, 2));
|
||||
this->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/memory_manager/memory_banks.h"
|
||||
#include "shared/source/os_interface/linux/memory_info_impl.h"
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
|
||||
@@ -47,7 +47,7 @@ TEST(MemoryInfo, givenMemoryRegionQuerySupportedWhenQueryingMemoryInfoThenMemory
|
||||
drm->queryMemoryInfo();
|
||||
|
||||
EXPECT_EQ(2u, drm->ioctlCallsCount);
|
||||
auto memoryInfo = static_cast<MemoryInfoImpl *>(drm->getMemoryInfo());
|
||||
auto memoryInfo = drm->getMemoryInfo();
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
EXPECT_EQ(2u, memoryInfo->getDrmRegionInfos().size());
|
||||
}
|
||||
@@ -104,7 +104,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsAndLocalMemoryEnabledWhenGettingMemor
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
regionInfo[1].probed_size = 16 * GB;
|
||||
|
||||
auto memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 2);
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, 2);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
auto regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::MainBank, *defaultHwInfo);
|
||||
@@ -129,7 +129,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsAndLocalMemoryEnabledWhenAssignRegion
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
regionInfo[1].probed_size = 16 * GB;
|
||||
|
||||
auto memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 2);
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, 2);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
memoryInfo->assignRegionsFromDistances(®ionInfo, 2);
|
||||
auto regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::MainBank, *defaultHwInfo);
|
||||
@@ -149,7 +149,7 @@ TEST(MemoryInfo, givenMemoryInfoWithoutDeviceRegionWhenGettingDeviceRegionSizeTh
|
||||
drm_i915_memory_region_info regionInfo[1] = {};
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[0].probed_size = 8 * GB;
|
||||
auto memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 1);
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, 1);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
auto regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::getBankForLocalMemory(0));
|
||||
EXPECT_EQ(0 * GB, regionSize);
|
||||
@@ -164,7 +164,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsAndLocalMemoryDisabledWhenGettingMemo
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
regionInfo[1].probed_size = 16 * GB;
|
||||
|
||||
auto memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 2);
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, 2);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
auto regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::MainBank, *defaultHwInfo);
|
||||
@@ -188,7 +188,7 @@ TEST(MemoryInfo, whenDebugVariablePrintMemoryRegionSizeIsSetAndGetMemoryRegionSi
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 1};
|
||||
regionInfo[0].probed_size = 16 * GB;
|
||||
|
||||
auto memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 1);
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, 1);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
@@ -211,7 +211,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenGettingMemoryRegionClassAndInstan
|
||||
regionInfo[2].region = {I915_MEMORY_CLASS_DEVICE, 1};
|
||||
regionInfo[2].probed_size = 32 * GB;
|
||||
|
||||
auto memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 3);
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, 3);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
DebugManager.flags.OverrideDrmRegion.set(1);
|
||||
@@ -258,7 +258,7 @@ HWTEST2_F(MemoryInfoTest, givenMemoryInfoWithRegionsWhenCreatingGemWithExtension
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 2);
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, 2);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
uint32_t handle = 0;
|
||||
@@ -278,7 +278,7 @@ HWTEST2_F(MemoryInfoTest, givenMemoryInfoWithRegionsWhenCreatingGemExtWithSingle
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
regionInfo[1].probed_size = 16 * GB;
|
||||
|
||||
auto memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 2);
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, 2);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
|
||||
@@ -137,7 +137,7 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenDrmMemoryManagerWhenCreateBuffer
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfoImpl(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->ioctlCallsCount = 0;
|
||||
|
||||
auto gpuAddress = 0x1234u;
|
||||
@@ -177,7 +177,7 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenMultiRootDeviceEnvironmentAndMem
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfoImpl(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->ioctlCallsCount = 0;
|
||||
executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
|
||||
@@ -222,7 +222,7 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenMultiRootDeviceEnvironmentAndMemory
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfoImpl(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->ioctlCallsCount = 0;
|
||||
mock->fdToHandleRetVal = -1;
|
||||
executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>();
|
||||
@@ -281,7 +281,7 @@ TEST_F(DrmMemoryManagerUsmSharedHandleTest, givenMultiRootDeviceEnvironmentAndMe
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfoImpl(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->ioctlCallsCount = 0;
|
||||
mock->fdToHandleRetVal = -1;
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
|
||||
@@ -348,7 +348,7 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenMemoryInfoWhenAllocateWithAlignm
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfoImpl(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->ioctlCallsCount = 0;
|
||||
|
||||
AllocationData allocationData;
|
||||
@@ -373,7 +373,7 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenMemoryInfoAndNotUseObjectMmapProper
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfoImpl(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->mmapOffsetRetVal = -1;
|
||||
|
||||
AllocationData allocationData;
|
||||
@@ -396,7 +396,7 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenMemoryInfoAndFailedMmapOffsetWhenAl
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfoImpl(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->mmapOffsetRetVal = -1;
|
||||
|
||||
AllocationData allocationData;
|
||||
@@ -416,7 +416,7 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenMemoryInfoAndDisabledMmapBOCreation
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfoImpl(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->mmapOffsetRetVal = -1;
|
||||
|
||||
AllocationData allocationData;
|
||||
@@ -438,7 +438,7 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenMemoryInfoAndFailedGemCreateExtWhen
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfoImpl(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->gemCreateExtRetVal = -1;
|
||||
|
||||
AllocationData allocationData;
|
||||
@@ -903,7 +903,7 @@ TEST_F(DrmMemoryManagerTestImpl, givenDrmMemoryManagerWhenGetLocalMemorySizeIsCa
|
||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
|
||||
TestedDrmMemoryManager memoryManager(executionEnvironment);
|
||||
|
||||
auto memoryInfo = static_cast<MemoryInfoImpl *>(drm->getMemoryInfo());
|
||||
auto memoryInfo = drm->getMemoryInfo();
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
EXPECT_EQ(memoryInfo->getMemoryRegionSize(MemoryBanks::getBankForLocalMemory(0)), memoryManager.getLocalMemorySize(0u, 0xF));
|
||||
}
|
||||
@@ -927,7 +927,7 @@ TEST_F(DrmMemoryManagerTestImpl, givenDrmMemoryManagerWhenGetLocalMemorySizeIsCa
|
||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
|
||||
TestedDrmMemoryManager memoryManager(executionEnvironment);
|
||||
|
||||
auto memoryInfo = static_cast<MemoryInfoImpl *>(drm->getMemoryInfo());
|
||||
auto memoryInfo = drm->getMemoryInfo();
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
EXPECT_EQ(0u, memoryManager.getLocalMemorySize(0u, 0u));
|
||||
}
|
||||
@@ -994,7 +994,7 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenAlignmentAndSizeWhenMmapReturnsU
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfoImpl(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->ioctlCallsCount = 0;
|
||||
|
||||
AllocationData allocationData;
|
||||
@@ -1031,7 +1031,7 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenAlignmentAndSizeWhenMmapReturnsA
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfoImpl(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->ioctlCallsCount = 0;
|
||||
|
||||
AllocationData allocationData;
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/os_interface/linux/memory_info_impl.h"
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
|
||||
constexpr drm_i915_memory_region_info memoryRegions[2] = {
|
||||
{{I915_MEMORY_CLASS_SYSTEM, 0}, 0, 64 * GB, 0, {}},
|
||||
{{I915_MEMORY_CLASS_DEVICE, 0}, 0, 8 * GB, 0, {}}};
|
||||
|
||||
struct MockMemoryInfo : public MemoryInfoImpl {
|
||||
MockMemoryInfo() : MemoryInfoImpl(memoryRegions, 2) {}
|
||||
struct MockMemoryInfo : public MemoryInfo {
|
||||
MockMemoryInfo() : MemoryInfo(memoryRegions, 2) {}
|
||||
~MockMemoryInfo() override{};
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/os_interface/linux/local_memory_helper.h"
|
||||
#include "shared/source/os_interface/linux/memory_info_impl.h"
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
#include "shared/test/common/libult/linux/drm_mock.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/os_interface/linux/local_memory_helper.h"
|
||||
#include "shared/source/os_interface/linux/memory_info_impl.h"
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
|
||||
@@ -101,7 +101,7 @@ DG1TEST_F(LocalMemoryHelperTestsDg1, givenDg1AndMemoryRegionQuerySupportedWhenQu
|
||||
drm->queryMemoryInfo();
|
||||
EXPECT_EQ(2u, drm->ioctlCallsCount);
|
||||
|
||||
auto memoryInfo = static_cast<MemoryInfoImpl *>(drm->getMemoryInfo());
|
||||
auto memoryInfo = drm->getMemoryInfo();
|
||||
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
EXPECT_EQ(2u, memoryInfo->getDrmRegionInfos().size());
|
||||
|
||||
@@ -42,7 +42,7 @@ set(NEO_CORE_OS_INTERFACE_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_memory_manager_local_memory.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_memory_operations_handler_create.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_query.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}memory_info_impl.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}memory_info_extended.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_drm.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id_linux.cpp
|
||||
@@ -55,6 +55,7 @@ set(NEO_CORE_OS_INTERFACE_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}engine_info_impl.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/flags${BRANCH_DIR_SUFFIX}drm_query_flags.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_info.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_info.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_context_linux.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_context_linux.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_inc.h
|
||||
|
||||
@@ -5,13 +5,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/source/helpers/string.h"
|
||||
#include "shared/source/os_interface/linux/cache_info_impl.h"
|
||||
#include "shared/source/os_interface/linux/drm_engine_mapper.h"
|
||||
#include "shared/source/os_interface/linux/engine_info_impl.h"
|
||||
#include "shared/source/os_interface/linux/local_memory_helper.h"
|
||||
#include "shared/source/os_interface/linux/memory_info_impl.h"
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
#include "shared/source/os_interface/linux/sys_calls.h"
|
||||
#include "shared/source/os_interface/linux/system_info.h"
|
||||
|
||||
@@ -60,7 +61,7 @@ bool Drm::queryMemoryInfo() {
|
||||
auto localMemHelper = LocalMemoryHelper::get(pHwInfo->platform.eProductFamily);
|
||||
auto data = localMemHelper->translateIfRequired(dataQuery.release(), length);
|
||||
auto memRegions = reinterpret_cast<drm_i915_query_memory_regions *>(data.get());
|
||||
this->memoryInfo.reset(new MemoryInfoImpl(memRegions->regions, memRegions->num_regions));
|
||||
this->memoryInfo.reset(new MemoryInfo(memRegions->regions, memRegions->num_regions));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
77
shared/source/os_interface/linux/memory_info.cpp
Normal file
77
shared/source/os_interface/linux/memory_info.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/helpers/basic_math.h"
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/source/os_interface/linux/drm_neo.h"
|
||||
#include "shared/source/os_interface/linux/local_memory_helper.h"
|
||||
|
||||
#include "drm/i915_drm.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
uint32_t MemoryInfo::createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) {
|
||||
auto pHwInfo = drm->getRootDeviceEnvironment().getHardwareInfo();
|
||||
return LocalMemoryHelper::get(pHwInfo->platform.eProductFamily)->createGemExt(drm, data, dataSize, allocSize, handle);
|
||||
}
|
||||
|
||||
drm_i915_gem_memory_class_instance MemoryInfo::getMemoryRegionClassAndInstance(uint32_t memoryBank, const HardwareInfo &hwInfo) {
|
||||
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
if (!hwHelper.getEnableLocalMemory(hwInfo) || memoryBank == 0) {
|
||||
return systemMemoryRegion.region;
|
||||
}
|
||||
|
||||
auto index = Math::log2(memoryBank);
|
||||
|
||||
index = hwHelper.isBankOverrideRequired(hwInfo) ? 0 : index;
|
||||
|
||||
if (DebugManager.flags.OverrideDrmRegion.get() != -1) {
|
||||
index = DebugManager.flags.OverrideDrmRegion.get();
|
||||
}
|
||||
|
||||
UNRECOVERABLE_IF(index >= localMemoryRegions.size());
|
||||
|
||||
return localMemoryRegions[index].region;
|
||||
}
|
||||
|
||||
size_t MemoryInfo::getMemoryRegionSize(uint32_t memoryBank) {
|
||||
if (DebugManager.flags.PrintMemoryRegionSizes.get()) {
|
||||
printRegionSizes();
|
||||
}
|
||||
if (memoryBank == 0) {
|
||||
return systemMemoryRegion.probed_size;
|
||||
}
|
||||
|
||||
auto index = Math::log2(memoryBank);
|
||||
|
||||
if (index < localMemoryRegions.size()) {
|
||||
return localMemoryRegions[index].probed_size;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MemoryInfo::printRegionSizes() {
|
||||
for (auto region : drmQueryRegions) {
|
||||
std::cout << "Memory type: " << region.region.memory_class
|
||||
<< ", memory instance: " << region.region.memory_instance
|
||||
<< ", region size: " << region.probed_size << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t MemoryInfo::createGemExtWithSingleRegion(Drm *drm, uint32_t memoryBanks, size_t allocSize, uint32_t &handle) {
|
||||
auto pHwInfo = drm->getRootDeviceEnvironment().getHardwareInfo();
|
||||
auto regionClassAndInstance = getMemoryRegionClassAndInstance(memoryBanks, *pHwInfo);
|
||||
auto ret = createGemExt(drm, ®ionClassAndInstance, 1, allocSize, handle);
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
@@ -6,21 +6,44 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "drm/i915_drm.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace NEO {
|
||||
class Drm;
|
||||
struct HardwareInfo;
|
||||
|
||||
class MemoryInfo {
|
||||
public:
|
||||
MemoryInfo() = default;
|
||||
virtual ~MemoryInfo() = 0;
|
||||
virtual size_t getMemoryRegionSize(uint32_t memoryBank) = 0;
|
||||
virtual uint32_t createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) = 0;
|
||||
virtual uint32_t createGemExtWithSingleRegion(Drm *drm, uint32_t memoryBanks, size_t allocSize, uint32_t &handle) = 0;
|
||||
using RegionContainer = std::vector<drm_i915_memory_region_info>;
|
||||
|
||||
virtual ~MemoryInfo(){};
|
||||
|
||||
MemoryInfo(const drm_i915_memory_region_info *regionInfo, size_t count);
|
||||
|
||||
void assignRegionsFromDistances(const void *distanceInfosPtr, size_t size);
|
||||
|
||||
MOCKABLE_VIRTUAL uint32_t createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle);
|
||||
|
||||
drm_i915_gem_memory_class_instance getMemoryRegionClassAndInstance(uint32_t memoryBank, const HardwareInfo &hwInfo);
|
||||
|
||||
MOCKABLE_VIRTUAL size_t getMemoryRegionSize(uint32_t memoryBank);
|
||||
|
||||
void printRegionSizes();
|
||||
|
||||
MOCKABLE_VIRTUAL uint32_t createGemExtWithSingleRegion(Drm *drm, uint32_t memoryBanks, size_t allocSize, uint32_t &handle);
|
||||
|
||||
const RegionContainer &getDrmRegionInfos() const { return drmQueryRegions; }
|
||||
|
||||
protected:
|
||||
const RegionContainer drmQueryRegions;
|
||||
|
||||
const drm_i915_memory_region_info &systemMemoryRegion;
|
||||
|
||||
RegionContainer localMemoryRegions;
|
||||
};
|
||||
|
||||
inline MemoryInfo::~MemoryInfo(){};
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -5,13 +5,16 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/linux/memory_info_impl.h"
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
|
||||
#include "drm/i915_drm.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
MemoryInfoImpl::MemoryInfoImpl(const drm_i915_memory_region_info *regionInfo, size_t count)
|
||||
MemoryInfo::MemoryInfo(const drm_i915_memory_region_info *regionInfo, size_t count)
|
||||
: drmQueryRegions(regionInfo, regionInfo + count), systemMemoryRegion(drmQueryRegions[0]) {
|
||||
UNRECOVERABLE_IF(systemMemoryRegion.region.memory_class != I915_MEMORY_CLASS_SYSTEM);
|
||||
std::copy_if(drmQueryRegions.begin(), drmQueryRegions.end(), std::back_inserter(localMemoryRegions),
|
||||
@@ -20,7 +23,7 @@ MemoryInfoImpl::MemoryInfoImpl(const drm_i915_memory_region_info *regionInfo, si
|
||||
});
|
||||
}
|
||||
|
||||
void MemoryInfoImpl::assignRegionsFromDistances(const void *distanceInfosPtr, size_t size) {
|
||||
void MemoryInfo::assignRegionsFromDistances(const void *distanceInfosPtr, size_t size) {
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/helpers/basic_math.h"
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/source/os_interface/linux/drm_neo.h"
|
||||
#include "shared/source/os_interface/linux/local_memory_helper.h"
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
|
||||
#include "drm/i915_drm.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class MemoryInfoImpl : public MemoryInfo {
|
||||
public:
|
||||
using RegionContainer = std::vector<drm_i915_memory_region_info>;
|
||||
|
||||
~MemoryInfoImpl() override = default;
|
||||
|
||||
MemoryInfoImpl(const drm_i915_memory_region_info *regionInfo, size_t count);
|
||||
|
||||
void assignRegionsFromDistances(const void *distanceInfosPtr, size_t size);
|
||||
|
||||
uint32_t createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) override {
|
||||
auto pHwInfo = drm->getRootDeviceEnvironment().getHardwareInfo();
|
||||
return LocalMemoryHelper::get(pHwInfo->platform.eProductFamily)->createGemExt(drm, data, dataSize, allocSize, handle);
|
||||
}
|
||||
|
||||
drm_i915_gem_memory_class_instance getMemoryRegionClassAndInstance(uint32_t memoryBank, const HardwareInfo &hwInfo) {
|
||||
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
if (!hwHelper.getEnableLocalMemory(hwInfo) || memoryBank == 0) {
|
||||
return systemMemoryRegion.region;
|
||||
}
|
||||
|
||||
auto index = Math::log2(memoryBank);
|
||||
|
||||
index = hwHelper.isBankOverrideRequired(hwInfo) ? 0 : index;
|
||||
|
||||
if (DebugManager.flags.OverrideDrmRegion.get() != -1) {
|
||||
index = DebugManager.flags.OverrideDrmRegion.get();
|
||||
}
|
||||
|
||||
UNRECOVERABLE_IF(index >= localMemoryRegions.size());
|
||||
|
||||
return localMemoryRegions[index].region;
|
||||
}
|
||||
|
||||
size_t getMemoryRegionSize(uint32_t memoryBank) override {
|
||||
if (DebugManager.flags.PrintMemoryRegionSizes.get()) {
|
||||
printRegionSizes();
|
||||
}
|
||||
if (memoryBank == 0) {
|
||||
return systemMemoryRegion.probed_size;
|
||||
}
|
||||
|
||||
auto index = Math::log2(memoryBank);
|
||||
|
||||
if (index < localMemoryRegions.size()) {
|
||||
return localMemoryRegions[index].probed_size;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void printRegionSizes() {
|
||||
for (auto region : drmQueryRegions) {
|
||||
std::cout << "Memory type: " << region.region.memory_class
|
||||
<< ", memory instance: " << region.region.memory_instance
|
||||
<< ", region size: " << region.probed_size << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t createGemExtWithSingleRegion(Drm *drm, uint32_t memoryBanks, size_t allocSize, uint32_t &handle) override {
|
||||
auto pHwInfo = drm->getRootDeviceEnvironment().getHardwareInfo();
|
||||
auto regionClassAndInstance = getMemoryRegionClassAndInstance(memoryBanks, *pHwInfo);
|
||||
auto ret = createGemExt(drm, ®ionClassAndInstance, 1, allocSize, handle);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const RegionContainer &getDrmRegionInfos() const { return drmQueryRegions; }
|
||||
|
||||
protected:
|
||||
const RegionContainer drmQueryRegions;
|
||||
|
||||
const drm_i915_memory_region_info &systemMemoryRegion;
|
||||
|
||||
RegionContainer localMemoryRegions;
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
@@ -145,9 +145,10 @@ class DrmMemoryManagerWithLocalMemoryFixture : public DrmMemoryManagerFixture {
|
||||
std::unique_ptr<VariableBackup<UltHwConfig>> backup;
|
||||
};
|
||||
|
||||
struct MockMemoryInfoImpl : public NEO::MemoryInfo {
|
||||
MockMemoryInfoImpl() {}
|
||||
~MockMemoryInfoImpl() override{};
|
||||
struct MockedMemoryInfo : public NEO::MemoryInfo {
|
||||
MockedMemoryInfo(const drm_i915_memory_region_info *regionInfo, size_t count) : MemoryInfo(regionInfo, count) {}
|
||||
~MockedMemoryInfo() override{};
|
||||
|
||||
size_t getMemoryRegionSize(uint32_t memoryBank) override {
|
||||
return 1024u;
|
||||
}
|
||||
@@ -190,7 +191,12 @@ class DrmMemoryManagerFixtureWithoutQuietIoctlExpectation {
|
||||
i++;
|
||||
}
|
||||
mock = static_cast<DrmMockCustom *>(executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->getDriverModel()->as<Drm>());
|
||||
mock->memoryInfo.reset(new MockMemoryInfoImpl());
|
||||
drm_i915_memory_region_info regionInfo[2] = {};
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[0].probed_size = 8 * GB;
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
regionInfo[1].probed_size = 16 * GB;
|
||||
mock->memoryInfo.reset(new MockedMemoryInfo(regionInfo, 2));
|
||||
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u);
|
||||
memoryManager.reset(new TestedDrmMemoryManager(enableLocalMem, false, false, *executionEnvironment));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user