mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +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
@ -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());
|
||||
|
Reference in New Issue
Block a user