diff --git a/core/unit_tests/preemption/preemption_tests.cpp b/core/unit_tests/preemption/preemption_tests.cpp index d028a9e98c..b4e1dbd09c 100644 --- a/core/unit_tests/preemption/preemption_tests.cpp +++ b/core/unit_tests/preemption/preemption_tests.cpp @@ -505,7 +505,7 @@ HWTEST_P(PreemptionTest, whenFailToCreatePreemptionAllocationThenFailToCreateDev } }; - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); std::unique_ptr mockDevice(MockDevice::create(executionEnvironment, 0)); EXPECT_EQ(nullptr, mockDevice); @@ -547,7 +547,7 @@ HWTEST_F(MidThreadPreemptionTests, givenMidThreadPreemptionWhenFailingOnCsrSurfa uint32_t allocateGraphicsMemoryCount = 0; }; - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->memoryManager = std::make_unique(*executionEnvironment); std::unique_ptr mockDevice(MockDevice::create(executionEnvironment, 0)); diff --git a/runtime/platform/platform.cpp b/runtime/platform/platform.cpp index 24f1d48d3c..13be853397 100644 --- a/runtime/platform/platform.cpp +++ b/runtime/platform/platform.cpp @@ -35,19 +35,24 @@ namespace NEO { -std::unique_ptr platformImpl; +std::vector> platformsImpl; bool getDevices(size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment); -Platform *platform() { return platformImpl.get(); } +Platform *platform() { + if (platformsImpl.empty()) { + return nullptr; + } + return platformsImpl[0].get(); +} Platform *constructPlatform() { static std::mutex mutex; std::unique_lock lock(mutex); - if (!platformImpl) { - platformImpl.reset(new Platform()); + if (platformsImpl.empty()) { + platformsImpl.push_back(std::make_unique()); } - return platformImpl.get(); + return platformsImpl[0].get(); } Platform::Platform() { diff --git a/runtime/platform/platform.h b/runtime/platform/platform.h index 23060ac2c4..b944918ea7 100644 --- a/runtime/platform/platform.h +++ b/runtime/platform/platform.h @@ -78,7 +78,7 @@ class Platform : public BaseObject<_cl_platform_id> { ExecutionEnvironment *executionEnvironment = nullptr; }; -extern std::unique_ptr platformImpl; +extern std::vector> platformsImpl; Platform *platform(); Platform *constructPlatform(); } // namespace NEO diff --git a/unit_tests/api/cl_create_command_queue_with_properties_tests.cpp b/unit_tests/api/cl_create_command_queue_with_properties_tests.cpp index a06d404125..fa8e3ff12e 100644 --- a/unit_tests/api/cl_create_command_queue_with_properties_tests.cpp +++ b/unit_tests/api/cl_create_command_queue_with_properties_tests.cpp @@ -53,7 +53,7 @@ struct clCreateCommandQueueWithPropertiesApi : public ApiFixture, } void SetUp() override { - platformImpl.reset(); + platformsImpl.clear(); MemoryManagementFixture::SetUp(); ApiFixture::SetUp(); } diff --git a/unit_tests/api/cl_get_platform_ids_tests.inl b/unit_tests/api/cl_get_platform_ids_tests.inl index 47481a3055..8200a86b4a 100644 --- a/unit_tests/api/cl_get_platform_ids_tests.inl +++ b/unit_tests/api/cl_get_platform_ids_tests.inl @@ -61,6 +61,6 @@ TEST(clGetPlatformIDsNegativeTests, GivenFailedInitializationWhenGettingPlatform EXPECT_EQ(0u, numPlatforms); EXPECT_EQ(nullptr, platformRet); - platformImpl.reset(nullptr); + platformsImpl.clear(); } } // namespace ULT diff --git a/unit_tests/aub_tests/fixtures/aub_fixture.h b/unit_tests/aub_tests/fixtures/aub_fixture.h index 9d397af625..6747806ba4 100644 --- a/unit_tests/aub_tests/fixtures/aub_fixture.h +++ b/unit_tests/aub_tests/fixtures/aub_fixture.h @@ -35,7 +35,7 @@ class AUBFixture : public CommandQueueHwFixture { std::stringstream strfilename; strfilename << testInfo->test_case_name() << "_" << testInfo->name() << "_" << hwHelper.getCsTraits(engineType).name; - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->setHwInfo(&hwInfo); if (testMode == TestMode::AubTestsWithTbx) { this->csr = TbxCommandStreamReceiver::create(strfilename.str(), true, *executionEnvironment, 0); diff --git a/unit_tests/aub_tests/fixtures/unified_memory_fixture.h b/unit_tests/aub_tests/fixtures/unified_memory_fixture.h index 821f4e957f..cff5748443 100644 --- a/unit_tests/aub_tests/fixtures/unified_memory_fixture.h +++ b/unit_tests/aub_tests/fixtures/unified_memory_fixture.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Intel Corporation + * Copyright (C) 2019-2020 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -22,7 +22,7 @@ class UnifiedMemoryAubFixture : public AUBFixture { void SetUp() override { AUBFixture::SetUp(nullptr); - if (!platformImpl->peekExecutionEnvironment()->memoryManager->getPageFaultManager()) { + if (!platform()->peekExecutionEnvironment()->memoryManager->getPageFaultManager()) { skipped = true; GTEST_SKIP(); } diff --git a/unit_tests/command_queue/command_queue_tests.cpp b/unit_tests/command_queue/command_queue_tests.cpp index 063cbe4656..132b803eaa 100644 --- a/unit_tests/command_queue/command_queue_tests.cpp +++ b/unit_tests/command_queue/command_queue_tests.cpp @@ -51,7 +51,7 @@ struct CommandQueueMemoryDevice void TearDown() override { DeviceFixture::TearDown(); - platformImpl.reset(); + platformsImpl.clear(); MemoryManagementFixture::TearDown(); } }; diff --git a/unit_tests/command_queue/enqueue_handler_tests.cpp b/unit_tests/command_queue/enqueue_handler_tests.cpp index 01bacc4380..afb30c374a 100644 --- a/unit_tests/command_queue/enqueue_handler_tests.cpp +++ b/unit_tests/command_queue/enqueue_handler_tests.cpp @@ -525,7 +525,7 @@ HWTEST_F(EnqueueHandlerTest, givenEnqueueHandlerWhenClSetKernelExecInfoAlreadyse struct EnqueueHandlerTestBasic : public ::testing::Test { template std::unique_ptr> setupFixtureAndCreateMockCommandQueue() { - auto executionEnvironment = platformImpl->peekExecutionEnvironment(); + auto executionEnvironment = platform()->peekExecutionEnvironment(); device = std::make_unique(MockDevice::createWithExecutionEnvironment(nullptr, executionEnvironment, 0u)); context = std::make_unique(device.get()); diff --git a/unit_tests/command_queue/enqueue_svm_tests.cpp b/unit_tests/command_queue/enqueue_svm_tests.cpp index 5747360e37..faf2209f75 100644 --- a/unit_tests/command_queue/enqueue_svm_tests.cpp +++ b/unit_tests/command_queue/enqueue_svm_tests.cpp @@ -38,7 +38,7 @@ struct EnqueueSvmTest : public DeviceFixture, } void SetUp() override { - if (platformImpl->peekExecutionEnvironment()->getHardwareInfo()->capabilityTable.ftrSvm == false) { + if (platform()->peekExecutionEnvironment()->getHardwareInfo()->capabilityTable.ftrSvm == false) { GTEST_SKIP(); } DeviceFixture::SetUp(); @@ -47,7 +47,7 @@ struct EnqueueSvmTest : public DeviceFixture, } void TearDown() override { - if (platformImpl->peekExecutionEnvironment()->getHardwareInfo()->capabilityTable.ftrSvm == false) { + if (platform()->peekExecutionEnvironment()->getHardwareInfo()->capabilityTable.ftrSvm == false) { return; } context->getSVMAllocsManager()->freeSVMAlloc(ptrSVM); @@ -893,7 +893,7 @@ TEST(CreateSvmAllocTests, givenVariousSvmAllocationPropertiesWhenAllocatingSvmTh struct EnqueueSvmTestLocalMemory : public DeviceFixture, public ::testing::Test { void SetUp() override { - if (platformImpl->peekExecutionEnvironment()->getHardwareInfo()->capabilityTable.ftrSvm == false) { + if (platform()->peekExecutionEnvironment()->getHardwareInfo()->capabilityTable.ftrSvm == false) { GTEST_SKIP(); } dbgRestore = std::make_unique(); @@ -908,7 +908,7 @@ struct EnqueueSvmTestLocalMemory : public DeviceFixture, } void TearDown() override { - if (platformImpl->peekExecutionEnvironment()->getHardwareInfo()->capabilityTable.ftrSvm == false) { + if (platform()->peekExecutionEnvironment()->getHardwareInfo()->capabilityTable.ftrSvm == false) { return; } context->getSVMAllocsManager()->freeSVMAlloc(svmPtr); diff --git a/unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp b/unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp index e941296625..af2664322d 100644 --- a/unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp +++ b/unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp @@ -453,7 +453,7 @@ class OsAgnosticMemoryManagerForImagesWithNoHostPtr : public OsAgnosticMemoryMan using AubCommandStreamReceiverNoHostPtrTests = ::testing::Test; HWTEST_F(AubCommandStreamReceiverNoHostPtrTests, givenAubCommandStreamReceiverWhenWriteMemoryIsCalledOnImageWithNoHostPtrThenResourceShouldBeLockedToGetCpuAddress) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); auto memoryManager = new OsAgnosticMemoryManagerForImagesWithNoHostPtr(*executionEnvironment); executionEnvironment->memoryManager.reset(memoryManager); auto engineInstance = HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances()[0]; @@ -486,7 +486,7 @@ HWTEST_F(AubCommandStreamReceiverNoHostPtrTests, givenAubCommandStreamReceiverWh } HWTEST_F(AubCommandStreamReceiverNoHostPtrTests, givenAubCommandStreamReceiverWhenWriteMemoryIsCalledOnLockedResourceThenResourceShouldNotBeUnlocked) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); auto memoryManager = new OsAgnosticMemoryManagerForImagesWithNoHostPtr(*executionEnvironment); executionEnvironment->memoryManager.reset(memoryManager); diff --git a/unit_tests/command_stream/command_stream_receiver_flush_task_3_tests.cpp b/unit_tests/command_stream/command_stream_receiver_flush_task_3_tests.cpp index 2bfe07398e..b78d92d460 100644 --- a/unit_tests/command_stream/command_stream_receiver_flush_task_3_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_flush_task_3_tests.cpp @@ -669,7 +669,7 @@ struct MockedMemoryManager : public OsAgnosticMemoryManager { HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenTotalResourceUsedExhaustsTheBudgetThenDoImplicitFlush) { CommandQueueHw commandQueue(nullptr, pClDevice, 0); auto &commandStream = commandQueue.getCS(4096u); - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); auto mockedMemoryManager = new MockedMemoryManager(*executionEnvironment); executionEnvironment->memoryManager.reset(mockedMemoryManager); auto mockCsr = std::make_unique>(*executionEnvironment, 0); diff --git a/unit_tests/command_stream/command_stream_receiver_tests.cpp b/unit_tests/command_stream/command_stream_receiver_tests.cpp index e9570aa32d..37d403af7c 100644 --- a/unit_tests/command_stream/command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_tests.cpp @@ -404,7 +404,7 @@ TEST(CommandStreamReceiverSimpleTest, givenVariousDataSetsWhenVerifyingMemoryThe } TEST(CommandStreamReceiverMultiContextTests, givenMultipleCsrsWhenSameResourcesAreUsedThenResidencyIsProperlyHandled) { - auto executionEnvironment = platformImpl->peekExecutionEnvironment(); + auto executionEnvironment = platform()->peekExecutionEnvironment(); std::unique_ptr device(Device::create(executionEnvironment, 0u)); @@ -441,7 +441,7 @@ TEST(CommandStreamReceiverMultiContextTests, givenMultipleCsrsWhenSameResourcesA struct CreateAllocationForHostSurfaceTest : public ::testing::Test { void SetUp() override { - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->setHwInfo(&hwInfo); gmockMemoryManager = new ::testing::NiceMock(*executionEnvironment); executionEnvironment->memoryManager.reset(gmockMemoryManager); diff --git a/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp b/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp index e50f243e7f..40d225745a 100644 --- a/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp @@ -113,7 +113,7 @@ struct MyMockCsrWithAubDump : CommandStreamReceiverWithAUBDump { struct CommandStreamReceiverWithAubDumpTest : public ::testing::TestWithParam, MockAubCenterFixture { void SetUp() override { MockAubCenterFixture::SetUp(); - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->initializeMemoryManager(); memoryManager = executionEnvironment->memoryManager.get(); ASSERT_NE(nullptr, memoryManager); @@ -141,7 +141,7 @@ struct CommandStreamReceiverWithAubDumpTest : public ::testing::TestWithParam; HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenCsrWithAubDumpWhenSettingOsContextThenReplicateItToAubCsr) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->initializeMemoryManager(); CommandStreamReceiverWithAUBDump> csrWithAubDump("aubfile", *executionEnvironment, 0); @@ -154,7 +154,7 @@ HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenCsrWithAubDumpWhenSett } HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenAubManagerAvailableWhenTbxCsrWithAubDumpIsCreatedThenAubCsrIsNotCreated) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->initializeMemoryManager(); std::string fileName = "file_name.aub"; MockAubManager *mockManager = new MockAubManager(); @@ -173,7 +173,7 @@ HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenAubManagerAvailableWhe MockAubCenter *mockAubCenter = new MockAubCenter(*platformDevices, false, fileName, CommandStreamReceiverType::CSR_HW_WITH_AUB); mockAubCenter->aubManager = std::unique_ptr(mockManager); - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->initializeMemoryManager(); executionEnvironment->rootDeviceEnvironments[0]->aubCenter = std::unique_ptr(mockAubCenter); @@ -186,7 +186,7 @@ HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenCsrWithAubDumpWhenWait MockAubCenter *mockAubCenter = new MockAubCenter(*platformDevices, false, "file_name.aub", CommandStreamReceiverType::CSR_HW_WITH_AUB); mockAubCenter->aubManager = std::unique_ptr(new MockAubManager()); - auto executionEnvironment = platformImpl->peekExecutionEnvironment(); + auto executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->initializeMemoryManager(); executionEnvironment->rootDeviceEnvironments[0]->aubCenter = std::unique_ptr(mockAubCenter); @@ -209,7 +209,7 @@ HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenCsrWithAubDumpWhenCrea MockAubCenter *mockAubCenter = new MockAubCenter(*platformDevices, false, "file_name.aub", CommandStreamReceiverType::CSR_HW_WITH_AUB); mockAubCenter->aubManager = std::unique_ptr(new MockAubManager()); - auto executionEnvironment = platformImpl->peekExecutionEnvironment(); + auto executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->initializeMemoryManager(); executionEnvironment->rootDeviceEnvironments[0]->aubCenter = std::unique_ptr(mockAubCenter); @@ -252,7 +252,7 @@ struct CommandStreamReceiverTagTests : public ::testing::Test { MockAubCenter *mockAubCenter = new MockAubCenter(*platformDevices, false, fileName, CommandStreamReceiverType::CSR_HW_WITH_AUB); mockAubCenter->aubManager = std::unique_ptr(mockManager); - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->initializeMemoryManager(); executionEnvironment->rootDeviceEnvironments[0]->aubCenter = std::unique_ptr(mockAubCenter); } @@ -311,7 +311,7 @@ HWTEST_F(SimulatedCsrTest, givenTbxWithAubDumpCsrTypeWhenCreateCommandStreamRece HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenNullAubManagerAvailableWhenTbxCsrWithAubDumpIsCreatedThenAubCsrIsCreated) { MockAubCenter *mockAubCenter = new MockAubCenter(); - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->initializeMemoryManager(); executionEnvironment->rootDeviceEnvironments[0]->aubCenter = std::unique_ptr(mockAubCenter); diff --git a/unit_tests/command_stream/get_devices_tests.cpp b/unit_tests/command_stream/get_devices_tests.cpp index f05448b5df..818f546ef1 100644 --- a/unit_tests/command_stream/get_devices_tests.cpp +++ b/unit_tests/command_stream/get_devices_tests.cpp @@ -62,7 +62,7 @@ HWTEST_F(GetDevicesTest, givenGetDevicesWhenCsrIsSetToVariousTypesThenTheFunctio } DebugManager.flags.ProductFamilyOverride.set(productFamily); - ExecutionEnvironment *exeEnv = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *exeEnv = platform()->peekExecutionEnvironment(); const auto ret = getDevices(numDevices, *exeEnv); hwInfo = exeEnv->getHardwareInfo(); @@ -133,7 +133,7 @@ HWTEST_F(GetDevicesTest, givenUpperCaseProductFamilyOverrideFlagSetWhenCreatingD DebugManager.flags.ProductFamilyOverride.set(hwPrefixUpperCase); DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_AUB); - ExecutionEnvironment *exeEnv = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *exeEnv = platform()->peekExecutionEnvironment(); bool ret = getDevices(numDevices, *exeEnv); EXPECT_TRUE(ret); @@ -151,7 +151,7 @@ HWTEST_F(GetDevicesTest, givenGetDevicesAndUnknownProductFamilyWhenCsrIsSetToVal DebugManager.flags.SetCommandStreamReceiver.set(csrType); DebugManager.flags.ProductFamilyOverride.set(productFamily); - ExecutionEnvironment *exeEnv = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *exeEnv = platform()->peekExecutionEnvironment(); auto ret = getDevices(numDevices, *exeEnv); hwInfo = exeEnv->getHardwareInfo(); diff --git a/unit_tests/command_stream/tbx_command_stream_tests.cpp b/unit_tests/command_stream/tbx_command_stream_tests.cpp index 8f00b8fa90..db68db4ac4 100644 --- a/unit_tests/command_stream/tbx_command_stream_tests.cpp +++ b/unit_tests/command_stream/tbx_command_stream_tests.cpp @@ -137,7 +137,7 @@ HWTEST_F(TbxCommandStreamTests, DISABLED_getCsTraits) { } TEST(TbxCommandStreamReceiverTest, givenNullFactoryEntryWhenTbxCsrIsCreatedThenNullptrIsReturned) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); GFXCORE_FAMILY family = executionEnvironment->getHardwareInfo()->platform.eRenderCoreFamily; VariableBackup tbxCsrFactoryBackup(&tbxCommandStreamReceiverFactory[family]); @@ -148,7 +148,7 @@ TEST(TbxCommandStreamReceiverTest, givenNullFactoryEntryWhenTbxCsrIsCreatedThenN } TEST(TbxCommandStreamReceiverTest, givenTbxCommandStreamReceiverWhenItIsCreatedWithWrongGfxCoreFamilyThenNullPointerShouldBeReturned) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); auto hwInfo = executionEnvironment->getMutableHardwareInfo(); hwInfo->platform.eRenderCoreFamily = GFXCORE_FAMILY_FORCE_ULONG; // wrong gfx core family @@ -158,7 +158,7 @@ TEST(TbxCommandStreamReceiverTest, givenTbxCommandStreamReceiverWhenItIsCreatedW } TEST(TbxCommandStreamReceiverTest, givenTbxCommandStreamReceiverWhenTypeIsCheckedThenTbxCsrIsReturned) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->initializeMemoryManager(); std::unique_ptr csr(TbxCommandStreamReceiver::create("", false, *executionEnvironment, 0)); EXPECT_NE(nullptr, csr); diff --git a/unit_tests/context/context_tests.cpp b/unit_tests/context/context_tests.cpp index 8e2f60ee4e..01544acdf8 100644 --- a/unit_tests/context/context_tests.cpp +++ b/unit_tests/context/context_tests.cpp @@ -301,7 +301,7 @@ TEST_F(ContextTest, givenContextWhenSharingTableIsNotEmptyThenReturnsSharingFunc } TEST(Context, givenFtrSvmFalseWhenContextIsCreatedThenSVMAllocsManagerIsNotCreated) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); auto hwInfo = executionEnvironment->getMutableHardwareInfo(); hwInfo->capabilityTable.ftrSvm = false; diff --git a/unit_tests/device/device_tests.cpp b/unit_tests/device/device_tests.cpp index 586f325ab2..d8d5e9bbfe 100644 --- a/unit_tests/device/device_tests.cpp +++ b/unit_tests/device/device_tests.cpp @@ -195,7 +195,7 @@ TEST(DeviceCreation, givenDeviceWhenItIsCreatedThenOsContextIsRegistredInMemoryM } TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachOsContextHasUniqueId) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); const size_t numDevices = 2; executionEnvironment->prepareRootDeviceEnvironments(numDevices); const auto &numGpgpuEngines = static_cast(HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances().size()); @@ -221,7 +221,7 @@ TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachOsContextHasU } TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachDeviceHasSeperateDeviceIndex) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); const size_t numDevices = 2; executionEnvironment->prepareRootDeviceEnvironments(numDevices); auto device = std::unique_ptr(Device::create(executionEnvironment, 0u)); @@ -232,7 +232,7 @@ TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachDeviceHasSepe } TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachDeviceHasSeperateCommandStreamReceiver) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); const size_t numDevices = 2; executionEnvironment->prepareRootDeviceEnvironments(numDevices); const auto &numGpgpuEngines = HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances().size(); @@ -248,7 +248,7 @@ TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachDeviceHasSepe } TEST(DeviceCreation, givenDeviceWhenAskingForDefaultEngineThenReturnValidValue) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); auto device = std::unique_ptr(Device::create(executionEnvironment, 0)); auto osContext = device->getDefaultEngine().osContext; diff --git a/unit_tests/event/event_tests.cpp b/unit_tests/event/event_tests.cpp index 7d4f00a403..859b730835 100644 --- a/unit_tests/event/event_tests.cpp +++ b/unit_tests/event/event_tests.cpp @@ -391,7 +391,7 @@ TEST_F(EventTest, Event_Wait_NonBlocking) { struct UpdateEventTest : public ::testing::Test { void SetUp() override { - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); memoryManager = new MockMemoryManager(*executionEnvironment); hostPtrManager = static_cast(memoryManager->getHostPtrManager()); executionEnvironment->memoryManager.reset(memoryManager); diff --git a/unit_tests/execution_environment/execution_environment_tests.cpp b/unit_tests/execution_environment/execution_environment_tests.cpp index 6333a7047b..10306fbda5 100644 --- a/unit_tests/execution_environment/execution_environment_tests.cpp +++ b/unit_tests/execution_environment/execution_environment_tests.cpp @@ -87,7 +87,7 @@ TEST(ExecutionEnvironment, givenPlatformWhenItIsCreatedThenItCreatesMemoryManage } TEST(ExecutionEnvironment, givenDeviceWhenItIsDestroyedThenMemoryManagerIsStillAvailable) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->initializeMemoryManager(); std::unique_ptr device(Device::create(executionEnvironment, 0u)); device.reset(nullptr); @@ -108,7 +108,7 @@ TEST(RootDeviceEnvironment, givenUseAubStreamFalseWhenGetAubManagerIsCalledThenR DebugManagerStateRestore dbgRestore; DebugManager.flags.UseAubStream.set(false); - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get(); rootDeviceEnvironment->initAubCenter(false, "", CommandStreamReceiverType::CSR_AUB); auto aubManager = rootDeviceEnvironment->aubCenter->getAubManager(); @@ -116,7 +116,7 @@ TEST(RootDeviceEnvironment, givenUseAubStreamFalseWhenGetAubManagerIsCalledThenR } TEST(RootDeviceEnvironment, givenExecutionEnvironmentWhenInitializeAubCenterIsCalledThenItIsInitalizedOnce) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get(); rootDeviceEnvironment->initAubCenter(false, "", CommandStreamReceiverType::CSR_AUB); auto currentAubCenter = rootDeviceEnvironment->aubCenter.get(); @@ -141,7 +141,7 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeMemoryManagerI } TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeMemoryManagerIsCalledThenItIsInitalized) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->initializeMemoryManager(); EXPECT_NE(nullptr, executionEnvironment->memoryManager); } @@ -199,7 +199,7 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe } TEST(ExecutionEnvironment, givenMultipleRootDevicesWhenTheyAreCreatedTheyAllReuseTheSameMemoryManager) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->prepareRootDeviceEnvironments(2); std::unique_ptr device(Device::create(executionEnvironment, 0u)); auto &commandStreamReceiver = device->getGpgpuCommandStreamReceiver(); diff --git a/unit_tests/fixtures/image_fixture.h b/unit_tests/fixtures/image_fixture.h index 9d5150e168..0655e64f84 100644 --- a/unit_tests/fixtures/image_fixture.h +++ b/unit_tests/fixtures/image_fixture.h @@ -116,7 +116,7 @@ struct ImageClearColorFixture : ::testing::Test { void setUpImpl() { hardwareInfo.capabilityTable.ftrRenderCompressedImages = true; - NEO::platformImpl.reset(); + NEO::platformsImpl.clear(); NEO::constructPlatform()->peekExecutionEnvironment()->setHwInfo(&hardwareInfo); NEO::platform()->peekExecutionEnvironment()->prepareRootDeviceEnvironments(1u); NEO::platform()->peekExecutionEnvironment()->initGmm(); diff --git a/unit_tests/fixtures/memory_allocator_fixture.h b/unit_tests/fixtures/memory_allocator_fixture.h index e4bc489cd0..5932d014dc 100644 --- a/unit_tests/fixtures/memory_allocator_fixture.h +++ b/unit_tests/fixtures/memory_allocator_fixture.h @@ -35,7 +35,7 @@ class MemoryAllocatorFixture : public MemoryManagementFixture { void TearDown() override { device.reset(); - platformImpl.reset(); + platformsImpl.clear(); MemoryManagementFixture::TearDown(); } diff --git a/unit_tests/fixtures/mock_aub_center_fixture.h b/unit_tests/fixtures/mock_aub_center_fixture.h index 31fea9f02b..fb9dfe4cc2 100644 --- a/unit_tests/fixtures/mock_aub_center_fixture.h +++ b/unit_tests/fixtures/mock_aub_center_fixture.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Intel Corporation + * Copyright (C) 2019-2020 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -20,7 +20,7 @@ struct MockAubCenterFixture { MockAubCenterFixture(CommandStreamReceiverType commandStreamReceiverType) : commandStreamReceiverType(commandStreamReceiverType){}; void SetUp() { - setMockAubCenter(*platformImpl->peekExecutionEnvironment()->rootDeviceEnvironments[0], commandStreamReceiverType); + setMockAubCenter(*platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0], commandStreamReceiverType); } void TearDown() { } diff --git a/unit_tests/fixtures/platform_fixture.cpp b/unit_tests/fixtures/platform_fixture.cpp index 79ab29b408..6297bdcfc1 100644 --- a/unit_tests/fixtures/platform_fixture.cpp +++ b/unit_tests/fixtures/platform_fixture.cpp @@ -41,7 +41,7 @@ void PlatformFixture::SetUp() { } void PlatformFixture::TearDown() { - platformImpl.reset(nullptr); + platformsImpl.clear(); delete[] devices; } } // namespace NEO diff --git a/unit_tests/gen12lp/hw_helper_tests_gen12lp.inl b/unit_tests/gen12lp/hw_helper_tests_gen12lp.inl index 1331b58497..9bdfada5d6 100644 --- a/unit_tests/gen12lp/hw_helper_tests_gen12lp.inl +++ b/unit_tests/gen12lp/hw_helper_tests_gen12lp.inl @@ -112,7 +112,7 @@ GEN12LPTEST_F(HwHelperTestGen12Lp, whenGetGpgpuEnginesThenReturnTwoRcsEnginesAnd class HwHelperTestsGen12LpBuffer : public ::testing::Test { public: void SetUp() override { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); device = std::make_unique(Device::create(executionEnvironment, 0u)); context = std::make_unique(device.get(), true); context->contextType = ContextType::CONTEXT_TYPE_UNRESTRICTIVE; diff --git a/unit_tests/gen12lp/windows/gmm_callbacks_tests_gen12lp.cpp b/unit_tests/gen12lp/windows/gmm_callbacks_tests_gen12lp.cpp index 876940a5f9..345a7139cb 100644 --- a/unit_tests/gen12lp/windows/gmm_callbacks_tests_gen12lp.cpp +++ b/unit_tests/gen12lp/windows/gmm_callbacks_tests_gen12lp.cpp @@ -44,7 +44,7 @@ GEN12LPTEST_F(Gen12LpGmmCallbacksTests, givenCsrWithoutAubDumpWhenNotifyAubCaptu GEN12LPTEST_F(Gen12LpGmmCallbacksTests, givenWddmCsrWhenWriteL3CalledThenWriteTwoMmio) { typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->initializeMemoryManager(); UltCommandStreamReceiver csr(*executionEnvironment, 0); uint8_t buffer[128] = {}; diff --git a/unit_tests/gen8/coherency_tests_gen8.cpp b/unit_tests/gen8/coherency_tests_gen8.cpp index ac270252a2..d6a8499b8e 100644 --- a/unit_tests/gen8/coherency_tests_gen8.cpp +++ b/unit_tests/gen8/coherency_tests_gen8.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2019 Intel Corporation + * Copyright (C) 2017-2020 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -16,7 +16,7 @@ using namespace NEO; typedef ::testing::Test Gen8CoherencyRequirements; GEN8TEST_F(Gen8CoherencyRequirements, noCoherencyProgramming) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->initializeMemoryManager(); CommandStreamReceiverHw csr(*executionEnvironment, 0); LinearStream stream; diff --git a/unit_tests/gen9/coherency_tests_gen9.cpp b/unit_tests/gen9/coherency_tests_gen9.cpp index 08e9540d3c..67dd97add1 100644 --- a/unit_tests/gen9/coherency_tests_gen9.cpp +++ b/unit_tests/gen9/coherency_tests_gen9.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2019 Intel Corporation + * Copyright (C) 2017-2020 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -16,7 +16,7 @@ using namespace NEO; typedef ::testing::Test Gen9CoherencyRequirements; GEN9TEST_F(Gen9CoherencyRequirements, noCoherencyProgramming) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->initializeMemoryManager(); CommandStreamReceiverHw csr(*executionEnvironment, 0); LinearStream stream; diff --git a/unit_tests/gmm_helper/gmm_helper_tests.cpp b/unit_tests/gmm_helper/gmm_helper_tests.cpp index e017b9f791..bc7d92af42 100644 --- a/unit_tests/gmm_helper/gmm_helper_tests.cpp +++ b/unit_tests/gmm_helper/gmm_helper_tests.cpp @@ -39,7 +39,7 @@ extern bool copyInputArgs; struct GmmTests : public ::testing::Test { void SetUp() override { - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); } ExecutionEnvironment *executionEnvironment; }; @@ -779,7 +779,7 @@ TEST(GmmHelperTest, givenPlatformAlreadyDestroyedWhenResourceIsBeingDestroyedThe auto executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->incRefInternal(); - platformImpl.reset(); + platformsImpl.clear(); EXPECT_EQ(nullptr, platform()); EXPECT_NO_THROW(delete gmmResourceInfo); diff --git a/unit_tests/gtpin/gtpin_tests.cpp b/unit_tests/gtpin/gtpin_tests.cpp index b465162d5c..8bef3be769 100644 --- a/unit_tests/gtpin/gtpin_tests.cpp +++ b/unit_tests/gtpin/gtpin_tests.cpp @@ -142,7 +142,7 @@ class GTPinFixture : public ContextFixture, public MemoryManagementFixture { public: void SetUp() override { - platformImpl.reset(); + platformsImpl.clear(); MemoryManagementFixture::SetUp(); constructPlatform(); pPlatform = platform(); @@ -174,7 +174,7 @@ class GTPinFixture : public ContextFixture, public MemoryManagementFixture { void TearDown() override { ContextFixture::TearDown(); - platformImpl.reset(nullptr); + platformsImpl.clear(); MemoryManagementFixture::TearDown(); NEO::isGTPinInitialized = false; } diff --git a/unit_tests/helpers/execution_environment_helper.cpp b/unit_tests/helpers/execution_environment_helper.cpp index f754d1c15a..8562f45055 100644 --- a/unit_tests/helpers/execution_environment_helper.cpp +++ b/unit_tests/helpers/execution_environment_helper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 Intel Corporation + * Copyright (C) 2018-2020 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -14,7 +14,7 @@ namespace NEO { ExecutionEnvironment *getExecutionEnvironmentImpl(HardwareInfo *&hwInfo, uint32_t rootDeviceEnvironments) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->prepareRootDeviceEnvironments(rootDeviceEnvironments); DebugManagerStateRestore restorer; DebugManager.flags.CreateMultipleRootDevices.set(rootDeviceEnvironments); diff --git a/unit_tests/helpers/timestamp_packet_tests.cpp b/unit_tests/helpers/timestamp_packet_tests.cpp index c62ce4a652..adaa06d6d0 100644 --- a/unit_tests/helpers/timestamp_packet_tests.cpp +++ b/unit_tests/helpers/timestamp_packet_tests.cpp @@ -48,7 +48,7 @@ struct TimestampPacketSimpleTests : public ::testing::Test { struct TimestampPacketTests : public TimestampPacketSimpleTests { void SetUp() override { - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->prepareRootDeviceEnvironments(2); device = std::make_unique(Device::create(executionEnvironment, 0u)); context = new MockContext(device.get()); diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp index a0508df590..6baf5cd2fb 100644 --- a/unit_tests/main.cpp +++ b/unit_tests/main.cpp @@ -68,6 +68,7 @@ extern std::string lastTest; bool generateRandomInput = false; void applyWorkarounds() { + platformsImpl.reserve(1); { std::ofstream f; const std::string fileName("_tmp_"); diff --git a/unit_tests/mem_obj/buffer_tests.cpp b/unit_tests/mem_obj/buffer_tests.cpp index f588b0d0b6..95857bc0f9 100644 --- a/unit_tests/mem_obj/buffer_tests.cpp +++ b/unit_tests/mem_obj/buffer_tests.cpp @@ -442,7 +442,7 @@ TEST(Buffer, givenZeroFlagsNoSharedContextAndRenderCompressedBuffersDisabledWhen } TEST(Buffer, givenClMemCopyHostPointerPassedToBufferCreateWhenAllocationIsNotInSystemMemoryPoolThenAllocationIsWrittenByEnqueueWriteBuffer) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); auto *memoryManager = new ::testing::NiceMock(*executionEnvironment); executionEnvironment->memoryManager.reset(memoryManager); @@ -468,7 +468,7 @@ TEST(Buffer, givenClMemCopyHostPointerPassedToBufferCreateWhenAllocationIsNotInS } struct RenderCompressedBuffersTests : public ::testing::Test { void SetUp() override { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); hwInfo = executionEnvironment->getMutableHardwareInfo(); device = std::make_unique(MockDevice::create(executionEnvironment, 0u)); context = std::make_unique(device.get(), true); @@ -590,7 +590,7 @@ TEST_F(RenderCompressedBuffersTests, givenDebugVariableSetWhenHwFlagIsNotSetThen struct RenderCompressedBuffersSvmTests : public RenderCompressedBuffersTests { void SetUp() override { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); hwInfo = executionEnvironment->getMutableHardwareInfo(); hwInfo->capabilityTable.gpuAddressSpace = MemoryConstants::max48BitAddress; RenderCompressedBuffersTests::SetUp(); @@ -611,7 +611,7 @@ TEST_F(RenderCompressedBuffersSvmTests, givenSvmAllocationWhenCreatingBufferThen struct RenderCompressedBuffersCopyHostMemoryTests : public RenderCompressedBuffersTests { void SetUp() override { RenderCompressedBuffersTests::SetUp(); - device->injectMemoryManager(new MockMemoryManager(true, false, *platformImpl->peekExecutionEnvironment())); + device->injectMemoryManager(new MockMemoryManager(true, false, *platform()->peekExecutionEnvironment())); context->memoryManager = device->getMemoryManager(); mockCmdQ = new MockCommandQueue(); context->setSpecialQueue(mockCmdQ); @@ -1484,7 +1484,7 @@ struct ValidHostPtr void TearDown() override { delete buffer; BaseClass::TearDown(); - platformImpl.reset(); + platformsImpl.clear(); MemoryManagementFixture::TearDown(); } diff --git a/unit_tests/mem_obj/destructor_callback_tests.cpp b/unit_tests/mem_obj/destructor_callback_tests.cpp index d2abf26aa5..7e3b3d87db 100644 --- a/unit_tests/mem_obj/destructor_callback_tests.cpp +++ b/unit_tests/mem_obj/destructor_callback_tests.cpp @@ -26,7 +26,7 @@ class DestructorCallbackFixture : public MemoryManagementFixture { void TearDown() override { delete BufferDefaults::context; - platformImpl.reset(); + platformsImpl.clear(); MemoryManagementFixture::TearDown(); } diff --git a/unit_tests/mem_obj/image_tests.cpp b/unit_tests/mem_obj/image_tests.cpp index fac6e3f341..913f5b54ca 100644 --- a/unit_tests/mem_obj/image_tests.cpp +++ b/unit_tests/mem_obj/image_tests.cpp @@ -525,7 +525,7 @@ struct CreateImageHostPtr void TearDown() override { delete image; BaseClass::TearDown(); - platformImpl.reset(); + platformsImpl.clear(); MemoryManagementFixture::TearDown(); } @@ -1175,7 +1175,7 @@ TEST(ImageTest, givenClMemForceLinearStorageSetWhenCreateImageThenDisallowTiling } TEST(ImageTest, givenClMemCopyHostPointerPassedToImageCreateWhenAllocationIsNotInSystemMemoryPoolThenAllocationIsWrittenByEnqueueWriteImage) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); auto *memoryManager = new ::testing::NiceMock(*executionEnvironment); executionEnvironment->memoryManager.reset(memoryManager); EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInDevicePool(::testing::_, ::testing::_)) diff --git a/unit_tests/mem_obj/mem_obj_destruction_tests.cpp b/unit_tests/mem_obj/mem_obj_destruction_tests.cpp index 119fd92aa6..21959fe614 100644 --- a/unit_tests/mem_obj/mem_obj_destruction_tests.cpp +++ b/unit_tests/mem_obj/mem_obj_destruction_tests.cpp @@ -31,7 +31,7 @@ void CL_CALLBACK emptyDestructorCallback(cl_mem memObj, void *userData) { class MemObjDestructionTest : public ::testing::TestWithParam { public: void SetUp() override { - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); memoryManager = new MockMemoryManager(*executionEnvironment); executionEnvironment->memoryManager.reset(memoryManager); device = std::make_unique(MockDevice::create(executionEnvironment, 0)); diff --git a/unit_tests/mem_obj/mem_obj_tests.cpp b/unit_tests/mem_obj/mem_obj_tests.cpp index 2ed14a3ff5..c4c9a5582a 100644 --- a/unit_tests/mem_obj/mem_obj_tests.cpp +++ b/unit_tests/mem_obj/mem_obj_tests.cpp @@ -168,7 +168,7 @@ TEST(MemObj, givenNotReadyGraphicsAllocationWhenMemObjDestroysAllocationAsyncThe } TEST(MemObj, givenReadyGraphicsAllocationWhenMemObjDestroysAllocationAsyncThenAllocationIsNotAddedToMemoryManagerAllocationList) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); auto device = std::make_unique(MockDevice::create(executionEnvironment, 0)); MockContext context(device.get()); auto memoryManager = executionEnvironment->memoryManager.get(); diff --git a/unit_tests/memory_manager/deferrable_allocation_deletion_tests.cpp b/unit_tests/memory_manager/deferrable_allocation_deletion_tests.cpp index 929d4f88fc..057499e01b 100644 --- a/unit_tests/memory_manager/deferrable_allocation_deletion_tests.cpp +++ b/unit_tests/memory_manager/deferrable_allocation_deletion_tests.cpp @@ -37,7 +37,7 @@ struct DeferredDeleterPublic : DeferredDeleter { struct DeferrableAllocationDeletionTest : ::testing::Test { void SetUp() override { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); memoryManager = new MockMemoryManager(*executionEnvironment); executionEnvironment->memoryManager.reset(memoryManager); device.reset(Device::create(executionEnvironment, 0u)); @@ -159,7 +159,7 @@ TEST_F(DeferrableAllocationDeletionTest, givenAllocationUsedByUnregisteredEngine DeferrableAllocationDeletion deletion{*memoryManager, *allocation}; device.reset(); - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->rootDeviceEnvironments.clear(); EXPECT_EQ(0u, memoryManager->registeredEngines.size()); EXPECT_TRUE(allocation->isUsed()); diff --git a/unit_tests/memory_manager/memory_manager_tests.cpp b/unit_tests/memory_manager/memory_manager_tests.cpp index 4466924b78..41448493a1 100644 --- a/unit_tests/memory_manager/memory_manager_tests.cpp +++ b/unit_tests/memory_manager/memory_manager_tests.cpp @@ -618,7 +618,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAskedFor32BitAllocationWhenL GTEST_SKIP(); } - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); MockMemoryManager memoryManager(*executionEnvironment); memoryManager.setForce32BitAllocations(true); memoryManager.forceLimitedRangeAllocator(0, 0xFFFFFFFFF); @@ -637,7 +637,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAskedForNon32BitAllocationWh GTEST_SKIP(); } - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); MockMemoryManager memoryManager(*executionEnvironment); memoryManager.forceLimitedRangeAllocator(0, 0xFFFFFFFFF); @@ -651,7 +651,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAskedForNon32BitAllocationWh } TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenAllocateGraphicsMemoryForImageIsCalledThenGraphicsAllocationIsReturned) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); MockMemoryManager memoryManager(*executionEnvironment); cl_image_desc imgDesc = {}; imgDesc.image_width = 512; @@ -670,7 +670,7 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenAllocateGraphicsMemor } TEST(OsAgnosticMemoryManager, givenEnabledLocalMemoryWhenAllocateGraphicsMemoryForImageIsCalledThenUseLocalMemoryIsNotSet) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); MockMemoryManager memoryManager(false, true, *executionEnvironment); cl_image_desc imgDesc = {}; imgDesc.image_width = 1; @@ -688,7 +688,7 @@ TEST(OsAgnosticMemoryManager, givenEnabledLocalMemoryWhenAllocateGraphicsMemoryF } TEST(OsAgnosticMemoryManager, givenHostPointerNotRequiringCopyWhenAllocateGraphicsMemoryForImageFromHostPtrIsCalledThenGraphicsAllocationIsReturned) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); MockMemoryManager memoryManager(false, false, *executionEnvironment); cl_image_desc imgDesc = {}; @@ -728,7 +728,7 @@ TEST(OsAgnosticMemoryManager, givenHostPointerNotRequiringCopyWhenAllocateGraphi } TEST(OsAgnosticMemoryManager, givenHostPointerRequiringCopyWhenAllocateGraphicsMemoryForImageFromHostPtrIsCalledThenNullptrIsReturned) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); MockMemoryManager memoryManager(false, false, *executionEnvironment); cl_image_desc imgDesc = {}; @@ -1263,7 +1263,7 @@ TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerAndFreeMemoryDisabledW } TEST(MemoryManager, givenSharedResourceCopyWhenAllocatingGraphicsMemoryThenAllocateGraphicsMemoryForImageIsCalled) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); MockMemoryManager memoryManager(false, true, *executionEnvironment); cl_image_desc imgDesc = {}; imgDesc.image_width = 1; @@ -1282,7 +1282,7 @@ TEST(MemoryManager, givenSharedResourceCopyWhenAllocatingGraphicsMemoryThenAlloc } TEST(MemoryManager, givenShareableWhenAllocatingGraphicsMemoryThenAllocateShareableIsCalled) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); MockMemoryManager memoryManager(false, true, *executionEnvironment); MockMemoryManager::AllocationData allocationData; @@ -1589,7 +1589,7 @@ HWTEST_F(GraphicsAllocationTests, givenAllocationUsedOnlyByNonDefaultCsrWhenChec } HWTEST_F(GraphicsAllocationTests, givenAllocationUsedOnlyByNonDefaultDeviceWhenCheckingUsageBeforeDestroyThenStoreItAsTemporaryAllocation) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); auto device = std::unique_ptr(Device::create(executionEnvironment, 0u)); auto &defaultCommandStreamReceiver = device->getGpgpuCommandStreamReceiver(); auto &nonDefaultCommandStreamReceiver = static_cast &>(*device->commandStreamReceivers[1]); @@ -1611,7 +1611,7 @@ HWTEST_F(GraphicsAllocationTests, givenAllocationUsedOnlyByNonDefaultDeviceWhenC } HWTEST_F(GraphicsAllocationTests, givenAllocationUsedByManyOsContextsWhenCheckingUsageBeforeDestroyThenMultiContextDestructorIsUsedForWaitingForAllOsContexts) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); auto memoryManager = new MockMemoryManager(false, false, *executionEnvironment); executionEnvironment->memoryManager.reset(memoryManager); auto multiContextDestructor = new MockDeferredDeleter(); @@ -2213,7 +2213,7 @@ HWTEST_F(MemoryAllocatorTest, givenMemoryManagerWhenHostPtrTrackingEnabledThenNo using PageTableManagerTest = ::testing::Test; HWTEST_F(PageTableManagerTest, givenMemoryManagerThatSupportsPageTableManagerWhenMapAuxGpuVAIsCalledThenItReturnsTrue) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->prepareRootDeviceEnvironments(2); auto memoryManager = new MockMemoryManager(false, false, *executionEnvironment); executionEnvironment->memoryManager.reset(memoryManager); diff --git a/unit_tests/memory_manager/surface_tests.cpp b/unit_tests/memory_manager/surface_tests.cpp index 804abc589c..04fc64f7d0 100644 --- a/unit_tests/memory_manager/surface_tests.cpp +++ b/unit_tests/memory_manager/surface_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2019 Intel Corporation + * Copyright (C) 2017-2020 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -60,7 +60,7 @@ TYPED_TEST_CASE(SurfaceTest, SurfaceTypes); HWTEST_TYPED_TEST(SurfaceTest, GivenSurfaceWhenInterfaceIsUsedThenSurfaceBehavesCorrectly) { int32_t execStamp; - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->initializeMemoryManager(); auto csr = std::make_unique>(execStamp, *executionEnvironment, 0); auto engine = HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances()[0]; diff --git a/unit_tests/memory_manager/unified_memory_manager_tests.cpp b/unit_tests/memory_manager/unified_memory_manager_tests.cpp index fd2912fd62..6ca14c1b93 100644 --- a/unit_tests/memory_manager/unified_memory_manager_tests.cpp +++ b/unit_tests/memory_manager/unified_memory_manager_tests.cpp @@ -554,7 +554,7 @@ TEST_F(UnifiedMemoryManagerPropertiesTest, givenDeviceBitfieldWithSingleBitSetWh struct ShareableUnifiedMemoryManagerPropertiesTest : public ::testing::Test { void SetUp() override { - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); bool svmSupported = executionEnvironment->getHardwareInfo()->capabilityTable.ftrSvm; if (!svmSupported) { GTEST_SKIP(); diff --git a/unit_tests/os_interface/device_factory_tests.cpp b/unit_tests/os_interface/device_factory_tests.cpp index 4ced9bca44..4c4265c82c 100644 --- a/unit_tests/os_interface/device_factory_tests.cpp +++ b/unit_tests/os_interface/device_factory_tests.cpp @@ -28,7 +28,7 @@ struct DeviceFactoryTest : public ::testing::Test { public: void SetUp() override { const HardwareInfo *hwInfo = platformDevices[0]; - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); mockGdiDll = setAdapterInfo(&hwInfo->platform, &hwInfo->gtSystemInfo, hwInfo->capabilityTable.gpuAddressSpace); } diff --git a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp index dc6270f02f..7125fbbbed 100644 --- a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp @@ -3353,9 +3353,9 @@ TEST(DrmMemoryMangerTest, givenMultipleRootDeviceWhenMemoryManagerGetsDrmThenDrm ultHwConfig.useMockedGetDevicesFunc = false; platform()->initialize(); - TestedDrmMemoryManager drmMemoryManager(*platformImpl->peekExecutionEnvironment()); - for (auto i = 0u; i < platformImpl->peekExecutionEnvironment()->rootDeviceEnvironments.size(); i++) { - auto drmFromRootDevice = platformImpl->peekExecutionEnvironment()->rootDeviceEnvironments[i]->osInterface->get()->getDrm(); + TestedDrmMemoryManager drmMemoryManager(*platform()->peekExecutionEnvironment()); + for (auto i = 0u; i < platform()->peekExecutionEnvironment()->rootDeviceEnvironments.size(); i++) { + auto drmFromRootDevice = platform()->peekExecutionEnvironment()->rootDeviceEnvironments[i]->osInterface->get()->getDrm(); EXPECT_EQ(drmFromRootDevice, &drmMemoryManager.getDrm(i)); } } diff --git a/unit_tests/os_interface/windows/device_command_stream_tests.cpp b/unit_tests/os_interface/windows/device_command_stream_tests.cpp index 5670b94636..e2e18201dd 100644 --- a/unit_tests/os_interface/windows/device_command_stream_tests.cpp +++ b/unit_tests/os_interface/windows/device_command_stream_tests.cpp @@ -143,7 +143,7 @@ using WddmDefaultTest = ::Test; using DeviceCommandStreamTest = ::Test; TEST_F(DeviceCommandStreamTest, CreateWddmCSR) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); auto wddm = Wddm::createWddm(*executionEnvironment->rootDeviceEnvironments[0].get()); executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique(); executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->setWddm(static_cast(wddm)); @@ -155,7 +155,7 @@ TEST_F(DeviceCommandStreamTest, CreateWddmCSR) { } TEST_F(DeviceCommandStreamTest, CreateWddmCSRWithAubDump) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); auto wddm = Wddm::createWddm(*executionEnvironment->rootDeviceEnvironments[0].get()); executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique(); executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->setWddm(static_cast(wddm)); @@ -817,7 +817,7 @@ using WddmSimpleTest = ::testing::Test; HWTEST_F(WddmSimpleTest, givenDefaultWddmCsrWhenItIsCreatedThenBatchingIsTurnedOn) { DebugManager.flags.CsrDispatchMode.set(0); - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); std::unique_ptr device(Device::create(executionEnvironment, 0u)); auto wddm = Wddm::createWddm(*executionEnvironment->rootDeviceEnvironments[0].get()); executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique(); diff --git a/unit_tests/os_interface/windows/wddm23_tests.cpp b/unit_tests/os_interface/windows/wddm23_tests.cpp index 66856fa83e..bb1b7e1504 100644 --- a/unit_tests/os_interface/windows/wddm23_tests.cpp +++ b/unit_tests/os_interface/windows/wddm23_tests.cpp @@ -25,7 +25,7 @@ struct Wddm23TestsWithoutWddmInit : public ::testing::Test, GdiDllFixture { void SetUp() override { GdiDllFixture::SetUp(); - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); wddm = static_cast(Wddm::createWddm(*executionEnvironment->rootDeviceEnvironments[0].get())); osInterface = std::make_unique(); osInterface->get()->setWddm(wddm); diff --git a/unit_tests/os_interface/windows/wddm_fixture.h b/unit_tests/os_interface/windows/wddm_fixture.h index 543414ee01..03014a4276 100644 --- a/unit_tests/os_interface/windows/wddm_fixture.h +++ b/unit_tests/os_interface/windows/wddm_fixture.h @@ -28,7 +28,7 @@ namespace NEO { struct WddmFixture : ::testing::Test { void SetUp() override { - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); wddm = static_cast(Wddm::createWddm(*executionEnvironment->rootDeviceEnvironments[0].get())); executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique(); executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->setWddm(wddm); @@ -54,7 +54,7 @@ struct WddmFixture : ::testing::Test { struct WddmFixtureWithMockGdiDll : public GdiDllFixture { void SetUp() override { - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); GdiDllFixture::SetUp(); wddm = static_cast(Wddm::createWddm(*executionEnvironment->rootDeviceEnvironments[0].get())); wddmMockInterface = new WddmMockInterface20(*wddm); @@ -87,7 +87,7 @@ struct WddmFixtureWithMockGdiDll : public GdiDllFixture { struct WddmInstrumentationGmmFixture { void SetUp() { - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); wddm.reset(static_cast(Wddm::createWddm(*executionEnvironment->rootDeviceEnvironments[0].get()))); gmmMem = new ::testing::NiceMock(executionEnvironment->getGmmClientContext()); wddm->gmmMemory.reset(gmmMem); diff --git a/unit_tests/os_interface/windows/wddm_kmdaf_listener_tests.cpp b/unit_tests/os_interface/windows/wddm_kmdaf_listener_tests.cpp index 95e0bc8dc7..99ae708e5a 100644 --- a/unit_tests/os_interface/windows/wddm_kmdaf_listener_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_kmdaf_listener_tests.cpp @@ -39,7 +39,7 @@ class WddmWithKmDafMock : public Wddm { class WddmKmDafListenerTest : public ::testing::Test { public: void SetUp() { - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); wddmWithKmDafMock.reset(new WddmWithKmDafMock(*executionEnvironment->rootDeviceEnvironments[0].get())); wddmWithKmDafMock->gdi.reset(new MockGdi()); auto hwInfo = *platformDevices[0]; diff --git a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp index acc1cea638..5f4cccd9e3 100644 --- a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp @@ -37,7 +37,7 @@ using namespace ::testing; void WddmMemoryManagerFixture::SetUp() { GdiDllFixture::SetUp(); - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); wddm = static_cast(Wddm::createWddm(*executionEnvironment->rootDeviceEnvironments[0].get())); if (platformDevices[0]->capabilityTable.ftrRenderCompressedBuffers || platformDevices[0]->capabilityTable.ftrRenderCompressedImages) { GMM_TRANSLATIONTABLE_CALLBACKS dummyTTCallbacks = {}; @@ -1808,9 +1808,9 @@ TEST(WddmMemoryManager, givenMultipleRootDeviceWhenMemoryManagerGetsWddmThenWddm ultHwConfig.useMockedGetDevicesFunc = false; platform()->initialize(); - MockWddmMemoryManager wddmMemoryManager(*platformImpl->peekExecutionEnvironment()); - for (auto i = 0u; i < platformImpl->peekExecutionEnvironment()->rootDeviceEnvironments.size(); i++) { - auto wddmFromRootDevice = platformImpl->peekExecutionEnvironment()->rootDeviceEnvironments[i]->osInterface->get()->getWddm(); + MockWddmMemoryManager wddmMemoryManager(*platform()->peekExecutionEnvironment()); + for (auto i = 0u; i < platform()->peekExecutionEnvironment()->rootDeviceEnvironments.size(); i++) { + auto wddmFromRootDevice = platform()->peekExecutionEnvironment()->rootDeviceEnvironments[i]->osInterface->get()->getWddm(); EXPECT_EQ(wddmFromRootDevice, &wddmMemoryManager.getWddm(i)); } } @@ -1823,11 +1823,11 @@ TEST(WddmMemoryManager, givenMultipleRootDeviceWhenCreateMemoryManagerThenTakeMa ultHwConfig.useMockedGetDevicesFunc = false; platform()->initialize(); for (auto i = 0u; i < numRootDevices; i++) { - auto wddm = static_cast(platformImpl->peekExecutionEnvironment()->rootDeviceEnvironments[i]->osInterface->get()->getWddm()); + auto wddm = static_cast(platform()->peekExecutionEnvironment()->rootDeviceEnvironments[i]->osInterface->get()->getWddm()); wddm->minAddress = i * (numRootDevices - i); } - MockWddmMemoryManager wddmMemoryManager(*platformImpl->peekExecutionEnvironment()); + MockWddmMemoryManager wddmMemoryManager(*platform()->peekExecutionEnvironment()); EXPECT_EQ(4u, wddmMemoryManager.getAlignedMallocRestrictions()->minAddress); } diff --git a/unit_tests/os_interface/windows/wddm_memory_manager_tests.h b/unit_tests/os_interface/windows/wddm_memory_manager_tests.h index f2cf2225dd..d9f3e1be6b 100644 --- a/unit_tests/os_interface/windows/wddm_memory_manager_tests.h +++ b/unit_tests/os_interface/windows/wddm_memory_manager_tests.h @@ -45,7 +45,7 @@ typedef ::Test WddmMemoryManagerTest; class MockWddmMemoryManagerFixture { public: void SetUp() { - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); gdi = new MockGdi(); wddm = static_cast(Wddm::createWddm(*executionEnvironment->rootDeviceEnvironments[0].get())); @@ -84,7 +84,7 @@ typedef ::Test WddmMemoryManagerResidencyTest; class ExecutionEnvironmentFixture : public ::testing::Test { public: ExecutionEnvironmentFixture() { - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); } ExecutionEnvironment *executionEnvironment; diff --git a/unit_tests/os_interface/windows/wddm_residency_controller_tests.cpp b/unit_tests/os_interface/windows/wddm_residency_controller_tests.cpp index f276b821b2..419931e1bf 100644 --- a/unit_tests/os_interface/windows/wddm_residency_controller_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_residency_controller_tests.cpp @@ -111,7 +111,7 @@ struct WddmResidencyControllerWithGdiTest : ::testing::Test { struct WddmResidencyControllerWithMockWddmTest : public WddmResidencyControllerTest { void SetUp() { - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); wddm = new ::testing::NiceMock(*executionEnvironment->rootDeviceEnvironments[0].get()); wddm->gdi = std::make_unique(); diff --git a/unit_tests/platform/platform_tests.cpp b/unit_tests/platform/platform_tests.cpp index 7c53734c4f..07d89af792 100644 --- a/unit_tests/platform/platform_tests.cpp +++ b/unit_tests/platform/platform_tests.cpp @@ -355,26 +355,24 @@ TEST_F(PlatformTest, testRemoveLastSpace) { EXPECT_EQ(std::string("x"), xSpaceString); } TEST(PlatformConstructionTest, givenPlatformConstructorWhenItIsCalledTwiceThenTheSamePlatformIsReturned) { - platformImpl.reset(); - ASSERT_EQ(nullptr, platformImpl); - auto platform = constructPlatform(); - EXPECT_EQ(platform, platformImpl.get()); + platformsImpl.clear(); + auto platform1 = constructPlatform(); + EXPECT_EQ(platform1, platform()); auto platform2 = constructPlatform(); - EXPECT_EQ(platform2, platform); - EXPECT_NE(platform, nullptr); + EXPECT_EQ(platform2, platform1); + EXPECT_NE(platform1, nullptr); } TEST(PlatformConstructionTest, givenPlatformConstructorWhenItIsCalledAfterResetThenNewPlatformIsConstructed) { - platformImpl.reset(); - ASSERT_EQ(nullptr, platformImpl); + platformsImpl.clear(); auto platform = constructPlatform(); - std::unique_ptr temporaryOwnership(std::move(platformImpl)); - EXPECT_EQ(nullptr, platformImpl.get()); + std::unique_ptr temporaryOwnership(std::move(platformsImpl[0])); + platformsImpl.clear(); auto platform2 = constructPlatform(); EXPECT_NE(platform2, platform); EXPECT_NE(platform, nullptr); EXPECT_NE(platform2, nullptr); - platformImpl.reset(nullptr); + platformsImpl.clear(); } TEST(PlatformInitLoopTests, givenPlatformWhenInitLoopHelperIsCalledThenItDoesNothing) { diff --git a/unit_tests/program/program_tests.cpp b/unit_tests/program/program_tests.cpp index 3fe87cf79f..6479e9ceff 100644 --- a/unit_tests/program/program_tests.cpp +++ b/unit_tests/program/program_tests.cpp @@ -2581,14 +2581,14 @@ TEST(SimpleProgramTests, givenDefaultProgramWhenSetDeviceIsCalledThenDeviceIsSet } TEST(ProgramDestructionTests, givenProgramUsingDeviceWhenItIsDestroyedAfterPlatfromCleanupThenItIsCleanedUpProperly) { - platformImpl->initialize(); - auto device = platformImpl->getClDevice(0); + platform()->initialize(); + auto device = platform()->getClDevice(0); MockContext *context = new MockContext(device, false); MockProgram *pProgram = new MockProgram(*device->getExecutionEnvironment(), context, false); auto globalAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); pProgram->setGlobalSurface(globalAllocation); - platformImpl.reset(nullptr); + platformsImpl.clear(); EXPECT_EQ(1, device->getRefInternalCount()); EXPECT_EQ(1, pProgram->getRefInternalCount()); context->decRefInternal(); diff --git a/unit_tests/sharings/gl/windows/gl_arb_sync_event_tests.cpp b/unit_tests/sharings/gl/windows/gl_arb_sync_event_tests.cpp index 6ed3669dbd..df3e631ea6 100644 --- a/unit_tests/sharings/gl/windows/gl_arb_sync_event_tests.cpp +++ b/unit_tests/sharings/gl/windows/gl_arb_sync_event_tests.cpp @@ -64,7 +64,7 @@ struct GlArbSyncEventTest : public ::testing::Test { } void SetUp() override { - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); auto mockCsr = new MockCommandStreamReceiver(*executionEnvironment, 0); executionEnvironment->memoryManager = std::make_unique(*executionEnvironment); device = std::make_unique(MockDevice::create(executionEnvironment, 0u)); diff --git a/unit_tests/sharings/gl/windows/gl_texture_tests.cpp b/unit_tests/sharings/gl/windows/gl_texture_tests.cpp index f0d0e510ab..5fda1751af 100644 --- a/unit_tests/sharings/gl/windows/gl_texture_tests.cpp +++ b/unit_tests/sharings/gl/windows/gl_texture_tests.cpp @@ -49,7 +49,7 @@ class GlSharingTextureTests : public ::testing::Test { }; void SetUp() override { - executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment = platform()->peekExecutionEnvironment(); imgDesc = {}; imgDesc.image_type = CL_MEM_OBJECT_IMAGE1D; imgDesc.image_width = 10; diff --git a/unit_tests/source_level_debugger/source_level_debugger_device_tests.cpp b/unit_tests/source_level_debugger/source_level_debugger_device_tests.cpp index 870af4548e..327f414843 100644 --- a/unit_tests/source_level_debugger/source_level_debugger_device_tests.cpp +++ b/unit_tests/source_level_debugger/source_level_debugger_device_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 Intel Corporation + * Copyright (C) 2018-2020 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -37,7 +37,7 @@ class MockDeviceWithDebuggerActive : public MockDevice { }; TEST(DeviceWithSourceLevelDebugger, givenDeviceWithSourceLevelDebuggerActiveWhenDeviceIsDestructedThenSourceLevelDebuggerIsNotified) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); auto gmock = new ::testing::NiceMock(new MockOsLibrary); executionEnvironment->sourceLevelDebugger.reset(gmock); auto device = std::unique_ptr(MockDevice::create(executionEnvironment, 0u)); @@ -46,7 +46,7 @@ TEST(DeviceWithSourceLevelDebugger, givenDeviceWithSourceLevelDebuggerActiveWhen } TEST(DeviceWithSourceLevelDebugger, givenDeviceWithSourceLevelDebuggerActiveWhenDeviceIsCreatedThenPreemptionIsDisabled) { - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->sourceLevelDebugger.reset(new MockActiveSourceLevelDebugger(new MockOsLibrary)); auto device = std::unique_ptr(MockDevice::create(executionEnvironment, 0u)); diff --git a/unit_tests/source_level_debugger/source_level_debugger_tests.cpp b/unit_tests/source_level_debugger/source_level_debugger_tests.cpp index df0906b8ae..ac980b5eb3 100644 --- a/unit_tests/source_level_debugger/source_level_debugger_tests.cpp +++ b/unit_tests/source_level_debugger/source_level_debugger_tests.cpp @@ -529,7 +529,7 @@ TEST(SourceLevelDebugger, givenTwoRootDevicesWhenSecondIsCreatedThenNotCreatingN DebuggerLibrary::setDebuggerActive(true); DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor); - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->prepareRootDeviceEnvironments(2); std::unique_ptr device1(Device::create(executionEnvironment, 0u)); @@ -550,7 +550,7 @@ TEST(SourceLevelDebugger, givenMultipleRootDevicesWhenTheyAreCreatedTheyAllReuse DebuggerLibrary::setLibraryAvailable(true); DebuggerLibrary::setDebuggerActive(true); - ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->prepareRootDeviceEnvironments(2); std::unique_ptr device1(Device::create(executionEnvironment, 0u)); auto sourceLevelDebugger = device1->getSourceLevelDebugger(); diff --git a/unit_tests/ult_config_listener.cpp b/unit_tests/ult_config_listener.cpp index 7b04e06f6e..cbd4cd2210 100644 --- a/unit_tests/ult_config_listener.cpp +++ b/unit_tests/ult_config_listener.cpp @@ -23,7 +23,7 @@ void NEO::UltConfigListener::OnTestStart(const ::testing::TestInfo &testInfo) { } void NEO::UltConfigListener::OnTestEnd(const ::testing::TestInfo &testInfo) { // Clear global platform that it shouldn't be reused between tests - platformImpl.reset(); + platformsImpl.clear(); MemoryManager::maxOsContextCount = 0u; // Ensure that global state is restored diff --git a/unit_tests/windows/get_devices_tests.cpp b/unit_tests/windows/get_devices_tests.cpp index c22be161cd..e0b92b2e80 100644 --- a/unit_tests/windows/get_devices_tests.cpp +++ b/unit_tests/windows/get_devices_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Intel Corporation + * Copyright (C) 2019-2020 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -24,7 +24,8 @@ HWTEST_F(GetDevicesTests, WhenGetDevicesIsCalledThenSuccessIsReturned) { } HWTEST_F(GetDevicesTests, whenGetDevicesIsCalledThenGmmIsBeingInitializedAfterFillingHwInfo) { - platformImpl.reset(new Platform()); + platformsImpl.clear(); + platformsImpl.push_back(std::make_unique()); size_t numDevicesReturned = 0; auto hwInfo = platform()->peekExecutionEnvironment()->getMutableHardwareInfo(); hwInfo->platform.eProductFamily = PRODUCT_FAMILY::IGFX_UNKNOWN;