Reverse logic of creating Memory Manager - part 1

-remove CSR::createMemoryManager method
-create MM from platform before creating devices

Change-Id: I0e7f091c53b0e60ae7101e82a305253af626330e
Signed-off-by: Jobczyk, Lukasz <lukasz.jobczyk@intel.com>
This commit is contained in:
Jobczyk, Lukasz
2019-02-19 08:55:11 +01:00
parent cd90cdc946
commit 878fd43a1a
49 changed files with 198 additions and 105 deletions

View File

@@ -89,6 +89,7 @@ TEST(AubCenter, GivenCsrTypeWhenGettingAubStreamModeThenCorrectModeIsReturned) {
TEST(AubCenter, GivenSetCommandStreamReceiverFlagEqualDefaultHwWhenAubManagerIsCreatedThenCsrTypeDefinesAubStreamMode) {
DebugManagerStateRestore restorer;
DebugManager.flags.UseAubStream.set(true);
DebugManager.flags.SetCommandStreamReceiver.set(-1);
std::vector<CommandStreamReceiverType> aubTypes = {CommandStreamReceiverType::CSR_HW,
CommandStreamReceiverType::CSR_HW_WITH_AUB,

View File

@@ -129,7 +129,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenItIsCreatedWithDebugSetti
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenItIsCreatedThenMemoryManagerIsNotNull) {
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(**platformDevices, "", true, *pDevice->executionEnvironment));
std::unique_ptr<MemoryManager> memoryManager(aubCsr->createMemoryManager(false, false));
std::unique_ptr<MemoryManager> memoryManager(new OsAgnosticMemoryManager(false, false, *pDevice->executionEnvironment));
EXPECT_NE(nullptr, memoryManager.get());
}
@@ -251,7 +251,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptur
HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWhenMakeResidentCalledMultipleTimesAffectsResidencyOnce) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
memoryManager.reset(aubCsr->createMemoryManager(false, false));
memoryManager.reset(new OsAgnosticMemoryManager(false, false, *pDevice->executionEnvironment));
aubCsr->setupContext(*pDevice->getDefaultEngine().osContext);
auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
@@ -693,8 +693,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMe
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
aubCsr->setupContext(*pDevice->getDefaultEngine().osContext);
memoryManager.reset(aubCsr->createMemoryManager(false, false));
memoryManager.reset(new OsAgnosticMemoryManager(false, false, *pDevice->executionEnvironment));
auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
@@ -718,7 +717,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMe
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcessResidencyIsCalledOnBufferAndImageAllocationsThenAllocationsTypesShouldBeMadeNonAubWritable) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
memoryManager.reset(aubCsr->createMemoryManager(false, false));
memoryManager.reset(new OsAgnosticMemoryManager(false, false, *pDevice->executionEnvironment));
aubCsr->setupContext(*pDevice->getDefaultEngine().osContext);
auto gfxBufferAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER});
@@ -739,7 +738,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptur
DebugManagerStateRestore stateRestore;
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsrToTestDumpAubNonWritable<FamilyType>> aubCsr(new MockAubCsrToTestDumpAubNonWritable<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
memoryManager.reset(aubCsr->createMemoryManager(false, false));
memoryManager.reset(new OsAgnosticMemoryManager(false, false, *pDevice->executionEnvironment));
aubCsr->setupContext(*pDevice->getDefaultEngine().osContext);
auto gfxBufferAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER});
@@ -764,7 +763,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
DebugManagerStateRestore stateRestore;
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsrToTestDumpAubNonWritable<FamilyType>> aubCsr(new MockAubCsrToTestDumpAubNonWritable<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
memoryManager.reset(aubCsr->createMemoryManager(false, false));
memoryManager.reset(new OsAgnosticMemoryManager(false, false, *pDevice->executionEnvironment));
aubCsr->setupContext(*pDevice->getDefaultEngine().osContext);
auto gfxBufferAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER});
@@ -803,7 +802,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphic
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
aubCsr->setupContext(*pDevice->getDefaultEngine().osContext);
memoryManager.reset(aubCsr->createMemoryManager(false, false));
memoryManager.reset(new OsAgnosticMemoryManager(false, false, *pDevice->executionEnvironment));
auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
@@ -815,7 +814,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphic
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphicsAllocationTypeIsNonAubWritableThenWriteMemoryIsNotAllowed) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
memoryManager.reset(aubCsr->createMemoryManager(false, false));
memoryManager.reset(new OsAgnosticMemoryManager(false, false, *pDevice->executionEnvironment));
auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});

