mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 07:14:10 +08:00
Move initialization of AubCenter to RootDeviceEnvironment
make RootDeviceEnvironments vector of unique_ptr Related-To: NEO-3857 Change-Id: I23998502198307c8535cdd5c9c4af5223a5d69a5 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
8cc6a65e69
commit
3e1b15c31d
@@ -5,6 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/execution_environment/root_device_environment.h"
|
||||
#include "runtime/execution_environment/execution_environment.h"
|
||||
#include "runtime/platform/platform.h"
|
||||
#include "unit_tests/api/cl_api_tests.h"
|
||||
@@ -28,7 +29,7 @@ TEST_F(clAddCommentToAubTest, givenNullptrCommentWhenAddCommentToAubThenErrorIsR
|
||||
}
|
||||
|
||||
TEST_F(clAddCommentToAubTest, givenAubCenterAndProperCommentButNullptrAubManagerWhenAddCommentToAubThenErrorIsReturned) {
|
||||
pPlatform->peekExecutionEnvironment()->rootDeviceEnvironments[0].aubCenter.reset(new MockAubCenter());
|
||||
pPlatform->peekExecutionEnvironment()->rootDeviceEnvironments[0]->aubCenter.reset(new MockAubCenter());
|
||||
|
||||
auto retVal = clAddCommentINTEL(pPlatform, "comment");
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
@@ -46,7 +47,7 @@ TEST_F(clAddCommentToAubTest, givenProperCommentAubCenterAndAubManagerWhenAddCom
|
||||
auto mockAubCenter = new MockAubCenter();
|
||||
auto mockAubManager = new AubManagerCommentMock;
|
||||
mockAubCenter->aubManager.reset(mockAubManager);
|
||||
pPlatform->peekExecutionEnvironment()->rootDeviceEnvironments[0].aubCenter.reset(mockAubCenter);
|
||||
pPlatform->peekExecutionEnvironment()->rootDeviceEnvironments[0]->aubCenter.reset(mockAubCenter);
|
||||
|
||||
EXPECT_FALSE(mockAubManager->addCommentCalled);
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ TEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenTypeIsChe
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenItIsCreatedThenAubManagerAndHardwareContextAreNull) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.UseAubStream.set(false);
|
||||
MockExecutionEnvironment executionEnvironment(platformDevices[0], false);
|
||||
MockExecutionEnvironment executionEnvironment(platformDevices[0], false, 1);
|
||||
executionEnvironment.initializeMemoryManager();
|
||||
|
||||
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, executionEnvironment, 0);
|
||||
@@ -118,40 +118,40 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipl
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipleInstancesAreCreatedThenTheyUseTheSameFileStream) {
|
||||
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex());
|
||||
auto streamProvider1 = pDevice->executionEnvironment->rootDeviceEnvironments[0].aubCenter->getStreamProvider();
|
||||
auto streamProvider1 = pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter->getStreamProvider();
|
||||
EXPECT_NE(nullptr, streamProvider1);
|
||||
auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex());
|
||||
auto streamProvider2 = pDevice->executionEnvironment->rootDeviceEnvironments[0].aubCenter->getStreamProvider();
|
||||
auto streamProvider2 = pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter->getStreamProvider();
|
||||
EXPECT_NE(nullptr, streamProvider2);
|
||||
EXPECT_EQ(streamProvider1, streamProvider2);
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipleInstancesAreCreatedThenTheyUseTheSamePhysicalAddressAllocator) {
|
||||
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex());
|
||||
auto physicalAddressAlocator1 = pDevice->executionEnvironment->rootDeviceEnvironments[0].aubCenter->getPhysicalAddressAllocator();
|
||||
auto physicalAddressAlocator1 = pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter->getPhysicalAddressAllocator();
|
||||
EXPECT_NE(nullptr, physicalAddressAlocator1);
|
||||
auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex());
|
||||
auto physicalAddressAlocator2 = pDevice->executionEnvironment->rootDeviceEnvironments[0].aubCenter->getPhysicalAddressAllocator();
|
||||
auto physicalAddressAlocator2 = pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter->getPhysicalAddressAllocator();
|
||||
EXPECT_NE(nullptr, physicalAddressAlocator2);
|
||||
EXPECT_EQ(physicalAddressAlocator1, physicalAddressAlocator2);
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipleInstancesAreCreatedThenTheyUseTheSameAddressMapper) {
|
||||
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex());
|
||||
auto addressMapper1 = pDevice->executionEnvironment->rootDeviceEnvironments[0].aubCenter->getAddressMapper();
|
||||
auto addressMapper1 = pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter->getAddressMapper();
|
||||
EXPECT_NE(nullptr, addressMapper1);
|
||||
auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex());
|
||||
auto addressMapper2 = pDevice->executionEnvironment->rootDeviceEnvironments[0].aubCenter->getAddressMapper();
|
||||
auto addressMapper2 = pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter->getAddressMapper();
|
||||
EXPECT_NE(nullptr, addressMapper2);
|
||||
EXPECT_EQ(addressMapper1, addressMapper2);
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipleInstancesAreCreatedThenTheyUseTheSameSubCaptureCommon) {
|
||||
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex());
|
||||
auto subCaptureCommon1 = pDevice->executionEnvironment->rootDeviceEnvironments[0].aubCenter->getSubCaptureCommon();
|
||||
auto subCaptureCommon1 = pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter->getSubCaptureCommon();
|
||||
EXPECT_NE(nullptr, subCaptureCommon1);
|
||||
auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex());
|
||||
auto subCaptureCommon2 = pDevice->executionEnvironment->rootDeviceEnvironments[0].aubCenter->getSubCaptureCommon();
|
||||
auto subCaptureCommon2 = pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter->getSubCaptureCommon();
|
||||
EXPECT_NE(nullptr, subCaptureCommon2);
|
||||
EXPECT_EQ(subCaptureCommon1, subCaptureCommon2);
|
||||
}
|
||||
@@ -161,7 +161,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWithAubMana
|
||||
MockAubManager *mockManager = new MockAubManager();
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, fileName, CommandStreamReceiverType::CSR_AUB);
|
||||
mockAubCenter->aubManager = std::unique_ptr<MockAubManager>(mockManager);
|
||||
pDevice->executionEnvironment->rootDeviceEnvironments[0].aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
|
||||
pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
|
||||
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(static_cast<AUBCommandStreamReceiverHw<FamilyType> *>(AUBCommandStreamReceiver::create(fileName, true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex())));
|
||||
ASSERT_NE(nullptr, aubCsr);
|
||||
@@ -177,7 +177,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenOsContextIsSetThenCreateH
|
||||
MockAubManager *mockManager = new MockAubManager();
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, fileName, CommandStreamReceiverType::CSR_AUB);
|
||||
mockAubCenter->aubManager = std::unique_ptr<MockAubManager>(mockManager);
|
||||
pDevice->executionEnvironment->rootDeviceEnvironments[0].aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
|
||||
pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
|
||||
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(static_cast<AUBCommandStreamReceiverHw<FamilyType> *>(AUBCommandStreamReceiver::create(fileName, true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex())));
|
||||
EXPECT_EQ(nullptr, aubCsr->hardwareContextController.get());
|
||||
@@ -194,7 +194,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenLowPriorityOsContextIsSet
|
||||
MockAubManager *mockManager = new MockAubManager();
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, fileName, CommandStreamReceiverType::CSR_AUB);
|
||||
mockAubCenter->aubManager = std::unique_ptr<MockAubManager>(mockManager);
|
||||
pDevice->executionEnvironment->rootDeviceEnvironments[0].aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
|
||||
pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
|
||||
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(static_cast<AUBCommandStreamReceiverHw<FamilyType> *>(AUBCommandStreamReceiver::create(fileName, true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex())));
|
||||
EXPECT_EQ(nullptr, aubCsr->hardwareContextController.get());
|
||||
@@ -251,7 +251,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWhenMakeResidentC
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipleInstancesInitializeTheirEnginesThenUniqueGlobalGttAdressesAreGenerated) {
|
||||
pDevice->executionEnvironment->rootDeviceEnvironments[0].aubCenter.reset(new AubCenter());
|
||||
pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter.reset(new AubCenter());
|
||||
|
||||
auto engineInstance = HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances()[0];
|
||||
MockOsContext osContext(0, 1, engineInstance, PreemptionMode::Disabled, false);
|
||||
|
||||
@@ -648,7 +648,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMemoryIsCalledThenGraphicsAllocationSizeIsReadCorrectly) {
|
||||
pDevice->executionEnvironment->rootDeviceEnvironments[0].aubCenter.reset(new AubCenter());
|
||||
pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter.reset(new AubCenter());
|
||||
|
||||
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", false, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex());
|
||||
aubCsr->setupContext(*pDevice->getDefaultEngine().osContext);
|
||||
@@ -896,7 +896,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenCompressedGraphicsAllocationWritabl
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "aubfile", CommandStreamReceiverType::CSR_AUB);
|
||||
mockAubCenter->aubManager = std::make_unique<MockAubManager>();
|
||||
|
||||
pDevice->executionEnvironment->rootDeviceEnvironments[0].aubCenter.reset(mockAubCenter);
|
||||
pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter.reset(mockAubCenter);
|
||||
MockAubCsr<FamilyType> aubCsr("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex());
|
||||
MockOsContext osContext(0, 1, aub_stream::ENGINE_RCS, PreemptionMode::Disabled, false);
|
||||
aubCsr.setupContext(osContext);
|
||||
@@ -1032,3 +1032,21 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWritableWhenDumpA
|
||||
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation);
|
||||
}
|
||||
|
||||
using SimulatedCsrTest = ::testing::Test;
|
||||
HWTEST_F(SimulatedCsrTest, givenAubCsrTypeWhenCreateCommandStreamReceiverThenProperAubCenterIsInitalized) {
|
||||
uint32_t expectedRootDeviceIndex = 10;
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
executionEnvironment.initializeMemoryManager();
|
||||
executionEnvironment.prepareRootDeviceEnvironments(expectedRootDeviceIndex + 2);
|
||||
|
||||
auto rootDeviceEnvironment = new MockRootDeviceEnvironment(executionEnvironment);
|
||||
executionEnvironment.rootDeviceEnvironments[expectedRootDeviceIndex].reset(rootDeviceEnvironment);
|
||||
|
||||
EXPECT_EQ(nullptr, executionEnvironment.rootDeviceEnvironments[expectedRootDeviceIndex]->aubCenter.get());
|
||||
EXPECT_FALSE(rootDeviceEnvironment->initAubCenterCalled);
|
||||
|
||||
auto csr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, executionEnvironment, expectedRootDeviceIndex);
|
||||
EXPECT_TRUE(rootDeviceEnvironment->initAubCenterCalled);
|
||||
EXPECT_NE(nullptr, executionEnvironment.rootDeviceEnvironments[expectedRootDeviceIndex]->aubCenter.get());
|
||||
}
|
||||
|
||||
@@ -227,6 +227,7 @@ HWTEST_F(CommandStreamReceiverTest, givenCsrWhenAllocateHeapMemoryIsCalledThenHe
|
||||
|
||||
TEST(CommandStreamReceiverSimpleTest, givenCSRWithoutTagAllocationWhenGetTagAllocationIsCalledThenNullptrIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
executionEnvironment.prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment.initializeMemoryManager();
|
||||
MockCommandStreamReceiver csr(executionEnvironment, 0);
|
||||
EXPECT_EQ(nullptr, csr.getTagAllocation());
|
||||
@@ -337,6 +338,7 @@ TEST(CommandStreamReceiverSimpleTest, givenNullHardwareDebugModeWhenInitializeTa
|
||||
|
||||
TEST(CommandStreamReceiverSimpleTest, givenVariousDataSetsWhenVerifyingMemoryThenCorrectValueIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
executionEnvironment.prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment.initializeMemoryManager();
|
||||
MockCommandStreamReceiver csr(executionEnvironment, 0);
|
||||
|
||||
@@ -593,6 +595,7 @@ HWTEST_P(CommandStreamReceiverWithAubSubCaptureTest, givenCommandStreamReceiverW
|
||||
bool isActive = status.second;
|
||||
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
executionEnvironment.prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment.initializeMemoryManager();
|
||||
MyMockCsr mockCsr(executionEnvironment, 0);
|
||||
|
||||
@@ -615,20 +618,22 @@ INSTANTIATE_TEST_CASE_P(
|
||||
testing::ValuesIn(aubSubCaptureStatus));
|
||||
|
||||
TEST(CommandStreamReceiverDeviceIndexTest, givenCsrWithOsContextWhenGetDeviceIndexThenGetHighestEnabledBitInDeviceBitfield) {
|
||||
ExecutionEnvironment executioneEnvironment;
|
||||
executioneEnvironment.initializeMemoryManager();
|
||||
MockCommandStreamReceiver csr(executioneEnvironment, 0);
|
||||
auto osContext = executioneEnvironment.memoryManager->createAndRegisterOsContext(&csr, aub_stream::EngineType::ENGINE_RCS, 0b10, PreemptionMode::Disabled, false);
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
executionEnvironment.prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment.initializeMemoryManager();
|
||||
MockCommandStreamReceiver csr(executionEnvironment, 0);
|
||||
auto osContext = executionEnvironment.memoryManager->createAndRegisterOsContext(&csr, aub_stream::EngineType::ENGINE_RCS, 0b10, PreemptionMode::Disabled, false);
|
||||
|
||||
csr.setupContext(*osContext);
|
||||
EXPECT_EQ(1u, csr.getDeviceIndex());
|
||||
}
|
||||
|
||||
TEST(CommandStreamReceiverDeviceIndexTest, givenOsContextWithNoDeviceBitfieldWhenGettingDeviceIndexThenZeroIsReturned) {
|
||||
ExecutionEnvironment executioneEnvironment;
|
||||
executioneEnvironment.initializeMemoryManager();
|
||||
MockCommandStreamReceiver csr(executioneEnvironment, 0);
|
||||
auto osContext = executioneEnvironment.memoryManager->createAndRegisterOsContext(&csr, aub_stream::EngineType::ENGINE_RCS, 0b00, PreemptionMode::Disabled, false);
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
executionEnvironment.prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment.initializeMemoryManager();
|
||||
MockCommandStreamReceiver csr(executionEnvironment, 0);
|
||||
auto osContext = executionEnvironment.memoryManager->createAndRegisterOsContext(&csr, aub_stream::EngineType::ENGINE_RCS, 0b00, PreemptionMode::Disabled, false);
|
||||
|
||||
csr.setupContext(*osContext);
|
||||
EXPECT_EQ(0u, csr.getDeviceIndex());
|
||||
@@ -639,7 +644,7 @@ TEST(CommandStreamReceiverRootDeviceIndexTest, commandStreamGraphicsAllocationsH
|
||||
|
||||
// Setup
|
||||
auto executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
executionEnvironment->rootDeviceEnvironments.resize(2 * expectedRootDeviceIndex);
|
||||
executionEnvironment->prepareRootDeviceEnvironments(2 * expectedRootDeviceIndex);
|
||||
auto memoryManager = new MockMemoryManager(false, false, *executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(executionEnvironment, expectedRootDeviceIndex));
|
||||
|
||||
@@ -153,7 +153,7 @@ HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenAubManagerAvailableWhe
|
||||
MockAubManager *mockManager = new MockAubManager();
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(*platformDevices, false, fileName, CommandStreamReceiverType::CSR_TBX_WITH_AUB);
|
||||
mockAubCenter->aubManager = std::unique_ptr<MockAubManager>(mockManager);
|
||||
executionEnvironment->rootDeviceEnvironments[0].aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
|
||||
|
||||
CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<FamilyType>> csrWithAubDump("aubfile", *executionEnvironment, 0);
|
||||
ASSERT_EQ(nullptr, csrWithAubDump.aubCSR);
|
||||
@@ -167,17 +167,51 @@ HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenAubManagerAvailableWhe
|
||||
|
||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
executionEnvironment->initializeMemoryManager();
|
||||
executionEnvironment->rootDeviceEnvironments[0].aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
|
||||
|
||||
CommandStreamReceiverWithAUBDump<UltCommandStreamReceiver<FamilyType>> csrWithAubDump("aubfile", *executionEnvironment, 0);
|
||||
ASSERT_NE(nullptr, csrWithAubDump.aubCSR);
|
||||
}
|
||||
|
||||
using SimulatedCsrTest = ::testing::Test;
|
||||
HWTEST_F(SimulatedCsrTest, givenHwWithAubDumpCsrTypeWhenCreateCommandStreamReceiverThenProperAubCenterIsInitialized) {
|
||||
uint32_t expectedRootDeviceIndex = 10;
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
executionEnvironment.initializeMemoryManager();
|
||||
executionEnvironment.prepareRootDeviceEnvironments(expectedRootDeviceIndex + 2);
|
||||
|
||||
auto rootDeviceEnvironment = new MockRootDeviceEnvironment(executionEnvironment);
|
||||
executionEnvironment.rootDeviceEnvironments[expectedRootDeviceIndex].reset(rootDeviceEnvironment);
|
||||
|
||||
EXPECT_EQ(nullptr, executionEnvironment.rootDeviceEnvironments[expectedRootDeviceIndex]->aubCenter.get());
|
||||
EXPECT_FALSE(rootDeviceEnvironment->initAubCenterCalled);
|
||||
|
||||
auto csr = std::make_unique<CommandStreamReceiverWithAUBDump<UltCommandStreamReceiver<FamilyType>>>("", executionEnvironment, expectedRootDeviceIndex);
|
||||
EXPECT_TRUE(rootDeviceEnvironment->initAubCenterCalled);
|
||||
EXPECT_NE(nullptr, rootDeviceEnvironment->aubCenter.get());
|
||||
}
|
||||
HWTEST_F(SimulatedCsrTest, givenTbxWithAubDumpCsrTypeWhenCreateCommandStreamReceiverThenProperAubCenterIsInitialized) {
|
||||
uint32_t expectedRootDeviceIndex = 10;
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
executionEnvironment.initializeMemoryManager();
|
||||
executionEnvironment.prepareRootDeviceEnvironments(expectedRootDeviceIndex + 2);
|
||||
|
||||
auto rootDeviceEnvironment = new MockRootDeviceEnvironment(executionEnvironment);
|
||||
executionEnvironment.rootDeviceEnvironments[expectedRootDeviceIndex].reset(rootDeviceEnvironment);
|
||||
|
||||
EXPECT_EQ(nullptr, executionEnvironment.rootDeviceEnvironments[expectedRootDeviceIndex]->aubCenter.get());
|
||||
EXPECT_FALSE(rootDeviceEnvironment->initAubCenterCalled);
|
||||
|
||||
auto csr = std::make_unique<CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<FamilyType>>>("", executionEnvironment, expectedRootDeviceIndex);
|
||||
EXPECT_TRUE(rootDeviceEnvironment->initAubCenterCalled);
|
||||
EXPECT_NE(nullptr, rootDeviceEnvironment->aubCenter.get());
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenNullAubManagerAvailableWhenTbxCsrWithAubDumpIsCreatedThenAubCsrIsCreated) {
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter();
|
||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
executionEnvironment->initializeMemoryManager();
|
||||
executionEnvironment->rootDeviceEnvironments[0].aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
|
||||
|
||||
CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<FamilyType>> csrWithAubDump("aubfile", *executionEnvironment, 0);
|
||||
EXPECT_NE(nullptr, csrWithAubDump.aubCSR);
|
||||
|
||||
@@ -25,7 +25,7 @@ HWTEST_P(CreateCommandStreamReceiverTest, givenCreateCommandStreamWhenCsrIsSetTo
|
||||
DebugManagerStateRestore stateRestorer;
|
||||
HardwareInfo *hwInfo = nullptr;
|
||||
ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo);
|
||||
MockAubCenterFixture::setMockAubCenter(executionEnvironment);
|
||||
MockAubCenterFixture::setMockAubCenter(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
CommandStreamReceiverType csrType = GetParam();
|
||||
|
||||
|
||||
@@ -359,7 +359,7 @@ TEST(ExperimentalCommandBufferRootDeviceIndexTest, experimentalCommandBufferGrap
|
||||
|
||||
// Setup
|
||||
auto executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
executionEnvironment->rootDeviceEnvironments.resize(2 * expectedRootDeviceIndex);
|
||||
executionEnvironment->prepareRootDeviceEnvironments(2 * expectedRootDeviceIndex);
|
||||
auto memoryManager = new MockMemoryManager(false, false, *executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(executionEnvironment, expectedRootDeviceIndex));
|
||||
|
||||
@@ -59,7 +59,7 @@ struct TbxFixture : public TbxCommandStreamFixture,
|
||||
|
||||
void SetUp() {
|
||||
DeviceFixture::SetUp();
|
||||
setMockAubCenter(pDevice->getExecutionEnvironment());
|
||||
setMockAubCenter(*pDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]);
|
||||
TbxCommandStreamFixture::SetUp(pDevice);
|
||||
MockAubCenterFixture::SetUp();
|
||||
}
|
||||
@@ -460,11 +460,11 @@ HWTEST_F(TbxCommandSteamSimpleTest, givenTbxCommandStreamReceiverWhenPhysicalAdd
|
||||
HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenItIsCreatedWithUseAubStreamFalseThenDontInitializeAubManager) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.UseAubStream.set(false);
|
||||
MockExecutionEnvironment executionEnvironment(platformDevices[0], false);
|
||||
MockExecutionEnvironment executionEnvironment(platformDevices[0], false, 1);
|
||||
executionEnvironment.initializeMemoryManager();
|
||||
|
||||
auto tbxCsr = std::make_unique<TbxCommandStreamReceiverHw<FamilyType>>(executionEnvironment, 0);
|
||||
EXPECT_EQ(nullptr, executionEnvironment.rootDeviceEnvironments[0].aubCenter->getAubManager());
|
||||
EXPECT_EQ(nullptr, executionEnvironment.rootDeviceEnvironments[0]->aubCenter->getAubManager());
|
||||
}
|
||||
|
||||
HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenFlushIsCalledThenItShouldCallTheExpectedHwContextFunctions) {
|
||||
@@ -559,7 +559,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenHardwareContextIsCreatedThenTbxSt
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(pDevice->executionEnvironment->getHardwareInfo(), false, "", CommandStreamReceiverType::CSR_TBX);
|
||||
mockAubCenter->aubManager = std::unique_ptr<MockAubManager>(mockManager);
|
||||
|
||||
pDevice->executionEnvironment->rootDeviceEnvironments[0].aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
|
||||
pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
|
||||
auto tbxCsr = std::unique_ptr<TbxCommandStreamReceiverHw<FamilyType>>(reinterpret_cast<TbxCommandStreamReceiverHw<FamilyType> *>(
|
||||
TbxCommandStreamReceiverHw<FamilyType>::create("", false, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex())));
|
||||
|
||||
@@ -575,7 +575,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenOsContextIsSetThenCreateHardwareC
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(hwInfo, false, fileName, CommandStreamReceiverType::CSR_TBX);
|
||||
mockAubCenter->aubManager = std::unique_ptr<MockAubManager>(mockManager);
|
||||
|
||||
pDevice->executionEnvironment->rootDeviceEnvironments[0].aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
|
||||
pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
|
||||
|
||||
std::unique_ptr<TbxCommandStreamReceiverHw<FamilyType>> tbxCsr(reinterpret_cast<TbxCommandStreamReceiverHw<FamilyType> *>(TbxCommandStreamReceiver::create(fileName, false, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex())));
|
||||
EXPECT_EQ(nullptr, tbxCsr->hardwareContextController.get());
|
||||
@@ -598,12 +598,13 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenCreatedWithAubDumpThenFileNameIsE
|
||||
executionEnvironment.setHwInfo(*platformDevices);
|
||||
executionEnvironment.initializeMemoryManager();
|
||||
|
||||
setMockAubCenter(&executionEnvironment, CommandStreamReceiverType::CSR_TBX);
|
||||
auto rootDeviceEnvironment = static_cast<MockRootDeviceEnvironment *>(executionEnvironment.rootDeviceEnvironments[0].get());
|
||||
setMockAubCenter(*rootDeviceEnvironment, CommandStreamReceiverType::CSR_TBX);
|
||||
|
||||
auto fullName = AUBCommandStreamReceiver::createFullFilePath(*platformDevices[0], "aubfile");
|
||||
|
||||
std::unique_ptr<TbxCommandStreamReceiverHw<FamilyType>> tbxCsr(reinterpret_cast<TbxCommandStreamReceiverHw<FamilyType> *>(TbxCommandStreamReceiver::create("aubfile", true, executionEnvironment, 0)));
|
||||
EXPECT_STREQ(fullName.c_str(), executionEnvironment.aubFileNameReceived.c_str());
|
||||
EXPECT_STREQ(fullName.c_str(), rootDeviceEnvironment->aubFileNameReceived.c_str());
|
||||
}
|
||||
|
||||
HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenCreatedWithAubDumpThenOpenIsCalledOnAubManagerToOpenFileStream) {
|
||||
@@ -616,6 +617,24 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenCreatedWithAubDumpThenOpenIsCalle
|
||||
EXPECT_TRUE(tbxCsrWithAubDump->aubManager->isOpen());
|
||||
}
|
||||
|
||||
using SimulatedCsrTest = ::testing::Test;
|
||||
HWTEST_F(SimulatedCsrTest, givenTbxCsrTypeWhenCreateCommandStreamReceiverThenProperAubCenterIsInitalized) {
|
||||
uint32_t expectedRootDeviceIndex = 10;
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
executionEnvironment.initializeMemoryManager();
|
||||
executionEnvironment.prepareRootDeviceEnvironments(expectedRootDeviceIndex + 2);
|
||||
|
||||
auto rootDeviceEnvironment = new MockRootDeviceEnvironment(executionEnvironment);
|
||||
executionEnvironment.rootDeviceEnvironments[expectedRootDeviceIndex].reset(rootDeviceEnvironment);
|
||||
|
||||
EXPECT_EQ(nullptr, executionEnvironment.rootDeviceEnvironments[expectedRootDeviceIndex]->aubCenter.get());
|
||||
EXPECT_FALSE(rootDeviceEnvironment->initAubCenterCalled);
|
||||
|
||||
auto csr = std::make_unique<TbxCommandStreamReceiverHw<FamilyType>>(executionEnvironment, expectedRootDeviceIndex);
|
||||
EXPECT_NE(nullptr, executionEnvironment.rootDeviceEnvironments[expectedRootDeviceIndex]->aubCenter.get());
|
||||
EXPECT_TRUE(rootDeviceEnvironment->initAubCenterCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenCreatedWithAubDumpInSubCaptureModeThenCreateSubCaptureManagerAndGenerateSubCaptureFileName) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.AUBDumpSubCaptureMode.set(static_cast<int32_t>(AubSubCaptureManager::SubCaptureMode::Filter));
|
||||
@@ -636,7 +655,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenCreatedWithAubDumpInSubCaptureMod
|
||||
}
|
||||
|
||||
HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenCreatedWithAubDumpSeveralTimesThenOpenIsCalledOnAubManagerOnceOnly) {
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices, true);
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices, true, 1);
|
||||
executionEnvironment.setHwInfo(*platformDevices);
|
||||
executionEnvironment.initializeMemoryManager();
|
||||
|
||||
@@ -646,7 +665,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenCreatedWithAubDumpSeveralTimesThe
|
||||
auto tbxCsrWithAubDump2 = std::unique_ptr<TbxCommandStreamReceiverHw<FamilyType>>(reinterpret_cast<TbxCommandStreamReceiverHw<FamilyType> *>(
|
||||
TbxCommandStreamReceiverHw<FamilyType>::create("aubfile", true, executionEnvironment, 0)));
|
||||
|
||||
auto mockManager = reinterpret_cast<MockAubManager *>(executionEnvironment.rootDeviceEnvironments[0].aubCenter->getAubManager());
|
||||
auto mockManager = reinterpret_cast<MockAubManager *>(executionEnvironment.rootDeviceEnvironments[0]->aubCenter->getAubManager());
|
||||
EXPECT_EQ(1u, mockManager->openCalledCnt);
|
||||
}
|
||||
|
||||
@@ -667,7 +686,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrInSubCaptureModeWhenFlushIsCalledAndS
|
||||
|
||||
tbxCsr.flush(batchBuffer, allocationsForResidency);
|
||||
|
||||
auto mockAubManager = reinterpret_cast<MockAubManager *>(pDevice->executionEnvironment->rootDeviceEnvironments[0].aubCenter->getAubManager());
|
||||
auto mockAubManager = reinterpret_cast<MockAubManager *>(pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter->getAubManager());
|
||||
EXPECT_TRUE(mockAubManager->isPaused);
|
||||
|
||||
pDevice->executionEnvironment->memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
@@ -691,7 +710,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrInSubCaptureModeWhenFlushIsCalledAndS
|
||||
|
||||
tbxCsr.flush(batchBuffer, allocationsForResidency);
|
||||
|
||||
auto mockAubManager = reinterpret_cast<MockAubManager *>(pDevice->executionEnvironment->rootDeviceEnvironments[0].aubCenter->getAubManager());
|
||||
auto mockAubManager = reinterpret_cast<MockAubManager *>(pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter->getAubManager());
|
||||
EXPECT_FALSE(mockAubManager->isPaused);
|
||||
|
||||
pDevice->executionEnvironment->memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
|
||||
@@ -197,6 +197,7 @@ TEST(DeviceGetCapsTest, givenDeviceWithMidThreadPreemptionWhenDeviceIsCreatedThe
|
||||
DebugManager.flags.ForcePreemptionMode.set((int32_t)PreemptionMode::MidThread);
|
||||
|
||||
auto executionEnvironment = new ExecutionEnvironment();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->builtins.reset(builtIns);
|
||||
auto device = std::unique_ptr<Device>(MockDevice::createWithExecutionEnvironment<MockDevice>(platformDevices[0], executionEnvironment, 0u));
|
||||
ASSERT_EQ(builtIns, device->getExecutionEnvironment()->getBuiltIns());
|
||||
@@ -817,6 +818,7 @@ TEST(DeviceGetCapsTest, GivenFlagEnabled64kbPagesWhenSetThenReturnCorrectValue)
|
||||
VariableBackup<bool> OsEnabled64kbPagesBackup(&OSInterface::osEnabled64kbPages);
|
||||
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
executionEnvironment.prepareRootDeviceEnvironments(1);
|
||||
auto &capabilityTable = executionEnvironment.getMutableHardwareInfo()->capabilityTable;
|
||||
std::unique_ptr<MemoryManager> memoryManager;
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ TEST(DeviceCreation, givenDeviceWhenItIsCreatedThenOsContextIsRegistredInMemoryM
|
||||
TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachOsContextHasUniqueId) {
|
||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
const size_t numDevices = 2;
|
||||
executionEnvironment->rootDeviceEnvironments.resize(numDevices);
|
||||
executionEnvironment->prepareRootDeviceEnvironments(numDevices);
|
||||
const auto &numGpgpuEngines = static_cast<uint32_t>(HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances().size());
|
||||
|
||||
auto device1 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(executionEnvironment, 0u));
|
||||
@@ -211,7 +211,7 @@ TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachOsContextHasU
|
||||
TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachDeviceHasSeperateDeviceIndex) {
|
||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
const size_t numDevices = 2;
|
||||
executionEnvironment->rootDeviceEnvironments.resize(numDevices);
|
||||
executionEnvironment->prepareRootDeviceEnvironments(numDevices);
|
||||
auto device = std::unique_ptr<MockDevice>(Device::create<MockDevice>(executionEnvironment, 0u));
|
||||
auto device2 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(executionEnvironment, 1u));
|
||||
|
||||
@@ -222,7 +222,7 @@ TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachDeviceHasSepe
|
||||
TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachDeviceHasSeperateCommandStreamReceiver) {
|
||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
const size_t numDevices = 2;
|
||||
executionEnvironment->rootDeviceEnvironments.resize(numDevices);
|
||||
executionEnvironment->prepareRootDeviceEnvironments(numDevices);
|
||||
const auto &numGpgpuEngines = HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances().size();
|
||||
auto device1 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(executionEnvironment, 0u));
|
||||
auto device2 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(executionEnvironment, 1u));
|
||||
@@ -268,6 +268,7 @@ HWTEST_F(DeviceHwTest, givenHwHelperInputWhenInitializingCsrThenCreatePageTableM
|
||||
localHwInfo.capabilityTable.ftrRenderCompressedImages = false;
|
||||
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
executionEnvironment.prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment.incRefInternal();
|
||||
executionEnvironment.initializeMemoryManager();
|
||||
executionEnvironment.setHwInfo(&localHwInfo);
|
||||
|
||||
@@ -83,6 +83,7 @@ TEST(SubDevicesTest, givenDeviceWithSubDevicesWhenSubDeviceCreationFailThenWhole
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.CreateMultipleSubDevices.set(10);
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
executionEnvironment.prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment.incRefInternal();
|
||||
executionEnvironment.memoryManager.reset(new FailMemoryManager(10, executionEnvironment));
|
||||
auto device = Device::create<RootDevice>(&executionEnvironment, 0u);
|
||||
|
||||
@@ -94,38 +94,41 @@ TEST(ExecutionEnvironment, givenDeviceWhenItIsDestroyedThenMemoryManagerIsStillA
|
||||
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
|
||||
}
|
||||
|
||||
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeAubCenterIsCalledThenItIsReceivesCorrectInputParams) {
|
||||
TEST(RootDeviceEnvironment, givenExecutionEnvironmentWhenInitializeAubCenterIsCalledThenItIsReceivesCorrectInputParams) {
|
||||
MockExecutionEnvironment executionEnvironment;
|
||||
executionEnvironment.setHwInfo(*platformDevices);
|
||||
executionEnvironment.initAubCenter(true, "test.aub", CommandStreamReceiverType::CSR_AUB);
|
||||
EXPECT_TRUE(executionEnvironment.initAubCenterCalled);
|
||||
EXPECT_TRUE(executionEnvironment.localMemoryEnabledReceived);
|
||||
EXPECT_STREQ(executionEnvironment.aubFileNameReceived.c_str(), "test.aub");
|
||||
auto rootDeviceEnvironment = static_cast<MockRootDeviceEnvironment *>(executionEnvironment.rootDeviceEnvironments[0].get());
|
||||
rootDeviceEnvironment->initAubCenter(true, "test.aub", CommandStreamReceiverType::CSR_AUB);
|
||||
EXPECT_TRUE(rootDeviceEnvironment->initAubCenterCalled);
|
||||
EXPECT_TRUE(rootDeviceEnvironment->localMemoryEnabledReceived);
|
||||
EXPECT_STREQ(rootDeviceEnvironment->aubFileNameReceived.c_str(), "test.aub");
|
||||
}
|
||||
|
||||
TEST(ExecutionEnvironment, givenUseAubStreamFalseWhenGetAubManagerIsCalledThenReturnNull) {
|
||||
TEST(RootDeviceEnvironment, givenUseAubStreamFalseWhenGetAubManagerIsCalledThenReturnNull) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.UseAubStream.set(false);
|
||||
|
||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
executionEnvironment->initAubCenter(false, "", CommandStreamReceiverType::CSR_AUB);
|
||||
auto aubManager = executionEnvironment->rootDeviceEnvironments[0].aubCenter->getAubManager();
|
||||
auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get();
|
||||
rootDeviceEnvironment->initAubCenter(false, "", CommandStreamReceiverType::CSR_AUB);
|
||||
auto aubManager = rootDeviceEnvironment->aubCenter->getAubManager();
|
||||
EXPECT_EQ(nullptr, aubManager);
|
||||
}
|
||||
|
||||
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeAubCenterIsCalledThenItIsInitalizedOnce) {
|
||||
TEST(RootDeviceEnvironment, givenExecutionEnvironmentWhenInitializeAubCenterIsCalledThenItIsInitalizedOnce) {
|
||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
executionEnvironment->initAubCenter(false, "", CommandStreamReceiverType::CSR_AUB);
|
||||
auto currentAubCenter = executionEnvironment->rootDeviceEnvironments[0].aubCenter.get();
|
||||
auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get();
|
||||
rootDeviceEnvironment->initAubCenter(false, "", CommandStreamReceiverType::CSR_AUB);
|
||||
auto currentAubCenter = rootDeviceEnvironment->aubCenter.get();
|
||||
EXPECT_NE(nullptr, currentAubCenter);
|
||||
auto currentAubStreamProvider = currentAubCenter->getStreamProvider();
|
||||
EXPECT_NE(nullptr, currentAubStreamProvider);
|
||||
auto currentAubFileStream = currentAubStreamProvider->getStream();
|
||||
EXPECT_NE(nullptr, currentAubFileStream);
|
||||
executionEnvironment->initAubCenter(false, "", CommandStreamReceiverType::CSR_AUB);
|
||||
EXPECT_EQ(currentAubCenter, executionEnvironment->rootDeviceEnvironments[0].aubCenter.get());
|
||||
EXPECT_EQ(currentAubStreamProvider, executionEnvironment->rootDeviceEnvironments[0].aubCenter->getStreamProvider());
|
||||
EXPECT_EQ(currentAubFileStream, executionEnvironment->rootDeviceEnvironments[0].aubCenter->getStreamProvider()->getStream());
|
||||
rootDeviceEnvironment->initAubCenter(false, "", CommandStreamReceiverType::CSR_AUB);
|
||||
EXPECT_EQ(currentAubCenter, rootDeviceEnvironment->aubCenter.get());
|
||||
EXPECT_EQ(currentAubStreamProvider, rootDeviceEnvironment->aubCenter->getStreamProvider());
|
||||
EXPECT_EQ(currentAubFileStream, rootDeviceEnvironment->aubCenter->getStreamProvider()->getStream());
|
||||
}
|
||||
|
||||
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeMemoryManagerIsCalledThenLocalMemorySupportedInMemoryManagerHasCorrectValue) {
|
||||
@@ -181,11 +184,12 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe
|
||||
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
executionEnvironment->setHwInfo(*platformDevices);
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->gmmHelper = std::make_unique<GmmHelperMock>(destructorId, platformDevices[0]);
|
||||
executionEnvironment->osInterface = std::make_unique<OsInterfaceMock>(destructorId);
|
||||
executionEnvironment->memoryOperationsInterface = std::make_unique<MemoryOperationsHandlerMock>(destructorId);
|
||||
executionEnvironment->memoryManager = std::make_unique<MemoryMangerMock>(destructorId, *executionEnvironment);
|
||||
executionEnvironment->rootDeviceEnvironments[0].aubCenter = std::make_unique<AubCenterMock>(destructorId);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->aubCenter = std::make_unique<AubCenterMock>(destructorId);
|
||||
executionEnvironment->builtins = std::make_unique<BuiltinsMock>(destructorId);
|
||||
executionEnvironment->compilerInterface = std::make_unique<CompilerInterfaceMock>(destructorId);
|
||||
executionEnvironment->sourceLevelDebugger = std::make_unique<SourceLevelDebuggerMock>(destructorId);
|
||||
@@ -196,7 +200,7 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe
|
||||
|
||||
TEST(ExecutionEnvironment, givenMultipleRootDevicesWhenTheyAreCreatedTheyAllReuseTheSameMemoryManager) {
|
||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
executionEnvironment->rootDeviceEnvironments.resize(2);
|
||||
executionEnvironment->prepareRootDeviceEnvironments(2);
|
||||
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(executionEnvironment, 0u));
|
||||
auto &commandStreamReceiver = device->getGpgpuCommandStreamReceiver();
|
||||
auto memoryManager = device->getMemoryManager();
|
||||
|
||||
@@ -15,7 +15,7 @@ struct AubCommandStreamReceiverFixture : public DeviceFixture, MockAubCenterFixt
|
||||
void SetUp() {
|
||||
DeviceFixture::SetUp();
|
||||
MockAubCenterFixture::SetUp();
|
||||
setMockAubCenter(pDevice->getExecutionEnvironment());
|
||||
setMockAubCenter(*pDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]);
|
||||
}
|
||||
void TearDown() {
|
||||
MockAubCenterFixture::TearDown();
|
||||
|
||||
@@ -24,6 +24,7 @@ class MemoryAllocatorFixture : public MemoryManagementFixture {
|
||||
MemoryManagementFixture::SetUp();
|
||||
executionEnvironment = new ExecutionEnvironment();
|
||||
executionEnvironment->setHwInfo(*platformDevices);
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
device.reset(MockDevice::createWithExecutionEnvironment<MockDevice>(*platformDevices, executionEnvironment, 0u));
|
||||
memoryManager = new MockMemoryManager(false, false, *executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
|
||||
@@ -21,7 +21,7 @@ class MemoryAllocatorMultiDeviceFixture : public MemoryManagementFixture {
|
||||
MemoryManagementFixture::SetUp();
|
||||
executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->setHwInfo(*platformDevices);
|
||||
executionEnvironment->rootDeviceEnvironments.resize(numRootDevices);
|
||||
executionEnvironment->prepareRootDeviceEnvironments(numRootDevices);
|
||||
memoryManager = new MockMemoryManager(false, false, *executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ using namespace NEO;
|
||||
|
||||
void MemoryManagerWithCsrFixture::SetUp() {
|
||||
executionEnvironment.setHwInfo(*platformDevices);
|
||||
executionEnvironment.prepareRootDeviceEnvironments(1);
|
||||
csr = std::make_unique<MockCommandStreamReceiver>(this->executionEnvironment, 0);
|
||||
memoryManager = new MockMemoryManager(executionEnvironment);
|
||||
executionEnvironment.memoryManager.reset(memoryManager);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "runtime/execution_environment/execution_environment.h"
|
||||
#include "core/execution_environment/root_device_environment.h"
|
||||
#include "runtime/platform/platform.h"
|
||||
#include "unit_tests/mocks/mock_aub_center.h"
|
||||
#include "unit_tests/mocks/mock_aub_manager.h"
|
||||
@@ -20,19 +20,19 @@ struct MockAubCenterFixture {
|
||||
MockAubCenterFixture(CommandStreamReceiverType commandStreamReceiverType) : commandStreamReceiverType(commandStreamReceiverType){};
|
||||
|
||||
void SetUp() {
|
||||
setMockAubCenter(platformImpl->peekExecutionEnvironment(), commandStreamReceiverType);
|
||||
setMockAubCenter(*platformImpl->peekExecutionEnvironment()->rootDeviceEnvironments[0], commandStreamReceiverType);
|
||||
}
|
||||
void TearDown() {
|
||||
}
|
||||
|
||||
static void setMockAubCenter(ExecutionEnvironment *executionEnvironment) {
|
||||
setMockAubCenter(executionEnvironment, CommandStreamReceiverType::CSR_AUB);
|
||||
static void setMockAubCenter(RootDeviceEnvironment &rootDeviceEnvironment) {
|
||||
setMockAubCenter(rootDeviceEnvironment, CommandStreamReceiverType::CSR_AUB);
|
||||
}
|
||||
static void setMockAubCenter(ExecutionEnvironment *executionEnvironment, CommandStreamReceiverType commandStreamReceiverType) {
|
||||
static void setMockAubCenter(RootDeviceEnvironment &rootDeviceEnvironment, CommandStreamReceiverType commandStreamReceiverType) {
|
||||
if (testMode != TestMode::AubTests && testMode != TestMode::AubTestsWithTbx) {
|
||||
auto mockAubCenter = std::make_unique<MockAubCenter>(platformDevices[0], false, "", commandStreamReceiverType);
|
||||
mockAubCenter->aubManager = std::make_unique<MockAubManager>();
|
||||
executionEnvironment->rootDeviceEnvironments[0].aubCenter.reset(mockAubCenter.release());
|
||||
rootDeviceEnvironment.aubCenter.reset(mockAubCenter.release());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "runtime/helpers/hardware_commands_helper.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
#include "test.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
@@ -144,6 +144,7 @@ class GTPinFixture : public ContextFixture, public MemoryManagementFixture {
|
||||
pPlatform = platform();
|
||||
auto executionEnvironment = pPlatform->peekExecutionEnvironment();
|
||||
executionEnvironment->setHwInfo(*platformDevices);
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
memoryManager = new MockMemoryManagerWithFailures(*executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
pPlatform->initialize();
|
||||
|
||||
@@ -49,7 +49,7 @@ struct TimestampPacketSimpleTests : public ::testing::Test {
|
||||
struct TimestampPacketTests : public TimestampPacketSimpleTests {
|
||||
void SetUp() override {
|
||||
executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
executionEnvironment->rootDeviceEnvironments.resize(2);
|
||||
executionEnvironment->prepareRootDeviceEnvironments(2);
|
||||
device = std::unique_ptr<MockDevice>(Device::create<MockDevice>(executionEnvironment, 0u));
|
||||
context = new MockContext(device.get());
|
||||
kernel = std::make_unique<MockKernelWithInternals>(*device, context);
|
||||
|
||||
@@ -467,6 +467,7 @@ class CommandStreamReceiverMock : public CommandStreamReceiver {
|
||||
|
||||
CommandStreamReceiverMock() : BaseClass(*(new ExecutionEnvironment), 0) {
|
||||
this->mockExecutionEnvironment.reset(&this->executionEnvironment);
|
||||
executionEnvironment.prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment.initializeMemoryManager();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ CommandStreamReceiver *createCommandStream(ExecutionEnvironment &executionEnviro
|
||||
bool getDevices(size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment) {
|
||||
if (overrideDeviceWithDefaultHardwareInfo) {
|
||||
numDevicesReturned = numPlatformDevices;
|
||||
executionEnvironment.rootDeviceEnvironments.resize(numDevicesReturned);
|
||||
executionEnvironment.prepareRootDeviceEnvironments(static_cast<uint32_t>(numDevicesReturned));
|
||||
return getDevicesResult;
|
||||
}
|
||||
|
||||
|
||||
@@ -805,11 +805,11 @@ TEST_F(HostPtrAllocationTest, whenPrepareOsHandlesForAllocationThenPopulateAsMan
|
||||
for (uint32_t expectedFragmentCount = 1; expectedFragmentCount <= 3; expectedFragmentCount++, allocationSize += MemoryConstants::pageSize) {
|
||||
auto requirements = hostPtrManager->getAllocationRequirements(cpuPtr, allocationSize);
|
||||
EXPECT_EQ(expectedFragmentCount, requirements.requiredFragmentsCount);
|
||||
auto osStorage = hostPtrManager->prepareOsStorageForAllocation(*memoryManager, allocationSize, cpuPtr);
|
||||
auto osStorage = hostPtrManager->prepareOsStorageForAllocation(*memoryManager, allocationSize, cpuPtr, 0);
|
||||
EXPECT_EQ(expectedFragmentCount, osStorage.fragmentCount);
|
||||
EXPECT_EQ(expectedFragmentCount, hostPtrManager->getFragmentCount());
|
||||
hostPtrManager->releaseHandleStorage(osStorage);
|
||||
memoryManager->cleanOsHandles(osStorage);
|
||||
memoryManager->cleanOsHandles(osStorage, 0);
|
||||
EXPECT_EQ(0u, hostPtrManager->getFragmentCount());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ TEST_F(MemoryAllocatorTest, NullOsHandleStorageAskedForPopulationReturnsFilledPo
|
||||
EXPECT_EQ(nullptr, storage.fragmentStorageData[1].osHandleStorage);
|
||||
EXPECT_EQ(nullptr, storage.fragmentStorageData[2].osHandleStorage);
|
||||
memoryManager->getHostPtrManager()->releaseHandleStorage(storage);
|
||||
memoryManager->cleanOsHandles(storage);
|
||||
memoryManager->cleanOsHandles(storage, 0);
|
||||
}
|
||||
|
||||
TEST_F(MemoryAllocatorTest, givenOsHandleStorageWhenOsHandlesAreCleanedAndAubManagerIsNotAvailableThenFreeMemoryIsNotCalledOnAubManager) {
|
||||
@@ -296,13 +296,13 @@ TEST_F(MemoryAllocatorTest, givenOsHandleStorageWhenOsHandlesAreCleanedAndAubMan
|
||||
MockMemoryManager mockMemoryManager(mockExecutionEnvironment);
|
||||
auto mockAubCenter = new MockAubCenter(platformDevices[0], false, "aubfile", CommandStreamReceiverType::CSR_AUB);
|
||||
mockAubCenter->aubManager.reset(nullptr);
|
||||
mockExecutionEnvironment.rootDeviceEnvironments[0].aubCenter.reset(mockAubCenter);
|
||||
mockExecutionEnvironment.rootDeviceEnvironments[0]->aubCenter.reset(mockAubCenter);
|
||||
|
||||
OsHandleStorage storage;
|
||||
storage.fragmentStorageData[0].cpuPtr = (void *)0x1000;
|
||||
mockMemoryManager.populateOsHandles(storage);
|
||||
mockMemoryManager.getHostPtrManager()->releaseHandleStorage(storage);
|
||||
mockMemoryManager.cleanOsHandles(storage);
|
||||
mockMemoryManager.cleanOsHandles(storage, 0);
|
||||
|
||||
EXPECT_EQ(nullptr, mockAubCenter->aubManager);
|
||||
}
|
||||
@@ -310,20 +310,27 @@ TEST_F(MemoryAllocatorTest, givenOsHandleStorageWhenOsHandlesAreCleanedAndAubMan
|
||||
TEST_F(MemoryAllocatorTest, givenOsHandleStorageAndFreeMemoryEnabledWhenOsHandlesAreCleanedAndAubManagerIsAvailableThenFreeMemoryIsCalledOnAubManager) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableFreeMemory.set(true);
|
||||
MockExecutionEnvironment mockExecutionEnvironment(*platformDevices);
|
||||
const uint32_t rootDeviceIndex = 1u;
|
||||
MockExecutionEnvironment mockExecutionEnvironment(*platformDevices, true, 3);
|
||||
MockMemoryManager mockMemoryManager(mockExecutionEnvironment);
|
||||
auto mockManager = new MockAubManager();
|
||||
auto mockAubCenter = new MockAubCenter(platformDevices[0], false, "aubfile", CommandStreamReceiverType::CSR_AUB);
|
||||
mockAubCenter->aubManager.reset(mockManager);
|
||||
mockExecutionEnvironment.rootDeviceEnvironments[0].aubCenter.reset(mockAubCenter);
|
||||
auto mockManager0 = new MockAubManager();
|
||||
auto mockAubCenter0 = new MockAubCenter(platformDevices[0], false, "aubfile", CommandStreamReceiverType::CSR_AUB);
|
||||
mockAubCenter0->aubManager.reset(mockManager0);
|
||||
mockExecutionEnvironment.rootDeviceEnvironments[0]->aubCenter.reset(mockAubCenter0);
|
||||
|
||||
auto mockManager1 = new MockAubManager();
|
||||
auto mockAubCenter1 = new MockAubCenter(platformDevices[0], false, "aubfile", CommandStreamReceiverType::CSR_AUB);
|
||||
mockAubCenter1->aubManager.reset(mockManager1);
|
||||
mockExecutionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->aubCenter.reset(mockAubCenter1);
|
||||
|
||||
OsHandleStorage storage;
|
||||
storage.fragmentStorageData[0].cpuPtr = (void *)0x1000;
|
||||
storage.fragmentStorageData[0].cpuPtr = reinterpret_cast<void *>(0x1000);
|
||||
mockMemoryManager.populateOsHandles(storage);
|
||||
mockMemoryManager.getHostPtrManager()->releaseHandleStorage(storage);
|
||||
mockMemoryManager.cleanOsHandles(storage);
|
||||
mockMemoryManager.cleanOsHandles(storage, rootDeviceIndex);
|
||||
|
||||
EXPECT_TRUE(mockManager->freeMemoryCalled);
|
||||
EXPECT_FALSE(mockManager0->freeMemoryCalled);
|
||||
EXPECT_TRUE(mockManager1->freeMemoryCalled);
|
||||
}
|
||||
|
||||
TEST_F(MemoryAllocatorTest, GivenEmptyMemoryManagerAndMisalingedHostPtrWithHugeSizeWhenAskedForHostPtrAllocationThenGraphicsAllocationIsBeignCreatedWithAllFragmentsPresent) {
|
||||
@@ -1227,7 +1234,7 @@ TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerAndFreeMemoryEnabledWh
|
||||
MockAubManager *mockManager = new MockAubManager();
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "file_name.aub", CommandStreamReceiverType::CSR_AUB);
|
||||
mockAubCenter->aubManager = std::unique_ptr<MockAubManager>(mockManager);
|
||||
executionEnvironment.rootDeviceEnvironments[0].aubCenter.reset(mockAubCenter);
|
||||
executionEnvironment.rootDeviceEnvironments[0]->aubCenter.reset(mockAubCenter);
|
||||
|
||||
auto gfxAllocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
EXPECT_FALSE(mockManager->freeMemoryCalled);
|
||||
@@ -1243,7 +1250,7 @@ TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerAndFreeMemoryDisabledW
|
||||
MockAubManager *mockManager = new MockAubManager();
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "file_name.aub", CommandStreamReceiverType::CSR_AUB);
|
||||
mockAubCenter->aubManager = std::unique_ptr<MockAubManager>(mockManager);
|
||||
executionEnvironment.rootDeviceEnvironments[0].aubCenter.reset(mockAubCenter);
|
||||
executionEnvironment.rootDeviceEnvironments[0]->aubCenter.reset(mockAubCenter);
|
||||
|
||||
auto gfxAllocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
EXPECT_FALSE(mockManager->freeMemoryCalled);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "core/command_stream/preemption.h"
|
||||
#include "core/execution_environment/root_device_environment.h"
|
||||
#include "runtime/command_stream/aub_command_stream_receiver_hw.h"
|
||||
#include "runtime/execution_environment/execution_environment.h"
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
@@ -177,8 +178,9 @@ struct AubExecutionEnvironment {
|
||||
template <typename CsrType>
|
||||
std::unique_ptr<AubExecutionEnvironment> getEnvironment(bool createTagAllocation, bool allocateCommandBuffer, bool standalone) {
|
||||
std::unique_ptr<ExecutionEnvironment> executionEnvironment(new ExecutionEnvironment);
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->setHwInfo(*platformDevices);
|
||||
executionEnvironment->rootDeviceEnvironments[0].aubCenter.reset(new AubCenter());
|
||||
executionEnvironment->rootDeviceEnvironments[0]->aubCenter.reset(new AubCenter());
|
||||
|
||||
executionEnvironment->initializeMemoryManager();
|
||||
auto commandStreamReceiver = std::make_unique<CsrType>("", standalone, *executionEnvironment, 0);
|
||||
|
||||
@@ -97,7 +97,7 @@ class MockDevice : public RootDevice {
|
||||
static T *createWithNewExecutionEnvironment(const HardwareInfo *pHwInfo) {
|
||||
ExecutionEnvironment *executionEnvironment = new ExecutionEnvironment();
|
||||
auto numRootDevices = DebugManager.flags.CreateMultipleRootDevices.get() ? DebugManager.flags.CreateMultipleRootDevices.get() : 1u;
|
||||
executionEnvironment->rootDeviceEnvironments.resize(numRootDevices);
|
||||
executionEnvironment->prepareRootDeviceEnvironments(numRootDevices);
|
||||
pHwInfo = pHwInfo ? pHwInfo : platformDevices[0];
|
||||
executionEnvironment->setHwInfo(pHwInfo);
|
||||
return createWithExecutionEnvironment<T>(pHwInfo, executionEnvironment, 0u);
|
||||
@@ -127,7 +127,8 @@ class MockDevice : public RootDevice {
|
||||
template <>
|
||||
inline Device *MockDevice::createWithNewExecutionEnvironment<Device>(const HardwareInfo *pHwInfo) {
|
||||
auto executionEnvironment = new ExecutionEnvironment();
|
||||
MockAubCenterFixture::setMockAubCenter(executionEnvironment);
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
MockAubCenterFixture::setMockAubCenter(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto hwInfo = pHwInfo ? pHwInfo : *platformDevices;
|
||||
executionEnvironment->setHwInfo(hwInfo);
|
||||
executionEnvironment->initializeMemoryManager();
|
||||
|
||||
@@ -13,14 +13,12 @@
|
||||
#include "unit_tests/fixtures/mock_aub_center_fixture.h"
|
||||
|
||||
namespace NEO {
|
||||
struct MockExecutionEnvironment : ExecutionEnvironment {
|
||||
MockExecutionEnvironment() = default;
|
||||
MockExecutionEnvironment(const HardwareInfo *hwInfo) : MockExecutionEnvironment(hwInfo, true) {}
|
||||
MockExecutionEnvironment(const HardwareInfo *hwInfo, bool useMockAubCenter) : useMockAubCenter(useMockAubCenter) {
|
||||
if (hwInfo) {
|
||||
setHwInfo(hwInfo);
|
||||
}
|
||||
}
|
||||
|
||||
struct MockRootDeviceEnvironment : public RootDeviceEnvironment {
|
||||
using RootDeviceEnvironment::RootDeviceEnvironment;
|
||||
|
||||
~MockRootDeviceEnvironment() override = default;
|
||||
|
||||
void initAubCenter(bool localMemoryEnabled, const std::string &aubFileName, CommandStreamReceiverType csrType) override {
|
||||
if (!initAubCenterCalled) {
|
||||
initAubCenterCalled = true;
|
||||
@@ -28,13 +26,33 @@ struct MockExecutionEnvironment : ExecutionEnvironment {
|
||||
aubFileNameReceived = aubFileName;
|
||||
}
|
||||
if (useMockAubCenter) {
|
||||
MockAubCenterFixture::setMockAubCenter(this);
|
||||
MockAubCenterFixture::setMockAubCenter(*this);
|
||||
}
|
||||
ExecutionEnvironment::initAubCenter(localMemoryEnabled, aubFileName, csrType);
|
||||
RootDeviceEnvironment::initAubCenter(localMemoryEnabled, aubFileName, csrType);
|
||||
}
|
||||
bool initAubCenterCalled = false;
|
||||
bool localMemoryEnabledReceived = false;
|
||||
std::string aubFileNameReceived = "";
|
||||
bool useMockAubCenter = true;
|
||||
};
|
||||
|
||||
struct MockExecutionEnvironment : ExecutionEnvironment {
|
||||
~MockExecutionEnvironment() override = default;
|
||||
MockExecutionEnvironment() : MockExecutionEnvironment(nullptr) {}
|
||||
MockExecutionEnvironment(const HardwareInfo *hwInfo) : MockExecutionEnvironment(hwInfo, true, 1u) {
|
||||
}
|
||||
MockExecutionEnvironment(const HardwareInfo *hwInfo, bool useMockAubCenter, uint32_t numRootDevices) {
|
||||
prepareRootDeviceEnvironments(numRootDevices);
|
||||
for (auto rootDeviceIndex = 0u; rootDeviceIndex < numRootDevices; rootDeviceIndex++) {
|
||||
auto rootDeviceEnvironment = new MockRootDeviceEnvironment(*this);
|
||||
rootDeviceEnvironment->useMockAubCenter = useMockAubCenter;
|
||||
rootDeviceEnvironments[rootDeviceIndex].reset(rootDeviceEnvironment);
|
||||
}
|
||||
|
||||
if (hwInfo) {
|
||||
setHwInfo(hwInfo);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -194,7 +194,7 @@ class FailMemoryManager : public MockMemoryManager {
|
||||
MemoryManager::AllocationStatus populateOsHandles(OsHandleStorage &handleStorage) override {
|
||||
return AllocationStatus::Error;
|
||||
};
|
||||
void cleanOsHandles(OsHandleStorage &handleStorage) override{};
|
||||
void cleanOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{};
|
||||
|
||||
uint64_t getSystemSharedMemory() override {
|
||||
return 0;
|
||||
|
||||
@@ -177,8 +177,32 @@ TEST_F(DeviceFactoryTest, givenSetCommandStreamReceiverInAubModeForTgllpProductF
|
||||
bool success = DeviceFactory::getDevicesForProductFamilyOverride(numDevices, executionEnvironment);
|
||||
ASSERT_TRUE(success);
|
||||
|
||||
EXPECT_TRUE(executionEnvironment.initAubCenterCalled);
|
||||
EXPECT_FALSE(executionEnvironment.localMemoryEnabledReceived);
|
||||
auto rootDeviceEnvironment = static_cast<MockRootDeviceEnvironment *>(executionEnvironment.rootDeviceEnvironments[0].get());
|
||||
|
||||
EXPECT_TRUE(rootDeviceEnvironment->initAubCenterCalled);
|
||||
EXPECT_FALSE(rootDeviceEnvironment->localMemoryEnabledReceived);
|
||||
}
|
||||
|
||||
TEST_F(DeviceFactoryTest, givenSetCommandStreamReceiverInAubModeWhenGetDevicesForProductFamilyOverrideIsCalledThenAllAubCentersAreInitializedCorrectly) {
|
||||
DeviceFactoryCleaner cleaner;
|
||||
DebugManagerStateRestore stateRestore;
|
||||
auto requiredDeviceCount = 2u;
|
||||
DebugManager.flags.CreateMultipleRootDevices.set(requiredDeviceCount);
|
||||
DebugManager.flags.SetCommandStreamReceiver.set(1);
|
||||
DebugManager.flags.ProductFamilyOverride.set("tgllp");
|
||||
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices, true, requiredDeviceCount);
|
||||
|
||||
size_t numDevices = 0;
|
||||
bool success = DeviceFactory::getDevicesForProductFamilyOverride(numDevices, executionEnvironment);
|
||||
ASSERT_TRUE(success);
|
||||
EXPECT_EQ(requiredDeviceCount, numDevices);
|
||||
|
||||
for (auto rootDeviceIndex = 0u; rootDeviceIndex < requiredDeviceCount; rootDeviceIndex++) {
|
||||
auto rootDeviceEnvironment = static_cast<MockRootDeviceEnvironment *>(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex].get());
|
||||
EXPECT_TRUE(rootDeviceEnvironment->initAubCenterCalled);
|
||||
EXPECT_FALSE(rootDeviceEnvironment->localMemoryEnabledReceived);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DeviceFactoryTest, givenGetDevicesCallWhenItIsDoneThenOsInterfaceIsAllocated) {
|
||||
|
||||
@@ -29,7 +29,7 @@ struct DeviceCommandStreamLeaksTest : ::testing::Test {
|
||||
void SetUp() override {
|
||||
HardwareInfo *hwInfo = nullptr;
|
||||
executionEnvironment = getExecutionEnvironmentImpl(hwInfo);
|
||||
MockAubCenterFixture::setMockAubCenter(executionEnvironment);
|
||||
MockAubCenterFixture::setMockAubCenter(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
}
|
||||
|
||||
ExecutionEnvironment *executionEnvironment;
|
||||
|
||||
@@ -31,6 +31,7 @@ class DrmCommandStreamTest : public ::testing::Test {
|
||||
mock = std::make_unique<::testing::NiceMock<DrmMockImpl>>(mockFd);
|
||||
|
||||
executionEnvironment.setHwInfo(*platformDevices);
|
||||
executionEnvironment.prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment.osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment.osInterface->get()->setDrm(mock.get());
|
||||
|
||||
@@ -91,6 +92,7 @@ class DrmCommandStreamEnhancedTest : public ::testing::Test {
|
||||
executionEnvironment = new ExecutionEnvironment;
|
||||
executionEnvironment->incRefInternal();
|
||||
executionEnvironment->setHwInfo(*platformDevices);
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->initGmm();
|
||||
this->dbgState = std::make_unique<DebugManagerStateRestore>();
|
||||
//make sure this is disabled, we don't want to test this now
|
||||
|
||||
@@ -572,7 +572,7 @@ TEST_F(DrmMemoryManagerTest, NullOsHandleStorageAskedForPopulationReturnsFilledP
|
||||
EXPECT_EQ(nullptr, storage.fragmentStorageData[1].osHandleStorage);
|
||||
EXPECT_EQ(nullptr, storage.fragmentStorageData[2].osHandleStorage);
|
||||
storage.fragmentStorageData[0].freeTheFragment = true;
|
||||
memoryManager->cleanOsHandles(storage);
|
||||
memoryManager->cleanOsHandles(storage, 0);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledHostMemoryValidationWhenReadOnlyPointerCausesPinningFailWithEfaultThenPopulateOsHandlesReturnsInvalidHostPointerError) {
|
||||
@@ -607,7 +607,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledHostMemoryValid
|
||||
EXPECT_EQ(nullptr, storage.fragmentStorageData[2].osHandleStorage);
|
||||
|
||||
storage.fragmentStorageData[0].freeTheFragment = true;
|
||||
memoryManager->cleanOsHandles(storage);
|
||||
memoryManager->cleanOsHandles(storage, 0);
|
||||
mock->ioctl_res_ext = &mock->NONE;
|
||||
}
|
||||
|
||||
@@ -642,7 +642,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledHostMemoryValid
|
||||
EXPECT_EQ(nullptr, storage.fragmentStorageData[2].osHandleStorage);
|
||||
|
||||
storage.fragmentStorageData[0].freeTheFragment = true;
|
||||
memoryManager->cleanOsHandles(storage);
|
||||
memoryManager->cleanOsHandles(storage, 0);
|
||||
mock->ioctl_res_ext = &mock->NONE;
|
||||
}
|
||||
|
||||
@@ -2538,7 +2538,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDisabledForcePinAndEna
|
||||
EXPECT_NE(nullptr, handleStorage.fragmentStorageData[0].osHandleStorage);
|
||||
handleStorage.fragmentStorageData[0].freeTheFragment = true;
|
||||
|
||||
memoryManager->cleanOsHandles(handleStorage);
|
||||
memoryManager->cleanOsHandles(handleStorage, 0);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDisabledForcePinAndEnabledValidateHostMemoryWhenPopulateOsHandlesIsCalledWithFirstFragmentAlreadyAllocatedThenNewBosAreValidated) {
|
||||
@@ -2604,7 +2604,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDisabledForcePinAndEna
|
||||
handleStorage.fragmentStorageData[1].freeTheFragment = true;
|
||||
handleStorage.fragmentStorageData[2].freeTheFragment = true;
|
||||
|
||||
memoryManager->cleanOsHandles(handleStorage);
|
||||
memoryManager->cleanOsHandles(handleStorage, 0);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenValidateHostPtrMemoryEnabledWhenHostPtrAllocationIsCreatedWithoutForcingPinThenBufferObjectIsPinned) {
|
||||
@@ -2647,7 +2647,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledHostMemoryValid
|
||||
|
||||
EXPECT_NE(nullptr, storage.fragmentStorageData[0].osHandleStorage);
|
||||
storage.fragmentStorageData[0].freeTheFragment = true;
|
||||
memoryManager->cleanOsHandles(storage);
|
||||
memoryManager->cleanOsHandles(storage, 0);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, givenForcePinAndHostMemoryValidationEnabledWhenSmallAllocationIsCreatedThenBufferObjectIsPinned) {
|
||||
@@ -2873,7 +2873,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledValidateHostMem
|
||||
handleStorage.fragmentStorageData[1].freeTheFragment = true;
|
||||
handleStorage.fragmentStorageData[2].freeTheFragment = true;
|
||||
|
||||
memoryManager->cleanOsHandles(handleStorage);
|
||||
memoryManager->cleanOsHandles(handleStorage, 0);
|
||||
mock->ioctl_res_ext = &mock->NONE;
|
||||
}
|
||||
|
||||
@@ -2922,7 +2922,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledValidateHostMem
|
||||
handleStorage.fragmentStorageData[1].freeTheFragment = true;
|
||||
handleStorage.fragmentStorageData[2].freeTheFragment = true;
|
||||
|
||||
memoryManager->cleanOsHandles(handleStorage);
|
||||
memoryManager->cleanOsHandles(handleStorage, 0);
|
||||
mock->ioctl_res_ext = &mock->NONE;
|
||||
}
|
||||
|
||||
@@ -2953,7 +2953,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledValidateHostMem
|
||||
EXPECT_NE(nullptr, hostPtrManager->getFragment(handleStorage.fragmentStorageData[0].cpuPtr));
|
||||
|
||||
handleStorage.fragmentStorageData[0].freeTheFragment = true;
|
||||
memoryManager->cleanOsHandles(handleStorage);
|
||||
memoryManager->cleanOsHandles(handleStorage, 0);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenCleanOsHandlesDeletesHandleDataThenOsHandleStorageAndResidencyIsSetToNullptr) {
|
||||
@@ -2974,7 +2974,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenCl
|
||||
handleStorage.fragmentStorageData[0].freeTheFragment = true;
|
||||
handleStorage.fragmentStorageData[1].freeTheFragment = true;
|
||||
|
||||
memoryManager->cleanOsHandles(handleStorage);
|
||||
memoryManager->cleanOsHandles(handleStorage, 0);
|
||||
|
||||
for (uint32_t i = 0; i < 2; i++) {
|
||||
EXPECT_EQ(nullptr, handleStorage.fragmentStorageData[i].osHandleStorage);
|
||||
|
||||
@@ -92,6 +92,7 @@ class DrmMemoryManagerFixtureWithoutQuietIoctlExpectation {
|
||||
void SetUp() {
|
||||
executionEnvironment = new ExecutionEnvironment;
|
||||
executionEnvironment->setHwInfo(*platformDevices);
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
mock = std::make_unique<DrmMockCustom>();
|
||||
executionEnvironment->osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment->osInterface->get()->setDrm(mock.get());
|
||||
|
||||
@@ -20,6 +20,7 @@ struct clCreateCommandQueueWithPropertiesLinux : public UltCommandStreamReceiver
|
||||
void SetUp() override {
|
||||
UltCommandStreamReceiverTest::SetUp();
|
||||
ExecutionEnvironment *executionEnvironment = new ExecutionEnvironment();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto osInterface = new OSInterface();
|
||||
osInterface->get()->setDrm(drm.get());
|
||||
executionEnvironment->osInterface.reset(osInterface);
|
||||
|
||||
@@ -914,7 +914,7 @@ TEST_F(WddmMemoryManagerTest, GivenThreeOsHandlesWhenAskedForDestroyAllocationsT
|
||||
storage.fragmentStorageData[2].osHandleStorage->gmm = new Gmm(pSysMem, 4096u, false);
|
||||
storage.fragmentStorageData[2].residency = new ResidencyData;
|
||||
|
||||
memoryManager->cleanOsHandles(storage);
|
||||
memoryManager->cleanOsHandles(storage, 0);
|
||||
|
||||
auto destroyWithResourceHandleCalled = 0u;
|
||||
D3DKMT_DESTROYALLOCATION2 *ptrToDestroyAlloc2 = nullptr;
|
||||
@@ -1076,7 +1076,7 @@ TEST_F(BufferWithWddmMemory, NullOsHandleStorageAskedForPopulationReturnsFilledP
|
||||
EXPECT_EQ(nullptr, storage.fragmentStorageData[1].osHandleStorage);
|
||||
EXPECT_EQ(nullptr, storage.fragmentStorageData[2].osHandleStorage);
|
||||
storage.fragmentStorageData[0].freeTheFragment = true;
|
||||
memoryManager->cleanOsHandles(storage);
|
||||
memoryManager->cleanOsHandles(storage, 0);
|
||||
}
|
||||
|
||||
TEST_F(BufferWithWddmMemory, GivenMisalignedHostPtrAndMultiplePagesSizeWhenAskedForGraphicsAllcoationThenItContainsAllFragmentsWithProperGpuAdrresses) {
|
||||
@@ -1585,7 +1585,7 @@ TEST_F(WddmMemoryManagerTest2, givenReadOnlyMemoryWhenCreateAllocationFailsThenP
|
||||
|
||||
EXPECT_EQ(MemoryManager::AllocationStatus::InvalidHostPointer, result);
|
||||
handleStorage.fragmentStorageData[0].freeTheFragment = true;
|
||||
memoryManager->cleanOsHandles(handleStorage);
|
||||
memoryManager->cleanOsHandles(handleStorage, 0);
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerTest2, givenReadOnlyMemoryPassedToPopulateOsHandlesWhenCreateAllocationFailsThenAllocatedFragmentsAreNotStored) {
|
||||
@@ -1610,7 +1610,7 @@ TEST_F(WddmMemoryManagerTest2, givenReadOnlyMemoryPassedToPopulateOsHandlesWhenC
|
||||
EXPECT_EQ(nullptr, hostPtrManager->getFragment(handleStorage.fragmentStorageData[1].cpuPtr));
|
||||
|
||||
handleStorage.fragmentStorageData[1].freeTheFragment = true;
|
||||
memoryManager->cleanOsHandles(handleStorage);
|
||||
memoryManager->cleanOsHandles(handleStorage, 0);
|
||||
}
|
||||
|
||||
TEST(WddmMemoryManagerCleanupTest, givenUsedTagAllocationInWddmMemoryManagerWhenCleanupMemoryManagerThenDontAccessCsr) {
|
||||
|
||||
@@ -37,9 +37,9 @@ struct MockPlatformWithMockExecutionEnvironment : public Platform {
|
||||
|
||||
MockPlatformWithMockExecutionEnvironment() {
|
||||
this->executionEnvironment->decRefInternal();
|
||||
mockExecutionEnvironment = new MockExecutionEnvironment(nullptr, false);
|
||||
mockExecutionEnvironment = new MockExecutionEnvironment(nullptr, false, 1);
|
||||
executionEnvironment = mockExecutionEnvironment;
|
||||
MockAubCenterFixture::setMockAubCenter(executionEnvironment);
|
||||
MockAubCenterFixture::setMockAubCenter(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
executionEnvironment->incRefInternal();
|
||||
}
|
||||
};
|
||||
@@ -149,7 +149,8 @@ TEST(PlatformTestSimple, givenCsrHwTypeWhenPlatformIsInitializedThenInitAubCente
|
||||
MockPlatformWithMockExecutionEnvironment platform;
|
||||
bool ret = platform.initialize();
|
||||
EXPECT_TRUE(ret);
|
||||
EXPECT_FALSE(platform.mockExecutionEnvironment->initAubCenterCalled);
|
||||
auto rootDeviceEnvironment = static_cast<MockRootDeviceEnvironment *>(platform.mockExecutionEnvironment->rootDeviceEnvironments[0].get());
|
||||
EXPECT_FALSE(rootDeviceEnvironment->initAubCenterCalled);
|
||||
}
|
||||
|
||||
TEST(PlatformTestSimple, givenNotCsrHwTypeWhenPlatformIsInitializedThenInitAubCenterIsCalled) {
|
||||
@@ -159,7 +160,8 @@ TEST(PlatformTestSimple, givenNotCsrHwTypeWhenPlatformIsInitializedThenInitAubCe
|
||||
MockPlatformWithMockExecutionEnvironment platform;
|
||||
bool ret = platform.initialize();
|
||||
EXPECT_TRUE(ret);
|
||||
EXPECT_TRUE(platform.mockExecutionEnvironment->initAubCenterCalled);
|
||||
auto rootDeviceEnvironment = static_cast<MockRootDeviceEnvironment *>(platform.mockExecutionEnvironment->rootDeviceEnvironments[0].get());
|
||||
EXPECT_TRUE(rootDeviceEnvironment->initAubCenterCalled);
|
||||
}
|
||||
|
||||
TEST(PlatformTestSimple, shutdownClosesAsyncEventHandlerThread) {
|
||||
|
||||
@@ -529,7 +529,7 @@ TEST(SourceLevelDebugger, givenTwoRootDevicesWhenSecondIsCreatedThenNotCreatingN
|
||||
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
|
||||
|
||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
executionEnvironment->rootDeviceEnvironments.resize(2);
|
||||
executionEnvironment->prepareRootDeviceEnvironments(2);
|
||||
|
||||
std::unique_ptr<Device> device1(Device::create<MockDevice>(executionEnvironment, 0u));
|
||||
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
|
||||
@@ -550,7 +550,7 @@ TEST(SourceLevelDebugger, givenMultipleRootDevicesWhenTheyAreCreatedTheyAllReuse
|
||||
DebuggerLibrary::setDebuggerActive(true);
|
||||
|
||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
executionEnvironment->rootDeviceEnvironments.resize(2);
|
||||
executionEnvironment->prepareRootDeviceEnvironments(2);
|
||||
std::unique_ptr<Device> device1(Device::create<NEO::MockDevice>(executionEnvironment, 0u));
|
||||
auto sourceLevelDebugger = device1->getSourceLevelDebugger();
|
||||
std::unique_ptr<Device> device2(Device::create<NEO::MockDevice>(executionEnvironment, 1u));
|
||||
|
||||
@@ -12,9 +12,10 @@
|
||||
#include "runtime/platform/platform.h"
|
||||
|
||||
void NEO::UltConfigListener::OnTestStart(const ::testing::TestInfo &testInfo) {
|
||||
constructPlatform()->peekExecutionEnvironment()->setHwInfo(*platformDevices);
|
||||
// Create platform and initialize gmm that dont want to create Platform and test gmm initialization path
|
||||
platform()->peekExecutionEnvironment()->initGmm();
|
||||
auto executionEnvironment = constructPlatform()->peekExecutionEnvironment();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->setHwInfo(*platformDevices);
|
||||
executionEnvironment->initGmm();
|
||||
}
|
||||
void NEO::UltConfigListener::OnTestEnd(const ::testing::TestInfo &testInfo) {
|
||||
// Clear global platform that it shouldn't be reused between tests
|
||||
|
||||
Reference in New Issue
Block a user