diff --git a/opencl/source/command_stream/create_command_stream_impl.cpp b/opencl/source/command_stream/create_command_stream_impl.cpp index 0e365e81ab..ff948d4740 100644 --- a/opencl/source/command_stream/create_command_stream_impl.cpp +++ b/opencl/source/command_stream/create_command_stream_impl.cpp @@ -49,11 +49,11 @@ CommandStreamReceiver *createCommandStreamImpl(ExecutionEnvironment &executionEn return commandStreamReceiver; } -bool getDevicesImpl(size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment) { +bool getDevicesImpl(ExecutionEnvironment &executionEnvironment) { if (DeviceFactory::isHwModeSelected()) { - return DeviceFactory::getDevices(numDevicesReturned, executionEnvironment); + return DeviceFactory::getDevices(executionEnvironment); } - return DeviceFactory::getDevicesForProductFamilyOverride(numDevicesReturned, executionEnvironment); + return DeviceFactory::getDevicesForProductFamilyOverride(executionEnvironment); } } // namespace NEO diff --git a/opencl/source/command_stream/create_command_stream_impl.h b/opencl/source/command_stream/create_command_stream_impl.h index a5e99dff34..53cd103e80 100644 --- a/opencl/source/command_stream/create_command_stream_impl.h +++ b/opencl/source/command_stream/create_command_stream_impl.h @@ -11,5 +11,5 @@ namespace NEO { class ExecutionEnvironment; extern CommandStreamReceiver *createCommandStreamImpl(ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex); -extern bool getDevicesImpl(size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment); +extern bool getDevicesImpl(ExecutionEnvironment &executionEnvironment); } // namespace NEO diff --git a/opencl/source/dll/get_devices.cpp b/opencl/source/dll/get_devices.cpp index 8eedc673e9..2b6074c657 100644 --- a/opencl/source/dll/get_devices.cpp +++ b/opencl/source/dll/get_devices.cpp @@ -12,8 +12,8 @@ namespace NEO { -bool getDevices(size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment) { - return getDevicesImpl(numDevicesReturned, executionEnvironment); +bool getDevices(ExecutionEnvironment &executionEnvironment) { + return getDevicesImpl(executionEnvironment); } } // namespace NEO 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 f6b28aa667..5a5d92c2cc 100644 --- a/opencl/test/unit_test/command_stream/get_devices_tests.cpp +++ b/opencl/test/unit_test/command_stream/get_devices_tests.cpp @@ -34,7 +34,6 @@ struct GetDevicesTest : ::testing::Test { void TearDown() override { } int i = 0; - size_t numDevices = 0; const HardwareInfo *hwInfo = nullptr; VariableBackup backup{&ultHwConfig}; @@ -65,7 +64,8 @@ HWTEST_F(GetDevicesTest, givenGetDevicesWhenCsrIsSetToVariousTypesThenTheFunctio platformsImpl.clear(); ExecutionEnvironment *exeEnv = constructPlatform()->peekExecutionEnvironment(); - const auto ret = getDevices(numDevices, *exeEnv); + const auto ret = getDevices(*exeEnv); + EXPECT_EQ(expectedDevices, exeEnv->rootDeviceEnvironments.size()); for (auto i = 0u; i < expectedDevices; i++) { hwInfo = exeEnv->rootDeviceEnvironments[i]->getHardwareInfo(); @@ -74,14 +74,12 @@ HWTEST_F(GetDevicesTest, givenGetDevicesWhenCsrIsSetToVariousTypesThenTheFunctio 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) @@ -135,7 +133,7 @@ HWTEST_F(GetDevicesTest, givenUpperCaseProductFamilyOverrideFlagSetWhenCreatingD DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_AUB); ExecutionEnvironment *exeEnv = platform()->peekExecutionEnvironment(); - bool ret = getDevices(numDevices, *exeEnv); + bool ret = getDevices(*exeEnv); EXPECT_TRUE(ret); EXPECT_EQ(productFamily, exeEnv->rootDeviceEnvironments[0]->getHardwareInfo()->platform.eProductFamily); @@ -153,7 +151,8 @@ HWTEST_F(GetDevicesTest, givenGetDevicesAndUnknownProductFamilyWhenCsrIsSetToVal platformsImpl.clear(); ExecutionEnvironment *exeEnv = constructPlatform()->peekExecutionEnvironment(); - auto ret = getDevices(numDevices, *exeEnv); + auto ret = getDevices(*exeEnv); + EXPECT_EQ(expectedDevices, exeEnv->rootDeviceEnvironments.size()); for (auto i = 0u; i < expectedDevices; i++) { hwInfo = exeEnv->rootDeviceEnvironments[i]->getHardwareInfo(); @@ -161,14 +160,12 @@ HWTEST_F(GetDevicesTest, givenGetDevicesAndUnknownProductFamilyWhenCsrIsSetToVal 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) 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 a314406baf..b84174610b 100644 --- a/opencl/test/unit_test/execution_environment/execution_environment_tests.cpp +++ b/opencl/test/unit_test/execution_environment/execution_environment_tests.cpp @@ -86,8 +86,7 @@ TEST(ExecutionEnvironment, givenDeviceThatHaveRefferencesAfterPlatformIsDestroye TEST(ExecutionEnvironment, givenPlatformWhenItIsCreatedThenItCreatesMemoryManagerInExecutionEnvironment) { auto executionEnvironment = new ExecutionEnvironment(); Platform platform(*executionEnvironment); - size_t numRootDevices; - getDevices(numRootDevices, *executionEnvironment); + getDevices(*executionEnvironment); platform.initialize(DeviceFactory::createDevices(*executionEnvironment)); EXPECT_NE(nullptr, executionEnvironment->memoryManager); } diff --git a/opencl/test/unit_test/gen12lp/tgllp/test_hw_info_config_tgllp.cpp b/opencl/test/unit_test/gen12lp/tgllp/test_hw_info_config_tgllp.cpp index 54d1cc5d00..5fd91d9b2f 100644 --- a/opencl/test/unit_test/gen12lp/tgllp/test_hw_info_config_tgllp.cpp +++ b/opencl/test/unit_test/gen12lp/tgllp/test_hw_info_config_tgllp.cpp @@ -113,8 +113,7 @@ TGLLPTEST_F(TgllpHwInfo, givenSetCommandStreamReceiverInAubModeForTgllpProductFa MockExecutionEnvironment executionEnvironment(*platformDevices); - size_t numDevices = 0; - bool success = DeviceFactory::getDevicesForProductFamilyOverride(numDevices, executionEnvironment); + bool success = DeviceFactory::getDevicesForProductFamilyOverride(executionEnvironment); ASSERT_TRUE(success); auto rootDeviceEnvironment = static_cast(executionEnvironment.rootDeviceEnvironments[0].get()); @@ -132,10 +131,8 @@ TGLLPTEST_F(TgllpHwInfo, givenSetCommandStreamReceiverInAubModeWhenGetDevicesFor MockExecutionEnvironment executionEnvironment(*platformDevices, true, requiredDeviceCount); - size_t numDevices = 0; - bool success = DeviceFactory::getDevicesForProductFamilyOverride(numDevices, executionEnvironment); + bool success = DeviceFactory::getDevicesForProductFamilyOverride(executionEnvironment); ASSERT_TRUE(success); - EXPECT_EQ(requiredDeviceCount, numDevices); std::set memoryOperationHandlers; for (auto rootDeviceIndex = 0u; rootDeviceIndex < requiredDeviceCount; rootDeviceIndex++) { diff --git a/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp b/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp index eeb1ba1430..483985b121 100644 --- a/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp +++ b/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp @@ -792,8 +792,7 @@ TEST(GmmHelperTest, givenPlatformAlreadyDestroyedWhenResourceIsBeingDestroyedThe TEST(GmmHelperTest, givenValidGmmFunctionsWhenCreateGmmHelperWithInitializedOsInterfaceThenProperParametersArePassed) { std::unique_ptr gmmHelper; auto executionEnvironment = platform()->peekExecutionEnvironment(); - size_t numDevices; - DeviceFactory::getDevices(numDevices, *executionEnvironment); + DeviceFactory::getDevices(*executionEnvironment); VariableBackup passedInputArgsBackup(&passedInputArgs); VariableBackup passedFtrTableBackup(&passedFtrTable); VariableBackup passedWaTableBackup(&passedWaTable); diff --git a/opencl/test/unit_test/helpers/execution_environment_helper.cpp b/opencl/test/unit_test/helpers/execution_environment_helper.cpp index e59aa2d190..d7751eb3d1 100644 --- a/opencl/test/unit_test/helpers/execution_environment_helper.cpp +++ b/opencl/test/unit_test/helpers/execution_environment_helper.cpp @@ -20,9 +20,8 @@ ExecutionEnvironment *getExecutionEnvironmentImpl(HardwareInfo *&hwInfo, uint32_ executionEnvironment->prepareRootDeviceEnvironments(rootDeviceEnvironments); DebugManagerStateRestore restorer; DebugManager.flags.CreateMultipleRootDevices.set(rootDeviceEnvironments); - size_t numDevicesReturned = 0; hwInfo = nullptr; - DeviceFactory::getDevices(numDevicesReturned, *executionEnvironment); + DeviceFactory::getDevices(*executionEnvironment); hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo(); executionEnvironment->initializeMemoryManager(); diff --git a/opencl/test/unit_test/libult/create_command_stream.cpp b/opencl/test/unit_test/libult/create_command_stream.cpp index 43f6567d8b..5d732a3e30 100644 --- a/opencl/test/unit_test/libult/create_command_stream.cpp +++ b/opencl/test/unit_test/libult/create_command_stream.cpp @@ -37,7 +37,7 @@ CommandStreamReceiver *createCommandStream(ExecutionEnvironment &executionEnviro return nullptr; } -bool getDevices(size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment) { +bool getDevices(ExecutionEnvironment &executionEnvironment) { if (executionEnvironment.rootDeviceEnvironments.size() == 0) { executionEnvironment.prepareRootDeviceEnvironments(1u); } @@ -46,9 +46,9 @@ bool getDevices(size_t &numDevicesReturned, ExecutionEnvironment &executionEnvir 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++) { + uint32_t numRootDevices = DebugManager.flags.CreateMultipleRootDevices.get() != 0 ? DebugManager.flags.CreateMultipleRootDevices.get() : 1u; + executionEnvironment.prepareRootDeviceEnvironments(numRootDevices); + for (auto i = 0u; i < numRootDevices; i++) { if (executionEnvironment.rootDeviceEnvironments[i]->getHardwareInfo() == nullptr || (executionEnvironment.rootDeviceEnvironments[i]->getHardwareInfo()->platform.eProductFamily == IGFX_UNKNOWN && executionEnvironment.rootDeviceEnvironments[i]->getHardwareInfo()->platform.eRenderCoreFamily == IGFX_UNKNOWN_CORE)) { @@ -60,6 +60,6 @@ bool getDevices(size_t &numDevicesReturned, ExecutionEnvironment &executionEnvir return ultHwConfig.mockedGetDevicesFuncResult; } - return getDevicesImpl(numDevicesReturned, executionEnvironment); + return getDevicesImpl(executionEnvironment); } } // namespace NEO diff --git a/opencl/test/unit_test/libult/create_command_stream.h b/opencl/test/unit_test/libult/create_command_stream.h index 6112288b54..47041bd5ee 100644 --- a/opencl/test/unit_test/libult/create_command_stream.h +++ b/opencl/test/unit_test/libult/create_command_stream.h @@ -14,5 +14,5 @@ class CommandStreamReceiver; class ExecutionEnvironment; extern CommandStreamReceiver *createCommandStream(ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex); -extern bool getDevices(size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment); +extern bool getDevices(ExecutionEnvironment &executionEnvironment); } // namespace NEO diff --git a/opencl/test/unit_test/os_interface/device_factory_tests.cpp b/opencl/test/unit_test/os_interface/device_factory_tests.cpp index 54364922b7..66259665a0 100644 --- a/opencl/test/unit_test/os_interface/device_factory_tests.cpp +++ b/opencl/test/unit_test/os_interface/device_factory_tests.cpp @@ -42,40 +42,19 @@ struct DeviceFactoryTest : public ::testing::Test { ExecutionEnvironment *executionEnvironment; }; -TEST_F(DeviceFactoryTest, GetDevices_Expect_True_If_Returned) { - size_t numDevices = 0; - bool success = DeviceFactory::getDevices(numDevices, *executionEnvironment); - - EXPECT_TRUE((numDevices > 0) ? success : !success); -} - -TEST_F(DeviceFactoryTest, GetDevices_Check_HwInfo_Null) { - size_t numDevices = 0; - bool success = DeviceFactory::getDevices(numDevices, *executionEnvironment); - EXPECT_TRUE((numDevices > 0) ? success : !success); -} - TEST_F(DeviceFactoryTest, GetDevices_Check_HwInfo_Platform) { const HardwareInfo *refHwinfo = *platformDevices; - size_t numDevices = 0; - bool success = DeviceFactory::getDevices(numDevices, *executionEnvironment); + bool success = DeviceFactory::getDevices(*executionEnvironment); + EXPECT_TRUE(success); const HardwareInfo *hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo(); - - EXPECT_TRUE((numDevices > 0) ? success : !success); - - if (numDevices > 0) { - EXPECT_EQ(refHwinfo->platform.eDisplayCoreFamily, hwInfo->platform.eDisplayCoreFamily); - } } TEST_F(DeviceFactoryTest, overrideKmdNotifySettings) { DebugManagerStateRestore stateRestore; - size_t numDevices = 0; - - bool success = DeviceFactory::getDevices(numDevices, *executionEnvironment); + bool success = DeviceFactory::getDevices(*executionEnvironment); auto hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo(); ASSERT_TRUE(success); auto refEnableKmdNotify = hwInfo->capabilityTable.kmdNotifyProperties.enableKmdNotify; @@ -96,7 +75,7 @@ TEST_F(DeviceFactoryTest, overrideKmdNotifySettings) { platformsImpl.clear(); executionEnvironment = constructPlatform()->peekExecutionEnvironment(); - success = DeviceFactory::getDevices(numDevices, *executionEnvironment); + success = DeviceFactory::getDevices(*executionEnvironment); ASSERT_TRUE(success); hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo(); @@ -117,9 +96,7 @@ TEST_F(DeviceFactoryTest, getEngineTypeDebugOverride) { int32_t debugEngineType = 2; DebugManager.flags.NodeOrdinal.set(debugEngineType); - size_t numDevices = 0; - - bool success = DeviceFactory::getDevices(numDevices, *executionEnvironment); + bool success = DeviceFactory::getDevices(*executionEnvironment); ASSERT_TRUE(success); auto hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo(); @@ -128,8 +105,7 @@ TEST_F(DeviceFactoryTest, getEngineTypeDebugOverride) { } TEST_F(DeviceFactoryTest, givenPointerToHwInfoWhenGetDevicedCalledThenRequiedSurfaceSizeIsSettedProperly) { - size_t numDevices = 0; - bool success = DeviceFactory::getDevices(numDevices, *executionEnvironment); + bool success = DeviceFactory::getDevices(*executionEnvironment); ASSERT_TRUE(success); auto hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo(); @@ -141,32 +117,17 @@ TEST_F(DeviceFactoryTest, givenCreateMultipleRootDevicesDebugFlagWhenGetDevicesI auto requiredDeviceCount = 2u; DebugManager.flags.CreateMultipleRootDevices.set(requiredDeviceCount); - size_t numDevices = 0; - bool success = DeviceFactory::getDevices(numDevices, *executionEnvironment); + bool success = DeviceFactory::getDevices(*executionEnvironment); ASSERT_TRUE(success); - EXPECT_EQ(requiredDeviceCount, numDevices); EXPECT_EQ(requiredDeviceCount, executionEnvironment->rootDeviceEnvironments.size()); } -TEST_F(DeviceFactoryTest, givenCreateMultipleRootDevicesDebugFlagWhenGetDevicesForProductFamilyOverrideIsCalledThenNumberOfReturnedDevicesIsEqualToDebugVariable) { - DebugManagerStateRestore stateRestore; - auto requiredDeviceCount = 2u; - DebugManager.flags.CreateMultipleRootDevices.set(requiredDeviceCount); - - size_t numDevices = 0; - bool success = DeviceFactory::getDevicesForProductFamilyOverride(numDevices, *executionEnvironment); - - ASSERT_TRUE(success); - EXPECT_EQ(requiredDeviceCount, numDevices); -} - TEST_F(DeviceFactoryTest, givenDebugFlagSetWhenGetDevicesIsCalledThenOverrideGpuAddressSpace) { DebugManagerStateRestore restore; DebugManager.flags.OverrideGpuAddressSpace.set(12); - size_t numDevices = 0; - bool success = DeviceFactory::getDevices(numDevices, *executionEnvironment); + bool success = DeviceFactory::getDevices(*executionEnvironment); EXPECT_TRUE(success); EXPECT_EQ(maxNBitValue(12), executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->capabilityTable.gpuAddressSpace); @@ -176,8 +137,7 @@ TEST_F(DeviceFactoryTest, givenDebugFlagSetWhenGetDevicesForProductFamilyOverrid DebugManagerStateRestore restore; DebugManager.flags.OverrideGpuAddressSpace.set(12); - size_t numDevices = 0; - bool success = DeviceFactory::getDevicesForProductFamilyOverride(numDevices, *executionEnvironment); + bool success = DeviceFactory::getDevicesForProductFamilyOverride(*executionEnvironment); EXPECT_TRUE(success); EXPECT_EQ(maxNBitValue(12), executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->capabilityTable.gpuAddressSpace); @@ -190,10 +150,8 @@ TEST_F(DeviceFactoryTest, whenGetDevicesIsCalledThenAllRootDeviceEnvironmentMemb MockExecutionEnvironment executionEnvironment(*platformDevices, true, requiredDeviceCount); - size_t numDevices = 0; - bool success = DeviceFactory::getDevices(numDevices, executionEnvironment); + bool success = DeviceFactory::getDevices(executionEnvironment); ASSERT_TRUE(success); - EXPECT_EQ(requiredDeviceCount, numDevices); std::set memoryOperationHandlers; std::set osInterfaces; @@ -218,8 +176,7 @@ TEST_F(DeviceFactoryTest, givenInvalidHwConfigStringGetDevicesForProductFamilyOv MockExecutionEnvironment executionEnvironment(*platformDevices); - size_t numDevices = 0; - bool success = DeviceFactory::getDevicesForProductFamilyOverride(numDevices, executionEnvironment); + bool success = DeviceFactory::getDevicesForProductFamilyOverride(executionEnvironment); EXPECT_FALSE(success); } @@ -229,13 +186,11 @@ TEST_F(DeviceFactoryTest, givenValidHwConfigStringGetDevicesForProductFamilyOver MockExecutionEnvironment executionEnvironment(*platformDevices); - size_t numDevices = 0; - EXPECT_ANY_THROW(DeviceFactory::getDevicesForProductFamilyOverride(numDevices, executionEnvironment)); + EXPECT_ANY_THROW(DeviceFactory::getDevicesForProductFamilyOverride(executionEnvironment)); } TEST_F(DeviceFactoryTest, givenGetDevicesCallWhenItIsDoneThenOsInterfaceIsAllocated) { - size_t numDevices = 0; - bool success = DeviceFactory::getDevices(numDevices, *executionEnvironment); + bool success = DeviceFactory::getDevices(*executionEnvironment); EXPECT_TRUE(success); EXPECT_NE(nullptr, executionEnvironment->rootDeviceEnvironments[0]->osInterface); } @@ -269,9 +224,8 @@ TEST(DiscoverDevices, whenDiscoverDevicesAndForceDeviceIdIsDifferentFromTheExist TEST(DiscoverDevices, whenDiscoverDevicesAndForceDeviceIdIsDifferentFromTheExistingDeviceThenGetDevicesReturnsFalse) { DebugManagerStateRestore stateRestore; DebugManager.flags.ForceDeviceId.set("invalid"); - size_t numDevices = 0u; ExecutionEnvironment executionEnviornment; - auto result = DeviceFactory::getDevices(numDevices, executionEnviornment); + auto result = DeviceFactory::getDevices(executionEnviornment); EXPECT_FALSE(result); } diff --git a/opencl/test/unit_test/os_interface/linux/device_factory_tests.cpp b/opencl/test/unit_test/os_interface/linux/device_factory_tests.cpp index 9381076a6f..a3ba2704c1 100644 --- a/opencl/test/unit_test/os_interface/linux/device_factory_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/device_factory_tests.cpp @@ -14,16 +14,14 @@ TEST_F(DeviceFactoryLinuxTest, GetDevicesCheckEUCntSSCnt) { const HardwareInfo *refHwinfo = *platformDevices; - size_t numDevices = 0; pDrm->StoredEUVal = 11; pDrm->StoredSSVal = 8; - bool success = DeviceFactory::getDevices(numDevices, executionEnvironment); + bool success = DeviceFactory::getDevices(executionEnvironment); auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo(); EXPECT_TRUE(success); - EXPECT_EQ((int)numDevices, 1); EXPECT_NE(hwInfo, nullptr); EXPECT_EQ(refHwinfo->platform.eDisplayCoreFamily, hwInfo->platform.eDisplayCoreFamily); EXPECT_EQ((int)hwInfo->gtSystemInfo.EUCount, 11); @@ -34,19 +32,17 @@ TEST_F(DeviceFactoryLinuxTest, GetDevicesCheckEUCntSSCnt) { } TEST_F(DeviceFactoryLinuxTest, GetDevicesDrmCreateFailedConfigureHwInfo) { - size_t numDevices = 0; pDrm->StoredRetValForDeviceID = -1; - bool success = DeviceFactory::getDevices(numDevices, executionEnvironment); + bool success = DeviceFactory::getDevices(executionEnvironment); EXPECT_FALSE(success); pDrm->StoredRetValForDeviceID = 0; } TEST_F(DeviceFactoryLinuxTest, givenGetDeviceCallWhenItIsDoneThenOsInterfaceIsAllocatedAndItContainDrm) { - size_t numDevices = 0; - bool success = DeviceFactory::getDevices(numDevices, executionEnvironment); + bool success = DeviceFactory::getDevices(executionEnvironment); EXPECT_TRUE(success); EXPECT_NE(nullptr, executionEnvironment.rootDeviceEnvironments[0]->osInterface); EXPECT_NE(nullptr, pDrm); @@ -56,8 +52,7 @@ TEST_F(DeviceFactoryLinuxTest, givenGetDeviceCallWhenItIsDoneThenOsInterfaceIsAl TEST_F(DeviceFactoryLinuxTest, whenDrmIsNotCretedThenGetDevicesFails) { delete pDrm; pDrm = nullptr; - size_t numDevices = 0; - bool success = DeviceFactory::getDevices(numDevices, executionEnvironment); + bool success = DeviceFactory::getDevices(executionEnvironment); EXPECT_FALSE(success); } 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 09087bdced..0cb27a1261 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 @@ -1875,9 +1875,8 @@ TEST(WddmMemoryManager, givenMultipleRootDeviceWhenMemoryManagerGetsWddmThenWddm DebugManager.flags.CreateMultipleRootDevices.set(4); VariableBackup backup{&ultHwConfig}; ultHwConfig.useMockedGetDevicesFunc = false; - size_t numRootDevices; auto executionEnvironment = platform()->peekExecutionEnvironment(); - getDevices(numRootDevices, *executionEnvironment); + getDevices(*executionEnvironment); MockWddmMemoryManager wddmMemoryManager(*executionEnvironment); for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { @@ -1892,10 +1891,8 @@ TEST(WddmMemoryManager, givenMultipleRootDeviceWhenCreateMemoryManagerThenTakeMa DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices); VariableBackup backup{&ultHwConfig}; ultHwConfig.useMockedGetDevicesFunc = false; - size_t numRootDevicesReturned; auto executionEnvironment = platform()->peekExecutionEnvironment(); - getDevices(numRootDevicesReturned, *executionEnvironment); - EXPECT_EQ(static_cast(numRootDevicesReturned), numRootDevices); + getDevices(*executionEnvironment); for (auto i = 0u; i < numRootDevices; i++) { auto wddm = static_cast(executionEnvironment->rootDeviceEnvironments[i]->osInterface->get()->getWddm()); wddm->minAddress = i * (numRootDevices - i); @@ -1912,23 +1909,21 @@ TEST(WddmMemoryManager, givenNoLocalMemoryOnAnyDeviceWhenIsCpuCopyRequiredIsCall VariableBackup backup{&ultHwConfig}; ultHwConfig.useMockedGetDevicesFunc = false; auto executionEnvironment = platform()->peekExecutionEnvironment(); - size_t numRootDevicesReturned; - getDevices(numRootDevicesReturned, *executionEnvironment); + getDevices(*executionEnvironment); MockWddmMemoryManager wddmMemoryManager(*executionEnvironment); EXPECT_FALSE(wddmMemoryManager.isCpuCopyRequired(&restorer)); } TEST(WddmMemoryManager, givenLocalPointerPassedToIsCpuCopyRequiredThenFalseIsReturned) { auto executionEnvironment = platform()->peekExecutionEnvironment(); - size_t numRootDevicesReturned; VariableBackup backup{&ultHwConfig}; ultHwConfig.useMockedGetDevicesFunc = false; - getDevices(numRootDevicesReturned, *executionEnvironment); + getDevices(*executionEnvironment); MockWddmMemoryManager wddmMemoryManager(*executionEnvironment); - EXPECT_FALSE(wddmMemoryManager.isCpuCopyRequired(&numRootDevicesReturned)); + EXPECT_FALSE(wddmMemoryManager.isCpuCopyRequired(&backup)); //call multiple times to make sure that result is constant - EXPECT_FALSE(wddmMemoryManager.isCpuCopyRequired(&numRootDevicesReturned)); - EXPECT_FALSE(wddmMemoryManager.isCpuCopyRequired(&numRootDevicesReturned)); - EXPECT_FALSE(wddmMemoryManager.isCpuCopyRequired(&numRootDevicesReturned)); - EXPECT_FALSE(wddmMemoryManager.isCpuCopyRequired(&numRootDevicesReturned)); + EXPECT_FALSE(wddmMemoryManager.isCpuCopyRequired(&backup)); + EXPECT_FALSE(wddmMemoryManager.isCpuCopyRequired(&backup)); + EXPECT_FALSE(wddmMemoryManager.isCpuCopyRequired(&backup)); + EXPECT_FALSE(wddmMemoryManager.isCpuCopyRequired(&backup)); } diff --git a/opencl/test/unit_test/windows/get_devices_tests.cpp b/opencl/test/unit_test/windows/get_devices_tests.cpp index 70c7059fa2..a15b0e0347 100644 --- a/opencl/test/unit_test/windows/get_devices_tests.cpp +++ b/opencl/test/unit_test/windows/get_devices_tests.cpp @@ -18,10 +18,9 @@ using namespace NEO; using GetDevicesTests = ::testing::Test; HWTEST_F(GetDevicesTests, WhenGetDevicesIsCalledThenSuccessIsReturned) { - size_t numDevicesReturned = 0; ExecutionEnvironment executionEnvironment; - auto returnValue = DeviceFactory::getDevices(numDevicesReturned, executionEnvironment); + auto returnValue = DeviceFactory::getDevices(executionEnvironment); EXPECT_EQ(true, returnValue); } @@ -29,12 +28,11 @@ HWTEST_F(GetDevicesTests, whenGetDevicesIsCalledThenGmmIsBeingInitializedAfterFi platformsImpl.clear(); auto executionEnvironment = new ExecutionEnvironment(); platformsImpl.push_back(std::make_unique(*executionEnvironment)); - size_t numDevicesReturned = 0; executionEnvironment->prepareRootDeviceEnvironments(1u); auto hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo(); hwInfo->platform.eProductFamily = PRODUCT_FAMILY::IGFX_UNKNOWN; hwInfo->platform.ePCHProductFamily = PCH_PRODUCT_FAMILY::PCH_UNKNOWN; - auto returnValue = DeviceFactory::getDevices(numDevicesReturned, *executionEnvironment); + auto returnValue = DeviceFactory::getDevices(*executionEnvironment); EXPECT_TRUE(returnValue); } diff --git a/shared/source/os_interface/device_factory.cpp b/shared/source/os_interface/device_factory.cpp index d9d062d958..a9d413b030 100644 --- a/shared/source/os_interface/device_factory.cpp +++ b/shared/source/os_interface/device_factory.cpp @@ -22,7 +22,7 @@ namespace NEO { -bool DeviceFactory::getDevicesForProductFamilyOverride(size_t &numDevices, ExecutionEnvironment &executionEnvironment) { +bool DeviceFactory::getDevicesForProductFamilyOverride(ExecutionEnvironment &executionEnvironment) { auto numRootDevices = 1u; if (DebugManager.flags.CreateMultipleRootDevices.get()) { numRootDevices = DebugManager.flags.CreateMultipleRootDevices.get(); @@ -32,7 +32,6 @@ bool DeviceFactory::getDevicesForProductFamilyOverride(size_t &numDevices, Execu auto productFamily = DebugManager.flags.ProductFamilyOverride.get(); const HardwareInfo *hwInfoConst = &DEFAULT_PLATFORM::hwInfo; getHwInfoForPlatformString(productFamily, hwInfoConst); - numDevices = 0; std::string hwInfoConfigStr; uint64_t hwInfoConfig = 0x0; DebugManager.getHardwareInfoOverride(hwInfoConfigStr); @@ -68,8 +67,6 @@ bool DeviceFactory::getDevicesForProductFamilyOverride(size_t &numDevices, Execu } executionEnvironment.calculateMaxOsContextCount(); - numDevices = numRootDevices; - return true; } @@ -85,16 +82,15 @@ bool DeviceFactory::isHwModeSelected() { } } -bool DeviceFactory::getDevices(size_t &totalNumRootDevices, ExecutionEnvironment &executionEnvironment) { +bool DeviceFactory::getDevices(ExecutionEnvironment &executionEnvironment) { using HwDeviceIds = std::vector>; HwDeviceIds hwDeviceIds = OSInterface::discoverDevices(executionEnvironment); - totalNumRootDevices = hwDeviceIds.size(); - if (totalNumRootDevices == 0) { + if (hwDeviceIds.empty()) { return false; } - executionEnvironment.prepareRootDeviceEnvironments(static_cast(totalNumRootDevices)); + executionEnvironment.prepareRootDeviceEnvironments(static_cast(hwDeviceIds.size())); uint32_t rootDeviceIndex = 0u; @@ -118,8 +114,7 @@ bool DeviceFactory::getDevices(size_t &totalNumRootDevices, ExecutionEnvironment std::vector> DeviceFactory::createDevices(ExecutionEnvironment &executionEnvironment) { std::vector> devices; - size_t numDevices; - auto status = NEO::getDevices(numDevices, executionEnvironment); + auto status = NEO::getDevices(executionEnvironment); if (!status) { return devices; } diff --git a/shared/source/os_interface/device_factory.h b/shared/source/os_interface/device_factory.h index b7cd5ec39c..e59056de06 100644 --- a/shared/source/os_interface/device_factory.h +++ b/shared/source/os_interface/device_factory.h @@ -14,11 +14,11 @@ namespace NEO { class ExecutionEnvironment; class Device; -bool getDevices(size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment); +bool getDevices(ExecutionEnvironment &executionEnvironment); class DeviceFactory { public: - static bool getDevices(size_t &numDevices, ExecutionEnvironment &executionEnvironment); - static bool getDevicesForProductFamilyOverride(size_t &numDevices, ExecutionEnvironment &executionEnvironment); + static bool getDevices(ExecutionEnvironment &executionEnvironment); + static bool getDevicesForProductFamilyOverride(ExecutionEnvironment &executionEnvironment); static std::vector> createDevices(ExecutionEnvironment &executionEnvironment); static bool isHwModeSelected();