diff --git a/opencl/source/api/api.cpp b/opencl/source/api/api.cpp index a8b87ea390..669e5ee48a 100644 --- a/opencl/source/api/api.cpp +++ b/opencl/source/api/api.cpp @@ -85,8 +85,10 @@ cl_int CL_API_CALL clGetPlatformIDs(cl_uint numEntries, static std::mutex mutex; std::unique_lock lock(mutex); if (platformsImpl.empty()) { - auto executionEnvironment = std::make_unique(); + auto executionEnvironment = new ExecutionEnvironment(); + executionEnvironment->incRefInternal(); auto allDevices = DeviceFactory::createDevices(*executionEnvironment); + executionEnvironment->decRefInternal(); if (allDevices.empty()) { retVal = CL_OUT_OF_HOST_MEMORY; break; @@ -94,7 +96,7 @@ cl_int CL_API_CALL clGetPlatformIDs(cl_uint numEntries, auto groupedDevices = Platform::groupDevices(std::move(allDevices)); for (auto &deviceVector : groupedDevices) { - auto pPlatform = Platform::createFunc(*executionEnvironment.release()); + auto pPlatform = Platform::createFunc(*executionEnvironment); if (!pPlatform || !pPlatform->initialize(std::move(deviceVector))) { retVal = CL_OUT_OF_HOST_MEMORY; break; diff --git a/opencl/source/dll/linux/drm_neo_create.cpp b/opencl/source/dll/linux/drm_neo_create.cpp index 82b71865ff..caa369e1f2 100644 --- a/opencl/source/dll/linux/drm_neo_create.cpp +++ b/opencl/source/dll/linux/drm_neo_create.cpp @@ -66,7 +66,7 @@ Drm *Drm::create(std::unique_ptr hwDeviceId, RootDeviceEnvironment & return nullptr; } drmObject->setGtType(eGtType); - rootDeviceEnvironment.executionEnvironment.setHwInfo(device->pHwInfo); + rootDeviceEnvironment.setHwInfo(device->pHwInfo); } else { printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "FATAL: Unknown device: deviceId: %04x, revisionId: %04x\n", drmObject->deviceId, drmObject->revisionId); diff --git a/opencl/test/unit_test/api/cl_enqueue_copy_buffer_rect_tests.inl b/opencl/test/unit_test/api/cl_enqueue_copy_buffer_rect_tests.inl index 613baf1c16..99b3f10e0e 100644 --- a/opencl/test/unit_test/api/cl_enqueue_copy_buffer_rect_tests.inl +++ b/opencl/test/unit_test/api/cl_enqueue_copy_buffer_rect_tests.inl @@ -14,7 +14,14 @@ using namespace NEO; -typedef api_tests clEnqueueCopyBufferRectTests; +struct clEnqueueCopyBufferRectTests : public ApiFixture<0>, ::testing::Test { + void SetUp() override { + ApiFixture::SetUp(); + } + void TearDown() override { + ApiFixture::TearDown(); + } +}; namespace ULT { diff --git a/opencl/test/unit_test/api/cl_svm_alloc_tests.inl b/opencl/test/unit_test/api/cl_svm_alloc_tests.inl index e772fbccde..5bfd24199b 100644 --- a/opencl/test/unit_test/api/cl_svm_alloc_tests.inl +++ b/opencl/test/unit_test/api/cl_svm_alloc_tests.inl @@ -120,7 +120,7 @@ INSTANTIATE_TEST_CASE_P( testing::ValuesIn(SVMAllocValidFlags)); TEST_P(clSVMAllocFtrFlagsTests, GivenCorrectFlagsWhenAllocatingSvmThenSvmIsAllocated) { - HardwareInfo *pHwInfo = pPlatform->peekExecutionEnvironment()->getMutableHardwareInfo(); + HardwareInfo *pHwInfo = pPlatform->peekExecutionEnvironment()->rootDeviceEnvironments[testedRootDeviceIndex]->getMutableHardwareInfo(); cl_mem_flags flags = GetParam(); void *SVMPtr = nullptr; diff --git a/opencl/test/unit_test/aub_tests/fixtures/aub_fixture.h b/opencl/test/unit_test/aub_tests/fixtures/aub_fixture.h index 1c511bd2fa..36e106ad60 100644 --- a/opencl/test/unit_test/aub_tests/fixtures/aub_fixture.h +++ b/opencl/test/unit_test/aub_tests/fixtures/aub_fixture.h @@ -37,7 +37,8 @@ class AUBFixture : public CommandQueueHwFixture { strfilename << testInfo->test_case_name() << "_" << testInfo->name() << "_" << hwHelper.getCsTraits(engineType).name; executionEnvironment = platform()->peekExecutionEnvironment(); - executionEnvironment->setHwInfo(&hwInfo); + executionEnvironment->prepareRootDeviceEnvironments(1u); + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(&hwInfo); if (testMode == TestMode::AubTestsWithTbx) { this->csr = TbxCommandStreamReceiver::create(strfilename.str(), true, *executionEnvironment, 0); } else { diff --git a/opencl/test/unit_test/command_queue/blit_enqueue_tests.cpp b/opencl/test/unit_test/command_queue/blit_enqueue_tests.cpp index 90e595d2cf..df9eeb9b48 100644 --- a/opencl/test/unit_test/command_queue/blit_enqueue_tests.cpp +++ b/opencl/test/unit_test/command_queue/blit_enqueue_tests.cpp @@ -58,7 +58,7 @@ struct BlitAuxTranslationTests : public ::testing::Test { DebugManager.flags.ForceAuxTranslationMode.set(1); DebugManager.flags.CsrDispatchMode.set(static_cast(DispatchMode::ImmediateDispatch)); device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); - auto &capabilityTable = device->getExecutionEnvironment()->getMutableHardwareInfo()->capabilityTable; + auto &capabilityTable = device->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable; bool createBcsEngine = !capabilityTable.blitterOperationsSupported; capabilityTable.blitterOperationsSupported = true; diff --git a/opencl/test/unit_test/command_stream/aub_command_stream_receiver_1_tests.cpp b/opencl/test/unit_test/command_stream/aub_command_stream_receiver_1_tests.cpp index 34f3eb54dd..0b022cb7a0 100644 --- a/opencl/test/unit_test/command_stream/aub_command_stream_receiver_1_tests.cpp +++ b/opencl/test/unit_test/command_stream/aub_command_stream_receiver_1_tests.cpp @@ -64,7 +64,7 @@ TEST_F(AubCommandStreamReceiverTests, givenStructureWhenMisalignedUint64ThenUseS } TEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenItIsCreatedWithWrongGfxCoreFamilyThenNullPointerShouldBeReturned) { - HardwareInfo *hwInfo = pDevice->executionEnvironment->getMutableHardwareInfo(); + HardwareInfo *hwInfo = pDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); hwInfo->platform.eRenderCoreFamily = GFXCORE_FAMILY_FORCE_ULONG; // wrong gfx core family diff --git a/opencl/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp b/opencl/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp index 614cfb396b..4b25f1c57e 100644 --- a/opencl/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp +++ b/opencl/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp @@ -1080,6 +1080,7 @@ HWTEST_F(SimulatedCsrTest, givenAubCsrTypeWhenCreateCommandStreamReceiverThenPro auto rootDeviceEnvironment = new MockRootDeviceEnvironment(executionEnvironment); executionEnvironment.rootDeviceEnvironments[expectedRootDeviceIndex].reset(rootDeviceEnvironment); + rootDeviceEnvironment->setHwInfo(*platformDevices); EXPECT_EQ(nullptr, executionEnvironment.rootDeviceEnvironments[expectedRootDeviceIndex]->aubCenter.get()); EXPECT_FALSE(rootDeviceEnvironment->initAubCenterCalled); diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp index 8b21619c13..6e579a39d8 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp @@ -313,7 +313,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenHigherTaskLevelWhenTimestampP HWTEST_F(CommandStreamReceiverFlushTaskTests, whenSamplerCacheFlushNotRequiredThenDontSendPipecontrol) { auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); - NEO::WorkaroundTable *waTable = &pDevice->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable; + NEO::WorkaroundTable *waTable = &pDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable; commandStreamReceiver.isPreambleSent = true; commandStreamReceiver.lastPreemptionMode = pDevice->getPreemptionMode(); @@ -338,7 +338,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, whenSamplerCacheFlushBeforeThenSen commandStreamReceiver.setSamplerCacheFlushRequired(CommandStreamReceiver::SamplerCacheFlushState::samplerCacheFlushBefore); configureCSRtoNonDirtyState(); commandStreamReceiver.taskLevel = taskLevel; - NEO::WorkaroundTable *waTable = &pDevice->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable; + NEO::WorkaroundTable *waTable = &pDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable; waTable->waSamplerCacheFlushBetweenRedescribedSurfaceReads = true; @@ -361,7 +361,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, whenSamplerCacheFlushBeforeAndWaSa commandStreamReceiver.setSamplerCacheFlushRequired(CommandStreamReceiver::SamplerCacheFlushState::samplerCacheFlushBefore); configureCSRtoNonDirtyState(); commandStreamReceiver.taskLevel = taskLevel; - NEO::WorkaroundTable *waTable = &pDevice->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable; + NEO::WorkaroundTable *waTable = &pDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable; waTable->waSamplerCacheFlushBetweenRedescribedSurfaceReads = false; @@ -382,7 +382,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, whenSamplerCacheFlushAfterThenSend commandStreamReceiver.setSamplerCacheFlushRequired(CommandStreamReceiver::SamplerCacheFlushState::samplerCacheFlushAfter); configureCSRtoNonDirtyState(); commandStreamReceiver.taskLevel = taskLevel; - NEO::WorkaroundTable *waTable = &pDevice->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable; + NEO::WorkaroundTable *waTable = &pDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable; waTable->waSamplerCacheFlushBetweenRedescribedSurfaceReads = true; diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp index 99e00a5044..b4d033305f 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp @@ -1063,7 +1063,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrWhenSamplerCacheFlushSentT auto samplerCacheFlushBeforeSize = commandStreamReceiver.getRequiredCmdStreamSize(flags, *pDevice); EXPECT_EQ(samplerCacheNotFlushedSize, samplerCacheFlushBeforeSize); - NEO::WorkaroundTable *waTable = &pDevice->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable; + NEO::WorkaroundTable *waTable = &pDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable; waTable->waSamplerCacheFlushBetweenRedescribedSurfaceReads = true; samplerCacheFlushBeforeSize = commandStreamReceiver.getRequiredCmdStreamSize(flags, *pDevice); diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_tests.cpp index 93082d0063..f203990a95 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_tests.cpp @@ -480,7 +480,8 @@ TEST(CommandStreamReceiverMultiContextTests, givenMultipleCsrsWhenSameResourcesA struct CreateAllocationForHostSurfaceTest : public ::testing::Test { void SetUp() override { executionEnvironment = platform()->peekExecutionEnvironment(); - executionEnvironment->setHwInfo(&hwInfo); + executionEnvironment->prepareRootDeviceEnvironments(1u); + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(&hwInfo); gmockMemoryManager = new ::testing::NiceMock(*executionEnvironment); executionEnvironment->memoryManager.reset(gmockMemoryManager); device.reset(MockDevice::create(executionEnvironment, 0u)); diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp index 56862e065b..9fb6f2b2bf 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp @@ -316,12 +316,11 @@ HWTEST_F(CommandStreamReceiverTagTests, givenCsrTypeWhenAskingForTagPoolSizeThen using SimulatedCsrTest = ::testing::Test; HWTEST_F(SimulatedCsrTest, givenHwWithAubDumpCsrTypeWhenCreateCommandStreamReceiverThenProperAubCenterIsInitialized) { uint32_t expectedRootDeviceIndex = 10; - MockExecutionEnvironment executionEnvironment; - executionEnvironment.prepareRootDeviceEnvironments(expectedRootDeviceIndex + 2); + MockExecutionEnvironment executionEnvironment(*platformDevices, true, expectedRootDeviceIndex + 2); executionEnvironment.initializeMemoryManager(); - auto rootDeviceEnvironment = new MockRootDeviceEnvironment(executionEnvironment); - executionEnvironment.rootDeviceEnvironments[expectedRootDeviceIndex].reset(rootDeviceEnvironment); + auto rootDeviceEnvironment = static_cast(executionEnvironment.rootDeviceEnvironments[expectedRootDeviceIndex].get()); + rootDeviceEnvironment->setHwInfo(*platformDevices); EXPECT_EQ(nullptr, executionEnvironment.rootDeviceEnvironments[expectedRootDeviceIndex]->aubCenter.get()); EXPECT_FALSE(rootDeviceEnvironment->initAubCenterCalled); @@ -332,12 +331,12 @@ HWTEST_F(SimulatedCsrTest, givenHwWithAubDumpCsrTypeWhenCreateCommandStreamRecei } HWTEST_F(SimulatedCsrTest, givenTbxWithAubDumpCsrTypeWhenCreateCommandStreamReceiverThenProperAubCenterIsInitialized) { uint32_t expectedRootDeviceIndex = 10; - MockExecutionEnvironment executionEnvironment; + MockExecutionEnvironment executionEnvironment(*platformDevices, true, expectedRootDeviceIndex + 2); executionEnvironment.initializeMemoryManager(); - executionEnvironment.prepareRootDeviceEnvironments(expectedRootDeviceIndex + 2); auto rootDeviceEnvironment = new MockRootDeviceEnvironment(executionEnvironment); executionEnvironment.rootDeviceEnvironments[expectedRootDeviceIndex].reset(rootDeviceEnvironment); + rootDeviceEnvironment->setHwInfo(*platformDevices); EXPECT_EQ(nullptr, executionEnvironment.rootDeviceEnvironments[expectedRootDeviceIndex]->aubCenter.get()); EXPECT_FALSE(rootDeviceEnvironment->initAubCenterCalled); diff --git a/opencl/test/unit_test/command_stream/get_devices_tests.cpp b/opencl/test/unit_test/command_stream/get_devices_tests.cpp index 570162b72d..b9a70ef569 100644 --- a/opencl/test/unit_test/command_stream/get_devices_tests.cpp +++ b/opencl/test/unit_test/command_stream/get_devices_tests.cpp @@ -65,47 +65,49 @@ HWTEST_F(GetDevicesTest, givenGetDevicesWhenCsrIsSetToVariousTypesThenTheFunctio ExecutionEnvironment *exeEnv = platform()->peekExecutionEnvironment(); const auto ret = getDevices(numDevices, *exeEnv); - hwInfo = exeEnv->getHardwareInfo(); + for (auto i = 0u; i < expectedDevices; i++) { + hwInfo = exeEnv->rootDeviceEnvironments[i]->getHardwareInfo(); - switch (csrType) { - case CSR_HW: - case CSR_HW_WITH_AUB: - EXPECT_TRUE(ret); - EXPECT_NE(nullptr, hwInfo); - EXPECT_EQ(expectedDevices, numDevices); - break; - case CSR_AUB: - case CSR_TBX: - case CSR_TBX_WITH_AUB: { - EXPECT_TRUE(ret); - EXPECT_NE(nullptr, hwInfo); - EXPECT_EQ(expectedDevices, numDevices); - for (i = 0; i < IGFX_MAX_PRODUCT; i++) { - auto hardwareInfo = hardwareInfoTable[i]; - if (hardwareInfo == nullptr) - continue; - if (hardwareInfoTable[i]->platform.eProductFamily == hwInfo->platform.eProductFamily) - break; + switch (csrType) { + case CSR_HW: + case CSR_HW_WITH_AUB: + EXPECT_TRUE(ret); + EXPECT_NE(nullptr, hwInfo); + EXPECT_EQ(expectedDevices, numDevices); + break; + case CSR_AUB: + case CSR_TBX: + case CSR_TBX_WITH_AUB: { + EXPECT_TRUE(ret); + EXPECT_NE(nullptr, hwInfo); + EXPECT_EQ(expectedDevices, numDevices); + for (i = 0; i < IGFX_MAX_PRODUCT; i++) { + auto hardwareInfo = hardwareInfoTable[i]; + if (hardwareInfo == nullptr) + continue; + if (hardwareInfoTable[i]->platform.eProductFamily == hwInfo->platform.eProductFamily) + break; + } + EXPECT_TRUE(i < IGFX_MAX_PRODUCT); + ASSERT_NE(nullptr, hardwarePrefix[i]); + + HardwareInfo hwInfoFromTable = *hardwareInfoTable[i]; + hwInfoFromTable.featureTable = {}; + hwInfoFromTable.workaroundTable = {}; + hwInfoFromTable.gtSystemInfo = {}; + hardwareInfoSetup[hwInfoFromTable.platform.eProductFamily](&hwInfoFromTable, true, 0x0); + HwInfoConfig *hwConfig = HwInfoConfig::get(hwInfoFromTable.platform.eProductFamily); + hwInfoFromTable.featureTable.ftrE2ECompression = 0; + hwConfig->configureHardwareCustom(&hwInfoFromTable, nullptr); + EXPECT_EQ(0, memcmp(&hwInfoFromTable.platform, &hwInfo->platform, sizeof(PLATFORM))); + EXPECT_EQ(0, memcmp(&hwInfoFromTable.capabilityTable, &hwInfo->capabilityTable, sizeof(RuntimeCapabilityTable))); + + EXPECT_STREQ(hardwarePrefix[i], productFamily.c_str()); + break; + } + default: + break; } - EXPECT_TRUE(i < IGFX_MAX_PRODUCT); - ASSERT_NE(nullptr, hardwarePrefix[i]); - - HardwareInfo hwInfoFromTable = *hardwareInfoTable[i]; - hwInfoFromTable.featureTable = {}; - hwInfoFromTable.workaroundTable = {}; - hwInfoFromTable.gtSystemInfo = {}; - hardwareInfoSetup[hwInfoFromTable.platform.eProductFamily](&hwInfoFromTable, true, 0x0); - HwInfoConfig *hwConfig = HwInfoConfig::get(hwInfoFromTable.platform.eProductFamily); - hwInfoFromTable.featureTable.ftrE2ECompression = 0; - hwConfig->configureHardwareCustom(&hwInfoFromTable, nullptr); - EXPECT_EQ(0, memcmp(&hwInfoFromTable.platform, &hwInfo->platform, sizeof(PLATFORM))); - EXPECT_EQ(0, memcmp(&hwInfoFromTable.capabilityTable, &hwInfo->capabilityTable, sizeof(RuntimeCapabilityTable))); - - EXPECT_STREQ(hardwarePrefix[i], productFamily.c_str()); - break; - } - default: - break; } } } @@ -151,44 +153,46 @@ HWTEST_F(GetDevicesTest, givenGetDevicesAndUnknownProductFamilyWhenCsrIsSetToVal ExecutionEnvironment *exeEnv = platform()->peekExecutionEnvironment(); auto ret = getDevices(numDevices, *exeEnv); - hwInfo = exeEnv->getHardwareInfo(); + for (auto i = 0u; i < expectedDevices; i++) { + hwInfo = exeEnv->rootDeviceEnvironments[i]->getHardwareInfo(); - switch (csrType) { - case CSR_HW: - case CSR_HW_WITH_AUB: - EXPECT_TRUE(ret); - EXPECT_EQ(expectedDevices, numDevices); - break; - case CSR_AUB: - case CSR_TBX: - case CSR_TBX_WITH_AUB: { - EXPECT_TRUE(ret); - EXPECT_NE(nullptr, hwInfo); - EXPECT_EQ(expectedDevices, numDevices); - for (i = 0; i < IGFX_MAX_PRODUCT; i++) { - auto hardwareInfo = hardwareInfoTable[i]; - if (hardwareInfo == nullptr) - continue; - if (hardwareInfoTable[i]->platform.eProductFamily == hwInfo->platform.eProductFamily) - break; + switch (csrType) { + case CSR_HW: + case CSR_HW_WITH_AUB: + EXPECT_TRUE(ret); + EXPECT_EQ(expectedDevices, numDevices); + break; + case CSR_AUB: + case CSR_TBX: + case CSR_TBX_WITH_AUB: { + EXPECT_TRUE(ret); + EXPECT_NE(nullptr, hwInfo); + EXPECT_EQ(expectedDevices, numDevices); + for (i = 0; i < IGFX_MAX_PRODUCT; i++) { + auto hardwareInfo = hardwareInfoTable[i]; + if (hardwareInfo == nullptr) + continue; + if (hardwareInfoTable[i]->platform.eProductFamily == hwInfo->platform.eProductFamily) + break; + } + EXPECT_TRUE(i < IGFX_MAX_PRODUCT); + ASSERT_NE(nullptr, hardwarePrefix[i]); + HardwareInfo defaultHwInfo = DEFAULT_PLATFORM::hwInfo; + defaultHwInfo.featureTable = {}; + defaultHwInfo.workaroundTable = {}; + defaultHwInfo.gtSystemInfo = {}; + hardwareInfoSetup[defaultHwInfo.platform.eProductFamily](&defaultHwInfo, true, 0x0); + HwInfoConfig *hwConfig = HwInfoConfig::get(defaultHwInfo.platform.eProductFamily); + defaultHwInfo.featureTable.ftrE2ECompression = 0; + hwConfig->configureHardwareCustom(&defaultHwInfo, nullptr); + EXPECT_EQ(0, memcmp(&defaultHwInfo.platform, &hwInfo->platform, sizeof(PLATFORM))); + EXPECT_EQ(0, memcmp(&defaultHwInfo.capabilityTable, &hwInfo->capabilityTable, sizeof(RuntimeCapabilityTable))); + + break; + } + default: + break; } - EXPECT_TRUE(i < IGFX_MAX_PRODUCT); - ASSERT_NE(nullptr, hardwarePrefix[i]); - HardwareInfo defaultHwInfo = DEFAULT_PLATFORM::hwInfo; - defaultHwInfo.featureTable = {}; - defaultHwInfo.workaroundTable = {}; - defaultHwInfo.gtSystemInfo = {}; - hardwareInfoSetup[defaultHwInfo.platform.eProductFamily](&defaultHwInfo, true, 0x0); - HwInfoConfig *hwConfig = HwInfoConfig::get(defaultHwInfo.platform.eProductFamily); - defaultHwInfo.featureTable.ftrE2ECompression = 0; - hwConfig->configureHardwareCustom(&defaultHwInfo, nullptr); - EXPECT_EQ(0, memcmp(&defaultHwInfo.platform, &hwInfo->platform, sizeof(PLATFORM))); - EXPECT_EQ(0, memcmp(&defaultHwInfo.capabilityTable, &hwInfo->capabilityTable, sizeof(RuntimeCapabilityTable))); - - break; - } - default: - break; } } } diff --git a/opencl/test/unit_test/command_stream/tbx_command_stream_tests.cpp b/opencl/test/unit_test/command_stream/tbx_command_stream_tests.cpp index 3bf4a1ba2b..e2b8595315 100644 --- a/opencl/test/unit_test/command_stream/tbx_command_stream_tests.cpp +++ b/opencl/test/unit_test/command_stream/tbx_command_stream_tests.cpp @@ -150,7 +150,8 @@ TEST(TbxCommandStreamReceiverTest, givenNullFactoryEntryWhenTbxCsrIsCreatedThenN TEST(TbxCommandStreamReceiverTest, givenTbxCommandStreamReceiverWhenItIsCreatedWithWrongGfxCoreFamilyThenNullPointerShouldBeReturned) { ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); - auto hwInfo = executionEnvironment->getMutableHardwareInfo(); + executionEnvironment->prepareRootDeviceEnvironments(1u); + auto hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo(); hwInfo->platform.eRenderCoreFamily = GFXCORE_FAMILY_FORCE_ULONG; // wrong gfx core family @@ -581,7 +582,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenItIsQueriedForPreferredTagPoolSiz HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenCreatedWithAubDumpThenFileNameIsExtendedWithSystemInfo) { MockExecutionEnvironment executionEnvironment; - executionEnvironment.setHwInfo(*platformDevices); + executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(*platformDevices); executionEnvironment.initializeMemoryManager(); auto rootDeviceEnvironment = static_cast(executionEnvironment.rootDeviceEnvironments[0].get()); @@ -595,7 +596,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenCreatedWithAubDumpThenFileNameIsE HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenCreatedWithAubDumpThenOpenIsCalledOnAubManagerToOpenFileStream) { MockExecutionEnvironment executionEnvironment; - executionEnvironment.setHwInfo(*platformDevices); + executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(*platformDevices); executionEnvironment.initializeMemoryManager(); std::unique_ptr> tbxCsrWithAubDump(reinterpret_cast *>( @@ -612,6 +613,7 @@ HWTEST_F(SimulatedCsrTest, givenTbxCsrTypeWhenCreateCommandStreamReceiverThenPro auto rootDeviceEnvironment = new MockRootDeviceEnvironment(executionEnvironment); executionEnvironment.rootDeviceEnvironments[expectedRootDeviceIndex].reset(rootDeviceEnvironment); + rootDeviceEnvironment->setHwInfo(*platformDevices); EXPECT_EQ(nullptr, executionEnvironment.rootDeviceEnvironments[expectedRootDeviceIndex]->aubCenter.get()); EXPECT_FALSE(rootDeviceEnvironment->initAubCenterCalled); @@ -626,7 +628,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenCreatedWithAubDumpInSubCaptureMod DebugManager.flags.AUBDumpSubCaptureMode.set(static_cast(AubSubCaptureManager::SubCaptureMode::Filter)); MockExecutionEnvironment executionEnvironment; - executionEnvironment.setHwInfo(*platformDevices); + executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(*platformDevices); executionEnvironment.initializeMemoryManager(); std::unique_ptr> tbxCsrWithAubDump(static_cast *>( @@ -642,7 +644,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenCreatedWithAubDumpInSubCaptureMod HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenCreatedWithAubDumpSeveralTimesThenOpenIsCalledOnAubManagerOnceOnly) { MockExecutionEnvironment executionEnvironment(*platformDevices, true, 1); - executionEnvironment.setHwInfo(*platformDevices); + executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(*platformDevices); executionEnvironment.initializeMemoryManager(); auto tbxCsrWithAubDump1 = std::unique_ptr>(reinterpret_cast *>( diff --git a/opencl/test/unit_test/context/context_tests.cpp b/opencl/test/unit_test/context/context_tests.cpp index a07b7c5b0e..124ebb90ec 100644 --- a/opencl/test/unit_test/context/context_tests.cpp +++ b/opencl/test/unit_test/context/context_tests.cpp @@ -303,7 +303,8 @@ TEST_F(ContextTest, givenContextWhenSharingTableIsNotEmptyThenReturnsSharingFunc TEST(Context, givenFtrSvmFalseWhenContextIsCreatedThenSVMAllocsManagerIsNotCreated) { ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); - auto hwInfo = executionEnvironment->getMutableHardwareInfo(); + executionEnvironment->prepareRootDeviceEnvironments(1u); + auto hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo(); hwInfo->capabilityTable.ftrSvm = false; auto device = std::make_unique(MockDevice::createWithExecutionEnvironment(hwInfo, executionEnvironment, 0)); diff --git a/opencl/test/unit_test/device/device_caps_tests.cpp b/opencl/test/unit_test/device/device_caps_tests.cpp index a8ad382b12..cafb92bc61 100644 --- a/opencl/test/unit_test/device/device_caps_tests.cpp +++ b/opencl/test/unit_test/device/device_caps_tests.cpp @@ -1031,7 +1031,7 @@ TEST_F(DeviceGetCapsTest, GivenFlagEnabled64kbPagesWhenSetThenReturnCorrectValue MockExecutionEnvironment executionEnvironment; executionEnvironment.prepareRootDeviceEnvironments(1); - auto &capabilityTable = executionEnvironment.getMutableHardwareInfo()->capabilityTable; + auto &capabilityTable = executionEnvironment.rootDeviceEnvironments[0]->getMutableHardwareInfo()->capabilityTable; std::unique_ptr memoryManager; DebugManager.flags.Enable64kbpages.set(-1); diff --git a/opencl/test/unit_test/device/device_tests.cpp b/opencl/test/unit_test/device/device_tests.cpp index 4a659f0570..0c3d8d6268 100644 --- a/opencl/test/unit_test/device/device_tests.cpp +++ b/opencl/test/unit_test/device/device_tests.cpp @@ -201,6 +201,9 @@ TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachOsContextHasU ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); const size_t numDevices = 2; executionEnvironment->prepareRootDeviceEnvironments(numDevices); + for (auto i = 0u; i < numDevices; i++) { + executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(*platformDevices); + } auto hwInfo = *platformDevices[0]; const auto &numGpgpuEngines = static_cast(HwHelper::get(hwInfo.platform.eRenderCoreFamily).getGpgpuEngineInstances(hwInfo).size()); @@ -228,6 +231,9 @@ TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachDeviceHasSepe ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); const size_t numDevices = 2; executionEnvironment->prepareRootDeviceEnvironments(numDevices); + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(*platformDevices); + } auto device = std::unique_ptr(Device::create(executionEnvironment, 0u)); auto device2 = std::unique_ptr(Device::create(executionEnvironment, 1u)); @@ -239,6 +245,9 @@ TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachDeviceHasSepe ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); const size_t numDevices = 2; executionEnvironment->prepareRootDeviceEnvironments(numDevices); + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(*platformDevices); + } auto hwInfo = *platformDevices[0]; const auto &numGpgpuEngines = HwHelper::get(hwInfo.platform.eRenderCoreFamily).getGpgpuEngineInstances(hwInfo).size(); auto device1 = std::unique_ptr(Device::create(executionEnvironment, 0u)); @@ -254,8 +263,9 @@ TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachDeviceHasSepe HWTEST_F(DeviceTest, givenDeviceWhenAskingForDefaultEngineThenReturnValidValue) { ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); + executionEnvironment->prepareRootDeviceEnvironments(1u); auto &hwHelper = HwHelperHw::get(); - hwHelper.adjustDefaultEngineType(executionEnvironment->getMutableHardwareInfo()); + hwHelper.adjustDefaultEngineType(executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo()); auto device = std::unique_ptr(Device::create(executionEnvironment, 0)); auto osContext = device->getDefaultEngine().osContext; @@ -290,21 +300,24 @@ HWTEST_F(DeviceHwTest, givenHwHelperInputWhenInitializingCsrThenCreatePageTableM MockExecutionEnvironment executionEnvironment; executionEnvironment.prepareRootDeviceEnvironments(3); executionEnvironment.incRefInternal(); + for (auto i = 0u; i < executionEnvironment.rootDeviceEnvironments.size(); i++) { + executionEnvironment.rootDeviceEnvironments[i]->setHwInfo(&localHwInfo); + } executionEnvironment.initializeMemoryManager(); - executionEnvironment.setHwInfo(&localHwInfo); auto defaultEngineType = getChosenEngineType(localHwInfo); std::unique_ptr device; device.reset(MockDevice::createWithExecutionEnvironment(&localHwInfo, &executionEnvironment, 0)); auto &csr0 = device->getUltCommandStreamReceiver(); EXPECT_FALSE(csr0.createPageTableManagerCalled); - auto hwInfo = executionEnvironment.getMutableHardwareInfo(); + auto hwInfo = executionEnvironment.rootDeviceEnvironments[1]->getMutableHardwareInfo(); hwInfo->capabilityTable.ftrRenderCompressedBuffers = true; hwInfo->capabilityTable.ftrRenderCompressedImages = false; device.reset(MockDevice::createWithExecutionEnvironment(&localHwInfo, &executionEnvironment, 1)); auto &csr1 = device->getUltCommandStreamReceiver(); EXPECT_EQ(csr1.needsPageTableManager(defaultEngineType), csr1.createPageTableManagerCalled); + hwInfo = executionEnvironment.rootDeviceEnvironments[2]->getMutableHardwareInfo(); hwInfo->capabilityTable.ftrRenderCompressedBuffers = false; hwInfo->capabilityTable.ftrRenderCompressedImages = true; device.reset(MockDevice::createWithExecutionEnvironment(&localHwInfo, &executionEnvironment, 2)); diff --git a/opencl/test/unit_test/event/event_tests.cpp b/opencl/test/unit_test/event/event_tests.cpp index 128f16d158..96b91a5a17 100644 --- a/opencl/test/unit_test/event/event_tests.cpp +++ b/opencl/test/unit_test/event/event_tests.cpp @@ -1388,7 +1388,7 @@ HWTEST_F(EventTest, givenQuickKmdSleepRequestWhenWaitIsCalledThenPassRequestToWa localHwInfo.capabilityTable.kmdNotifyProperties.delayQuickKmdSleepMicroseconds = 1; localHwInfo.capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds = 2; - pDevice->executionEnvironment->setHwInfo(&localHwInfo); + pDevice->executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->setHwInfo(&localHwInfo); auto csr = new ::testing::NiceMock(*pDevice->executionEnvironment); pDevice->resetCommandStreamReceiver(csr); @@ -1416,7 +1416,7 @@ HWTEST_F(EventTest, givenNonQuickKmdSleepRequestWhenWaitIsCalledThenPassRequestT localHwInfo.capabilityTable.kmdNotifyProperties.delayQuickKmdSleepMicroseconds = 1; localHwInfo.capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds = 2; - pDevice->executionEnvironment->setHwInfo(&localHwInfo); + pDevice->executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->setHwInfo(&localHwInfo); auto csr = new ::testing::NiceMock(*pDevice->executionEnvironment); pDevice->resetCommandStreamReceiver(csr); diff --git a/opencl/test/unit_test/execution_environment/execution_environment_tests.cpp b/opencl/test/unit_test/execution_environment/execution_environment_tests.cpp index bc474938e5..52f033a176 100644 --- a/opencl/test/unit_test/execution_environment/execution_environment_tests.cpp +++ b/opencl/test/unit_test/execution_environment/execution_environment_tests.cpp @@ -102,7 +102,7 @@ TEST(ExecutionEnvironment, givenDeviceWhenItIsDestroyedThenMemoryManagerIsStillA TEST(RootDeviceEnvironment, givenExecutionEnvironmentWhenInitializeAubCenterIsCalledThenItIsReceivesCorrectInputParams) { MockExecutionEnvironment executionEnvironment; - executionEnvironment.setHwInfo(*platformDevices); + executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(*platformDevices); auto rootDeviceEnvironment = static_cast(executionEnvironment.rootDeviceEnvironments[0].get()); rootDeviceEnvironment->initAubCenter(true, "test.aub", CommandStreamReceiverType::CSR_AUB); EXPECT_TRUE(rootDeviceEnvironment->initAubCenterCalled); @@ -153,7 +153,7 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeMemoryManagerI } static_assert(sizeof(ExecutionEnvironment) == sizeof(std::unique_ptr) + sizeof(std::vector) + - (is64bit ? 32 : 20), + (is64bit ? 24 : 16), "New members detected in ExecutionEnvironment, please ensure that destruction sequence of objects is correct"); TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDestroyedThenDeleteSequenceIsSpecified) { @@ -185,8 +185,8 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe }; auto executionEnvironment = std::make_unique(); - executionEnvironment->setHwInfo(*platformDevices); executionEnvironment->prepareRootDeviceEnvironments(1); + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(*platformDevices); executionEnvironment->rootDeviceEnvironments[0]->gmmHelper = std::make_unique(destructorId, platformDevices[0]); executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique(destructorId); executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique(destructorId); @@ -203,6 +203,9 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe TEST(ExecutionEnvironment, givenMultipleRootDevicesWhenTheyAreCreatedTheyAllReuseTheSameMemoryManager) { ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->prepareRootDeviceEnvironments(2); + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(*platformDevices); + } std::unique_ptr device(Device::create(executionEnvironment, 0u)); auto &commandStreamReceiver = device->getGpgpuCommandStreamReceiver(); auto memoryManager = device->getMemoryManager(); @@ -238,10 +241,3 @@ TEST(ExecutionEnvironment, whenCalculateMaxOsContexCountThenGlobalVariableHasPro EXPECT_EQ(expectedOsContextCount, MemoryManager::maxOsContextCount); } -TEST(RootDeviceEnvironment, whenGetHardwareInfoIsCalledThenHardwareInfoIsTakenFromExecutionEnvironment) { - ExecutionEnvironment executionEnvironment; - HardwareInfo hwInfo = {}; - executionEnvironment.setHwInfo(&hwInfo); - RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment); - EXPECT_EQ(rootDeviceEnvironment.getHardwareInfo(), executionEnvironment.getHardwareInfo()); -} diff --git a/opencl/test/unit_test/fixtures/image_fixture.h b/opencl/test/unit_test/fixtures/image_fixture.h index 74798147b8..20e32067a3 100644 --- a/opencl/test/unit_test/fixtures/image_fixture.h +++ b/opencl/test/unit_test/fixtures/image_fixture.h @@ -119,8 +119,8 @@ struct ImageClearColorFixture : ::testing::Test { hardwareInfo.capabilityTable.ftrRenderCompressedImages = true; NEO::platformsImpl.clear(); - NEO::constructPlatform()->peekExecutionEnvironment()->setHwInfo(&hardwareInfo); - NEO::platform()->peekExecutionEnvironment()->prepareRootDeviceEnvironments(1u); + NEO::constructPlatform()->peekExecutionEnvironment()->prepareRootDeviceEnvironments(1u); + NEO::platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]->setHwInfo(&hardwareInfo); NEO::platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]->initGmm(); } diff --git a/opencl/test/unit_test/fixtures/media_kernel_fixture.h b/opencl/test/unit_test/fixtures/media_kernel_fixture.h index 6f97df5ed5..737f6b97e1 100644 --- a/opencl/test/unit_test/fixtures/media_kernel_fixture.h +++ b/opencl/test/unit_test/fixtures/media_kernel_fixture.h @@ -56,7 +56,7 @@ struct MediaKernelFixture : public HelloWorldFixture, } void SetUp() override { - skipVmeTest = !platform()->peekExecutionEnvironment()->getHardwareInfo()->capabilityTable.supportsVme; + skipVmeTest = !platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]->getHardwareInfo()->capabilityTable.supportsVme; if (skipVmeTest) { GTEST_SKIP(); } diff --git a/opencl/test/unit_test/fixtures/memory_allocator_fixture.h b/opencl/test/unit_test/fixtures/memory_allocator_fixture.h index b6cc6fb2a1..431322d9f2 100644 --- a/opencl/test/unit_test/fixtures/memory_allocator_fixture.h +++ b/opencl/test/unit_test/fixtures/memory_allocator_fixture.h @@ -23,8 +23,8 @@ class MemoryAllocatorFixture : public MemoryManagementFixture { void SetUp() override { MemoryManagementFixture::SetUp(); executionEnvironment = new ExecutionEnvironment(); - executionEnvironment->setHwInfo(*platformDevices); executionEnvironment->prepareRootDeviceEnvironments(1); + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(*platformDevices); device.reset(MockDevice::createWithExecutionEnvironment(*platformDevices, executionEnvironment, 0u)); memoryManager = new MockMemoryManager(false, false, *executionEnvironment); executionEnvironment->memoryManager.reset(memoryManager); diff --git a/opencl/test/unit_test/fixtures/memory_manager_fixture.cpp b/opencl/test/unit_test/fixtures/memory_manager_fixture.cpp index dfcf7e277f..bf6aa667ae 100644 --- a/opencl/test/unit_test/fixtures/memory_manager_fixture.cpp +++ b/opencl/test/unit_test/fixtures/memory_manager_fixture.cpp @@ -17,8 +17,8 @@ using namespace NEO; void MemoryManagerWithCsrFixture::SetUp() { - executionEnvironment.setHwInfo(*platformDevices); executionEnvironment.prepareRootDeviceEnvironments(1); + executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(*platformDevices); csr = std::make_unique(this->executionEnvironment, 0); memoryManager = new MockMemoryManager(executionEnvironment); executionEnvironment.memoryManager.reset(memoryManager); diff --git a/opencl/test/unit_test/gen12lp/windows/gmm_callbacks_tests_gen12lp.cpp b/opencl/test/unit_test/gen12lp/windows/gmm_callbacks_tests_gen12lp.cpp index 62e010c748..4ee85e56e7 100644 --- a/opencl/test/unit_test/gen12lp/windows/gmm_callbacks_tests_gen12lp.cpp +++ b/opencl/test/unit_test/gen12lp/windows/gmm_callbacks_tests_gen12lp.cpp @@ -80,7 +80,7 @@ GEN12LPTEST_F(Gen12LpGmmCallbacksTests, givenCcsEnabledhenWriteL3CalledThenSetRe localHwInfo.featureTable.ftrCCSNode = true; ExecutionEnvironment executionEnvironment; executionEnvironment.prepareRootDeviceEnvironments(1u); - executionEnvironment.setHwInfo(&localHwInfo); + executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(&localHwInfo); executionEnvironment.initializeMemoryManager(); UltCommandStreamReceiver csr(executionEnvironment, 0); uint8_t buffer[128] = {}; @@ -108,7 +108,7 @@ GEN12LPTEST_F(Gen12LpGmmCallbacksTests, givenCcsDisabledhenWriteL3CalledThenSetR localHwInfo.featureTable.ftrCCSNode = false; ExecutionEnvironment executionEnvironment; executionEnvironment.prepareRootDeviceEnvironments(1u); - executionEnvironment.setHwInfo(&localHwInfo); + executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(&localHwInfo); executionEnvironment.initializeMemoryManager(); UltCommandStreamReceiver csr(executionEnvironment, 0); uint8_t buffer[128] = {}; diff --git a/opencl/test/unit_test/gtpin/gtpin_tests.cpp b/opencl/test/unit_test/gtpin/gtpin_tests.cpp index 8b02ae802e..3ea8b82bbd 100644 --- a/opencl/test/unit_test/gtpin/gtpin_tests.cpp +++ b/opencl/test/unit_test/gtpin/gtpin_tests.cpp @@ -149,8 +149,8 @@ class GTPinFixture : public ContextFixture, public MemoryManagementFixture { constructPlatform(); pPlatform = platform(); auto executionEnvironment = pPlatform->peekExecutionEnvironment(); - executionEnvironment->setHwInfo(*platformDevices); executionEnvironment->prepareRootDeviceEnvironments(1); + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(*platformDevices); memoryManager = new MockMemoryManagerWithFailures(*executionEnvironment); executionEnvironment->memoryManager.reset(memoryManager); initPlatform(); diff --git a/opencl/test/unit_test/helpers/execution_environment_helper.cpp b/opencl/test/unit_test/helpers/execution_environment_helper.cpp index 24dd67c9dd..e59aa2d190 100644 --- a/opencl/test/unit_test/helpers/execution_environment_helper.cpp +++ b/opencl/test/unit_test/helpers/execution_environment_helper.cpp @@ -7,6 +7,7 @@ #include "opencl/test/unit_test/helpers/execution_environment_helper.h" +#include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/os_interface/device_factory.h" #include "shared/test/unit_test/helpers/debug_manager_state_restore.h" @@ -22,7 +23,7 @@ ExecutionEnvironment *getExecutionEnvironmentImpl(HardwareInfo *&hwInfo, uint32_ size_t numDevicesReturned = 0; hwInfo = nullptr; DeviceFactory::getDevices(numDevicesReturned, *executionEnvironment); - hwInfo = executionEnvironment->getMutableHardwareInfo(); + hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo(); executionEnvironment->initializeMemoryManager(); return executionEnvironment; diff --git a/opencl/test/unit_test/helpers/execution_environment_helper.h b/opencl/test/unit_test/helpers/execution_environment_helper.h index c64826db63..04c4294b08 100644 --- a/opencl/test/unit_test/helpers/execution_environment_helper.h +++ b/opencl/test/unit_test/helpers/execution_environment_helper.h @@ -13,5 +13,6 @@ #include namespace NEO { +struct HardwareInfo; ExecutionEnvironment *getExecutionEnvironmentImpl(HardwareInfo *&hwInfo, uint32_t rootDeviceEnvironments); } // namespace NEO diff --git a/opencl/test/unit_test/helpers/kmd_notify_tests.cpp b/opencl/test/unit_test/helpers/kmd_notify_tests.cpp index 22cd65be42..2ee766f99e 100644 --- a/opencl/test/unit_test/helpers/kmd_notify_tests.cpp +++ b/opencl/test/unit_test/helpers/kmd_notify_tests.cpp @@ -26,7 +26,7 @@ using namespace NEO; struct KmdNotifyTests : public ::testing::Test { void SetUp() override { device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); - hwInfo = device->getExecutionEnvironment()->getMutableHardwareInfo(); + hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); cmdQ.reset(new MockCommandQueue(&context, device.get(), nullptr)); *device->getDefaultEngine().commandStreamReceiver->getTagAddress() = taskCountToWait; cmdQ->getGpgpuCommandStreamReceiver().waitForFlushStamp(flushStampToWait); diff --git a/opencl/test/unit_test/helpers/timestamp_packet_tests.cpp b/opencl/test/unit_test/helpers/timestamp_packet_tests.cpp index a3884c3ec7..346c37ade0 100644 --- a/opencl/test/unit_test/helpers/timestamp_packet_tests.cpp +++ b/opencl/test/unit_test/helpers/timestamp_packet_tests.cpp @@ -50,6 +50,9 @@ struct TimestampPacketTests : public TimestampPacketSimpleTests { void SetUp() override { executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->prepareRootDeviceEnvironments(2); + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(*platformDevices); + } device = std::make_unique(Device::create(executionEnvironment, 0u)); context = new MockContext(device.get()); kernel = std::make_unique(*device, context); diff --git a/opencl/test/unit_test/kernel/kernel_tests.cpp b/opencl/test/unit_test/kernel/kernel_tests.cpp index cb5d1a6af3..2121e5b460 100644 --- a/opencl/test/unit_test/kernel/kernel_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_tests.cpp @@ -468,8 +468,8 @@ class CommandStreamReceiverMock : public CommandStreamReceiver { CommandStreamReceiverMock() : BaseClass(*(new ExecutionEnvironment), 0) { this->mockExecutionEnvironment.reset(&this->executionEnvironment); - executionEnvironment.setHwInfo(platformDevices[0]); executionEnvironment.prepareRootDeviceEnvironments(1); + executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(platformDevices[0]); executionEnvironment.initializeMemoryManager(); } @@ -2676,7 +2676,7 @@ TEST(KernelTest, givenFtrRenderCompressedBuffersWhenInitializingArgsWithNonState DebugManagerStateRestore restore; DebugManager.flags.DisableAuxTranslation.set(false); auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); - auto hwInfo = device->getExecutionEnvironment()->getMutableHardwareInfo(); + auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); auto &capabilityTable = hwInfo->capabilityTable; auto context = clUniquePtr(new MockContext(device.get())); context->contextType = ContextType::CONTEXT_TYPE_UNRESTRICTIVE; diff --git a/opencl/test/unit_test/libult/create_command_stream.cpp b/opencl/test/unit_test/libult/create_command_stream.cpp index 4cf8658930..43f6567d8b 100644 --- a/opencl/test/unit_test/libult/create_command_stream.cpp +++ b/opencl/test/unit_test/libult/create_command_stream.cpp @@ -38,13 +38,23 @@ CommandStreamReceiver *createCommandStream(ExecutionEnvironment &executionEnviro } bool getDevices(size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment) { - auto currentHwInfo = executionEnvironment.getHardwareInfo(); + if (executionEnvironment.rootDeviceEnvironments.size() == 0) { + executionEnvironment.prepareRootDeviceEnvironments(1u); + } + auto currentHwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo(); if (currentHwInfo->platform.eProductFamily == IGFX_UNKNOWN && currentHwInfo->platform.eRenderCoreFamily == IGFX_UNKNOWN_CORE) { - executionEnvironment.setHwInfo(platformDevices[0]); + executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(platformDevices[0]); } if (ultHwConfig.useMockedGetDevicesFunc) { numDevicesReturned = DebugManager.flags.CreateMultipleRootDevices.get() != 0 ? DebugManager.flags.CreateMultipleRootDevices.get() : 1u; executionEnvironment.prepareRootDeviceEnvironments(static_cast(numDevicesReturned)); + for (auto i = 0u; i < numDevicesReturned; i++) { + if (executionEnvironment.rootDeviceEnvironments[i]->getHardwareInfo() == nullptr || + (executionEnvironment.rootDeviceEnvironments[i]->getHardwareInfo()->platform.eProductFamily == IGFX_UNKNOWN && + executionEnvironment.rootDeviceEnvironments[i]->getHardwareInfo()->platform.eRenderCoreFamily == IGFX_UNKNOWN_CORE)) { + executionEnvironment.rootDeviceEnvironments[i]->setHwInfo(platformDevices[0]); + } + } executionEnvironment.calculateMaxOsContextCount(); executionEnvironment.initializeMemoryManager(); return ultHwConfig.mockedGetDevicesFuncResult; diff --git a/opencl/test/unit_test/linux/main_linux_dll.cpp b/opencl/test/unit_test/linux/main_linux_dll.cpp index be7647e3e5..9ed1d289b4 100644 --- a/opencl/test/unit_test/linux/main_linux_dll.cpp +++ b/opencl/test/unit_test/linux/main_linux_dll.cpp @@ -344,11 +344,11 @@ int main(int argc, char **argv) { } TEST_F(DrmTests, whenCreateDrmIsCalledThenProperHwInfoIsSetup) { - auto oldHwInfo = executionEnvironment.getMutableHardwareInfo(); + auto oldHwInfo = rootDeviceEnvironment->getMutableHardwareInfo(); *oldHwInfo = {}; auto drm = DrmWrap::createDrm(*rootDeviceEnvironment); EXPECT_NE(drm, nullptr); - auto currentHwInfo = executionEnvironment.getHardwareInfo(); + auto currentHwInfo = rootDeviceEnvironment->getHardwareInfo(); EXPECT_NE(IGFX_UNKNOWN, currentHwInfo->platform.eProductFamily); EXPECT_NE(IGFX_UNKNOWN_CORE, currentHwInfo->platform.eRenderCoreFamily); EXPECT_LT(0u, currentHwInfo->gtSystemInfo.EUCount); diff --git a/opencl/test/unit_test/mem_obj/buffer_tests.cpp b/opencl/test/unit_test/mem_obj/buffer_tests.cpp index df5554ac1f..19173e3a6f 100644 --- a/opencl/test/unit_test/mem_obj/buffer_tests.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_tests.cpp @@ -475,7 +475,8 @@ TEST(Buffer, givenClMemCopyHostPointerPassedToBufferCreateWhenAllocationIsNotInS struct RenderCompressedBuffersTests : public ::testing::Test { void SetUp() override { ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); - hwInfo = executionEnvironment->getMutableHardwareInfo(); + executionEnvironment->prepareRootDeviceEnvironments(1u); + hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo(); device = std::make_unique(MockDevice::create(executionEnvironment, 0u)); context = std::make_unique(device.get(), true); context->contextType = ContextType::CONTEXT_TYPE_UNRESTRICTIVE; @@ -597,7 +598,8 @@ TEST_F(RenderCompressedBuffersTests, givenDebugVariableSetWhenHwFlagIsNotSetThen struct RenderCompressedBuffersSvmTests : public RenderCompressedBuffersTests { void SetUp() override { ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); - hwInfo = executionEnvironment->getMutableHardwareInfo(); + executionEnvironment->prepareRootDeviceEnvironments(1u); + hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo(); hwInfo->capabilityTable.gpuAddressSpace = MemoryConstants::max48BitAddress; RenderCompressedBuffersTests::SetUp(); } @@ -712,7 +714,7 @@ struct BcsBufferTests : public ::testing::Test { DebugManager.flags.EnableTimestampPacket.set(1); DebugManager.flags.EnableBlitterOperationsForReadWriteBuffers.set(1); device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); - auto &capabilityTable = device->getExecutionEnvironment()->getMutableHardwareInfo()->capabilityTable; + auto &capabilityTable = device->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable; bool createBcsEngine = !capabilityTable.blitterOperationsSupported; capabilityTable.blitterOperationsSupported = true; @@ -763,7 +765,7 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenBcsSupportedWhenEnqueueBufferOperationIs auto bufferForBlt1 = clUniquePtr(Buffer::create(bcsMockContext.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal)); bufferForBlt0->forceDisallowCPUCopy = true; bufferForBlt1->forceDisallowCPUCopy = true; - auto *hwInfo = device->getExecutionEnvironment()->getMutableHardwareInfo(); + auto *hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); DebugManager.flags.EnableBlitterOperationsForReadWriteBuffers.set(0); hwInfo->capabilityTable.blitterOperationsSupported = false; diff --git a/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp b/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp index efebadfb54..67684ff713 100644 --- a/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp +++ b/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp @@ -1167,8 +1167,8 @@ using OsAgnosticMemoryManagerWithParams = ::testing::TestWithParam; TEST_P(OsAgnosticMemoryManagerWithParams, givenReducedGpuAddressSpaceWhenAllocateGraphicsMemoryForHostPtrIsCalledThenAllocationWithoutFragmentsIsCreated) { bool requiresL3Flush = GetParam(); MockExecutionEnvironment executionEnvironment(*platformDevices); - executionEnvironment.setHwInfo(platformDevices[0]); - if (executionEnvironment.isFullRangeSvm() || is32bit) { + executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(platformDevices[0]); + if (executionEnvironment.rootDeviceEnvironments[0]->isFullRangeSvm() || is32bit) { return; } OsAgnosticMemoryManager memoryManager(executionEnvironment); @@ -1186,8 +1186,8 @@ TEST_P(OsAgnosticMemoryManagerWithParams, givenReducedGpuAddressSpaceWhenAllocat TEST_P(OsAgnosticMemoryManagerWithParams, givenFullGpuAddressSpaceWhenAllocateGraphicsMemoryForHostPtrIsCalledThenAllocationWithFragmentsIsCreated) { bool requiresL3Flush = GetParam(); MockExecutionEnvironment executionEnvironment(*platformDevices); - executionEnvironment.setHwInfo(platformDevices[0]); - if ((!executionEnvironment.isFullRangeSvm() && !is32bit) || !platformDevices[0]->capabilityTable.hostPtrTrackingEnabled) { + executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(platformDevices[0]); + if ((!executionEnvironment.rootDeviceEnvironments[0]->isFullRangeSvm() && !is32bit) || !platformDevices[0]->capabilityTable.hostPtrTrackingEnabled) { GTEST_SKIP(); } OsAgnosticMemoryManager memoryManager(executionEnvironment); @@ -1212,8 +1212,8 @@ TEST_P(OsAgnosticMemoryManagerWithParams, givenDisabledHostPtrTrackingWhenAlloca bool requiresL3Flush = GetParam(); MockExecutionEnvironment executionEnvironment(*platformDevices); - executionEnvironment.setHwInfo(platformDevices[0]); - if (!executionEnvironment.isFullRangeSvm()) { + executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(platformDevices[0]); + if (!executionEnvironment.rootDeviceEnvironments[0]->isFullRangeSvm()) { return; } OsAgnosticMemoryManager memoryManager(executionEnvironment); @@ -2230,10 +2230,10 @@ HWTEST_F(MemoryAllocatorTest, givenMemoryManagerWhenHostPtrTrackingEnabledThenNo DebugManager.flags.EnableHostPtrTracking.set(1); auto result = memoryManager->useNonSvmHostPtrAlloc(GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR, 0u); - EXPECT_EQ(!executionEnvironment->isFullRangeSvm() && !is32bit, result); + EXPECT_EQ(!executionEnvironment->rootDeviceEnvironments[0]->isFullRangeSvm() && !is32bit, result); result = memoryManager->useNonSvmHostPtrAlloc(GraphicsAllocation::AllocationType::MAP_ALLOCATION, 0u); - EXPECT_EQ(!executionEnvironment->isFullRangeSvm() && !is32bit, result); + EXPECT_EQ(!executionEnvironment->rootDeviceEnvironments[0]->isFullRangeSvm() && !is32bit, result); } using PageTableManagerTest = ::testing::Test; @@ -2241,6 +2241,9 @@ using PageTableManagerTest = ::testing::Test; HWTEST_F(PageTableManagerTest, givenMemoryManagerThatSupportsPageTableManagerWhenMapAuxGpuVAIsCalledThenItReturnsTrue) { ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->prepareRootDeviceEnvironments(2); + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(*platformDevices); + } auto memoryManager = new MockMemoryManager(false, false, *executionEnvironment); executionEnvironment->memoryManager.reset(memoryManager); MockGraphicsAllocation allocation(1u, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull); diff --git a/opencl/test/unit_test/mocks/mock_aub_csr.h b/opencl/test/unit_test/mocks/mock_aub_csr.h index b0d12d6d7e..8944d1be85 100644 --- a/opencl/test/unit_test/mocks/mock_aub_csr.h +++ b/opencl/test/unit_test/mocks/mock_aub_csr.h @@ -182,7 +182,7 @@ template std::unique_ptr getEnvironment(bool createTagAllocation, bool allocateCommandBuffer, bool standalone) { std::unique_ptr executionEnvironment(new ExecutionEnvironment); executionEnvironment->prepareRootDeviceEnvironments(1); - executionEnvironment->setHwInfo(*platformDevices); + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(*platformDevices); executionEnvironment->rootDeviceEnvironments[0]->aubCenter.reset(new AubCenter()); executionEnvironment->initializeMemoryManager(); diff --git a/opencl/test/unit_test/mocks/mock_device.cpp b/opencl/test/unit_test/mocks/mock_device.cpp index 38d64d338d..94c0a37e33 100644 --- a/opencl/test/unit_test/mocks/mock_device.cpp +++ b/opencl/test/unit_test/mocks/mock_device.cpp @@ -53,7 +53,7 @@ MockDevice::MockDevice(ExecutionEnvironment *executionEnvironment, uint32_t root bool aubUsage = (testMode == TestMode::AubTests) || (testMode == TestMode::AubTestsWithTbx); this->mockMemoryManager.reset(new MemoryManagerCreate(false, enableLocalMemory, aubUsage, *executionEnvironment)); this->osTime = MockOSTime::create(); - executionEnvironment->setHwInfo(&hwInfo); + executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(&hwInfo); executionEnvironment->initializeMemoryManager(); initializeCaps(); preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfo); diff --git a/opencl/test/unit_test/mocks/mock_device.h b/opencl/test/unit_test/mocks/mock_device.h index 32c61b1aca..da99ff144a 100644 --- a/opencl/test/unit_test/mocks/mock_device.h +++ b/opencl/test/unit_test/mocks/mock_device.h @@ -94,7 +94,7 @@ class MockDevice : public RootDevice { template static T *createWithExecutionEnvironment(const HardwareInfo *pHwInfo, ExecutionEnvironment *executionEnvironment, uint32_t rootDeviceIndex) { pHwInfo = pHwInfo ? pHwInfo : platformDevices[0]; - executionEnvironment->setHwInfo(pHwInfo); + executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(pHwInfo); T *device = new T(executionEnvironment, rootDeviceIndex); executionEnvironment->memoryManager = std::move(device->mockMemoryManager); return createDeviceInternals(device); @@ -106,7 +106,9 @@ class MockDevice : public RootDevice { auto numRootDevices = DebugManager.flags.CreateMultipleRootDevices.get() ? DebugManager.flags.CreateMultipleRootDevices.get() : 1u; executionEnvironment->prepareRootDeviceEnvironments(numRootDevices); pHwInfo = pHwInfo ? pHwInfo : platformDevices[0]; - executionEnvironment->setHwInfo(pHwInfo); + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(pHwInfo); + } return createWithExecutionEnvironment(pHwInfo, executionEnvironment, rootDeviceIndex); } @@ -175,7 +177,7 @@ inline Device *MockDevice::createWithNewExecutionEnvironment(const Hardw executionEnvironment->prepareRootDeviceEnvironments(1); MockAubCenterFixture::setMockAubCenter(*executionEnvironment->rootDeviceEnvironments[0]); auto hwInfo = pHwInfo ? pHwInfo : *platformDevices; - executionEnvironment->setHwInfo(hwInfo); + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(hwInfo); executionEnvironment->initializeMemoryManager(); return Device::create(executionEnvironment, 0u); } diff --git a/opencl/test/unit_test/mocks/mock_execution_environment.h b/opencl/test/unit_test/mocks/mock_execution_environment.h index 2c38d71d1b..fd6c6a9c38 100644 --- a/opencl/test/unit_test/mocks/mock_execution_environment.h +++ b/opencl/test/unit_test/mocks/mock_execution_environment.h @@ -47,13 +47,14 @@ struct MockExecutionEnvironment : ExecutionEnvironment { auto rootDeviceEnvironment = new MockRootDeviceEnvironment(*this); rootDeviceEnvironment->useMockAubCenter = useMockAubCenter; rootDeviceEnvironments[rootDeviceIndex].reset(rootDeviceEnvironment); + + if (hwInfo) { + rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(hwInfo); + } else { + rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(platformDevices[0]); + } } - if (hwInfo) { - setHwInfo(hwInfo); - } else { - setHwInfo(platformDevices[0]); - } calculateMaxOsContextCount(); } void initGmm() { diff --git a/opencl/test/unit_test/mocks/mock_platform.cpp b/opencl/test/unit_test/mocks/mock_platform.cpp index 5f2ac7c03d..1106c7ac7e 100644 --- a/opencl/test/unit_test/mocks/mock_platform.cpp +++ b/opencl/test/unit_test/mocks/mock_platform.cpp @@ -17,6 +17,7 @@ bool initPlatform() { return pPlatform->initialize(DeviceFactory::createDevices(*pPlatform->peekExecutionEnvironment())); } bool MockPlatform::initializeWithNewDevices() { + executionEnvironment.prepareRootDeviceEnvironments(1u); return Platform::initialize(DeviceFactory::createDevices(executionEnvironment)); } } // namespace NEO diff --git a/opencl/test/unit_test/mocks/mock_program.cpp b/opencl/test/unit_test/mocks/mock_program.cpp index 6f58d55787..e0850b96f1 100644 --- a/opencl/test/unit_test/mocks/mock_program.cpp +++ b/opencl/test/unit_test/mocks/mock_program.cpp @@ -53,8 +53,10 @@ void GlobalMockSipProgram::resetAllocationState() { void GlobalMockSipProgram::initSipProgram() { cl_int retVal = 0; std::vector binary = MockCompilerInterface::getDummyGenBinary(); - executionEnvironment.setHwInfo(*platformDevices); executionEnvironment.prepareRootDeviceEnvironments(maxRootDeviceCount); + for (auto i = 0u; i < executionEnvironment.rootDeviceEnvironments.size(); i++) { + executionEnvironment.rootDeviceEnvironments[i]->setHwInfo(*platformDevices); + } executionEnvironment.calculateMaxOsContextCount(); sipProgram = Program::createFromGenBinary(executionEnvironment, nullptr, diff --git a/opencl/test/unit_test/os_interface/linux/drm_command_stream_fixture.h b/opencl/test/unit_test/os_interface/linux/drm_command_stream_fixture.h index 63e8425a90..cf4d2f85e7 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_command_stream_fixture.h +++ b/opencl/test/unit_test/os_interface/linux/drm_command_stream_fixture.h @@ -35,7 +35,7 @@ class DrmCommandStreamTest : public ::testing::Test { executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique(); executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setDrm(mock); - auto hwInfo = executionEnvironment.getHardwareInfo(); + auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo(); osContext = std::make_unique(*mock, 0u, 1, HwHelper::get(hwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0], PreemptionHelper::getDefaultPreemptionMode(*hwInfo), false, false, false); diff --git a/opencl/test/unit_test/os_interface/linux/drm_command_stream_mm_tests.cpp b/opencl/test/unit_test/os_interface/linux/drm_command_stream_mm_tests.cpp index c01fedd3b8..4824785bdc 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_command_stream_mm_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/drm_command_stream_mm_tests.cpp @@ -48,7 +48,7 @@ HWTEST_F(DrmCommandStreamMMTest, givenForcePinDisabledWhenMemoryManagerIsCreated auto drm = new DrmMockCustom(); MockExecutionEnvironment executionEnvironment; - executionEnvironment.setHwInfo(*platformDevices); + executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(*platformDevices); executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique(); executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setDrm(drm); @@ -64,9 +64,9 @@ HWTEST_F(DrmCommandStreamMMTest, givenForcePinDisabledWhenMemoryManagerIsCreated HWTEST_F(DrmCommandStreamMMTest, givenExecutionEnvironmentWithMoreThanOneRootDeviceEnvWhenCreatingDrmMemoryManagerThenCreateAsManyPinBBs) { MockExecutionEnvironment executionEnvironment; executionEnvironment.prepareRootDeviceEnvironments(2); - executionEnvironment.setHwInfo(*platformDevices); for (uint32_t rootDeviceIndex = 0; rootDeviceIndex < executionEnvironment.rootDeviceEnvironments.size(); rootDeviceIndex++) { + executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(*platformDevices); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique(); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->setDrm(new DrmMockCustom()); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = std::make_unique(); diff --git a/opencl/test/unit_test/os_interface/linux/drm_command_stream_tests.cpp b/opencl/test/unit_test/os_interface/linux/drm_command_stream_tests.cpp index 739aea377e..68c412298a 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_command_stream_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/drm_command_stream_tests.cpp @@ -1385,6 +1385,7 @@ struct MockDrmCsr : public DrmCommandStreamReceiver { HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenDrmCommandStreamReceiverWhenCreatePageTableMngrIsCalledThenCreatePageTableManager) { executionEnvironment.prepareRootDeviceEnvironments(2); + executionEnvironment.rootDeviceEnvironments[1]->setHwInfo(*platformDevices); executionEnvironment.rootDeviceEnvironments[1]->initGmm(); executionEnvironment.rootDeviceEnvironments[1]->osInterface = std::make_unique(); executionEnvironment.rootDeviceEnvironments[1]->osInterface->get()->setDrm(new DrmMockCustom()); diff --git a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp index f973e5008f..91ebfe236f 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp @@ -511,6 +511,9 @@ TEST_F(DrmMemoryManagerTest, givenDrmAllocationWhenHandleFenceCompletionThenCall TEST(DrmMemoryManagerTest2, givenDrmMemoryManagerWhengetSystemSharedMemoryIsCalledThenContextGetParamIsCalled) { auto executionEnvironment = std::make_unique(); executionEnvironment->prepareRootDeviceEnvironments(4u); + for (auto i = 0u; i < 4u; i++) { + executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(*platformDevices); + } auto memoryManager = std::make_unique(false, false, false, *executionEnvironment); for (auto i = 0u; i < 4u; i++) { @@ -540,6 +543,9 @@ TEST_F(DrmMemoryManagerTest, getMaxApplicationAddress) { TEST(DrmMemoryManagerTest2, getMinimumSystemSharedMemory) { auto executionEnvironment = std::make_unique(); executionEnvironment->prepareRootDeviceEnvironments(4u); + for (auto i = 0u; i < 4u; i++) { + executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(*platformDevices); + } auto memoryManager = std::make_unique(false, false, false, *executionEnvironment); for (auto i = 0u; i < 4u; i++) { auto mock = new DrmMockCustom(); @@ -3156,7 +3162,7 @@ TEST_F(DrmMemoryManagerBasic, ifLimitedRangeAllocatorAvailableWhenAskedForAlloca } TEST_F(DrmMemoryManagerBasic, givenSpecificAddressSpaceWhenInitializingMemoryManagerThenSetCorrectHeaps) { - executionEnvironment.getMutableHardwareInfo()->capabilityTable.gpuAddressSpace = maxNBitValue(48); + executionEnvironment.rootDeviceEnvironments[0]->getMutableHardwareInfo()->capabilityTable.gpuAddressSpace = maxNBitValue(48); TestedDrmMemoryManager memoryManager(false, false, false, executionEnvironment); auto gfxPartition = memoryManager.getGfxPartition(0); @@ -3250,6 +3256,9 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, whenReservingAddressRangeTh TEST(DrmMemoryManagerWithExplicitExpectationsTest2, whenObtainFdFromHandleIsCalledThenProperFdHandleIsReturned) { auto executionEnvironment = std::make_unique(); executionEnvironment->prepareRootDeviceEnvironments(4u); + for (auto i = 0u; i < 4u; i++) { + executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(*platformDevices); + } auto memoryManager = std::make_unique(false, false, false, *executionEnvironment); for (auto i = 0u; i < 4u; i++) { auto mock = new DrmMockCustom(); diff --git a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.h b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.h index 673bd90959..0862619b46 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.h +++ b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.h @@ -95,8 +95,8 @@ class DrmMemoryManagerFixtureWithoutQuietIoctlExpectation { void SetUp() { executionEnvironment = new ExecutionEnvironment; - executionEnvironment->setHwInfo(*platformDevices); executionEnvironment->prepareRootDeviceEnvironments(1); + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(*platformDevices); mock = new DrmMockCustom(); executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique(); executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->setDrm(mock); diff --git a/opencl/test/unit_test/os_interface/linux/drm_neo_create.cpp b/opencl/test/unit_test/os_interface/linux/drm_neo_create.cpp index a7e455fbd3..b3bae96e04 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_neo_create.cpp +++ b/opencl/test/unit_test/os_interface/linux/drm_neo_create.cpp @@ -5,6 +5,9 @@ * */ +#include "shared/source/execution_environment/root_device_environment.h" +#include "shared/test/unit_test/helpers/default_hw_info.h" + #include "opencl/test/unit_test/os_interface/linux/drm_mock.h" #include "drm/i915_drm.h" @@ -28,6 +31,7 @@ class DrmMockDefault : public DrmMock { Drm **pDrmToReturnFromCreateFunc = nullptr; Drm *Drm::create(std::unique_ptr hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) { + rootDeviceEnvironment.setHwInfo(platformDevices[0]); if (pDrmToReturnFromCreateFunc) { return *pDrmToReturnFromCreateFunc; } diff --git a/opencl/test/unit_test/os_interface/windows/device_command_stream_tests.cpp b/opencl/test/unit_test/os_interface/windows/device_command_stream_tests.cpp index f9e1921d53..bc7e313a19 100644 --- a/opencl/test/unit_test/os_interface/windows/device_command_stream_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/device_command_stream_tests.cpp @@ -245,7 +245,7 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOf HardwareInfo *hwInfo = nullptr; ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo, 1); hwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::Disabled; - executionEnvironment->setHwInfo(hwInfo); + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(hwInfo); auto wddm = static_cast(executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->getWddm()); auto csr = std::make_unique>(*executionEnvironment, 0); executionEnvironment->memoryManager.reset(new MemoryManagerCreate(false, false, *executionEnvironment)); @@ -271,7 +271,7 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOn HardwareInfo *hwInfo = nullptr; ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo, 1); hwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread; - executionEnvironment->setHwInfo(hwInfo); + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(hwInfo); auto wddm = static_cast(executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->getWddm()); auto csr = std::make_unique>(*executionEnvironment, 0); executionEnvironment->memoryManager.reset(new MemoryManagerCreate(false, false, *executionEnvironment)); @@ -298,7 +298,7 @@ TEST(WddmPreemptionHeaderTests, givenDeviceSupportingPreemptionWhenCommandStream HardwareInfo *hwInfo = nullptr; ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo, 1); hwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread; - executionEnvironment->setHwInfo(hwInfo); + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(hwInfo); auto commandStreamReceiver = std::make_unique>(*executionEnvironment, 0); auto commandHeader = commandStreamReceiver->commandBufferHeader; auto header = reinterpret_cast(commandHeader); @@ -309,7 +309,7 @@ TEST(WddmPreemptionHeaderTests, givenDevicenotSupportingPreemptionWhenCommandStr HardwareInfo *hwInfo = nullptr; ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo, 1); hwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::Disabled; - executionEnvironment->setHwInfo(hwInfo); + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(hwInfo); auto commandStreamReceiver = std::make_unique>(*executionEnvironment, 0); auto commandHeader = commandStreamReceiver->commandBufferHeader; auto header = reinterpret_cast(commandHeader); @@ -945,7 +945,7 @@ TEST_F(WddmCommandStreamTest, whenDirectSubmissionDisabledThenExpectNoFeatureAva TEST_F(WddmCommandStreamTest, whenDirectSubmissionEnabledOnRcsThenExpectFeatureAvailable) { DebugManager.flags.EnableDirectSubmission.set(1); - auto hwInfo = device->getExecutionEnvironment()->getMutableHardwareInfo(); + auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].engineSupported = true; bool ret = csr->initDirectSubmission(*device.get(), *osContext.get()); @@ -956,7 +956,7 @@ TEST_F(WddmCommandStreamTest, whenDirectSubmissionEnabledOnRcsThenExpectFeatureA TEST_F(WddmCommandStreamTest, givenDirectSubmissionEnabledWhenPlatformNotSupportsRcsThenExpectFeatureNotAvailable) { DebugManager.flags.EnableDirectSubmission.set(1); - auto hwInfo = device->getExecutionEnvironment()->getMutableHardwareInfo(); + auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].engineSupported = false; bool ret = csr->initDirectSubmission(*device.get(), *osContext.get()); @@ -972,7 +972,7 @@ TEST_F(WddmCommandStreamTest, whenDirectSubmissionEnabledOnBcsThenExpectFeatureA false, false, false)); osContext->setDefaultContext(true); - auto hwInfo = device->getExecutionEnvironment()->getMutableHardwareInfo(); + auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_BCS].engineSupported = true; bool ret = csr->initDirectSubmission(*device.get(), *osContext.get()); @@ -988,7 +988,7 @@ TEST_F(WddmCommandStreamTest, givenDirectSubmissionEnabledWhenPlatformNotSupport false, false, false)); osContext->setDefaultContext(true); - auto hwInfo = device->getExecutionEnvironment()->getMutableHardwareInfo(); + auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_BCS].engineSupported = false; bool ret = csr->initDirectSubmission(*device.get(), *osContext.get()); @@ -1004,7 +1004,7 @@ TEST_F(WddmCommandStreamTest, givenLowPriorityContextWhenDirectSubmissionDisable true, false, false)); osContext->setDefaultContext(true); - auto hwInfo = device->getExecutionEnvironment()->getMutableHardwareInfo(); + auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].engineSupported = true; hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].useLowPriority = false; @@ -1020,7 +1020,7 @@ TEST_F(WddmCommandStreamTest, givenLowPriorityContextWhenDirectSubmissionEnabled 0, 0, aub_stream::ENGINE_RCS, PreemptionMode::ThreadGroup, true, false, false)); - auto hwInfo = device->getExecutionEnvironment()->getMutableHardwareInfo(); + auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].engineSupported = true; hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].useLowPriority = true; bool ret = csr->initDirectSubmission(*device.get(), *osContext.get()); @@ -1036,7 +1036,7 @@ TEST_F(WddmCommandStreamTest, givenInternalContextWhenDirectSubmissionDisabledOn false, true, false)); osContext->setDefaultContext(true); - auto hwInfo = device->getExecutionEnvironment()->getMutableHardwareInfo(); + auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].engineSupported = true; hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].useInternal = false; @@ -1052,7 +1052,7 @@ TEST_F(WddmCommandStreamTest, givenInternalContextWhenDirectSubmissionEnabledOnI 0, 0, aub_stream::ENGINE_RCS, PreemptionMode::ThreadGroup, false, true, false)); - auto hwInfo = device->getExecutionEnvironment()->getMutableHardwareInfo(); + auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].engineSupported = true; hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].useInternal = true; @@ -1069,7 +1069,7 @@ TEST_F(WddmCommandStreamTest, givenRootDeviceContextWhenDirectSubmissionDisabled false, false, true)); osContext->setDefaultContext(true); - auto hwInfo = device->getExecutionEnvironment()->getMutableHardwareInfo(); + auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].engineSupported = true; hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].useRootDevice = false; @@ -1085,7 +1085,7 @@ TEST_F(WddmCommandStreamTest, givenRootDeviceContextWhenDirectSubmissionEnabledO 0, 0, aub_stream::ENGINE_RCS, PreemptionMode::ThreadGroup, false, false, true)); - auto hwInfo = device->getExecutionEnvironment()->getMutableHardwareInfo(); + auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].engineSupported = true; hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].useRootDevice = true; @@ -1102,7 +1102,7 @@ TEST_F(WddmCommandStreamTest, givenNonDefaultContextWhenDirectSubmissionDisabled false, false, false)); osContext->setDefaultContext(false); - auto hwInfo = device->getExecutionEnvironment()->getMutableHardwareInfo(); + auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].engineSupported = true; hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].useNonDefault = false; @@ -1119,7 +1119,7 @@ TEST_F(WddmCommandStreamTest, givenNonDefaultContextContextWhenDirectSubmissionE false, false, false)); osContext->setDefaultContext(false); - auto hwInfo = device->getExecutionEnvironment()->getMutableHardwareInfo(); + auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].engineSupported = true; hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].useNonDefault = true; diff --git a/opencl/test/unit_test/os_interface/windows/hw_info_config_win_tests.cpp b/opencl/test/unit_test/os_interface/windows/hw_info_config_win_tests.cpp index 3b2b9b8d26..e59f3be7f5 100644 --- a/opencl/test/unit_test/os_interface/windows/hw_info_config_win_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/hw_info_config_win_tests.cpp @@ -69,7 +69,7 @@ void HwInfoConfigTestWindows::SetUp() { std::unique_ptr wddm(Wddm::createWddm(nullptr, *rootDeviceEnvironment)); wddm->init(); - outHwInfo = *executionEnvironment->getHardwareInfo(); + outHwInfo = *rootDeviceEnvironment->getHardwareInfo(); } void HwInfoConfigTestWindows::TearDown() { diff --git a/opencl/test/unit_test/os_interface/windows/wddm20_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm20_tests.cpp index 24efb2f247..59757ab717 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm20_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm20_tests.cpp @@ -528,7 +528,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationF auto wddmAllocation = (WddmAllocation *)graphicsAllocation; ASSERT_NE(nullptr, wddmAllocation); - if (is32bit && executionEnvironment->isFullRangeSvm()) { + if (is32bit && executionEnvironment->rootDeviceEnvironments[graphicsAllocation->getRootDeviceIndex()]->isFullRangeSvm()) { EXPECT_NE(wddm->mapGpuVirtualAddressResult.cpuPtrPassed, nullptr); } else { EXPECT_EQ(wddm->mapGpuVirtualAddressResult.cpuPtrPassed, nullptr); diff --git a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp index bbe6a3fd62..084183fd8c 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp @@ -347,6 +347,9 @@ TEST_F(WddmMemoryManagerSimpleTest, givenNonZeroFenceValueOnSingleEngineRegister TEST_F(WddmMemoryManagerSimpleTest, givenNonZeroFenceValuesOnMultipleEnginesRegisteredWhenHandleFenceCompletionIsCalledThenWaitOnCpuForEachEngine) { executionEnvironment->prepareRootDeviceEnvironments(2u); + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(*platformDevices); + } std::unique_ptr csr(createCommandStream(*executionEnvironment, 1u)); auto wddm2 = static_cast(Wddm::createWddm(nullptr, *executionEnvironment->rootDeviceEnvironments[0].get())); @@ -377,6 +380,9 @@ TEST_F(WddmMemoryManagerSimpleTest, givenNonZeroFenceValuesOnMultipleEnginesRegi TEST_F(WddmMemoryManagerSimpleTest, givenNonZeroFenceValueOnSomeOfMultipleEnginesRegisteredWhenHandleFenceCompletionIsCalledThenWaitOnCpuForTheseEngines) { executionEnvironment->prepareRootDeviceEnvironments(2u); + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(*platformDevices); + } std::unique_ptr csr(createCommandStream(*executionEnvironment, 1u)); auto wddm2 = static_cast(Wddm::createWddm(nullptr, *executionEnvironment->rootDeviceEnvironments[0].get())); @@ -1411,7 +1417,7 @@ TEST_F(MockWddmMemoryManagerTest, givenWddmWhenallocateGraphicsMemory64kbThenLoc GraphicsAllocation *galloc = memoryManager64k.allocateGraphicsMemory64kb(allocationData); EXPECT_EQ(lockCount + 1, wddm->lockResult.called); EXPECT_EQ(mapGpuVirtualAddressResult + 1, wddm->mapGpuVirtualAddressResult.called); - if (executionEnvironment->isFullRangeSvm()) { + if (executionEnvironment->rootDeviceEnvironments[0]->isFullRangeSvm()) { EXPECT_NE(nullptr, wddm->mapGpuVirtualAddressResult.cpuPtrPassed); } else { EXPECT_EQ(nullptr, wddm->mapGpuVirtualAddressResult.cpuPtrPassed); @@ -1438,6 +1444,9 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerAnd32bitBuildThenSvmPartitio TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWithRegisteredOsContextWhenCallingIsMemoryBudgetExhaustedThenReturnFalse) { executionEnvironment->prepareRootDeviceEnvironments(3u); + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(*platformDevices); + } executionEnvironment->initializeMemoryManager(); for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { auto wddm = static_cast(Wddm::createWddm(nullptr, *executionEnvironment->rootDeviceEnvironments[i].get())); @@ -1460,6 +1469,9 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWithRegisteredOsContextWhenC TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWithRegisteredOsContextWithExhaustedMemoryBudgetWhenCallingIsMemoryBudgetExhaustedThenReturnTrue) { executionEnvironment->prepareRootDeviceEnvironments(3u); + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(*platformDevices); + } executionEnvironment->initializeMemoryManager(); for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { auto wddm = static_cast(Wddm::createWddm(nullptr, *executionEnvironment->rootDeviceEnvironments[i].get())); @@ -1802,7 +1814,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenSvmCpuAllocationWhenSizeAndAlignmentPro EXPECT_NE(nullptr, allocation->getUnderlyingBuffer()); EXPECT_EQ(allocation->getUnderlyingBuffer(), allocation->getDriverAllocatedCpuPtr()); //limited platforms will not use heap HeapIndex::HEAP_SVM - if (executionEnvironment->isFullRangeSvm()) { + if (executionEnvironment->rootDeviceEnvironments[allocation->getRootDeviceIndex()]->isFullRangeSvm()) { EXPECT_EQ(alignUp(allocation->getReservedAddressPtr(), size), reinterpret_cast(allocation->getGpuAddress())); } EXPECT_EQ((2 * size), allocation->getReservedAddressSize()); @@ -1822,7 +1834,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenWriteCombinedAllocationThenCpuAddressIs EXPECT_NE(nullptr, allocation->getUnderlyingBuffer()); EXPECT_NE(nullptr, reinterpret_cast(allocation->getGpuAddress())); - if (executionEnvironment->isFullRangeSvm()) { + if (executionEnvironment->rootDeviceEnvironments[allocation->getRootDeviceIndex()]->isFullRangeSvm()) { EXPECT_EQ(allocation->getUnderlyingBuffer(), reinterpret_cast(allocation->getGpuAddress())); } @@ -1834,7 +1846,7 @@ TEST_F(WddmMemoryManagerSimpleTest, whenCreatingWddmMemoryManagerThenSupportsMul } TEST_F(WddmMemoryManagerSimpleTest, givenBufferHostMemoryAllocationAndLimitedRangeAnd32BitThenAllocationGoesToSvmHeap) { - if (executionEnvironment->isFullRangeSvm()) { + if (executionEnvironment->rootDeviceEnvironments[0]->isFullRangeSvm()) { GTEST_SKIP(); } diff --git a/opencl/test/unit_test/program/program_tests.cpp b/opencl/test/unit_test/program/program_tests.cpp index 508ac5dd3e..a54b8a534a 100644 --- a/opencl/test/unit_test/program/program_tests.cpp +++ b/opencl/test/unit_test/program/program_tests.cpp @@ -1914,6 +1914,7 @@ TEST_F(ProgramTests, RebuildBinaryButNoCompilerInterface) { auto pDevice = pContext->getDevice(0); auto executionEnvironment = pDevice->getExecutionEnvironment(); std::unique_ptr rootDeviceEnvironment = std::make_unique(*executionEnvironment); + rootDeviceEnvironment->setHwInfo(&pDevice->getHardwareInfo()); std::swap(rootDeviceEnvironment, executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]); auto program = std::make_unique(*executionEnvironment); EXPECT_NE(nullptr, program); @@ -2752,6 +2753,7 @@ TEST_F(setProgramSpecializationConstantTests, givenInvalidGetSpecConstantsInfoRe TEST(setProgramSpecializationConstantTest, givenUninitializedCompilerinterfaceWhenSetProgramSpecializationConstantThenErrorIsReturned) { auto executionEnvironment = new MockExecutionEnvironment(); executionEnvironment->rootDeviceEnvironments[0] = std::make_unique(*executionEnvironment); + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(*platformDevices); MockDevice mockDevice(executionEnvironment, 0); SpecializationConstantProgramMock mockProgram(*executionEnvironment); mockProgram.setDevice(&mockDevice); diff --git a/opencl/test/unit_test/source_level_debugger/source_level_debugger_tests.cpp b/opencl/test/unit_test/source_level_debugger/source_level_debugger_tests.cpp index e4e9ae2201..771982ba4d 100644 --- a/opencl/test/unit_test/source_level_debugger/source_level_debugger_tests.cpp +++ b/opencl/test/unit_test/source_level_debugger/source_level_debugger_tests.cpp @@ -538,7 +538,9 @@ TEST(SourceLevelDebugger, givenTwoRootDevicesWhenSecondIsCreatedThenNotCreatingN ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->prepareRootDeviceEnvironments(2); - + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(*platformDevices); + } std::unique_ptr device1(Device::create(executionEnvironment, 0u)); EXPECT_NE(nullptr, executionEnvironment->memoryManager); EXPECT_TRUE(interceptor.initCalled); @@ -559,6 +561,9 @@ TEST(SourceLevelDebugger, givenMultipleRootDevicesWhenTheyAreCreatedTheyAllReuse ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->prepareRootDeviceEnvironments(2); + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(*platformDevices); + } std::unique_ptr device1(Device::create(executionEnvironment, 0u)); auto sourceLevelDebugger = device1->getDebugger(); std::unique_ptr device2(Device::create(executionEnvironment, 1u)); diff --git a/opencl/test/unit_test/ult_config_listener.cpp b/opencl/test/unit_test/ult_config_listener.cpp index f8242a2721..486bb4b67e 100644 --- a/opencl/test/unit_test/ult_config_listener.cpp +++ b/opencl/test/unit_test/ult_config_listener.cpp @@ -18,7 +18,7 @@ void NEO::UltConfigListener::OnTestStart(const ::testing::TestInfo &testInfo) { referencedHwInfo = *platformDevices[0]; auto executionEnvironment = constructPlatform()->peekExecutionEnvironment(); executionEnvironment->prepareRootDeviceEnvironments(1); - executionEnvironment->setHwInfo(*platformDevices); + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(*platformDevices); executionEnvironment->calculateMaxOsContextCount(); executionEnvironment->rootDeviceEnvironments[0]->initGmm(); } diff --git a/opencl/test/unit_test/windows/get_devices_tests.cpp b/opencl/test/unit_test/windows/get_devices_tests.cpp index 11e6efb87c..70c7059fa2 100644 --- a/opencl/test/unit_test/windows/get_devices_tests.cpp +++ b/opencl/test/unit_test/windows/get_devices_tests.cpp @@ -6,6 +6,7 @@ */ #include "shared/source/execution_environment/execution_environment.h" +#include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/helpers/hw_info.h" #include "shared/source/os_interface/device_factory.h" @@ -29,7 +30,8 @@ HWTEST_F(GetDevicesTests, whenGetDevicesIsCalledThenGmmIsBeingInitializedAfterFi auto executionEnvironment = new ExecutionEnvironment(); platformsImpl.push_back(std::make_unique(*executionEnvironment)); size_t numDevicesReturned = 0; - auto hwInfo = executionEnvironment->getMutableHardwareInfo(); + executionEnvironment->prepareRootDeviceEnvironments(1u); + auto hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo(); hwInfo->platform.eProductFamily = PRODUCT_FAMILY::IGFX_UNKNOWN; hwInfo->platform.ePCHProductFamily = PCH_PRODUCT_FAMILY::PCH_UNKNOWN; diff --git a/shared/source/device/device.h b/shared/source/device/device.h index 4c535c3a7b..7b72f4fa41 100644 --- a/shared/source/device/device.h +++ b/shared/source/device/device.h @@ -59,7 +59,7 @@ class Device : public ReferenceTrackedObject { const RootDeviceEnvironment &getRootDeviceEnvironment() const { return *executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]; } const HardwareCapabilities &getHardwareCapabilities() const { return hardwareCapabilities; } bool isFullRangeSvm() const { - return executionEnvironment->isFullRangeSvm(); + return getRootDeviceEnvironment().isFullRangeSvm(); } bool areSharedSystemAllocationsAllowed() const { return this->deviceInfo.sharedSystemMemCapabilities != 0u; diff --git a/shared/source/execution_environment/execution_environment.cpp b/shared/source/execution_environment/execution_environment.cpp index 2004c3ce8f..e499217b7e 100644 --- a/shared/source/execution_environment/execution_environment.cpp +++ b/shared/source/execution_environment/execution_environment.cpp @@ -18,9 +18,7 @@ #include "opencl/source/memory_manager/os_agnostic_memory_manager.h" namespace NEO { -ExecutionEnvironment::ExecutionEnvironment() { - hwInfo = std::make_unique(); -}; +ExecutionEnvironment::ExecutionEnvironment() = default; ExecutionEnvironment::~ExecutionEnvironment() { debugger.reset(); @@ -33,10 +31,6 @@ ExecutionEnvironment::~ExecutionEnvironment() { rootDeviceEnvironments.clear(); } -void ExecutionEnvironment::setHwInfo(const HardwareInfo *hwInfo) { - *this->hwInfo = *hwInfo; -} - void ExecutionEnvironment::initializeMemoryManager() { if (this->memoryManager) { return; @@ -63,7 +57,7 @@ void ExecutionEnvironment::initializeMemoryManager() { } void ExecutionEnvironment::initDebugger() { - debugger = Debugger::create(hwInfo.get()); + debugger = Debugger::create(rootDeviceEnvironments[0]->getMutableHardwareInfo()); } void ExecutionEnvironment::calculateMaxOsContextCount() { @@ -78,10 +72,6 @@ void ExecutionEnvironment::calculateMaxOsContextCount() { } } -bool ExecutionEnvironment::isFullRangeSvm() const { - return hwInfo->capabilityTable.gpuAddressSpace >= maxNBitValue(47); -} - void ExecutionEnvironment::prepareRootDeviceEnvironments(uint32_t numRootDevices) { if (rootDeviceEnvironments.size() < numRootDevices) { rootDeviceEnvironments.resize(numRootDevices); diff --git a/shared/source/execution_environment/execution_environment.h b/shared/source/execution_environment/execution_environment.h index f6562beb3c..eab030bf13 100644 --- a/shared/source/execution_environment/execution_environment.h +++ b/shared/source/execution_environment/execution_environment.h @@ -14,13 +14,9 @@ namespace NEO { class MemoryManager; class Debugger; struct RootDeviceEnvironment; -struct HardwareInfo; class ExecutionEnvironment : public ReferenceTrackedObject { - protected: - std::unique_ptr hwInfo; - public: ExecutionEnvironment(); ~ExecutionEnvironment() override; @@ -28,10 +24,6 @@ class ExecutionEnvironment : public ReferenceTrackedObject void initializeMemoryManager(); void initDebugger(); void calculateMaxOsContextCount(); - void setHwInfo(const HardwareInfo *hwInfo); - const HardwareInfo *getHardwareInfo() const { return hwInfo.get(); } - HardwareInfo *getMutableHardwareInfo() const { return hwInfo.get(); } - bool isFullRangeSvm() const; void prepareRootDeviceEnvironments(uint32_t numRootDevices); std::unique_ptr memoryManager; diff --git a/shared/source/execution_environment/root_device_environment.cpp b/shared/source/execution_environment/root_device_environment.cpp index 3ccfaa8bed..e697422902 100644 --- a/shared/source/execution_environment/root_device_environment.cpp +++ b/shared/source/execution_environment/root_device_environment.cpp @@ -13,6 +13,7 @@ #include "shared/source/execution_environment/execution_environment.h" #include "shared/source/gmm_helper/gmm_helper.h" #include "shared/source/gmm_helper/page_table_mngr.h" +#include "shared/source/helpers/hw_info.h" #include "shared/source/memory_manager/memory_operations_handler.h" #include "shared/source/os_interface/os_interface.h" @@ -20,7 +21,10 @@ namespace NEO { -RootDeviceEnvironment::RootDeviceEnvironment(ExecutionEnvironment &executionEnvironment) : executionEnvironment(executionEnvironment) {} +RootDeviceEnvironment::RootDeviceEnvironment(ExecutionEnvironment &executionEnvironment) : executionEnvironment(executionEnvironment) { + hwInfo = std::make_unique(); +} + RootDeviceEnvironment::~RootDeviceEnvironment() = default; void RootDeviceEnvironment::initAubCenter(bool localMemoryEnabled, const std::string &aubFileName, CommandStreamReceiverType csrType) { @@ -29,7 +33,19 @@ void RootDeviceEnvironment::initAubCenter(bool localMemoryEnabled, const std::st } } const HardwareInfo *RootDeviceEnvironment::getHardwareInfo() const { - return executionEnvironment.getHardwareInfo(); + return hwInfo.get(); +} + +HardwareInfo *RootDeviceEnvironment::getMutableHardwareInfo() const { + return hwInfo.get(); +} + +void RootDeviceEnvironment::setHwInfo(const HardwareInfo *hwInfo) { + *this->hwInfo = *hwInfo; +} + +bool RootDeviceEnvironment::isFullRangeSvm() const { + return hwInfo->capabilityTable.gpuAddressSpace >= maxNBitValue(47); } GmmHelper *RootDeviceEnvironment::getGmmHelper() const { diff --git a/shared/source/execution_environment/root_device_environment.h b/shared/source/execution_environment/root_device_environment.h index 21cb7f6d9b..ea9343022b 100644 --- a/shared/source/execution_environment/root_device_environment.h +++ b/shared/source/execution_environment/root_device_environment.h @@ -28,10 +28,18 @@ struct HardwareInfo; class HwDeviceId; struct RootDeviceEnvironment { + protected: + std::unique_ptr hwInfo; + + public: RootDeviceEnvironment(ExecutionEnvironment &executionEnvironment); RootDeviceEnvironment(RootDeviceEnvironment &) = delete; MOCKABLE_VIRTUAL ~RootDeviceEnvironment(); + MOCKABLE_VIRTUAL const HardwareInfo *getHardwareInfo() const; + HardwareInfo *getMutableHardwareInfo() const; + void setHwInfo(const HardwareInfo *hwInfo); + bool isFullRangeSvm() const; MOCKABLE_VIRTUAL void initAubCenter(bool localMemoryEnabled, const std::string &aubFileName, CommandStreamReceiverType csrType); bool initOsInterface(std::unique_ptr &&hwDeviceId); diff --git a/shared/source/memory_manager/memory_manager.cpp b/shared/source/memory_manager/memory_manager.cpp index 0baec4832e..989e1ac828 100644 --- a/shared/source/memory_manager/memory_manager.cpp +++ b/shared/source/memory_manager/memory_manager.cpp @@ -513,6 +513,19 @@ bool MemoryManager::isHostPointerTrackingEnabled(uint32_t rootDeviceIndex) { return (peekExecutionEnvironment().rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo()->capabilityTable.hostPtrTrackingEnabled | is32bit); } +bool MemoryManager::useNonSvmHostPtrAlloc(GraphicsAllocation::AllocationType allocationType, uint32_t rootDeviceIndex) { + bool isExternalHostPtrAlloc = (allocationType == GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR); + bool isMapAlloc = (allocationType == GraphicsAllocation::AllocationType::MAP_ALLOCATION); + + if (forceNonSvmForExternalHostPtr && isExternalHostPtrAlloc) { + return true; + } + + bool isNonSvmPtrCapable = ((!peekExecutionEnvironment().rootDeviceEnvironments[rootDeviceIndex]->isFullRangeSvm() || !isHostPointerTrackingEnabled(rootDeviceIndex)) & !is32bit); + + return isNonSvmPtrCapable && (isExternalHostPtrAlloc || isMapAlloc); +} + bool MemoryManager::isCopyRequired(ImageInfo &imgInfo, const void *hostPtr) { if (!hostPtr) { return false; diff --git a/shared/source/memory_manager/memory_manager.h b/shared/source/memory_manager/memory_manager.h index 0844832400..829e850563 100644 --- a/shared/source/memory_manager/memory_manager.h +++ b/shared/source/memory_manager/memory_manager.h @@ -205,18 +205,7 @@ class MemoryManager { } static bool isCopyRequired(ImageInfo &imgInfo, const void *hostPtr); - bool useNonSvmHostPtrAlloc(GraphicsAllocation::AllocationType allocationType, uint32_t rootDeviceIndex) { - bool isExternalHostPtrAlloc = (allocationType == GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR); - bool isMapAlloc = (allocationType == GraphicsAllocation::AllocationType::MAP_ALLOCATION); - - if (forceNonSvmForExternalHostPtr && isExternalHostPtrAlloc) { - return true; - } - - bool isNonSvmPtrCapable = ((!peekExecutionEnvironment().isFullRangeSvm() || !isHostPointerTrackingEnabled(rootDeviceIndex)) & !is32bit); - - return isNonSvmPtrCapable && (isExternalHostPtrAlloc || isMapAlloc); - } + bool useNonSvmHostPtrAlloc(GraphicsAllocation::AllocationType allocationType, uint32_t rootDeviceIndex); StorageInfo createStorageInfoFromProperties(const AllocationProperties &properties); virtual GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, const AllocationData &allocationData) = 0; diff --git a/shared/source/os_interface/device_factory.cpp b/shared/source/os_interface/device_factory.cpp index 8028aa82dc..e5e7f339be 100644 --- a/shared/source/os_interface/device_factory.cpp +++ b/shared/source/os_interface/device_factory.cpp @@ -37,39 +37,39 @@ bool DeviceFactory::getDevicesForProductFamilyOverride(size_t &numDevices, Execu uint64_t hwInfoConfig = 0x0; DebugManager.getHardwareInfoOverride(hwInfoConfigStr); - auto hardwareInfo = executionEnvironment.getMutableHardwareInfo(); - *hardwareInfo = *hwInfoConst; + for (auto rootDeviceIndex = 0u; rootDeviceIndex < numRootDevices; rootDeviceIndex++) { + auto hardwareInfo = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getMutableHardwareInfo(); + *hardwareInfo = *hwInfoConst; - if (hwInfoConfigStr == "default") { - hwInfoConfig = defaultHardwareInfoConfigTable[hwInfoConst->platform.eProductFamily]; - } else if (!parseHwInfoConfigString(hwInfoConfigStr, hwInfoConfig)) { - return false; - } - setHwInfoValuesFromConfig(hwInfoConfig, *hardwareInfo); + if (hwInfoConfigStr == "default") { + hwInfoConfig = defaultHardwareInfoConfigTable[hwInfoConst->platform.eProductFamily]; + } else if (!parseHwInfoConfigString(hwInfoConfigStr, hwInfoConfig)) { + return false; + } + setHwInfoValuesFromConfig(hwInfoConfig, *hardwareInfo); - hardwareInfoSetup[hwInfoConst->platform.eProductFamily](hardwareInfo, true, hwInfoConfig); + hardwareInfoSetup[hwInfoConst->platform.eProductFamily](hardwareInfo, true, hwInfoConfig); - HwInfoConfig *hwConfig = HwInfoConfig::get(hardwareInfo->platform.eProductFamily); - hardwareInfo->featureTable.ftrE2ECompression = 0; - hwConfig->configureHardwareCustom(hardwareInfo, nullptr); + HwInfoConfig *hwConfig = HwInfoConfig::get(hardwareInfo->platform.eProductFamily); + hardwareInfo->featureTable.ftrE2ECompression = 0; + hwConfig->configureHardwareCustom(hardwareInfo, nullptr); - executionEnvironment.calculateMaxOsContextCount(); - numDevices = numRootDevices; - auto csrType = DebugManager.flags.SetCommandStreamReceiver.get(); - if (csrType > 0) { - auto &hwHelper = HwHelper::get(hardwareInfo->platform.eRenderCoreFamily); - auto localMemoryEnabled = hwHelper.getEnableLocalMemory(*hardwareInfo); - for (auto rootDeviceIndex = 0u; rootDeviceIndex < numRootDevices; rootDeviceIndex++) { + auto csrType = DebugManager.flags.SetCommandStreamReceiver.get(); + if (csrType > 0) { + auto &hwHelper = HwHelper::get(hardwareInfo->platform.eRenderCoreFamily); + auto localMemoryEnabled = hwHelper.getEnableLocalMemory(*hardwareInfo); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->initAubCenter(localMemoryEnabled, "", static_cast(csrType)); auto aubCenter = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->aubCenter.get(); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = std::make_unique(aubCenter->getAubManager()); } + + if (DebugManager.flags.OverrideGpuAddressSpace.get() != -1) { + hardwareInfo->capabilityTable.gpuAddressSpace = maxNBitValue(static_cast(DebugManager.flags.OverrideGpuAddressSpace.get())); + } } - if (DebugManager.flags.OverrideGpuAddressSpace.get() != -1) { - executionEnvironment.getMutableHardwareInfo()->capabilityTable.gpuAddressSpace = - maxNBitValue(static_cast(DebugManager.flags.OverrideGpuAddressSpace.get())); - } + executionEnvironment.calculateMaxOsContextCount(); + numDevices = numRootDevices; return true; } @@ -104,16 +104,16 @@ bool DeviceFactory::getDevices(size_t &totalNumRootDevices, ExecutionEnvironment return false; } + if (DebugManager.flags.OverrideGpuAddressSpace.get() != -1) { + executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getMutableHardwareInfo()->capabilityTable.gpuAddressSpace = + maxNBitValue(static_cast(DebugManager.flags.OverrideGpuAddressSpace.get())); + } + rootDeviceIndex++; } executionEnvironment.calculateMaxOsContextCount(); - if (DebugManager.flags.OverrideGpuAddressSpace.get() != -1) { - executionEnvironment.getMutableHardwareInfo()->capabilityTable.gpuAddressSpace = - maxNBitValue(static_cast(DebugManager.flags.OverrideGpuAddressSpace.get())); - } - return true; } diff --git a/shared/source/os_interface/linux/os_interface.cpp b/shared/source/os_interface/linux/os_interface.cpp index cc79482a16..6c1c45d025 100644 --- a/shared/source/os_interface/linux/os_interface.cpp +++ b/shared/source/os_interface/linux/os_interface.cpp @@ -53,7 +53,7 @@ bool RootDeviceEnvironment::initOsInterface(std::unique_ptr &&hwDevi memoryOperationsInterface = std::make_unique(); osInterface.reset(new OSInterface()); osInterface->get()->setDrm(drm); - auto hardwareInfo = executionEnvironment.getMutableHardwareInfo(); + auto hardwareInfo = getMutableHardwareInfo(); HwInfoConfig *hwConfig = HwInfoConfig::get(hardwareInfo->platform.eProductFamily); if (hwConfig->configureHwInfo(hardwareInfo, hardwareInfo, osInterface.get())) { return false; diff --git a/shared/source/os_interface/windows/wddm/wddm.cpp b/shared/source/os_interface/windows/wddm/wddm.cpp index adf2c853dd..f96cdda36f 100644 --- a/shared/source/os_interface/windows/wddm/wddm.cpp +++ b/shared/source/os_interface/windows/wddm/wddm.cpp @@ -110,7 +110,7 @@ bool Wddm::init() { } auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*hardwareInfo); - rootDeviceEnvironment.executionEnvironment.setHwInfo(hardwareInfo.get()); + rootDeviceEnvironment.setHwInfo(hardwareInfo.get()); rootDeviceEnvironment.initGmm(); if (WddmVersion::WDDM_2_3 == getWddmVersion()) { diff --git a/shared/source/os_interface/windows/wddm_memory_manager.cpp b/shared/source/os_interface/windows/wddm_memory_manager.cpp index 1b6cc90c34..0e458921cf 100644 --- a/shared/source/os_interface/windows/wddm_memory_manager.cpp +++ b/shared/source/os_interface/windows/wddm_memory_manager.cpp @@ -506,8 +506,8 @@ bool WddmMemoryManager::createWddmAllocation(WddmAllocation *allocation, void *r bool WddmMemoryManager::mapGpuVaForOneHandleAllocation(WddmAllocation *allocation, const void *preferredGpuVirtualAddress) { D3DGPU_VIRTUAL_ADDRESS addressToMap = castToUint64(preferredGpuVirtualAddress); - auto heapIndex = selectHeap(allocation, preferredGpuVirtualAddress != nullptr, is32bit || executionEnvironment.isFullRangeSvm()); - if (!executionEnvironment.isFullRangeSvm()) { + auto heapIndex = selectHeap(allocation, preferredGpuVirtualAddress != nullptr, is32bit || executionEnvironment.rootDeviceEnvironments[allocation->getRootDeviceIndex()]->isFullRangeSvm()); + if (!executionEnvironment.rootDeviceEnvironments[allocation->getRootDeviceIndex()]->isFullRangeSvm()) { addressToMap = 0u; } if (allocation->reservedGpuVirtualAddress) { diff --git a/shared/test/unit_test/fixtures/preemption_fixture.cpp b/shared/test/unit_test/fixtures/preemption_fixture.cpp index 4c112533e7..bc4a891610 100644 --- a/shared/test/unit_test/fixtures/preemption_fixture.cpp +++ b/shared/test/unit_test/fixtures/preemption_fixture.cpp @@ -50,7 +50,7 @@ void DevicePreemptionTests::SetUp() { ASSERT_NE(nullptr, context); ASSERT_NE(nullptr, cmdQ); - waTable = &device->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable; + waTable = &device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable; } void DevicePreemptionTests::TearDown() { diff --git a/shared/test/unit_test/gen12lp/test_preamble_gen12lp.cpp b/shared/test/unit_test/gen12lp/test_preamble_gen12lp.cpp index 6766247e21..70d0106287 100644 --- a/shared/test/unit_test/gen12lp/test_preamble_gen12lp.cpp +++ b/shared/test/unit_test/gen12lp/test_preamble_gen12lp.cpp @@ -125,7 +125,7 @@ TGLLPTEST_F(Gen12LpPreambleVfeState, givenCfeFusedEuDispatchFlagsWhenprogramAddi using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE; DebugManagerStateRestore restorer; - auto pHwInfo = pPlatform->getDevice(0)->getExecutionEnvironment()->getMutableHardwareInfo(); + auto pHwInfo = pPlatform->getDevice(0)->getRootDeviceEnvironment().getMutableHardwareInfo(); auto pMediaVfeState = reinterpret_cast(linearStream.getSpace(sizeof(MEDIA_VFE_STATE))); *pMediaVfeState = FamilyType::cmdInitMediaVfeState; auto &waTable = pHwInfo->workaroundTable; diff --git a/shared/test/unit_test/gen8/test_preemption_gen8.cpp b/shared/test/unit_test/gen8/test_preemption_gen8.cpp index 7448ae09de..41a7242646 100644 --- a/shared/test/unit_test/gen8/test_preemption_gen8.cpp +++ b/shared/test/unit_test/gen8/test_preemption_gen8.cpp @@ -140,7 +140,7 @@ GEN8TEST_F(Gen8PreemptionTests, getPreemptionWaCsSizeMidBatch) { GEN8TEST_F(Gen8PreemptionTests, getPreemptionWaCsSizeThreadGroupNoWa) { size_t expectedSize = 0; device->setPreemptionMode(PreemptionMode::ThreadGroup); - device->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false; + device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false; size_t size = PreemptionHelper::getPreemptionWaCsSize(device->getDevice()); EXPECT_EQ(expectedSize, size); } @@ -149,7 +149,7 @@ GEN8TEST_F(Gen8PreemptionTests, getPreemptionWaCsSizeThreadGroupWa) { typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; size_t expectedSize = 2 * sizeof(MI_LOAD_REGISTER_IMM); device->setPreemptionMode(PreemptionMode::ThreadGroup); - device->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true; + device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true; size_t size = PreemptionHelper::getPreemptionWaCsSize(device->getDevice()); EXPECT_EQ(expectedSize, size); } @@ -157,7 +157,7 @@ GEN8TEST_F(Gen8PreemptionTests, getPreemptionWaCsSizeThreadGroupWa) { GEN8TEST_F(Gen8PreemptionTests, getPreemptionWaCsSizeMidThreadNoWa) { size_t expectedSize = 0; device->setPreemptionMode(PreemptionMode::MidThread); - device->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false; + device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false; size_t size = PreemptionHelper::getPreemptionWaCsSize(device->getDevice()); EXPECT_EQ(expectedSize, size); } @@ -166,7 +166,7 @@ GEN8TEST_F(Gen8PreemptionTests, getPreemptionWaCsSizeMidThreadWa) { typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; size_t expectedSize = 2 * sizeof(MI_LOAD_REGISTER_IMM); device->setPreemptionMode(PreemptionMode::MidThread); - device->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true; + device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true; size_t size = PreemptionHelper::getPreemptionWaCsSize(device->getDevice()); EXPECT_EQ(expectedSize, size); } @@ -229,14 +229,14 @@ GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenMidBatchPreemptionWhenProgrammi GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenThreadGroupPreemptionNoWaSetWhenProgrammingWaCmdsBeginThenExpectNoCmd) { device->setPreemptionMode(PreemptionMode::ThreadGroup); - device->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false; + device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false; PreemptionHelper::applyPreemptionWaCmdsBegin(&cmdBuffer, device->getDevice()); EXPECT_EQ(0u, cmdBuffer.getUsed()); } GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenThreadGroupPreemptionNoWaSetWhenProgrammingWaCmdsEndThenExpectNoCmd) { device->setPreemptionMode(PreemptionMode::ThreadGroup); - device->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false; + device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false; PreemptionHelper::applyPreemptionWaCmdsEnd(&cmdBuffer, device->getDevice()); EXPECT_EQ(0u, cmdBuffer.getUsed()); } @@ -244,7 +244,7 @@ GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenThreadGroupPreemptionNoWaSetWhe GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenThreadGroupPreemptionWaSetWhenProgrammingWaCmdsBeginThenExpectMmioCmd) { using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM; device->setPreemptionMode(PreemptionMode::ThreadGroup); - device->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true; + device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true; PreemptionHelper::applyPreemptionWaCmdsBegin(&cmdBuffer, device->getDevice()); cmdBufferParser.parseCommands(cmdBuffer); @@ -259,7 +259,7 @@ GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenThreadGroupPreemptionWaSetWhenP GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenThreadGroupPreemptionWaSetWhenProgrammingWaCmdsEndThenExpectMmioCmd) { using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM; device->setPreemptionMode(PreemptionMode::ThreadGroup); - device->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true; + device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true; PreemptionHelper::applyPreemptionWaCmdsEnd(&cmdBuffer, device->getDevice()); cmdBufferParser.parseCommands(cmdBuffer); @@ -273,14 +273,14 @@ GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenThreadGroupPreemptionWaSetWhenP GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenMidThreadPreemptionNoWaSetWhenProgrammingWaCmdsBeginThenExpectNoCmd) { device->setPreemptionMode(PreemptionMode::MidThread); - device->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false; + device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false; PreemptionHelper::applyPreemptionWaCmdsBegin(&cmdBuffer, device->getDevice()); EXPECT_EQ(0u, cmdBuffer.getUsed()); } GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenMidThreadPreemptionNoWaSetWhenProgrammingWaCmdsEndThenExpectNoCmd) { device->setPreemptionMode(PreemptionMode::MidThread); - device->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false; + device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false; PreemptionHelper::applyPreemptionWaCmdsEnd(&cmdBuffer, device->getDevice()); EXPECT_EQ(0u, cmdBuffer.getUsed()); } @@ -288,7 +288,7 @@ GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenMidThreadPreemptionNoWaSetWhenP GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenMidThreadPreemptionWaSetWhenProgrammingWaCmdsBeginThenExpectMmioCmd) { using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM; device->setPreemptionMode(PreemptionMode::MidThread); - device->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true; + device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true; PreemptionHelper::applyPreemptionWaCmdsBegin(&cmdBuffer, device->getDevice()); cmdBufferParser.parseCommands(cmdBuffer); @@ -303,7 +303,7 @@ GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenMidThreadPreemptionWaSetWhenPro GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenMidThreadPreemptionWaSetWhenProgrammingWaCmdsEndThenExpectMmioCmd) { using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM; device->setPreemptionMode(PreemptionMode::MidThread); - device->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true; + device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true; PreemptionHelper::applyPreemptionWaCmdsEnd(&cmdBuffer, device->getDevice()); cmdBufferParser.parseCommands(cmdBuffer); diff --git a/shared/test/unit_test/gen9/test_preemption_gen9.cpp b/shared/test/unit_test/gen9/test_preemption_gen9.cpp index 687b5269a7..5a7f98dc2a 100644 --- a/shared/test/unit_test/gen9/test_preemption_gen9.cpp +++ b/shared/test/unit_test/gen9/test_preemption_gen9.cpp @@ -89,7 +89,7 @@ GEN9TEST_F(Gen9PreemptionTests, whenMidThreadPreemptionIsAvailableThenStateSipIs GEN9TEST_F(Gen9ThreadGroupPreemptionEnqueueKernelTest, givenSecondEnqueueWithTheSamePreemptionRequestThenDontReprogramThreadGroupNoWa) { pDevice->setPreemptionMode(PreemptionMode::ThreadGroup); - pDevice->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false; + pDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false; auto &csr = pDevice->getUltCommandStreamReceiver(); csr.getMemoryManager()->setForce32BitAllocations(false); csr.setMediaVFEStateDirty(false); @@ -121,7 +121,7 @@ GEN9TEST_F(Gen9ThreadGroupPreemptionEnqueueKernelTest, givenSecondEnqueueWithThe GEN9TEST_F(Gen9ThreadGroupPreemptionEnqueueKernelTest, givenSecondEnqueueWithTheSamePreemptionRequestThenDontReprogramThreadGroupWa) { pDevice->setPreemptionMode(PreemptionMode::ThreadGroup); - pDevice->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true; + pDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true; auto &csr = pDevice->getUltCommandStreamReceiver(); csr.getMemoryManager()->setForce32BitAllocations(false); csr.setMediaVFEStateDirty(false); @@ -252,7 +252,7 @@ GEN9TEST_F(Gen9MidThreadPreemptionEnqueueKernelTest, givenSecondEnqueueWithTheSa typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; typedef typename FamilyType::GPGPU_CSR_BASE_ADDRESS GPGPU_CSR_BASE_ADDRESS; - pDevice->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false; + pDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false; auto &csr = pDevice->getUltCommandStreamReceiver(); csr.getMemoryManager()->setForce32BitAllocations(false); @@ -329,7 +329,7 @@ GEN9TEST_F(Gen9MidThreadPreemptionEnqueueKernelTest, givenSecondEnqueueWithTheSa typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; typedef typename FamilyType::GPGPU_CSR_BASE_ADDRESS GPGPU_CSR_BASE_ADDRESS; - pDevice->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true; + pDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true; auto &csr = pDevice->getUltCommandStreamReceiver(); csr.getMemoryManager()->setForce32BitAllocations(false); @@ -454,7 +454,7 @@ GEN9TEST_F(Gen9PreemptionTests, getPreemptionWaCsSizeMidBatch) { GEN9TEST_F(Gen9PreemptionTests, getPreemptionWaCsSizeThreadGroupNoWa) { size_t expectedSize = 0; device->setPreemptionMode(PreemptionMode::ThreadGroup); - device->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false; + device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false; size_t size = PreemptionHelper::getPreemptionWaCsSize(device->getDevice()); EXPECT_EQ(expectedSize, size); } @@ -463,7 +463,7 @@ GEN9TEST_F(Gen9PreemptionTests, getPreemptionWaCsSizeThreadGroupWa) { typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; size_t expectedSize = 2 * sizeof(MI_LOAD_REGISTER_IMM); device->setPreemptionMode(PreemptionMode::ThreadGroup); - device->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true; + device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true; size_t size = PreemptionHelper::getPreemptionWaCsSize(device->getDevice()); EXPECT_EQ(expectedSize, size); } @@ -471,7 +471,7 @@ GEN9TEST_F(Gen9PreemptionTests, getPreemptionWaCsSizeThreadGroupWa) { GEN9TEST_F(Gen9PreemptionTests, getPreemptionWaCsSizeMidThreadNoWa) { size_t expectedSize = 0; device->setPreemptionMode(PreemptionMode::MidThread); - device->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false; + device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false; size_t size = PreemptionHelper::getPreemptionWaCsSize(device->getDevice()); EXPECT_EQ(expectedSize, size); } @@ -480,7 +480,7 @@ GEN9TEST_F(Gen9PreemptionTests, getPreemptionWaCsSizeMidThreadWa) { typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; size_t expectedSize = 2 * sizeof(MI_LOAD_REGISTER_IMM); device->setPreemptionMode(PreemptionMode::MidThread); - device->getExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true; + device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true; size_t size = PreemptionHelper::getPreemptionWaCsSize(device->getDevice()); EXPECT_EQ(expectedSize, size); } diff --git a/shared/test/unit_test/preamble/preamble_fixture.h b/shared/test/unit_test/preamble/preamble_fixture.h index 60ac3d4c71..07a378af02 100644 --- a/shared/test/unit_test/preamble/preamble_fixture.h +++ b/shared/test/unit_test/preamble/preamble_fixture.h @@ -40,7 +40,7 @@ class PreambleVfeState : public PlatformFixture, LinearStreamFixture::SetUp(); HardwareParse::SetUp(); PlatformFixture::SetUp(); - testWaTable = &pPlatform->peekExecutionEnvironment()->getMutableHardwareInfo()->workaroundTable; + testWaTable = &pPlatform->peekExecutionEnvironment()->rootDeviceEnvironments[0]->getMutableHardwareInfo()->workaroundTable; } void TearDown() override { PlatformFixture::TearDown(); diff --git a/shared/test/unit_test/preemption/preemption_tests.cpp b/shared/test/unit_test/preemption/preemption_tests.cpp index 72f0926f1f..c03f177b03 100644 --- a/shared/test/unit_test/preemption/preemption_tests.cpp +++ b/shared/test/unit_test/preemption/preemption_tests.cpp @@ -539,7 +539,7 @@ HWTEST_F(MidThreadPreemptionTests, givenMidThreadPreemptionWhenFailingOnCsrSurfa FailingMemoryManager(ExecutionEnvironment &executionEnvironment) : OsAgnosticMemoryManager(executionEnvironment) {} GraphicsAllocation *allocateGraphicsMemoryWithAlignment(const AllocationData &allocationData) override { - auto hwInfo = executionEnvironment.getHardwareInfo(); + auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo(); if (++allocateGraphicsMemoryCount > HwHelper::get(hwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo).size() - 1) { return nullptr; }