diff --git a/opencl/test/unit_test/api/cl_get_platform_ids_tests.inl b/opencl/test/unit_test/api/cl_get_platform_ids_tests.inl index ab3afd7439..a67189e668 100644 --- a/opencl/test/unit_test/api/cl_get_platform_ids_tests.inl +++ b/opencl/test/unit_test/api/cl_get_platform_ids_tests.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2024 Intel Corporation + * Copyright (C) 2018-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -9,6 +9,7 @@ #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/ult_hw_config.h" #include "shared/test/common/helpers/variable_backup.h" +#include "shared/test/common/mocks/mock_execution_environment.h" #include "shared/test/common/mocks/mock_io_functions.h" #include "opencl/source/context/context.h" @@ -298,4 +299,48 @@ TEST(clGetPlatformIDsTest, givenDefaultFP64EmulationStateWhenGettingPlatformIdsT platformsImpl->clear(); } + +TEST(clGetPlatformIDsTest, givenMultipleDifferentDevicesWhenGetPlatformIdsThenSeparatePlatformIsReturnedPerEachProductFamily) { + platformsImpl->clear(); + VariableBackup backup(&ultHwConfig); + const size_t numRootDevices = 5u; + MockExecutionEnvironment executionEnvironment(defaultHwInfo.get(), true, numRootDevices); + + executionEnvironment.rootDeviceEnvironments[0]->getMutableHardwareInfo()->platform.eProductFamily = IGFX_LUNARLAKE; + executionEnvironment.rootDeviceEnvironments[0]->getMutableHardwareInfo()->capabilityTable.isIntegratedDevice = true; + executionEnvironment.rootDeviceEnvironments[1]->getMutableHardwareInfo()->platform.eProductFamily = IGFX_BMG; + executionEnvironment.rootDeviceEnvironments[1]->getMutableHardwareInfo()->capabilityTable.isIntegratedDevice = false; + executionEnvironment.rootDeviceEnvironments[2]->getMutableHardwareInfo()->platform.eProductFamily = IGFX_LUNARLAKE; + executionEnvironment.rootDeviceEnvironments[2]->getMutableHardwareInfo()->capabilityTable.isIntegratedDevice = true; + executionEnvironment.rootDeviceEnvironments[3]->getMutableHardwareInfo()->platform.eProductFamily = IGFX_LUNARLAKE; + executionEnvironment.rootDeviceEnvironments[3]->getMutableHardwareInfo()->capabilityTable.isIntegratedDevice = true; + executionEnvironment.rootDeviceEnvironments[4]->getMutableHardwareInfo()->platform.eProductFamily = IGFX_PTL; + executionEnvironment.rootDeviceEnvironments[4]->getMutableHardwareInfo()->capabilityTable.isIntegratedDevice = true; + + ultHwConfig.sourceExecutionEnvironment = &executionEnvironment; + + uint32_t numPlatforms = 0; + clGetPlatformIDs(0, nullptr, &numPlatforms); + + ASSERT_EQ(3u, numPlatforms); + + cl_platform_id platforms[3]; + clGetPlatformIDs(3, platforms, &numPlatforms); + + auto platform0 = static_cast(platforms[0]); + auto platform1 = static_cast(platforms[1]); + auto platform2 = static_cast(platforms[2]); + + EXPECT_EQ(1u, platform0->getNumDevices()); + + EXPECT_EQ(IGFX_BMG, platform0->getClDevices()[0]->getHardwareInfo().platform.eProductFamily); + + EXPECT_EQ(1u, platform1->getNumDevices()); + EXPECT_EQ(IGFX_PTL, platform1->getClDevices()[0]->getHardwareInfo().platform.eProductFamily); + + EXPECT_EQ(3u, platform2->getNumDevices()); + EXPECT_EQ(IGFX_LUNARLAKE, platform2->getClDevices()[0]->getHardwareInfo().platform.eProductFamily); + EXPECT_EQ(IGFX_LUNARLAKE, platform2->getClDevices()[1]->getHardwareInfo().platform.eProductFamily); + EXPECT_EQ(IGFX_LUNARLAKE, platform2->getClDevices()[2]->getHardwareInfo().platform.eProductFamily); +} } // namespace ULT diff --git a/shared/test/common/base_ult_config_listener.cpp b/shared/test/common/base_ult_config_listener.cpp index 317e186f58..63ac24ba84 100644 --- a/shared/test/common/base_ult_config_listener.cpp +++ b/shared/test/common/base_ult_config_listener.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2024 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -50,7 +50,7 @@ void BaseUltConfigListener::OnTestEnd(const ::testing::TestInfo &) { // Ensure that global state is restored UltHwConfig expectedState{}; - static_assert(sizeof(UltHwConfig) == (16 * sizeof(bool) + sizeof(const char *)), ""); // Ensure that there is no internal padding + static_assert(sizeof(UltHwConfig) == (16 * sizeof(bool) + sizeof(const char *) + sizeof(ExecutionEnvironment *)), ""); // Ensure that there is no internal padding EXPECT_EQ(0, memcmp(&expectedState, &ultHwConfig, sizeof(UltHwConfig))); EXPECT_EQ(0, memcmp(&referencedHwInfo.platform, &defaultHwInfo->platform, sizeof(PLATFORM))); diff --git a/shared/test/common/helpers/ult_hw_config.h b/shared/test/common/helpers/ult_hw_config.h index 1edfcb61b5..68412a1c2c 100644 --- a/shared/test/common/helpers/ult_hw_config.h +++ b/shared/test/common/helpers/ult_hw_config.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2024 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -7,8 +7,11 @@ #pragma once namespace NEO { + +class ExecutionEnvironment; struct UltHwConfig { const char *aubTestName = nullptr; + ExecutionEnvironment *sourceExecutionEnvironment = nullptr; bool mockedPrepareDeviceEnvironmentsFuncResult = true; bool useHwCsr = false; diff --git a/shared/test/common/libult/create_command_stream.cpp b/shared/test/common/libult/create_command_stream.cpp index 8866dfde6e..4b1815a38b 100644 --- a/shared/test/common/libult/create_command_stream.cpp +++ b/shared/test/common/libult/create_command_stream.cpp @@ -49,6 +49,20 @@ CommandStreamReceiver *createCommandStream(ExecutionEnvironment &executionEnviro bool prepareDeviceEnvironments(ExecutionEnvironment &executionEnvironment) { auto retVal = true; + if (ultHwConfig.sourceExecutionEnvironment && ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc) { + if (executionEnvironment.rootDeviceEnvironments.size() < ultHwConfig.sourceExecutionEnvironment->rootDeviceEnvironments.size()) { + executionEnvironment.rootDeviceEnvironments.resize(ultHwConfig.sourceExecutionEnvironment->rootDeviceEnvironments.size()); + } + for (uint32_t i = 0; i < ultHwConfig.sourceExecutionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment.rootDeviceEnvironments[i] = std::make_unique(executionEnvironment); + executionEnvironment.rootDeviceEnvironments[i]->setHwInfoAndInitHelpers(defaultHwInfo.get()); + executionEnvironment.rootDeviceEnvironments[i]->initGmm(); + + executionEnvironment.rootDeviceEnvironments[i]->getMutableHardwareInfo()->platform = ultHwConfig.sourceExecutionEnvironment->rootDeviceEnvironments[i]->getHardwareInfo()->platform; + executionEnvironment.rootDeviceEnvironments[i]->getMutableHardwareInfo()->capabilityTable = ultHwConfig.sourceExecutionEnvironment->rootDeviceEnvironments[i]->getHardwareInfo()->capabilityTable; + } + return ultHwConfig.mockedPrepareDeviceEnvironmentsFuncResult; + } if (executionEnvironment.rootDeviceEnvironments.size() == 0) { executionEnvironment.prepareRootDeviceEnvironments(1u); }