View File

@@ -51,9 +51,8 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedBatchBufferFlatteningInImmediateDispatchModeThenNewCombinedBatchBufferIsCreated) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
memoryManager.reset(aubCsr->createMemoryManager(false, false));
std::unique_ptr<MemoryManager> memoryManager(new OsAgnosticMemoryManager(false, false, *pDevice->executionEnvironment));
auto flatBatchBufferHelper = new FlatBatchBufferHelperHw<FamilyType>(*pDevice->executionEnvironment);
aubCsr->overwriteFlatBatchBufferHelper(flatBatchBufferHelper);
@@ -81,9 +80,8 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedBatchBufferInImmediateDispatchModeAndNoChainedBatchBufferThenCombinedBatchBufferIsNotCreated) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
memoryManager.reset(aubCsr->createMemoryManager(false, false));
std::unique_ptr<MemoryManager> memoryManager(new OsAgnosticMemoryManager(false, false, *pDevice->executionEnvironment));
auto flatBatchBufferHelper = new FlatBatchBufferHelperHw<FamilyType>(*pDevice->executionEnvironment);
aubCsr->overwriteFlatBatchBufferHelper(flatBatchBufferHelper);
@@ -105,9 +103,8 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedBatchBufferAndNotImmediateOrBatchedDispatchModeThenCombinedBatchBufferIsNotCreated) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
memoryManager.reset(aubCsr->createMemoryManager(false, false));
std::unique_ptr<MemoryManager> memoryManager(new OsAgnosticMemoryManager(false, false, *pDevice->executionEnvironment));
auto flatBatchBufferHelper = new FlatBatchBufferHelperHw<FamilyType>(*pDevice->executionEnvironment);
aubCsr->overwriteFlatBatchBufferHelper(flatBatchBufferHelper);
@@ -389,9 +386,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGetIndi
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGetIndirectPatchCommandsIsCalledForNonEmptyPatchInfoListThenIndirectPatchCommandBufferIsCreated) {
typedef typename FamilyType::MI_STORE_DATA_IMM MI_STORE_DATA_IMM;
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
memoryManager.reset(aubCsr->createMemoryManager(false, false));
PatchInfoData patchInfo1(0xA000, 0u, PatchInfoAllocationType::KernelArg, 0x6000, 0x100, PatchInfoAllocationType::IndirectObjectHeap);
PatchInfoData patchInfo2(0xB000, 0u, PatchInfoAllocationType::KernelArg, 0x6000, 0x200, PatchInfoAllocationType::IndirectObjectHeap);
@@ -416,9 +411,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddBatc
DebugManagerStateRestore dbgRestore;
DebugManager.flags.FlattenBatchBufferForAUBDump.set(true);
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
memoryManager.reset(aubCsr->createMemoryManager(false, false));
MI_BATCH_BUFFER_START bbStart;
@@ -657,11 +650,10 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMemoryIsCalledThenGraphicsAllocationSizeIsReadCorrectly) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
pDevice->executionEnvironment->aubCenter.reset(new AubCenter());
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(*platformDevices[0], "", false, *pDevice->executionEnvironment);
memoryManager.reset(aubCsr->createMemoryManager(false, false));
std::unique_ptr<MemoryManager> memoryManager(new OsAgnosticMemoryManager(false, false, *pDevice->executionEnvironment));
PhysicalAddressAllocator allocator;
struct PpgttMock : std::conditional<is64bit, PML4, PDPE>::type {

View File

@@ -388,8 +388,6 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, CreateCommandStreamReceiverHw) {
auto csrHw = CommandStreamReceiverHw<FamilyType>::create(hwInfo, executionEnvironment);
EXPECT_NE(nullptr, csrHw);
MemoryManager *mm = csrHw->createMemoryManager(false, false);
EXPECT_EQ(nullptr, mm);
GmmPageTableMngr *ptm = csrHw->createPageTableManager();
EXPECT_EQ(nullptr, ptm);
delete csrHw;

View File

@@ -105,8 +105,8 @@ struct CommandStreamReceiverWithAubDumpTest : public ::testing::TestWithParam<bo
createAubCSR = GetParam();
csrWithAubDump = new MyMockCsrWithAubDump<MyMockCsr>(DEFAULT_TEST_PLATFORM::hwInfo, createAubCSR, executionEnvironment);
ASSERT_NE(nullptr, csrWithAubDump);
memoryManager = csrWithAubDump->createMemoryManager(false, false);
executionEnvironment.memoryManager.reset(memoryManager);
executionEnvironment.initializeMemoryManager(false, false);
memoryManager = executionEnvironment.memoryManager.get();
ASSERT_NE(nullptr, memoryManager);
auto osContext = executionEnvironment.memoryManager->createAndRegisterOsContext(csrWithAubDump,

View File

@@ -49,7 +49,7 @@ HWTEST_P(CreateCommandStreamReceiverTest, givenCreateCommandStreamWhenCsrIsSetTo
if (csrType < CommandStreamReceiverType::CSR_TYPES_NUM) {
EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0][0].get());
executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0][0]->createMemoryManager(false, false));
executionEnvironment->initializeMemoryManager(false, false);
EXPECT_NE(nullptr, executionEnvironment->memoryManager.get());
} else {
EXPECT_EQ(nullptr, executionEnvironment->commandStreamReceivers[0][0]);

View File

@@ -22,7 +22,7 @@ void TbxCommandStreamFixture::SetUp(MockDevice *pDevice) {
const auto &hwInfo = pDevice->getHardwareInfo();
pCommandStreamReceiver = TbxCommandStreamReceiver::create(hwInfo, "", false, *pDevice->executionEnvironment);
ASSERT_NE(nullptr, pCommandStreamReceiver);
mmTbx = pCommandStreamReceiver->createMemoryManager(false, false);
mmTbx = new TbxMemoryManager(false, false, *pDevice->executionEnvironment);
pDevice->resetCommandStreamReceiver(pCommandStreamReceiver);
}

View File

@@ -143,9 +143,6 @@ TEST(DeviceCreation, givenHwWithAubCsrInDebugVarsWhenDeviceIsCreatedThenIsSimula
}
TEST(DeviceCreation, givenDefaultHwCsrInDebugVarsWhenDeviceIsCreatedThenIsSimulationReturnsFalse) {
int32_t defaultHwCsr = CommandStreamReceiverType::CSR_HW;
EXPECT_EQ(defaultHwCsr, DebugManager.flags.SetCommandStreamReceiver.get());
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
EXPECT_FALSE(device->isSimulation());
}
@@ -230,9 +227,6 @@ TEST(DeviceCreation, givenFtrSimulationModeFlagTrueWhenNoOtherSimulationFlagsAre
HardwareInfo hwInfo = {platformDevices[0]->pPlatform, &skuTable, platformDevices[0]->pWaTable,
platformDevices[0]->pSysInfo, platformDevices[0]->capabilityTable};
int32_t defaultHwCsr = CommandStreamReceiverType::CSR_HW;
EXPECT_EQ(defaultHwCsr, DebugManager.flags.SetCommandStreamReceiver.get());
bool simulationFromDeviceId = hwInfo.capabilityTable.isSimulation(hwInfo.pPlatform->usDeviceID);
EXPECT_FALSE(simulationFromDeviceId);

View File

@@ -179,14 +179,14 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeMemoryManagerI
auto executionEnvironment = device->getExecutionEnvironment();
executionEnvironment->initializeCommandStreamReceiver(hwInfo, 0, 0);
auto enableLocalMemory = HwHelper::get(hwInfo->pPlatform->eRenderCoreFamily).getEnableLocalMemory(*hwInfo);
executionEnvironment->initializeMemoryManager(false, enableLocalMemory, 0, 0);
executionEnvironment->initializeMemoryManager(false, enableLocalMemory);
EXPECT_EQ(enableLocalMemory, executionEnvironment->memoryManager->isLocalMemorySupported());
}
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeMemoryManagerIsCalledThenItIsInitalized) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0, 0);
executionEnvironment->initializeMemoryManager(false, false, 0, 0);
executionEnvironment->initializeMemoryManager(false, false);
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
}
static_assert(sizeof(ExecutionEnvironment) == sizeof(std::vector<std::unique_ptr<CommandStreamReceiver>>) +
@@ -284,7 +284,7 @@ HWTEST_F(ExecutionEnvironmentHw, givenHwHelperInputWhenInitializingCsrThenCreate
TEST(ExecutionEnvironment, whenSpecialCsrNotExistThenReturnNullSpecialEngineControl) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0, 0);
executionEnvironment->initializeMemoryManager(false, false, 0, 0);
executionEnvironment->initializeMemoryManager(false, false);
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
auto engineControl = executionEnvironment->getEngineControlForSpecialCsr();
EXPECT_EQ(nullptr, engineControl);
@@ -293,7 +293,7 @@ TEST(ExecutionEnvironment, whenSpecialCsrNotExistThenReturnNullSpecialEngineCont
TEST(ExecutionEnvironment, whenSpecialCsrExistsThenReturnSpecialEngineControl) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0, 0);
executionEnvironment->initializeMemoryManager(false, false, 0, 0);
executionEnvironment->initializeMemoryManager(false, false);
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
executionEnvironment->specialCommandStreamReceiver.reset(createCommandStream(platformDevices[0], *executionEnvironment));
@@ -308,3 +308,12 @@ TEST(ExecutionEnvironment, whenSpecialCsrExistsThenReturnSpecialEngineControl) {
ASSERT_NE(nullptr, engineControl);
EXPECT_EQ(executionEnvironment->specialCommandStreamReceiver.get(), engineControl->commandStreamReceiver);
}
TEST(ExecutionEnvironment, givenUnproperSetCsrFlagValueWhenInitializingMemoryManagerThenCreateDefaultMemoryManager) {
DebugManagerStateRestore restorer;
DebugManager.flags.SetCommandStreamReceiver.set(10);
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->initializeMemoryManager(false, false);
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
}

View File

@@ -95,6 +95,7 @@ add_library (igdrcl_libult_env OBJECT
)
set(IGDRCL_SRCS_LIB_ULT_ENV_WINDOWS
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/windows/create_wddm_memory_manager.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/windows/options.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/windows/sys_calls.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/windows/ult_dxgi_factory.cpp
@@ -103,6 +104,7 @@ set(IGDRCL_SRCS_LIB_ULT_ENV_WINDOWS
)
set(IGDRCL_SRCS_LIB_ULT_ENV_LINUX
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/linux/create_drm_memory_manager.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/linux/options.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/linux/allocator_helper.cpp
)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Intel Corporation
* Copyright (C) 2018-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -10,6 +10,7 @@
namespace OCLRT {
extern bool overrideCommandStreamReceiverCreation;
extern bool overrideDeviceWithDefaultHardwareInfo;
extern bool overrideMemoryManagerCreation;
extern CommandStreamReceiver *createCommandStream(const HardwareInfo *pHwInfo, ExecutionEnvironment &executionEnvironment);
extern bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment);

View File

@@ -80,10 +80,6 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
return new UltCommandStreamReceiver<GfxFamily>(hwInfoIn, executionEnvironment);
}
virtual MemoryManager *createMemoryManager(bool enable64kbPages, bool enableLocalMemory) override {
return new OsAgnosticMemoryManager(enable64kbPages, enableLocalMemory, executionEnvironment);
}
virtual GmmPageTableMngr *createPageTableManager() override {
createPageTableManagerCalled = true;
return nullptr;

View File

@@ -10,6 +10,7 @@ set(IGDRCL_SRCS_linux_tests
${IGDRCL_SOURCE_DIR}/unit_tests/aub_stream_mocks/aub_stream_interface_mock.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/libult/os_interface.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/linux/allocator_helper.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/linux/create_drm_memory_manager.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/linux/options.cpp
)
@@ -25,6 +26,7 @@ set(IGDRCL_SRCS_linux_dll_tests
${IGDRCL_SOURCE_DIR}/runtime/dll/linux/options.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/aub_stream_mocks/aub_stream_interface_mock.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/libult/os_interface.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/linux/create_drm_memory_manager.cpp
)
if(IGDRCL__LIBVA_FOUND)

View File

@@ -64,7 +64,7 @@ HWTEST_TYPED_TEST(SurfaceTest, GivenSurfaceWhenInterfaceIsUsedThenSurfaceBehaves
executionEnvironment.commandStreamReceivers.resize(1);
MockCsr<FamilyType> *csr = new MockCsr<FamilyType>(execStamp, executionEnvironment);
executionEnvironment.commandStreamReceivers[0].push_back(std::unique_ptr<CommandStreamReceiver>(csr));
executionEnvironment.memoryManager.reset(csr->createMemoryManager(false, false));
executionEnvironment.initializeMemoryManager(false, false);
auto engine = HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0];
auto osContext = executionEnvironment.memoryManager->createAndRegisterOsContext(csr, engine, 1, PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
csr->setupContext(*osContext);

View File

@@ -165,7 +165,7 @@ std::unique_ptr<AubExecutionEnvironment> getEnvironment(bool createTagAllocation
executionEnvironment->commandStreamReceivers.resize(1);
executionEnvironment->commandStreamReceivers[0].push_back(std::make_unique<CsrType>(*platformDevices[0], "", standalone, *executionEnvironment));
executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0][0]->createMemoryManager(false, false));
executionEnvironment->initializeMemoryManager(false, false);
if (createTagAllocation) {
executionEnvironment->commandStreamReceivers[0][0]->initializeTagAllocation();
}

View File

@@ -98,7 +98,7 @@ std::unique_ptr<TbxExecutionEnvironment> getEnvironment(bool createTagAllocation
executionEnvironment->commandStreamReceivers.resize(1);
executionEnvironment->commandStreamReceivers[0].push_back(std::make_unique<CsrType>(*platformDevices[0], *executionEnvironment));
executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0][0]->createMemoryManager(false, false));
executionEnvironment->initializeMemoryManager(false, false);
if (createTagAllocation) {
executionEnvironment->commandStreamReceivers[0][0]->initializeTagAllocation();
}

View File

@@ -0,0 +1,24 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
#include "runtime/os_interface/linux/drm_memory_manager.h"
#include "runtime/os_interface/linux/os_interface.h"
#include "runtime/os_interface/os_interface.h"
#include "unit_tests/libult/create_command_stream.h"
namespace OCLRT {
bool overrideMemoryManagerCreation = true;
std::unique_ptr<MemoryManager> MemoryManager::createMemoryManager(bool enable64KBpages, bool enableLocalMemory, ExecutionEnvironment &executionEnvironment) {
if (overrideMemoryManagerCreation) {
return std::make_unique<OsAgnosticMemoryManager>(enable64KBpages, enableLocalMemory, executionEnvironment);
}
return std::make_unique<DrmMemoryManager>(executionEnvironment.osInterface->get()->getDrm(), gemCloseWorkerMode::gemCloseWorkerInactive, DebugManager.flags.EnableForcePin.get(), true, executionEnvironment);
}
} // namespace OCLRT

View File

@@ -31,7 +31,7 @@ HWTEST_F(DrmCommandStreamMMTest, MMwithPinBB) {
DrmCommandStreamReceiver<FamilyType> csr(*platformDevices[0], executionEnvironment,
gemCloseWorkerMode::gemCloseWorkerInactive);
auto memoryManager = static_cast<DrmMemoryManager *>(csr.createMemoryManager(false, false));
auto memoryManager = new DrmMemoryManager(executionEnvironment.osInterface->get()->getDrm(), gemCloseWorkerInactive, DebugManager.flags.EnableForcePin.get(), true, executionEnvironment);
executionEnvironment.memoryManager.reset(memoryManager);
ASSERT_NE(nullptr, memoryManager);
EXPECT_NE(nullptr, memoryManager->getPinBB());
@@ -50,7 +50,7 @@ HWTEST_F(DrmCommandStreamMMTest, givenForcePinDisabledWhenMemoryManagerIsCreated
DrmCommandStreamReceiver<FamilyType> csr(*platformDevices[0], executionEnvironment,
gemCloseWorkerMode::gemCloseWorkerInactive);
auto memoryManager = static_cast<DrmMemoryManager *>(csr.createMemoryManager(false, false));
auto memoryManager = new DrmMemoryManager(executionEnvironment.osInterface->get()->getDrm(), gemCloseWorkerInactive, DebugManager.flags.EnableForcePin.get(), true, executionEnvironment);
executionEnvironment.memoryManager.reset(memoryManager);
ASSERT_NE(nullptr, memoryManager);
EXPECT_NE(nullptr, memoryManager->getPinBB());

View File

@@ -54,7 +54,7 @@ class DrmCommandStreamFixture {
// Memory manager creates pinBB with ioctl, expect one call
EXPECT_CALL(*mock, ioctl(::testing::_, ::testing::_))
.Times(1);
memoryManager = static_cast<DrmMemoryManager *>(csr->createMemoryManager(false, false));
memoryManager = new DrmMemoryManager(executionEnvironment.osInterface->get()->getDrm(), gemCloseWorkerActive, DebugManager.flags.EnableForcePin.get(), true, executionEnvironment);
executionEnvironment.memoryManager.reset(memoryManager);
::testing::Mock::VerifyAndClearExpectations(mock.get());
@@ -577,7 +577,7 @@ class DrmCommandStreamEnhancedFixture
tCsr = new TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>(*executionEnvironment);
csr = tCsr;
ASSERT_NE(nullptr, csr);
mm = reinterpret_cast<DrmMemoryManager *>(csr->createMemoryManager(false, false));
mm = new DrmMemoryManager(executionEnvironment->osInterface->get()->getDrm(), gemCloseWorkerInactive, DebugManager.flags.EnableForcePin.get(), true, *executionEnvironment);
ASSERT_NE(nullptr, mm);
executionEnvironment->memoryManager.reset(mm);
device.reset(MockDevice::create<MockDevice>(platformDevices[0], executionEnvironment, 0u));

View File

@@ -0,0 +1,24 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
#include "runtime/os_interface/os_interface.h"
#include "runtime/os_interface/windows/os_interface.h"
#include "runtime/os_interface/windows/wddm_memory_manager.h"
#include "unit_tests/libult/create_command_stream.h"
namespace OCLRT {
bool overrideMemoryManagerCreation = true;
std::unique_ptr<MemoryManager> MemoryManager::createMemoryManager(bool enable64KBpages, bool enableLocalMemory, ExecutionEnvironment &executionEnvironment) {
if (overrideMemoryManagerCreation) {
return std::make_unique<OsAgnosticMemoryManager>(enable64KBpages, enableLocalMemory, executionEnvironment);
}
return std::make_unique<WddmMemoryManager>(enable64KBpages, enableLocalMemory, executionEnvironment.osInterface->get()->getWddm(), executionEnvironment);
}
} // namespace OCLRT

View File

@@ -124,7 +124,7 @@ class WddmCommandStreamWithMockGdiFixture {
ASSERT_NE(wddm, nullptr);
DebugManager.flags.CsrDispatchMode.set(static_cast<uint32_t>(DispatchMode::ImmediateDispatch));
this->csr = new MockWddmCsr<DEFAULT_TEST_FAMILY_NAME>(*platformDevices[0], *executionEnvironment);
memoryManager = csr->createMemoryManager(false, false);
memoryManager = new WddmMemoryManager(false, false, wddm, *executionEnvironment);
ASSERT_NE(nullptr, memoryManager);
executionEnvironment->memoryManager.reset(memoryManager);
device = std::unique_ptr<MockDevice>(Device::create<MockDevice>(platformDevices[0], executionEnvironment, 0u));
@@ -245,7 +245,7 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOf
executionEnvironment->commandStreamReceivers.resize(1);
executionEnvironment->commandStreamReceivers[0].push_back(
std::make_unique<MockWddmCsr<DEFAULT_TEST_FAMILY_NAME>>(hwInfo[0], *executionEnvironment));
executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0][0]->createMemoryManager(false, false));
executionEnvironment->memoryManager.reset(new WddmMemoryManager(false, false, wddm, *executionEnvironment));
executionEnvironment->commandStreamReceivers[0][0]->overrideDispatchPolicy(DispatchMode::ImmediateDispatch);
OsContextWin osContext(*wddm, 0u, 1, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionHelper::getDefaultPreemptionMode(*hwInfo));
executionEnvironment->commandStreamReceivers[0][0]->setupContext(osContext);
@@ -270,7 +270,7 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOn
executionEnvironment->commandStreamReceivers.resize(1);
executionEnvironment->commandStreamReceivers[0].push_back(std::make_unique<MockWddmCsr<DEFAULT_TEST_FAMILY_NAME>>(hwInfo[0],
*executionEnvironment));
executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0][0]->createMemoryManager(false, false));
executionEnvironment->memoryManager.reset(new WddmMemoryManager(false, false, wddm, *executionEnvironment));
executionEnvironment->commandStreamReceivers[0][0]->overrideDispatchPolicy(DispatchMode::ImmediateDispatch);
OsContextWin osContext(*wddm, 0u, 1, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionHelper::getDefaultPreemptionMode(*hwInfo));
executionEnvironment->commandStreamReceivers[0][0]->setupContext(osContext);
@@ -886,7 +886,7 @@ HWTEST_F(WddmCsrCompressionTests, givenEnabledCompressionWhenFlushingThenInitTra
auto mockWddmCsr = new MockWddmCsr<FamilyType>(hwInfo[0], *executionEnvironment);
mockWddmCsr->createPageTableManager();
mockWddmCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch);
executionEnvironment->memoryManager.reset(mockWddmCsr->createMemoryManager(false, false));
executionEnvironment->memoryManager.reset(new WddmMemoryManager(false, false, executionEnvironment->osInterface->get()->getWddm(), *executionEnvironment));
auto mockMngr = reinterpret_cast<MockGmmPageTableMngr *>(myMockWddm->getPageTableManager());
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(hwInfo, executionEnvironment, 0u));
@@ -928,7 +928,7 @@ HWTEST_F(WddmCsrCompressionTests, givenDisabledCompressionWhenFlushingThenDontIn
auto mockWddmCsr = new MockWddmCsr<FamilyType>(hwInfo[0], *executionEnvironment);
mockWddmCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch);
executionEnvironment->memoryManager.reset(mockWddmCsr->createMemoryManager(false, false));
executionEnvironment->memoryManager.reset(new WddmMemoryManager(false, false, executionEnvironment->osInterface->get()->getWddm(), *executionEnvironment));
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(hwInfo, executionEnvironment, 0u));
device->resetCommandStreamReceiver(mockWddmCsr);

