mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
Reverse logic of creating Memory Manager - part 6
-Remove a redundant condition from the MemoryManager constructor Change-Id: I4b6c56f30a19e77a7a20f68c6d85516aaa52d102 Signed-off-by: Jobczyk, Lukasz <lukasz.jobczyk@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
e772321e82
commit
a025dc6985
@@ -35,14 +35,9 @@ namespace NEO {
|
||||
MemoryManager::MemoryManager(ExecutionEnvironment &executionEnvironment) : allocator32Bit(nullptr),
|
||||
executionEnvironment(executionEnvironment), hostPtrManager(std::make_unique<HostPtrManager>()),
|
||||
multiContextResourceDestructor(std::make_unique<DeferredDeleter>()) {
|
||||
this->localMemorySupported = false;
|
||||
this->enable64kbpages = false;
|
||||
|
||||
auto hwInfo = executionEnvironment.getHardwareInfo();
|
||||
if (hwInfo != nullptr) {
|
||||
this->localMemorySupported = HwHelper::get(hwInfo->pPlatform->eRenderCoreFamily).getEnableLocalMemory(*hwInfo);
|
||||
this->enable64kbpages = OSInterface::osEnabled64kbPages && hwInfo->capabilityTable.ftr64KBpages;
|
||||
}
|
||||
if (DebugManager.flags.Enable64kbpages.get() > -1) {
|
||||
this->enable64kbpages = DebugManager.flags.Enable64kbpages.get() != 0;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "unit_tests/helpers/unit_test_helper.h"
|
||||
#include "unit_tests/mocks/mock_command_queue.h"
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
|
||||
#include "reg_configs_common.h"
|
||||
|
||||
@@ -458,7 +459,7 @@ HWTEST_F(EnqueueReadBufferTypeTest, givenEnqueueReadBufferCalledWhenLockedPtrInT
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.DoCpuCopyOnReadBuffer.set(true);
|
||||
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
MockContext ctx;
|
||||
cl_int retVal;
|
||||
@@ -485,7 +486,7 @@ HWTEST_F(EnqueueReadBufferTypeTest, gicenEnqueueReadBufferCalledWhenLockedPtrInT
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.DoCpuCopyOnReadBuffer.set(true);
|
||||
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
MockContext ctx;
|
||||
cl_int retVal;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "unit_tests/helpers/unit_test_helper.h"
|
||||
#include "unit_tests/mocks/mock_command_queue.h"
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
|
||||
#include "reg_configs_common.h"
|
||||
|
||||
@@ -367,7 +368,7 @@ HWTEST_F(EnqueueWriteBufferTypeTest, givenEnqueueWriteBufferCalledWhenLockedPtrI
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.DoCpuCopyOnWriteBuffer.set(true);
|
||||
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
MockContext ctx;
|
||||
cl_int retVal;
|
||||
@@ -394,7 +395,7 @@ HWTEST_F(EnqueueWriteBufferTypeTest, givenEnqueueWriteBufferCalledWhenLockedPtrI
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.DoCpuCopyOnWriteBuffer.set(true);
|
||||
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
MockContext ctx;
|
||||
cl_int retVal;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "unit_tests/mocks/mock_builtins.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_csr.h"
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
#include "unit_tests/mocks/mock_graphics_allocation.h"
|
||||
#include "unit_tests/mocks/mock_memory_manager.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
@@ -343,7 +344,7 @@ TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenItIsDestroye
|
||||
|
||||
auto mockGraphicsAllocation = new MockGraphicsAllocationWithDestructorTracing(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0llu, 0llu, 1u, MemoryPool::MemoryNull, false);
|
||||
mockGraphicsAllocation->destructorCalled = &destructorCalled;
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
executionEnvironment.commandStreamReceivers.resize(1);
|
||||
executionEnvironment.commandStreamReceivers[0].push_back(std::make_unique<MockCommandStreamReceiver>(executionEnvironment));
|
||||
auto csr = executionEnvironment.commandStreamReceivers[0][0].get();
|
||||
@@ -355,7 +356,7 @@ TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenItIsDestroye
|
||||
}
|
||||
|
||||
TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenInitializeTagAllocationIsCalledThenTagAllocationIsBeingAllocated) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
auto csr = new MockCommandStreamReceiver(executionEnvironment);
|
||||
executionEnvironment.commandStreamReceivers.resize(1);
|
||||
executionEnvironment.commandStreamReceivers[0].push_back(std::unique_ptr<CommandStreamReceiver>(csr));
|
||||
@@ -371,7 +372,7 @@ TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenInitializeTa
|
||||
TEST(CommandStreamReceiverSimpleTest, givenNullHardwareDebugModeWhenInitializeTagAllocationIsCalledThenTagAllocationIsBeingAllocatedAndinitialValueIsMinusOne) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableNullHardware.set(true);
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
executionEnvironment.commandStreamReceivers.resize(1);
|
||||
auto csr = new MockCommandStreamReceiver(executionEnvironment);
|
||||
executionEnvironment.commandStreamReceivers[0].push_back(std::unique_ptr<CommandStreamReceiver>(csr));
|
||||
|
||||
@@ -285,7 +285,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenFlushIsCalledTh
|
||||
}
|
||||
|
||||
TEST(TbxMemoryManagerTest, givenTbxMemoryManagerWhenItIsQueriedForSystemSharedMemoryThen1GBIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
TbxMemoryManager memoryManager(executionEnvironment);
|
||||
EXPECT_EQ(1 * GB, memoryManager.getSystemSharedMemory());
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe
|
||||
OsInterfaceMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
|
||||
};
|
||||
struct MemoryMangerMock : public DestructorCounted<MockMemoryManager, 6> {
|
||||
MemoryMangerMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
|
||||
MemoryMangerMock(uint32_t &destructorId, ExecutionEnvironment &executionEnvironment) : DestructorCounted(destructorId, executionEnvironment) {}
|
||||
};
|
||||
struct AubCenterMock : public DestructorCounted<AubCenter, 5> {
|
||||
AubCenterMock(uint32_t &destructorId) : DestructorCounted(destructorId, platformDevices[0], false, "", CommandStreamReceiverType::CSR_AUB) {}
|
||||
@@ -231,10 +231,11 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe
|
||||
};
|
||||
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
executionEnvironment->setHwInfo(*platformDevices);
|
||||
executionEnvironment->commandStreamReceivers.resize(1);
|
||||
executionEnvironment->gmmHelper = std::make_unique<GmmHelperMock>(destructorId, platformDevices[0]);
|
||||
executionEnvironment->osInterface = std::make_unique<OsInterfaceMock>(destructorId);
|
||||
executionEnvironment->memoryManager = std::make_unique<MemoryMangerMock>(destructorId);
|
||||
executionEnvironment->memoryManager = std::make_unique<MemoryMangerMock>(destructorId, *executionEnvironment);
|
||||
executionEnvironment->aubCenter = std::make_unique<AubCenterMock>(destructorId);
|
||||
executionEnvironment->commandStreamReceivers[0].push_back(std::make_unique<CommandStreamReceiverMock>(destructorId, *executionEnvironment));
|
||||
executionEnvironment->specialCommandStreamReceiver = std::make_unique<SpecialCommandStreamReceiverMock>(destructorId, *executionEnvironment);
|
||||
@@ -314,7 +315,7 @@ TEST(ExecutionEnvironment, givenUnproperSetCsrFlagValueWhenInitializingMemoryMan
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.SetCommandStreamReceiver.set(10);
|
||||
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>(*platformDevices);
|
||||
executionEnvironment->initializeMemoryManager();
|
||||
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
using namespace NEO;
|
||||
|
||||
void MemoryManagerWithCsrFixture::SetUp() {
|
||||
executionEnvironment.setHwInfo(*platformDevices);
|
||||
csr = new MockCommandStreamReceiver(this->executionEnvironment);
|
||||
memoryManager = new MockMemoryManager(executionEnvironment);
|
||||
executionEnvironment.memoryManager.reset(memoryManager);
|
||||
|
||||
@@ -143,6 +143,7 @@ class GTPinFixture : public ContextFixture, public MemoryManagementFixture {
|
||||
constructPlatform();
|
||||
pPlatform = platform();
|
||||
auto executionEnvironment = pPlatform->peekExecutionEnvironment();
|
||||
executionEnvironment->setHwInfo(*platformDevices);
|
||||
memoryManager = new MockMemoryManagerWithFailures(*executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
pPlatform->initialize();
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "unit_tests/mocks/mock_command_queue.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_device.h"
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
#include "unit_tests/mocks/mock_mdi.h"
|
||||
#include "unit_tests/mocks/mock_memory_manager.h"
|
||||
@@ -197,7 +198,8 @@ TEST_F(TimestampPacketSimpleTests, givenImplicitDependencyWhenEndTagIsWrittenThe
|
||||
}
|
||||
|
||||
TEST_F(TimestampPacketSimpleTests, whenNewTagIsTakenThenReinitialize) {
|
||||
MockMemoryManager memoryManager;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(executionEnvironment);
|
||||
MockTagAllocator<TimestampPacket> allocator(&memoryManager, 1);
|
||||
|
||||
auto firstNode = allocator.getTag();
|
||||
@@ -238,7 +240,8 @@ TEST_F(TimestampPacketSimpleTests, whenObjectIsCreatedThenInitializeAllStamps) {
|
||||
}
|
||||
|
||||
TEST_F(TimestampPacketSimpleTests, whenAskedForStampAddressThenReturnWithValidOffset) {
|
||||
MockMemoryManager memoryManager;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(executionEnvironment);
|
||||
MockTagAllocator<TimestampPacket> allocator(&memoryManager, 1);
|
||||
|
||||
auto node = allocator.getTag();
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "runtime/helpers/properties_helper.h"
|
||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "unit_tests/mocks/mock_buffer.h"
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
#include "unit_tests/mocks/mock_memory_manager.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
@@ -24,7 +25,7 @@ TEST(TransferPropertiesTest, givenTransferPropertiesCreatedWhenDefaultDebugSetti
|
||||
}
|
||||
|
||||
TEST(TransferPropertiesTest, givenAllocationInNonSystemPoolWhenTransferPropertiesAreCreatedForMapBufferThenLockPtrIsSet) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, true, executionEnvironment);
|
||||
|
||||
MockContext ctx;
|
||||
@@ -41,7 +42,7 @@ TEST(TransferPropertiesTest, givenAllocationInNonSystemPoolWhenTransferPropertie
|
||||
}
|
||||
|
||||
TEST(TransferPropertiesTest, givenAllocationInSystemPoolWhenTransferPropertiesAreCreatedForMapBufferThenLockPtrIsNotSet) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, true, executionEnvironment);
|
||||
|
||||
MockContext ctx;
|
||||
@@ -67,7 +68,7 @@ TEST(TransferPropertiesTest, givenTransferPropertiesCreatedWhenMemoryManagerInMe
|
||||
}
|
||||
|
||||
TEST(TransferPropertiesTest, givenTransferPropertiesWhenLockedPtrIsSetThenItIsReturnedForReadWrite) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, true, executionEnvironment);
|
||||
|
||||
MockContext ctx;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "unit_tests/helpers/variable_backup.h"
|
||||
#include "unit_tests/linux/drm_wrap.h"
|
||||
#include "unit_tests/linux/mock_os_layer.h"
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
#include "unit_tests/os_interface/linux/device_command_stream_fixture.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
@@ -362,7 +363,7 @@ TEST(AllocatorHelper, givenExpectedSizeToMapWhenGetSizetoMapCalledThenExpectedVa
|
||||
|
||||
TEST(DrmMemoryManagerCreate, whenCallCreateMemoryManagerThenDrmMemoryManagerIsCreated) {
|
||||
DrmMockSuccess mock;
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
|
||||
executionEnvironment.osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment.osInterface->get()->setDrm(&mock);
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#include "unit_tests/fixtures/platform_fixture.h"
|
||||
#include "unit_tests/helpers/memory_management.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
#include "unit_tests/mocks/mock_memory_manager.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
@@ -49,8 +51,8 @@ class TestedMemoryManager : public OsAgnosticMemoryManager {
|
||||
};
|
||||
|
||||
TEST(BufferTests, doPinIsSet) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
std::unique_ptr<TestedMemoryManager> mm(new TestedMemoryManager(executionEnvironment));
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
std::unique_ptr<TestedMemoryManager> mm(new MemoryManagerCreate<TestedMemoryManager>(false, false, executionEnvironment));
|
||||
{
|
||||
MockContext context;
|
||||
auto size = MemoryConstants::pageSize * 32;
|
||||
@@ -72,7 +74,7 @@ TEST(BufferTests, doPinIsSet) {
|
||||
}
|
||||
}
|
||||
TEST(BufferTests, doPinIsSetForHostPtr) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
std::unique_ptr<TestedMemoryManager> mm(new TestedMemoryManager(executionEnvironment));
|
||||
{
|
||||
MockContext context;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "unit_tests/mocks/mock_buffer.h"
|
||||
#include "unit_tests/mocks/mock_command_queue.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
#include "unit_tests/mocks/mock_gmm_resource_info.h"
|
||||
#include "unit_tests/mocks/mock_memory_manager.h"
|
||||
|
||||
@@ -572,7 +573,8 @@ TEST_F(RenderCompressedBuffersTests, givenSvmAllocationWhenCreatingBufferThenFor
|
||||
struct RenderCompressedBuffersCopyHostMemoryTests : public RenderCompressedBuffersTests {
|
||||
void SetUp() override {
|
||||
RenderCompressedBuffersTests::SetUp();
|
||||
device->injectMemoryManager(new MockMemoryManager(true, false));
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
device->injectMemoryManager(new MockMemoryManager(true, false, executionEnvironment));
|
||||
context->setMemoryManager(device->getMemoryManager());
|
||||
mockCmdQ = new MockCommandQueue();
|
||||
context->setSpecialQueue(mockCmdQ);
|
||||
|
||||
@@ -216,8 +216,8 @@ TEST(MemObj, givenMemoryManagerWithoutDeviceWhenMemObjDestroysAllocationAsyncThe
|
||||
}
|
||||
|
||||
TEST(MemObj, givenMemObjAndPointerToObjStorageWithProperCommandWhenCheckIfMemTransferRequiredThenReturnFalse) {
|
||||
MockMemoryManager memoryManager;
|
||||
MockContext context;
|
||||
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
||||
|
||||
context.setMemoryManager(&memoryManager);
|
||||
|
||||
@@ -243,8 +243,8 @@ TEST(MemObj, givenMemObjAndPointerToObjStorageWithProperCommandWhenCheckIfMemTra
|
||||
EXPECT_FALSE(isMemTransferNeeded);
|
||||
}
|
||||
TEST(MemObj, givenMemObjAndPointerToObjStorageBadCommandWhenCheckIfMemTransferRequiredThenReturnTrue) {
|
||||
MockMemoryManager memoryManager;
|
||||
MockContext context;
|
||||
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
||||
|
||||
context.setMemoryManager(&memoryManager);
|
||||
|
||||
@@ -255,8 +255,8 @@ TEST(MemObj, givenMemObjAndPointerToObjStorageBadCommandWhenCheckIfMemTransferRe
|
||||
EXPECT_TRUE(isMemTransferNeeded);
|
||||
}
|
||||
TEST(MemObj, givenMemObjAndPointerToDiffrentStorageAndProperCommandWhenCheckIfMemTransferRequiredThenReturnTrue) {
|
||||
MockMemoryManager memoryManager;
|
||||
MockContext context;
|
||||
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
||||
|
||||
context.setMemoryManager(&memoryManager);
|
||||
|
||||
@@ -286,8 +286,8 @@ TEST(MemObj, givenTiledObjectWhenAskedForCpuMappingThenReturnFalse) {
|
||||
}
|
||||
|
||||
TEST(MemObj, givenRenderCompressedGmmWhenAskingForMappingOnCpuThenDisallow) {
|
||||
MockMemoryManager memoryManager;
|
||||
MockContext context;
|
||||
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
||||
|
||||
context.setMemoryManager(&memoryManager);
|
||||
|
||||
@@ -304,8 +304,8 @@ TEST(MemObj, givenRenderCompressedGmmWhenAskingForMappingOnCpuThenDisallow) {
|
||||
}
|
||||
|
||||
TEST(MemObj, givenDefaultWhenAskedForCpuMappingThenReturnTrue) {
|
||||
MockMemoryManager memoryManager;
|
||||
MockContext context;
|
||||
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
||||
|
||||
context.setMemoryManager(&memoryManager);
|
||||
|
||||
@@ -320,8 +320,8 @@ TEST(MemObj, givenDefaultWhenAskedForCpuMappingThenReturnTrue) {
|
||||
}
|
||||
|
||||
TEST(MemObj, givenNonCpuAccessibleMemoryWhenAskingForMappingOnCpuThenDisallow) {
|
||||
MockMemoryManager memoryManager;
|
||||
MockContext context;
|
||||
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
||||
|
||||
context.setMemoryManager(&memoryManager);
|
||||
|
||||
@@ -337,9 +337,8 @@ TEST(MemObj, givenNonCpuAccessibleMemoryWhenAskingForMappingOnCpuThenDisallow) {
|
||||
}
|
||||
|
||||
TEST(MemObj, givenMultipleMemObjectsWithReusedGraphicsAllocationWhenDestroyedThenFreeAllocationOnce) {
|
||||
|
||||
MockMemoryManager memoryManager;
|
||||
MockContext context;
|
||||
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
||||
context.setMemoryManager(&memoryManager);
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
@@ -374,8 +373,8 @@ TEST(MemObj, givenMemObjectWhenContextIsNotNullThenContextOutlivesMemobjects) {
|
||||
}
|
||||
|
||||
TEST(MemObj, givenSharedMemObjectWithNullGfxAllocationWhenSettingGfxAllocationThenSucceed) {
|
||||
MockMemoryManager memoryManager;
|
||||
MockContext context;
|
||||
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
||||
context.setMemoryManager(&memoryManager);
|
||||
MockGraphicsAllocation *gfxAllocation = new MockGraphicsAllocation(nullptr, 0);
|
||||
|
||||
@@ -391,8 +390,8 @@ TEST(MemObj, givenSharedMemObjectWithNullGfxAllocationWhenSettingGfxAllocationTh
|
||||
}
|
||||
|
||||
TEST(MemObj, givenSharedMemObjectAndNullGfxAllocationProvidedWhenSettingGfxAllocationThenSucceed) {
|
||||
MockMemoryManager memoryManager;
|
||||
MockContext context;
|
||||
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
||||
context.setMemoryManager(&memoryManager);
|
||||
MockGraphicsAllocation *graphicsAllocation = new MockGraphicsAllocation(nullptr, 0);
|
||||
|
||||
@@ -407,8 +406,8 @@ TEST(MemObj, givenSharedMemObjectAndNullGfxAllocationProvidedWhenSettingGfxAlloc
|
||||
}
|
||||
|
||||
TEST(MemObj, givenSharedMemObjectAndZeroReuseCountWhenChangingGfxAllocationThenOldAllocationIsDestroyed) {
|
||||
MockMemoryManager memoryManager;
|
||||
MockContext context;
|
||||
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
||||
context.setMemoryManager(&memoryManager);
|
||||
MockGraphicsAllocation *oldGfxAllocation = new MockGraphicsAllocation(nullptr, 0);
|
||||
MockGraphicsAllocation *newGfxAllocation = new MockGraphicsAllocation(nullptr, 0);
|
||||
@@ -426,8 +425,8 @@ TEST(MemObj, givenSharedMemObjectAndZeroReuseCountWhenChangingGfxAllocationThenO
|
||||
}
|
||||
|
||||
TEST(MemObj, givenSharedMemObjectAndNonZeroReuseCountWhenChangingGfxAllocationThenOldAllocationIsNotDestroyed) {
|
||||
MockMemoryManager memoryManager;
|
||||
MockContext context;
|
||||
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
||||
context.setMemoryManager(&memoryManager);
|
||||
MockGraphicsAllocation *oldGfxAllocation = new MockGraphicsAllocation(nullptr, 0);
|
||||
MockGraphicsAllocation *newGfxAllocation = new MockGraphicsAllocation(nullptr, 0);
|
||||
@@ -445,8 +444,8 @@ TEST(MemObj, givenSharedMemObjectAndNonZeroReuseCountWhenChangingGfxAllocationTh
|
||||
}
|
||||
|
||||
TEST(MemObj, givenNotSharedMemObjectWhenChangingGfxAllocationThenOldAllocationIsDestroyed) {
|
||||
MockMemoryManager memoryManager;
|
||||
MockContext context;
|
||||
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
|
||||
context.setMemoryManager(&memoryManager);
|
||||
MockGraphicsAllocation *oldGfxAllocation = new MockGraphicsAllocation(nullptr, 0);
|
||||
MockGraphicsAllocation *newGfxAllocation = new MockGraphicsAllocation(nullptr, 0);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "runtime/helpers/array_count.h"
|
||||
|
||||
TEST(MemoryManagerTest, givenNotSetUseSystemMemoryWhenGraphicsAllocationInDevicePoolIsAllocatedThenAllocationIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Error;
|
||||
@@ -26,7 +26,7 @@ TEST(MemoryManagerTest, givenNotSetUseSystemMemoryWhenGraphicsAllocationInDevice
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenImageOrSharedResourceCopyWhenGraphicsAllocationInDevicePoolIsAllocatedThenNullptrIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Error;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "runtime/mem_obj/mem_obj_helper.h"
|
||||
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
#include "unit_tests/mocks/mock_memory_manager.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
@@ -16,7 +17,7 @@
|
||||
using namespace NEO;
|
||||
|
||||
TEST(MemoryManagerTest, givenSetUseSytemMemoryWhenGraphicsAllocationInDevicePoolIsAllocatedThenNullptrIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
AllocationData allocData;
|
||||
@@ -30,7 +31,7 @@ TEST(MemoryManagerTest, givenSetUseSytemMemoryWhenGraphicsAllocationInDevicePool
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenAllowed32BitAndFroce32BitWhenGraphicsAllocationInDevicePoolIsAllocatedThenNullptrIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
memoryManager.setForce32BitAllocations(true);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/mocks/mock_allocation_properties.h"
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
#include "unit_tests/mocks/mock_memory_manager.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
@@ -161,7 +162,7 @@ INSTANTIATE_TEST_CASE_P(Disallow32BitAnd64kbPagesTypes,
|
||||
::testing::ValuesIn(allocationTypesWith32BitAnd64KbPagesNotAllowed));
|
||||
|
||||
TEST(MemoryManagerTest, givenForced32BitSetWhenGraphicsMemoryFor32BitAllowedTypeIsAllocatedThen32BitAllocationIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
|
||||
memoryManager.setForce32BitAllocations(true);
|
||||
|
||||
@@ -184,7 +185,7 @@ TEST(MemoryManagerTest, givenForced32BitSetWhenGraphicsMemoryFor32BitAllowedType
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenForced32BitEnabledWhenGraphicsMemoryWihtoutAllow32BitFlagIsAllocatedThenNon32BitAllocationIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(executionEnvironment);
|
||||
memoryManager.setForce32BitAllocations(true);
|
||||
|
||||
@@ -202,7 +203,7 @@ TEST(MemoryManagerTest, givenForced32BitEnabledWhenGraphicsMemoryWihtoutAllow32B
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenForced32BitDisabledWhenGraphicsMemoryWith32BitFlagFor32BitAllowedTypeIsAllocatedThenNon32BitAllocationIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(executionEnvironment);
|
||||
memoryManager.setForce32BitAllocations(false);
|
||||
|
||||
@@ -219,7 +220,7 @@ TEST(MemoryManagerTest, givenForced32BitDisabledWhenGraphicsMemoryWith32BitFlagF
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenEnabled64kbPagesWhenGraphicsMemoryMustBeHostMemoryAndIsAllocatedWithNullptrForBufferThen64kbAllocationIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(true, false, executionEnvironment);
|
||||
AllocationData allocData;
|
||||
AllocationProperties properties(true, 10, GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
|
||||
@@ -237,7 +238,8 @@ TEST(MemoryManagerTest, givenEnabled64kbPagesWhenGraphicsMemoryMustBeHostMemoryA
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenEnabled64kbPagesWhenGraphicsMemoryWithoutAllow64kbPagesFlagsIsAllocatedThenNon64kbAllocationIsReturned) {
|
||||
MockMemoryManager memoryManager(true, false);
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(true, false, executionEnvironment);
|
||||
AllocationData allocData;
|
||||
AllocationProperties properties(true, 10, GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
@@ -253,7 +255,8 @@ TEST(MemoryManagerTest, givenEnabled64kbPagesWhenGraphicsMemoryWithoutAllow64kbP
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenDisabled64kbPagesWhenGraphicsMemoryMustBeHostMemoryAndIsAllocatedWithNullptrForBufferThenNon64kbAllocationIsReturned) {
|
||||
MockMemoryManager memoryManager(false, false);
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
AllocationData allocData;
|
||||
AllocationProperties properties(true, 10, GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
|
||||
|
||||
@@ -269,7 +272,7 @@ TEST(MemoryManagerTest, givenDisabled64kbPagesWhenGraphicsMemoryMustBeHostMemory
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenForced32BitAndEnabled64kbPagesWhenGraphicsMemoryMustBeHostMemoryAndIsAllocatedWithNullptrForBufferThen32BitAllocationOver64kbIsChosen) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
|
||||
memoryManager.setForce32BitAllocations(true);
|
||||
|
||||
@@ -290,7 +293,7 @@ TEST(MemoryManagerTest, givenForced32BitAndEnabled64kbPagesWhenGraphicsMemoryMus
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenEnabled64kbPagesWhenGraphicsMemoryIsAllocatedWithHostPtrForBufferThenExistingMemoryIsUsedForAllocation) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(true, false, executionEnvironment);
|
||||
AllocationData allocData;
|
||||
AllocationProperties properties(false, 1, GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
|
||||
@@ -307,7 +310,8 @@ TEST(MemoryManagerTest, givenEnabled64kbPagesWhenGraphicsMemoryIsAllocatedWithHo
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenMemoryManagerWhenGraphicsMemoryAllocationInDevicePoolFailsThenFallbackAllocationIsReturned) {
|
||||
MockMemoryManager memoryManager(false, true);
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
|
||||
memoryManager.failInDevicePool = true;
|
||||
|
||||
@@ -320,7 +324,8 @@ TEST(MemoryManagerTest, givenMemoryManagerWhenGraphicsMemoryAllocationInDevicePo
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenMemoryManagerWhenBufferTypeIsPassedThenAllocateGraphicsMemoryInPreferredPoolCanAllocateInDevicePool) {
|
||||
MockMemoryManager memoryManager(false, true);
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER});
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
@@ -328,7 +333,8 @@ TEST(MemoryManagerTest, givenMemoryManagerWhenBufferTypeIsPassedThenAllocateGrap
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenMemoryManagerWhenBufferTypeIsPassedAndAllocateInDevicePoolFailsWithErrorThenAllocateGraphicsMemoryInPreferredPoolReturnsNullptr) {
|
||||
MockMemoryManager memoryManager(false, true);
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
|
||||
memoryManager.failInDevicePoolWithError = true;
|
||||
|
||||
@@ -387,7 +393,8 @@ TEST(MemoryManagerTest, givenProfilingTagBufferTypeWhenGetAllocationDataIsCalled
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenAllocationPropertiesWithMultiOsContextCapableFlagEnabledWhenAllocateMemoryThenAllocationIsMultiOsContextCapable) {
|
||||
MockMemoryManager memoryManager(false, false);
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
AllocationProperties properties{MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER};
|
||||
properties.flags.multiOsContextCapable = true;
|
||||
|
||||
@@ -401,7 +408,8 @@ TEST(MemoryManagerTest, givenAllocationPropertiesWithMultiOsContextCapableFlagEn
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenAllocationPropertiesWithMultiOsContextCapableFlagDisabledWhenAllocateMemoryThenAllocationIsNotMultiOsContextCapable) {
|
||||
MockMemoryManager memoryManager(false, false);
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
AllocationProperties properties{MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER};
|
||||
properties.flags.multiOsContextCapable = false;
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "unit_tests/mocks/mock_deferrable_deletion.h"
|
||||
#include "unit_tests/mocks/mock_deferred_deleter.h"
|
||||
#include "unit_tests/mocks/mock_device.h"
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
#include "unit_tests/mocks/mock_gmm.h"
|
||||
#include "unit_tests/mocks/mock_graphics_allocation.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
@@ -539,13 +540,13 @@ TEST_F(MemoryAllocatorTest, given32BitDeviceWhenPrintfSurfaceIsCreatedThen32BitA
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenItIsCreatedThenForce32BitAllocationsIsFalse) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||
EXPECT_FALSE(memoryManager.peekForce32BitAllocations());
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenForce32bitallocationIsCalledWithTrueThenMemoryManagerForces32BitAlloactions) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||
memoryManager.setForce32BitAllocations(true);
|
||||
EXPECT_TRUE(memoryManager.peekForce32BitAllocations());
|
||||
@@ -664,7 +665,7 @@ TEST(OsAgnosticMemoryManager, givenHostPointerRequiringCopyWhenAllocateGraphicsM
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerAndUnifiedAuxCapableAllocationWhenMappingThenReturnFalse) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||
|
||||
auto gmm = new Gmm(nullptr, 123, false);
|
||||
@@ -680,7 +681,7 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerAndUnifiedAuxCapableAlloc
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAllocateGraphicsMemoryIsCalledThenMemoryPoolIsSystem4KBPages) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
|
||||
auto size = 4096u;
|
||||
|
||||
@@ -691,7 +692,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAllocateGraphicsMemoryIsCall
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenMemoryManagerWith64KBPagesEnabledWhenAllocateGraphicsMemory64kbIsCalledThenMemoryPoolIsSystem64KBPages) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(true, false, executionEnvironment);
|
||||
AllocationData allocationData;
|
||||
allocationData.size = 4096u;
|
||||
@@ -711,7 +712,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWith64KBPagesEnabledWhenAllocate
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockOsAgnosticManagerWithFailingAllocate memoryManager(true, executionEnvironment);
|
||||
AllocationData allocationData;
|
||||
allocationData.size = 4096u;
|
||||
@@ -721,7 +722,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWith64KBPagesEnabledWhenAllocate
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAllocateGraphicsMemoryWithPtrIsCalledThenMemoryPoolIsSystem4KBPages) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
|
||||
void *ptr = reinterpret_cast<void *>(0x1001);
|
||||
auto size = MemoryConstants::pageSize;
|
||||
@@ -735,7 +736,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAllocateGraphicsMemoryWithPt
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAllocate32BitGraphicsMemoryWithPtrIsCalledThenMemoryPoolIsSystem4KBPagesWith32BitGpuAddressing) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
void *ptr = reinterpret_cast<void *>(0x1001);
|
||||
auto size = MemoryConstants::pageSize;
|
||||
@@ -749,7 +750,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAllocate32BitGraphicsMemoryW
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAllocate32BitGraphicsMemoryWithoutPtrIsCalledThenMemoryPoolIsSystem4KBPagesWith32BitGpuAddressing) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
void *ptr = nullptr;
|
||||
auto size = MemoryConstants::pageSize;
|
||||
@@ -762,7 +763,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAllocate32BitGraphicsMemoryW
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenMemoryManagerWith64KBPagesEnabledWhenAllocateGraphicsMemoryThenMemoryPoolIsSystem64KBPages) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(true, false, executionEnvironment);
|
||||
auto svmAllocation = memoryManager.allocateGraphicsMemoryWithProperties({MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SVM});
|
||||
EXPECT_NE(nullptr, svmAllocation);
|
||||
@@ -771,7 +772,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWith64KBPagesEnabledWhenAllocate
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenMemoryManagerWith64KBPagesDisabledWhenAllocateGraphicsMemoryThen4KBGraphicsAllocationIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
|
||||
auto svmAllocation = memoryManager.allocateGraphicsMemoryWithProperties({MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SVM});
|
||||
EXPECT_EQ(MemoryPool::System4KBPages, svmAllocation->getMemoryPool());
|
||||
@@ -779,7 +780,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWith64KBPagesDisabledWhenAllocat
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenCreateGraphicsAllocationFromSharedObjectIsCalledThenGraphicsAllocationIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
|
||||
osHandle handle = 1;
|
||||
auto size = 4096u;
|
||||
@@ -794,14 +795,14 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenCreateGraphicsAllocat
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenCreateAllocationFromNtHandleIsCalledThenReturnNullptr) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||
auto graphicsAllocation = memoryManager.createGraphicsAllocationFromNTHandle((void *)1);
|
||||
EXPECT_EQ(nullptr, graphicsAllocation);
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenLockUnlockCalledThenReturnCpuPtr) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
@@ -817,7 +818,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenLockUnlockCalledThenReturnCp
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenGraphicsAllocationContainsOffsetWhenAddressIsObtainedThenOffsetIsAdded) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
|
||||
|
||||
auto graphicsAllocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
@@ -837,7 +838,7 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenGraphicsAllocationCon
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenGraphicsAllocationIsPaddedThenNewGraphicsAllocationIsCreated) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
|
||||
auto graphicsAllocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
|
||||
@@ -856,7 +857,7 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenGraphicsAllocationIsP
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenTwoGraphicsAllocationArePaddedThenOnlyOnePaddingBufferIsUsed) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
|
||||
auto graphicsAllocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
|
||||
@@ -880,7 +881,7 @@ TEST(OsAgnosticMemoryManager, pleaseDetectLeak) {
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAllocateMemoryWithNoAlignmentProvidedThenAllocationIsAlignedToPageSize) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
|
||||
MockAllocationProperties properties(MemoryConstants::pageSize >> 1);
|
||||
properties.alignment = 0;
|
||||
@@ -893,7 +894,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAllocateMemoryWithNoAlignmen
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAllocateMemoryWithAlignmentNotAlignedToPageSizeThenAlignmentIsAlignedUp) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
|
||||
MockAllocationProperties properties(MemoryConstants::pageSize >> 1);
|
||||
properties.alignment = MemoryConstants::pageSize - 1;
|
||||
@@ -906,13 +907,14 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAllocateMemoryWithAlignmentN
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenCommonMemoryManagerWhenIsAskedIfApplicationMemoryBudgetIsExhaustedThenFalseIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||
EXPECT_FALSE(memoryManager.isMemoryBudgetExhausted());
|
||||
}
|
||||
|
||||
class MemoryManagerWithAsyncDeleterTest : public ::testing::Test {
|
||||
public:
|
||||
MemoryManagerWithAsyncDeleterTest() : memoryManager(false, false){};
|
||||
void SetUp() override {
|
||||
memoryManager.overrideAsyncDeleterFlag(true);
|
||||
}
|
||||
@@ -962,7 +964,8 @@ TEST_F(MemoryManagerWithAsyncDeleterTest, givenMemoryManagerWhenAllocateGraphics
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenIsAsyncDeleterEnabledCalledThenReturnsValueOfFlag) {
|
||||
MockMemoryManager memoryManager;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(executionEnvironment);
|
||||
memoryManager.overrideAsyncDeleterFlag(false);
|
||||
EXPECT_FALSE(memoryManager.isAsyncDeleterEnabled());
|
||||
memoryManager.overrideAsyncDeleterFlag(true);
|
||||
@@ -970,7 +973,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenIsAsyncDeleterEnabledCalledT
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenItIsCreatedThenAsyncDeleterEnabledIsFalse) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||
EXPECT_FALSE(memoryManager.isAsyncDeleterEnabled());
|
||||
EXPECT_EQ(nullptr, memoryManager.getDeferredDeleter());
|
||||
@@ -979,7 +982,7 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenItIsCreatedThenAsyncD
|
||||
TEST(OsAgnosticMemoryManager, givenEnabledAsyncDeleterFlagWhenMemoryManagerIsCreatedThenAsyncDeleterEnabledIsFalseAndDeleterIsNullptr) {
|
||||
bool defaultEnableDeferredDeleterFlag = DebugManager.flags.EnableDeferredDeleter.get();
|
||||
DebugManager.flags.EnableDeferredDeleter.set(true);
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||
EXPECT_FALSE(memoryManager.isAsyncDeleterEnabled());
|
||||
EXPECT_EQ(nullptr, memoryManager.getDeferredDeleter());
|
||||
@@ -989,7 +992,7 @@ TEST(OsAgnosticMemoryManager, givenEnabledAsyncDeleterFlagWhenMemoryManagerIsCre
|
||||
TEST(OsAgnosticMemoryManager, givenDisabledAsyncDeleterFlagWhenMemoryManagerIsCreatedThenAsyncDeleterEnabledIsFalseAndDeleterIsNullptr) {
|
||||
bool defaultEnableDeferredDeleterFlag = DebugManager.flags.EnableDeferredDeleter.get();
|
||||
DebugManager.flags.EnableDeferredDeleter.set(false);
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||
EXPECT_FALSE(memoryManager.isAsyncDeleterEnabled());
|
||||
EXPECT_EQ(nullptr, memoryManager.getDeferredDeleter());
|
||||
@@ -999,7 +1002,7 @@ TEST(OsAgnosticMemoryManager, givenDisabledAsyncDeleterFlagWhenMemoryManagerIsCr
|
||||
TEST(OsAgnosticMemoryManager, GivenEnabled64kbPagesWhenHostMemoryAllocationIsCreatedThenAlignedto64KbAllocationIsReturned) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.Enable64kbpages.set(true);
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(true, false, executionEnvironment);
|
||||
|
||||
GraphicsAllocation *galloc = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize64k, GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY});
|
||||
@@ -1017,7 +1020,7 @@ TEST(OsAgnosticMemoryManager, GivenEnabled64kbPagesWhenHostMemoryAllocationIsCre
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenPointerAndSizeWhenCreateInternalAllocationIsCalledThenGraphicsAllocationIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
auto ptr = (void *)0x100000;
|
||||
size_t allocationSize = 4096;
|
||||
@@ -1027,13 +1030,13 @@ TEST(OsAgnosticMemoryManager, givenPointerAndSizeWhenCreateInternalAllocationIsC
|
||||
memoryManager.freeGraphicsMemory(graphicsAllocation);
|
||||
}
|
||||
TEST(OsAgnosticMemoryManager, givenDefaultOsAgnosticMemoryManagerWhenItIsQueriedForInternalHeapBaseThen32BitAllocatorBaseIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||
auto heapBase = memoryManager.allocator32Bit->getBase();
|
||||
EXPECT_EQ(heapBase, memoryManager.getInternalHeapBaseAddress());
|
||||
}
|
||||
TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerWhenAllocateGraphicsMemoryForNonSvmHostPtrIsCalledThenAllocationIsCreated) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(executionEnvironment);
|
||||
AllocationData allocationData;
|
||||
allocationData.size = 13;
|
||||
@@ -1049,7 +1052,7 @@ using OsAgnosticMemoryManagerWithParams = ::testing::TestWithParam<bool>;
|
||||
|
||||
TEST_P(OsAgnosticMemoryManagerWithParams, givenReducedGpuAddressSpaceWhenAllocateGraphicsMemoryForHostPtrIsCalledThenAllocationWithoutFragmentsIsCreated) {
|
||||
bool requiresL3Flush = GetParam();
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
executionEnvironment.setHwInfo(platformDevices[0]);
|
||||
if (executionEnvironment.isFullRangeSvm()) {
|
||||
return;
|
||||
@@ -1068,7 +1071,7 @@ TEST_P(OsAgnosticMemoryManagerWithParams, givenReducedGpuAddressSpaceWhenAllocat
|
||||
|
||||
TEST_P(OsAgnosticMemoryManagerWithParams, givenFullGpuAddressSpaceWhenAllocateGraphicsMemoryForHostPtrIsCalledThenAllocationWithFragmentsIsCreated) {
|
||||
bool requiresL3Flush = GetParam();
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
executionEnvironment.setHwInfo(platformDevices[0]);
|
||||
if (!executionEnvironment.isFullRangeSvm()) {
|
||||
return;
|
||||
@@ -1091,7 +1094,7 @@ TEST_P(OsAgnosticMemoryManagerWithParams, givenDisabledHostPtrTrackingWhenAlloca
|
||||
DebugManager.flags.EnableHostPtrTracking.set(false);
|
||||
|
||||
bool requiresL3Flush = GetParam();
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
executionEnvironment.setHwInfo(platformDevices[0]);
|
||||
if (!executionEnvironment.isFullRangeSvm()) {
|
||||
return;
|
||||
@@ -1114,7 +1117,7 @@ INSTANTIATE_TEST_CASE_P(OsAgnosticMemoryManagerWithParams,
|
||||
::testing::Values(false, true));
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenLocalMemoryNotSupportedWhenMemoryManagerIsCreatedThenAllocator32BitHasCorrectBaseAddress) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, false, executionEnvironment);
|
||||
uint64_t heap32Base = 0x80000000000ul;
|
||||
|
||||
@@ -1125,7 +1128,7 @@ TEST(OsAgnosticMemoryManager, givenLocalMemoryNotSupportedWhenMemoryManagerIsCre
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenLocalMemorySupportedAndNotAubUsageWhenMemoryManagerIsCreatedThenAllocator32BitHasCorrectBaseAddress) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, true, false, executionEnvironment);
|
||||
memoryManager.allocator32Bit.reset(memoryManager.create32BitAllocator(false));
|
||||
uint64_t heap32Base = 0x80000000000ul;
|
||||
@@ -1137,7 +1140,7 @@ TEST(OsAgnosticMemoryManager, givenLocalMemorySupportedAndNotAubUsageWhenMemoryM
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenLocalMemoryNotSupportedAndAubUsageWhenMemoryManagerIsCreatedThenAllocator32BitHasCorrectBaseAddress) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, true, executionEnvironment);
|
||||
uint64_t heap32Base = 0x80000000000ul;
|
||||
|
||||
@@ -1148,7 +1151,7 @@ TEST(OsAgnosticMemoryManager, givenLocalMemoryNotSupportedAndAubUsageWhenMemoryM
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenLocalMemorySupportedAndAubUsageWhenMemoryManagerIsCreatedThenAllocator32BitHasCorrectBaseAddress) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, true, true, executionEnvironment);
|
||||
memoryManager.allocator32Bit.reset(memoryManager.create32BitAllocator(true));
|
||||
uint64_t heap32Base = 0x80000000000ul;
|
||||
@@ -1308,7 +1311,7 @@ TEST_F(MemoryManagerWithCsrTest, givenAllocationThatWasUsedAndIsNotCompletedWhen
|
||||
|
||||
class MockAlignMallocMemoryManager : public MockMemoryManager {
|
||||
public:
|
||||
MockAlignMallocMemoryManager() {
|
||||
MockAlignMallocMemoryManager(ExecutionEnvironment &executionEnvironment) : MockMemoryManager(executionEnvironment) {
|
||||
testMallocRestrictions.minAddress = 0;
|
||||
alignMallocRestrictions = nullptr;
|
||||
alignMallocCount = 0;
|
||||
@@ -1360,7 +1363,8 @@ class MockAlignMallocMemoryManagerTest : public MemoryAllocatorTest {
|
||||
void SetUp() override {
|
||||
MemoryAllocatorTest::SetUp();
|
||||
|
||||
alignedMemoryManager = new (std::nothrow) MockAlignMallocMemoryManager;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
alignedMemoryManager = new (std::nothrow) MockAlignMallocMemoryManager(executionEnvironment);
|
||||
//assert we have memory manager
|
||||
ASSERT_NE(nullptr, memoryManager);
|
||||
}
|
||||
@@ -1535,7 +1539,7 @@ TEST(GraphicsAllocation, givenSharedHandleBasedConstructorWhenGraphicsAllocation
|
||||
}
|
||||
|
||||
TEST(ResidencyDataTest, givenOsContextWhenItIsRegisteredToMemoryManagerThenRefCountIncreases) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
memoryManager.createAndRegisterOsContext(nullptr, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0],
|
||||
1, PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]), false);
|
||||
@@ -1544,7 +1548,7 @@ TEST(ResidencyDataTest, givenOsContextWhenItIsRegisteredToMemoryManagerThenRefCo
|
||||
}
|
||||
|
||||
TEST(ResidencyDataTest, givenDeviceBitfieldWhenCreatingOsContextThenSetValidValue) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
DeviceBitfield deviceBitfield = getDeviceBitfieldForNDevices(2);
|
||||
PreemptionMode preemptionMode = PreemptionMode::MidThread;
|
||||
@@ -1556,7 +1560,7 @@ TEST(ResidencyDataTest, givenDeviceBitfieldWhenCreatingOsContextThenSetValidValu
|
||||
}
|
||||
|
||||
TEST(ResidencyDataTest, givenTwoOsContextsWhenTheyAreRegisteredFromHigherToLowerThenProperSizeIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
memoryManager.createAndRegisterOsContext(nullptr, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0],
|
||||
1, PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]), false);
|
||||
@@ -1605,7 +1609,7 @@ TEST(ResidencyDataTest, givenResidencyDataWhenUpdateCompletionDataIsCalledThenIt
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenMemoryManagerWhenLockIsCalledOnLockedResourceThenDoesNothing) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
|
||||
@@ -1625,7 +1629,7 @@ TEST(MemoryManagerTest, givenMemoryManagerWhenLockIsCalledOnLockedResourceThenDo
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenMemoryManagerWhenAllocationWasNotUnlockedThenItIsUnlockedDuringDestruction) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
|
||||
@@ -1715,14 +1719,14 @@ TEST_F(MemoryAllocatorTest, whenCommandStreamerIsNotRegisteredThenReturnNullEngi
|
||||
EXPECT_EQ(nullptr, engineControl);
|
||||
}
|
||||
TEST(MemoryManagerCopyMemoryTest, givenAllocationWithNoStorageWhenCopyMemoryToAllocationThenReturnFalse) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
uint8_t memory = 1;
|
||||
MockGraphicsAllocation invalidAllocation{nullptr, 0u};
|
||||
EXPECT_FALSE(memoryManager.copyMemoryToAllocation(&invalidAllocation, &memory, sizeof(memory)));
|
||||
}
|
||||
TEST(MemoryManagerCopyMemoryTest, givenValidAllocationAndMemoryWhenCopyMemoryToAllocationThenDataIsCopied) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
constexpr uint8_t allocationSize = 10;
|
||||
uint8_t allocationStorage[allocationSize] = {0};
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
#include "unit_tests/mocks/mock_memory_manager.h"
|
||||
#include "unit_tests/mocks/mock_svm_manager.h"
|
||||
|
||||
@@ -13,8 +14,8 @@
|
||||
using namespace NEO;
|
||||
|
||||
struct SVMMemoryAllocatorTest : ::testing::Test {
|
||||
SVMMemoryAllocatorTest() : memoryManager(false, false, executionEnvironment), svmManager(&memoryManager) {}
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
SVMMemoryAllocatorTest() : executionEnvironment(*platformDevices), memoryManager(false, false, executionEnvironment), svmManager(&memoryManager) {}
|
||||
MockExecutionEnvironment executionEnvironment;
|
||||
MockMemoryManager memoryManager;
|
||||
MockSVMAllocsManager svmManager;
|
||||
};
|
||||
|
||||
@@ -78,5 +78,5 @@ FailDevice::FailDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executi
|
||||
}
|
||||
FailDeviceAfterOne::FailDeviceAfterOne(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex)
|
||||
: MockDevice(hwInfo, executionEnvironment, deviceIndex) {
|
||||
this->mockMemoryManager.reset(new FailMemoryManager(1));
|
||||
this->mockMemoryManager.reset(new FailMemoryManager(1, *executionEnvironment));
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ GraphicsAllocation *MockMemoryManager::allocate32BitGraphicsMemory(size_t size,
|
||||
return allocate32BitGraphicsMemoryImpl(allocationData);
|
||||
}
|
||||
|
||||
FailMemoryManager::FailMemoryManager(int32_t failedAllocationsCount) {
|
||||
FailMemoryManager::FailMemoryManager(int32_t failedAllocationsCount, ExecutionEnvironment &executionEnvironment) : MockMemoryManager(executionEnvironment) {
|
||||
this->failedAllocationsCount = failedAllocationsCount;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
#include "runtime/execution_environment/execution_environment.h"
|
||||
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
#include "unit_tests/mocks/mock_host_ptr_manager.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
@@ -46,10 +47,10 @@ class MockMemoryManager : public MemoryManagerCreate<OsAgnosticMemoryManager> {
|
||||
hostPtrManager.reset(new MockHostPtrManager);
|
||||
};
|
||||
|
||||
MockMemoryManager() : MockMemoryManager(*(new ExecutionEnvironment)) {
|
||||
MockMemoryManager() : MockMemoryManager(*(new MockExecutionEnvironment(*platformDevices))) {
|
||||
mockExecutionEnvironment.reset(&executionEnvironment);
|
||||
};
|
||||
MockMemoryManager(bool enable64pages, bool enableLocalMemory) : MemoryManagerCreate(enable64pages, enableLocalMemory, *(new ExecutionEnvironment)) {
|
||||
MockMemoryManager(bool enable64pages, bool enableLocalMemory) : MemoryManagerCreate(enable64pages, enableLocalMemory, *(new MockExecutionEnvironment(*platformDevices))) {
|
||||
mockExecutionEnvironment.reset(&executionEnvironment);
|
||||
}
|
||||
GraphicsAllocation *allocateGraphicsMemory64kb(const AllocationData &allocationData) override;
|
||||
@@ -137,7 +138,7 @@ class FailMemoryManager : public MockMemoryManager {
|
||||
public:
|
||||
using MemoryManager::allocateGraphicsMemoryWithProperties;
|
||||
using MockMemoryManager::MockMemoryManager;
|
||||
FailMemoryManager(int32_t failedAllocationsCount);
|
||||
FailMemoryManager(int32_t failedAllocationsCount, ExecutionEnvironment &executionEnvironment);
|
||||
|
||||
GraphicsAllocation *allocateGraphicsMemoryWithAlignment(const AllocationData &allocationData) override {
|
||||
if (failedAllocationsCount <= 0) {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "runtime/os_interface/linux/drm_memory_manager.h"
|
||||
#include "runtime/os_interface/linux/os_interface.h"
|
||||
#include "unit_tests/mocks/linux/mock_drm_memory_manager.h"
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
#include "unit_tests/os_interface/linux/device_command_stream_fixture.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
@@ -33,7 +34,7 @@ TEST(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSharedAllocationIsCreatedFro
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
executionEnvironment.osInterface = std::make_unique<OSInterface>();
|
||||
auto mock = make_unique<MockDrm>(0);
|
||||
executionEnvironment.osInterface->get()->setDrm(mock.get());
|
||||
@@ -97,7 +98,7 @@ TEST(DrmMemoryManagerTest, givenMultipleThreadsWhenSharedAllocationIsCreatedThen
|
||||
}
|
||||
};
|
||||
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
executionEnvironment.osInterface = std::make_unique<OSInterface>();
|
||||
auto mock = make_unique<MockDrm>(0);
|
||||
executionEnvironment.osInterface->get()->setDrm(mock.get());
|
||||
|
||||
@@ -98,7 +98,7 @@ TEST(ApiOsTest, notSupportedApiList) {
|
||||
TEST(DeviceOsTest, DeviceCreationFailMidThreadPreemption) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::MidThread));
|
||||
auto pDevice = MockDevice::createWithNewExecutionEnvironment<FailDeviceAfterOne>(nullptr);
|
||||
auto pDevice = MockDevice::createWithNewExecutionEnvironment<FailDeviceAfterOne>(*platformDevices);
|
||||
|
||||
EXPECT_THAT(pDevice, nullptr);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "runtime/os_interface/linux/drm_memory_manager.h"
|
||||
#include "runtime/os_interface/linux/os_interface.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
#include "unit_tests/os_interface/linux/device_command_stream_fixture.h"
|
||||
|
||||
#include "drm/i915_drm.h"
|
||||
@@ -54,6 +55,7 @@ class DrmMockForWorker : public Drm {
|
||||
|
||||
class DrmGemCloseWorkerFixture {
|
||||
public:
|
||||
DrmGemCloseWorkerFixture() : executionEnvironment(*platformDevices){};
|
||||
//max loop count for while
|
||||
static const uint32_t deadCntInit = 10 * 1000 * 1000;
|
||||
|
||||
@@ -99,7 +101,7 @@ class DrmGemCloseWorkerFixture {
|
||||
: DrmAllocation(GraphicsAllocation::AllocationType::UNDECIDED, bo, nullptr, 0, MemoryPool::MemoryNull, 1u, false) {
|
||||
}
|
||||
};
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment;
|
||||
};
|
||||
|
||||
typedef Test<DrmGemCloseWorkerFixture> DrmGemCloseWorkerTests;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "runtime/os_interface/linux/drm_memory_manager.h"
|
||||
#include "runtime/os_interface/linux/os_interface.h"
|
||||
#include "unit_tests/mocks/linux/mock_drm_memory_manager.h"
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
using namespace NEO;
|
||||
@@ -17,7 +18,7 @@ using namespace ::testing;
|
||||
using AllocationData = TestedDrmMemoryManager::AllocationData;
|
||||
|
||||
TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenAllocateInDevicePoolIsCalledThenNullptrAndStatusRetryIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
executionEnvironment.osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment.osInterface->get()->setDrm(Drm::get(0));
|
||||
TestedDrmMemoryManager memoryManager(executionEnvironment);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "unit_tests/fixtures/memory_management_fixture.h"
|
||||
#include "unit_tests/mocks/linux/mock_drm_memory_manager.h"
|
||||
#include "unit_tests/mocks/mock_device.h"
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
#include "unit_tests/os_interface/linux/device_command_stream_fixture.h"
|
||||
|
||||
#include <memory>
|
||||
@@ -20,12 +21,13 @@ using AllocationData = TestedDrmMemoryManager::AllocationData;
|
||||
|
||||
class DrmMemoryManagerBasic : public ::testing::Test {
|
||||
public:
|
||||
DrmMemoryManagerBasic() : executionEnvironment(*platformDevices){};
|
||||
void SetUp() override {
|
||||
executionEnvironment.osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment.osInterface->get()->setDrm(Drm::get(0));
|
||||
}
|
||||
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment;
|
||||
};
|
||||
|
||||
class DrmMemoryManagerFixture : public MemoryManagementFixture {
|
||||
@@ -37,7 +39,7 @@ class DrmMemoryManagerFixture : public MemoryManagementFixture {
|
||||
void SetUp() override {
|
||||
MemoryManagementFixture::SetUp();
|
||||
this->mock = new DrmMockCustom;
|
||||
executionEnvironment = new ExecutionEnvironment;
|
||||
executionEnvironment = new MockExecutionEnvironment(*platformDevices);
|
||||
executionEnvironment->incRefInternal();
|
||||
executionEnvironment->osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment->osInterface->get()->setDrm(mock);
|
||||
|
||||
@@ -62,7 +62,7 @@ TEST(DeviceOsTest, DeviceCreationFail) {
|
||||
TEST(DeviceOsTest, DeviceCreationFailMidThreadPreemption) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::MidThread));
|
||||
auto pDevice = MockDevice::createWithNewExecutionEnvironment<FailDeviceAfterOne>(nullptr);
|
||||
auto pDevice = MockDevice::createWithNewExecutionEnvironment<FailDeviceAfterOne>(*platformDevices);
|
||||
|
||||
EXPECT_THAT(pDevice, nullptr);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "runtime/execution_environment/execution_environment.h"
|
||||
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
||||
#include "runtime/program/kernel_info.h"
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
@@ -108,7 +109,7 @@ TEST(KernelInfo, decodeImageKernelArgument) {
|
||||
|
||||
TEST(KernelInfoTest, givenKernelInfoWhenCreateKernelAllocationThenCopyWholeKernelHeapToKernelAllocation) {
|
||||
KernelInfo kernelInfo;
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||
SKernelBinaryHeaderCommon kernelHeader;
|
||||
const size_t heapSize = 0x40;
|
||||
@@ -137,7 +138,7 @@ class MyMemoryManager : public OsAgnosticMemoryManager {
|
||||
|
||||
TEST(KernelInfoTest, givenKernelInfoWhenCreateKernelAllocationAndCannotAllocateMemoryThenReturnsFalse) {
|
||||
KernelInfo kernelInfo;
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MyMemoryManager memoryManager(executionEnvironment);
|
||||
SKernelBinaryHeaderCommon kernelHeader;
|
||||
kernelInfo.heapInfo.pKernelHeader = &kernelHeader;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "unit_tests/libult/ult_command_stream_receiver.h"
|
||||
#include "unit_tests/mocks/gl/mock_gl_sharing.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
#include "unit_tests/mocks/mock_gmm.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
@@ -23,7 +24,7 @@ class CreateFromGlTexture : public ::testing::Test {
|
||||
// temp solution - we need to query size from GMM:
|
||||
class TempMM : public OsAgnosticMemoryManager {
|
||||
public:
|
||||
TempMM() : OsAgnosticMemoryManager(*(new ExecutionEnvironment)) {
|
||||
TempMM() : OsAgnosticMemoryManager(*(new MockExecutionEnvironment(*platformDevices))) {
|
||||
mockExecutionEnvironment.reset(&executionEnvironment);
|
||||
}
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness) override {
|
||||
|
||||
Reference in New Issue
Block a user