diff --git a/core/unit_tests/helpers/default_hw_info.h b/core/unit_tests/helpers/default_hw_info.h index 6f5114b2fb..fbdf0ad4ca 100644 --- a/core/unit_tests/helpers/default_hw_info.h +++ b/core/unit_tests/helpers/default_hw_info.h @@ -10,7 +10,6 @@ namespace NEO { struct HardwareInfo; -extern size_t numPlatformDevices; extern const HardwareInfo **platformDevices; } // namespace NEO diff --git a/core/unit_tests/helpers/default_hw_info.inl b/core/unit_tests/helpers/default_hw_info.inl index 1bc6ec4e79..ef499f6c2f 100644 --- a/core/unit_tests/helpers/default_hw_info.inl +++ b/core/unit_tests/helpers/default_hw_info.inl @@ -13,6 +13,5 @@ static const HardwareInfo *DefaultPlatformDevices[] = { &DEFAULT_TEST_PLATFORM::hwInfo, }; -size_t numPlatformDevices = arrayCount(DefaultPlatformDevices); const HardwareInfo **platformDevices = DefaultPlatformDevices; } // namespace NEO diff --git a/unit_tests/api/cl_api_tests.h b/unit_tests/api/cl_api_tests.h index 14f656bffb..da95fb7737 100644 --- a/unit_tests/api/cl_api_tests.h +++ b/unit_tests/api/cl_api_tests.h @@ -7,6 +7,7 @@ #pragma once #include "core/execution_environment/root_device_environment.h" +#include "core/unit_tests/helpers/debug_manager_state_restore.h" #include "runtime/api/api.h" #include "runtime/command_queue/command_queue.h" #include "runtime/tracing/tracing_api.h" @@ -25,7 +26,6 @@ namespace NEO { class Context; class MockClDevice; struct RootDeviceEnvironment; -extern size_t numPlatformDevices; template struct ApiFixture : PlatformFixture { @@ -33,7 +33,7 @@ struct ApiFixture : PlatformFixture { ~ApiFixture() = default; virtual void SetUp() { - numDevicesBackup = numRootDevices; + DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices); PlatformFixture::SetUp(); if (rootDeviceIndex != 0u) { @@ -67,7 +67,7 @@ struct ApiFixture : PlatformFixture { PlatformFixture::TearDown(); } - + DebugManagerStateRestore restorer; cl_int retVal = CL_SUCCESS; size_t retSize = 0; @@ -77,7 +77,6 @@ struct ApiFixture : PlatformFixture { MockProgram *pProgram = nullptr; constexpr static uint32_t numRootDevices = maxRootDeviceCount; constexpr static uint32_t testedRootDeviceIndex = rootDeviceIndex; - VariableBackup numDevicesBackup{&numPlatformDevices}; cl_device_id testedClDevice = nullptr; std::unique_ptr rootDeviceEnvironmentBackup; }; diff --git a/unit_tests/context/context_tests.cpp b/unit_tests/context/context_tests.cpp index bcdace75f3..d6cba51b44 100644 --- a/unit_tests/context/context_tests.cpp +++ b/unit_tests/context/context_tests.cpp @@ -70,7 +70,6 @@ struct ContextTest : public PlatformFixture, }; TEST_F(ContextTest, WhenCreatingContextThenDevicesAllDevicesExist) { - EXPECT_EQ(numPlatformDevices, context->getNumDevices()); for (size_t deviceOrdinal = 0; deviceOrdinal < context->getNumDevices(); ++deviceOrdinal) { EXPECT_NE(nullptr, context->getDevice(deviceOrdinal)); } @@ -333,8 +332,7 @@ TEST(MultiDeviceContextTest, givenContextWithMultipleDevicesWhenGettingTotalNumb DebugManagerStateRestore restorer; const uint32_t numDevices = 2u; const uint32_t numSubDevices = 3u; - VariableBackup numDevicesBackup(&numPlatformDevices); - numDevicesBackup = numDevices; + DebugManager.flags.CreateMultipleRootDevices.set(numDevices); DebugManager.flags.CreateMultipleSubDevices.set(numSubDevices); initPlatform(); auto device0 = platform()->getClDevice(0); diff --git a/unit_tests/libult/create_command_stream.cpp b/unit_tests/libult/create_command_stream.cpp index 05a45d2011..278a58d95a 100644 --- a/unit_tests/libult/create_command_stream.cpp +++ b/unit_tests/libult/create_command_stream.cpp @@ -41,7 +41,7 @@ bool getDevices(size_t &numDevicesReturned, ExecutionEnvironment &executionEnvir executionEnvironment.setHwInfo(platformDevices[0]); } if (ultHwConfig.useMockedGetDevicesFunc) { - numDevicesReturned = numPlatformDevices; + numDevicesReturned = DebugManager.flags.CreateMultipleRootDevices.get() != 0 ? DebugManager.flags.CreateMultipleRootDevices.get() : 1u; executionEnvironment.prepareRootDeviceEnvironments(static_cast(numDevicesReturned)); executionEnvironment.calculateMaxOsContextCount(); executionEnvironment.initializeMemoryManager(); diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp index c17a956be6..cac311765e 100644 --- a/unit_tests/main.cpp +++ b/unit_tests/main.cpp @@ -195,7 +195,6 @@ int main(int argc, char **argv) { #endif ::testing::InitGoogleMock(&argc, argv); - auto numDevices = numPlatformDevices; HardwareInfo device = DEFAULT_TEST_PLATFORM::hwInfo; ::productFamily = device.platform.eProductFamily; @@ -217,11 +216,6 @@ int main(int argc, char **argv) { testMode = TestMode::AubTestsWithTbx; } initialHardwareTag = 0; - } else if (!strcmp("--devices", argv[i])) { - ++i; - if (i < argc) { - numDevices = atoi(argv[i]); - } } else if (!strcmp("--rev_id", argv[i])) { ++i; if (i < argc) { @@ -295,10 +289,6 @@ int main(int argc, char **argv) { } } - if (numDevices < 1) { - return -1; - } - uint32_t threadsPerEu = hwInfoConfigFactory[productFamily]->threadsPerEu; PLATFORM platform; auto hardwareInfo = hardwareInfoTable[productFamily]; @@ -378,13 +368,8 @@ int main(int argc, char **argv) { } #endif - auto pDevices = new const HardwareInfo *[numDevices]; - for (decltype(numDevices) i = 0; i < numDevices; ++i) { - pDevices[i] = &device; - } - - numPlatformDevices = numDevices; - platformDevices = pDevices; + platformDevices = new const HardwareInfo *[1]; + platformDevices[0] = &device; auto &listeners = ::testing::UnitTest::GetInstance()->listeners(); if (useDefaultListener == false) { @@ -462,7 +447,7 @@ int main(int argc, char **argv) { cleanTestHelpers(); - delete[] pDevices; + delete[] platformDevices; return retVal; }