View File

@@ -1,12 +1,11 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "unit_tests/mocks/mock_wddm.h"
#include "unit_tests/mocks/mock_wddm_interface23.h"
namespace OCLRT {
Wddm *Wddm::createWddm() {

View File

@@ -23,6 +23,7 @@ if(WIN32)
)
target_sources(igdrcl_tbx_tests PRIVATE
${IGDRCL_SOURCE_DIR}/runtime/dll/windows/options.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/windows/create_wddm_memory_manager.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/windows/sys_calls.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/windows/wddm_calls.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/windows/wddm_create.cpp
@@ -32,6 +33,7 @@ else()
target_sources(igdrcl_tbx_tests PRIVATE
${IGDRCL_SOURCE_DIR}/runtime/dll/linux/allocator_helper.cpp
${IGDRCL_SOURCE_DIR}/runtime/dll/linux/options.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/linux/create_drm_memory_manager.cpp
)
endif()

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -15,7 +15,7 @@ using namespace OCLRT;
namespace OCLRT {
bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment);
}
} // namespace OCLRT
TEST(CSRTests, getDevices) {
HardwareInfo *hwInfo = nullptr;

View File

@@ -15,7 +15,7 @@ LogAllocationMemoryPool = 0
LogMemoryObject = 0
ForceLinearImages = 0
ForceSLML3Config = 0
SetCommandStreamReceiver = 0
SetCommandStreamReceiver = -1
ForceOCLVersion = 0
Force32bitAddressing = 0
EnableVaLibCalls = 1