diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index c7005917c3..30df064818 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2024 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -663,9 +663,8 @@ ze_result_t DeviceImp::getP2PProperties(ze_device_handle_t hPeerDevice, } ze_result_t DeviceImp::getRootDevice(ze_device_handle_t *phRootDevice) { - DriverHandleImp *driverHandleImp = static_cast(driverHandle); // Given FLAT device Hierarchy mode, then nullptr is returned for the root device since no traversal is allowed. - if (driverHandleImp->deviceHierarchyMode == L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_FLAT) { + if (this->neoDevice->getExecutionEnvironment()->getDeviceHierarchyMode() == NEO::DeviceHierarchyMode::FLAT) { *phRootDevice = nullptr; return ZE_RESULT_SUCCESS; } @@ -1006,11 +1005,8 @@ ze_result_t DeviceImp::getProperties(ze_device_properties_t *pDeviceProperties) pDeviceProperties->flags |= ZE_DEVICE_PROPERTY_FLAG_INTEGRATED; } - if (isSubdevice) { - DriverHandleImp *driverHandleImp = static_cast(driverHandle); - if (driverHandleImp->deviceHierarchyMode != L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_FLAT) { - pDeviceProperties->flags |= ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE; - } + if (isSubdevice && this->neoDevice->getExecutionEnvironment()->getDeviceHierarchyMode() != NEO::DeviceHierarchyMode::FLAT) { + pDeviceProperties->flags |= ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE; } if (this->neoDevice->getDeviceInfo().errorCorrectionSupport) { @@ -1198,9 +1194,8 @@ ze_result_t DeviceImp::getGlobalTimestampsUsingOsInterface(uint64_t *hostTimesta } ze_result_t DeviceImp::getSubDevices(uint32_t *pCount, ze_device_handle_t *phSubdevices) { - DriverHandleImp *driverHandleImp = static_cast(driverHandle); // Given FLAT device Hierarchy mode, then a count of 0 is returned since no traversal is allowed. - if (driverHandleImp->deviceHierarchyMode == L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_FLAT) { + if (this->neoDevice->getExecutionEnvironment()->getDeviceHierarchyMode() == NEO::DeviceHierarchyMode::FLAT) { *pCount = 0; return ZE_RESULT_SUCCESS; } diff --git a/level_zero/core/source/driver/driver.cpp b/level_zero/core/source/driver/driver.cpp index 848da3f261..51096bb8e5 100644 --- a/level_zero/core/source/driver/driver.cpp +++ b/level_zero/core/source/driver/driver.cpp @@ -53,8 +53,6 @@ void DriverImp::initialize(ze_result_t *result) { envReader.getSetting("ZE_ENABLE_PCI_ID_DEVICE_ORDER", false); envVariables.fp64Emulation = envReader.getSetting("NEO_FP64_EMULATION", false); - envVariables.deviceHierarchyMode = - envReader.getSetting("ZE_FLAT_DEVICE_HIERARCHY", std::string(NEO::deviceHierarchyUnk)); auto executionEnvironment = new NEO::ExecutionEnvironment(); UNRECOVERABLE_IF(nullptr == executionEnvironment); diff --git a/level_zero/core/source/driver/driver_handle_imp.cpp b/level_zero/core/source/driver/driver_handle_imp.cpp index 9981c7dc3d..f9e011362b 100644 --- a/level_zero/core/source/driver/driver_handle_imp.cpp +++ b/level_zero/core/source/driver/driver_handle_imp.cpp @@ -298,17 +298,7 @@ DriverHandle *DriverHandle::create(std::vector> dev driverHandle->enableProgramDebugging = static_cast(envVariables.programDebugging); driverHandle->enableSysman = envVariables.sysman; driverHandle->enablePciIdDeviceOrder = envVariables.pciIdDeviceOrder; - char const *preferredDeviceHierarchy = envVariables.deviceHierarchyMode.c_str(); - if ((strcmp(preferredDeviceHierarchy, NEO::deviceHierarchyUnk) == 0) || ((strcmp(preferredDeviceHierarchy, NEO::deviceHierarchyComposite) != 0) && (strcmp(preferredDeviceHierarchy, NEO::deviceHierarchyFlat) != 0) && (strcmp(preferredDeviceHierarchy, NEO::deviceHierarchyCombined) != 0))) { - preferredDeviceHierarchy = devices[0]->getGfxCoreHelper().getDefaultDeviceHierarchy(); - } - if (strcmp(preferredDeviceHierarchy, NEO::deviceHierarchyComposite) == 0) { - driverHandle->deviceHierarchyMode = L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_COMPOSITE; - } else if (strcmp(preferredDeviceHierarchy, NEO::deviceHierarchyFlat) == 0) { - driverHandle->deviceHierarchyMode = L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_FLAT; - } else if (strcmp(preferredDeviceHierarchy, NEO::deviceHierarchyCombined) == 0) { - driverHandle->deviceHierarchyMode = L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_COMBINED; - } + ze_result_t res = driverHandle->initialize(std::move(devices)); if (res != ZE_RESULT_SUCCESS) { delete driverHandle; @@ -338,12 +328,9 @@ void DriverHandleImp::initHostUsmAllocPool() { } ze_result_t DriverHandleImp::getDevice(uint32_t *pCount, ze_device_handle_t *phDevices) { - bool exposeSubDevices = false; // If the user has requested FLAT or COMBINED device hierarchy model, then report all the sub devices as devices. - if (this->deviceHierarchyMode != L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_COMPOSITE) { - exposeSubDevices = true; - } + bool exposeSubDevices = (this->devices.size() && this->devices[0]->getNEODevice()->getExecutionEnvironment()->getDeviceHierarchyMode() != NEO::DeviceHierarchyMode::COMPOSITE); uint32_t numDevices = 0; if (exposeSubDevices) { @@ -871,10 +858,7 @@ ze_result_t DriverHandleImp::fabricVertexGetExp(uint32_t *pCount, ze_fabric_vert this->initializeVertexes(); } - bool exposeSubDevices = false; - if (deviceHierarchyMode == L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_FLAT) { - exposeSubDevices = true; - } + bool exposeSubDevices = this->devices[0]->getNEODevice()->getExecutionEnvironment()->getDeviceHierarchyMode() != NEO::DeviceHierarchyMode::COMPOSITE; if (*pCount == 0) { if (exposeSubDevices) { diff --git a/level_zero/core/source/driver/driver_handle_imp.h b/level_zero/core/source/driver/driver_handle_imp.h index 411b02c647..e382c1f6fe 100644 --- a/level_zero/core/source/driver/driver_handle_imp.h +++ b/level_zero/core/source/driver/driver_handle_imp.h @@ -27,11 +27,6 @@ struct FabricEdge; struct Image; class ExternalSemaphoreController; -enum L0DeviceHierarchyMode { - L0_DEVICE_HIERARCHY_COMPOSITE, - L0_DEVICE_HIERARCHY_FLAT, - L0_DEVICE_HIERARCHY_COMBINED -}; #pragma pack(1) struct IpcMemoryData { uint64_t handle = 0; @@ -172,7 +167,6 @@ struct DriverHandleImp : public DriverHandle { bool enableSysman = false; bool enablePciIdDeviceOrder = false; uint8_t powerHint = 0; - L0DeviceHierarchyMode deviceHierarchyMode = L0_DEVICE_HIERARCHY_COMPOSITE; // Error messages per thread, variable initialized / destoryed per thread, // not based on the lifetime of the object of a class. diff --git a/level_zero/core/source/driver/driver_imp.h b/level_zero/core/source/driver/driver_imp.h index 3f97abc563..106607d391 100644 --- a/level_zero/core/source/driver/driver_imp.h +++ b/level_zero/core/source/driver/driver_imp.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2024 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -42,7 +42,6 @@ struct L0EnvVariables { bool sysman; bool pciIdDeviceOrder; bool fp64Emulation; - std::string deviceHierarchyMode; }; } // namespace L0 diff --git a/level_zero/core/test/unit_tests/fixtures/device_fixture.cpp b/level_zero/core/test/unit_tests/fixtures/device_fixture.cpp index caea4f3fd7..27e950ed68 100644 --- a/level_zero/core/test/unit_tests/fixtures/device_fixture.cpp +++ b/level_zero/core/test/unit_tests/fixtures/device_fixture.cpp @@ -131,11 +131,7 @@ void MultiDeviceFixtureHierarchy::setUp() { executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = std::make_unique(); } - if (driverHandle->deviceHierarchyMode == L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_FLAT) { - executionEnvironment->setExposeSubDevicesAsDevices(true); - } else if (driverHandle->deviceHierarchyMode == L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_COMBINED) { - executionEnvironment->setCombinedDeviceHierarchy(true); - } + executionEnvironment->setDeviceHierarchyMode(deviceHierarchyMode); auto devices = NEO::DeviceFactory::createDevices(*executionEnvironment); if (devices.size()) { diff --git a/level_zero/core/test/unit_tests/fixtures/device_fixture.h b/level_zero/core/test/unit_tests/fixtures/device_fixture.h index 5577ab0d15..4892c3fc3b 100644 --- a/level_zero/core/test/unit_tests/fixtures/device_fixture.h +++ b/level_zero/core/test/unit_tests/fixtures/device_fixture.h @@ -130,6 +130,7 @@ struct MultiDeviceFixture { uint32_t numRootDevices = 4u; uint32_t numSubDevices = 2u; L0::ContextImp *context = nullptr; + NEO::DeviceHierarchyMode deviceHierarchyMode = NEO::DeviceHierarchyMode::COMPOSITE; VariableBackup<_ze_driver_handle_t *> globalDriverHandleBackup{&globalDriverHandle}; VariableBackup driverCountBackup{&driverCount}; @@ -139,23 +140,18 @@ struct MultiDeviceFixtureHierarchy : public MultiDeviceFixture { void setUp(); }; -struct MultiDeviceFixtureCompositeHierarchy : public MultiDeviceFixtureHierarchy { - void setUp() { - this->driverHandle->deviceHierarchyMode = L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_COMPOSITE; - MultiDeviceFixtureHierarchy::setUp(); - } -}; +struct MultiDeviceFixtureCompositeHierarchy : public MultiDeviceFixtureHierarchy {}; struct MultiDeviceFixtureFlatHierarchy : public MultiDeviceFixtureHierarchy { void setUp() { - this->driverHandle->deviceHierarchyMode = L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_FLAT; + this->deviceHierarchyMode = NEO::DeviceHierarchyMode::FLAT; MultiDeviceFixtureHierarchy::setUp(); } }; struct MultiDeviceFixtureCombinedHierarchy : public MultiDeviceFixtureHierarchy { void setUp() { - this->driverHandle->deviceHierarchyMode = L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_COMBINED; + this->deviceHierarchyMode = NEO::DeviceHierarchyMode::COMBINED; MultiDeviceFixtureHierarchy::setUp(); } }; diff --git a/level_zero/core/test/unit_tests/sources/device/test_device_pci_bus_info.cpp b/level_zero/core/test/unit_tests/sources/device/test_device_pci_bus_info.cpp index cc239acc2f..9495befc9d 100644 --- a/level_zero/core/test/unit_tests/sources/device/test_device_pci_bus_info.cpp +++ b/level_zero/core/test/unit_tests/sources/device/test_device_pci_bus_info.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Intel Corporation + * Copyright (C) 2024-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -62,7 +62,7 @@ TEST_F(PciBusInfoTest, givenSuccessfulReadingOfBusValuesThenCorrectValuesAreRetu } } -TEST_P(PciBusOrderingTest, givenMultipleDevicesAndZePcieIdOrderingSetThenDevicesAndVerticesAreInCorrectOrder) { +TEST_P(PciBusOrderingTest, givenMultipleDevicesWithCompositeHierarchyAndZePcieIdOrderingSetThenDevicesAndVerticesAreInCorrectOrder) { constexpr uint32_t numRootDevices = 6u; constexpr uint32_t numSubDevices = 2u; const NEO::PhysicalDevicePciBusInfo busInfos[numRootDevices] = {{2, 0, 3, 0}, {2, 0, 1, 9}, {0, 0, 0, 1}, {0, 3, 5, 0}, {1, 3, 5, 0}, {0, 4, 1, 0}}; @@ -76,6 +76,7 @@ TEST_P(PciBusOrderingTest, givenMultipleDevicesAndZePcieIdOrderingSetThenDevices debugManager.flags.EnableChipsetUniqueUUID.set(0); auto executionEnvironment = NEO::MockDevice::prepareExecutionEnvironment(defaultHwInfo.get(), 0u); + executionEnvironment->setDeviceHierarchyMode(COMPOSITE); auto memoryManager = new MockMemoryManagerOsAgnosticContext(*executionEnvironment); executionEnvironment->memoryManager.reset(memoryManager); auto neoDevices = NEO::DeviceFactory::createDevices(*executionEnvironment); diff --git a/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp b/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp index 8602e45b46..dbb7afa880 100644 --- a/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp +++ b/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp @@ -558,107 +558,6 @@ TEST_F(DriverImpTest, givenEnabledProgramDebuggingWhenCreatingExecutionEnvironme L0::globalDriver = nullptr; } -TEST_F(DriverImpTest, whenCreatingExecutionEnvironmentThenDefaultHierarchyIsEnabled) { - - ze_result_t result = ZE_RESULT_ERROR_UNINITIALIZED; - DriverImp driverImp; - driverImp.initialize(&result); - L0::DriverHandleImp *driverHandleImp = reinterpret_cast(L0::globalDriverHandle); - auto &gfxCoreHelper = driverHandleImp->memoryManager->peekExecutionEnvironment().rootDeviceEnvironments[0]->getHelper(); - if (strcmp(gfxCoreHelper.getDefaultDeviceHierarchy(), "COMPOSITE") == 0) { - EXPECT_EQ(driverHandleImp->deviceHierarchyMode, L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_COMPOSITE); - } else { - EXPECT_EQ(driverHandleImp->deviceHierarchyMode, L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_FLAT); - } - ASSERT_NE(nullptr, L0::globalDriver); - ASSERT_NE(0u, L0::globalDriver->numDevices); - - delete L0::globalDriver; - L0::globalDriverHandle = nullptr; - L0::globalDriver = nullptr; -} - -TEST_F(DriverImpTest, givenFlatDeviceHierarchyWhenCreatingExecutionEnvironmentThenFlatHierarchyIsEnabled) { - - VariableBackup mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0); - std::unordered_map mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "FLAT"}}; - VariableBackup *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs); - - ze_result_t result = ZE_RESULT_ERROR_UNINITIALIZED; - DriverImp driverImp; - driverImp.initialize(&result); - L0::DriverHandleImp *driverHandleImp = reinterpret_cast(L0::globalDriverHandle); - EXPECT_EQ(driverHandleImp->deviceHierarchyMode, L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_FLAT); - ASSERT_NE(nullptr, L0::globalDriver); - ASSERT_NE(0u, L0::globalDriver->numDevices); - - delete L0::globalDriver; - L0::globalDriverHandle = nullptr; - L0::globalDriver = nullptr; -} - -TEST_F(DriverImpTest, givenCompositeDeviceHierarchyWhenCreatingExecutionEnvironmentThenCompositeHierarchyIsEnabled) { - - VariableBackup mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0); - std::unordered_map mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "COMPOSITE"}}; - VariableBackup *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs); - - ze_result_t result = ZE_RESULT_ERROR_UNINITIALIZED; - DriverImp driverImp; - driverImp.initialize(&result); - L0::DriverHandleImp *driverHandleImp = reinterpret_cast(L0::globalDriverHandle); - EXPECT_EQ(driverHandleImp->deviceHierarchyMode, L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_COMPOSITE); - ASSERT_NE(nullptr, L0::globalDriver); - ASSERT_NE(0u, L0::globalDriver->numDevices); - - delete L0::globalDriver; - L0::globalDriverHandle = nullptr; - L0::globalDriver = nullptr; -} - -TEST_F(DriverImpTest, givenCombinedDeviceHierarchyWhenCreatingExecutionEnvironmentThenCombinedHierarchyIsEnabled) { - - VariableBackup mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0); - std::unordered_map mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "COMBINED"}}; - VariableBackup *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs); - - ze_result_t result = ZE_RESULT_ERROR_UNINITIALIZED; - DriverImp driverImp; - driverImp.initialize(&result); - L0::DriverHandleImp *driverHandleImp = reinterpret_cast(L0::globalDriverHandle); - EXPECT_EQ(driverHandleImp->deviceHierarchyMode, L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_COMBINED); - ASSERT_NE(nullptr, L0::globalDriver); - ASSERT_NE(0u, L0::globalDriver->numDevices); - - delete L0::globalDriver; - L0::globalDriverHandle = nullptr; - L0::globalDriver = nullptr; -} - -TEST_F(DriverImpTest, givenErrantDeviceHierarchyWhenCreatingExecutionEnvironmentThenDefaultHierarchyIsEnabled) { - - VariableBackup mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0); - std::unordered_map mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "Flat"}}; - VariableBackup *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs); - - ze_result_t result = ZE_RESULT_ERROR_UNINITIALIZED; - DriverImp driverImp; - driverImp.initialize(&result); - L0::DriverHandleImp *driverHandleImp = reinterpret_cast(L0::globalDriverHandle); - auto &gfxCoreHelper = driverHandleImp->memoryManager->peekExecutionEnvironment().rootDeviceEnvironments[0]->getHelper(); - if (strcmp(gfxCoreHelper.getDefaultDeviceHierarchy(), "COMPOSITE") == 0) { - EXPECT_EQ(driverHandleImp->deviceHierarchyMode, L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_COMPOSITE); - } else { - EXPECT_EQ(driverHandleImp->deviceHierarchyMode, L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_FLAT); - } - ASSERT_NE(nullptr, L0::globalDriver); - ASSERT_NE(0u, L0::globalDriver->numDevices); - - delete L0::globalDriver; - L0::globalDriverHandle = nullptr; - L0::globalDriver = nullptr; -} - TEST_F(DriverImpTest, givenEnableProgramDebuggingWithValue2WhenCreatingExecutionEnvironmentThenDebuggingEnabledIsTrue) { VariableBackup mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0); diff --git a/level_zero/core/test/unit_tests/sources/event/test_event.cpp b/level_zero/core/test/unit_tests/sources/event/test_event.cpp index 16fc4a14eb..6a5c871fbf 100644 --- a/level_zero/core/test/unit_tests/sources/event/test_event.cpp +++ b/level_zero/core/test/unit_tests/sources/event/test_event.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2024 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -2810,9 +2810,9 @@ TEST_F(TimestampEventCreate, givenEventWhenQueryKernelTimestampThenNotReadyRetur EXPECT_EQ(0u, resultTimestamp.global.kernelEnd); } -TEST_F(EventPoolCreateMultiDevice, givenFlatHierarchyWhenCallZeGetDevicesThenSubDevicesAreReturnedAsSeparateDevices) { - this->driverHandle->deviceHierarchyMode = L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_FLAT; +using EventPoolCreateMultiDeviceFlatHierarchy = Test; +TEST_F(EventPoolCreateMultiDeviceFlatHierarchy, givenFlatHierarchyWhenCallZeGetDevicesThenSubDevicesAreReturnedAsSeparateDevices) { uint32_t deviceCount = 0; ze_result_t result = zeDeviceGet(driverHandle.get(), &deviceCount, nullptr); EXPECT_EQ(ZE_RESULT_SUCCESS, result); @@ -4311,6 +4311,8 @@ struct EventDynamicPacketUseFixture : public DeviceFixture { void testSingleDevice() { ze_result_t result = ZE_RESULT_SUCCESS; + device->getNEODevice()->getExecutionEnvironment()->setDeviceHierarchyMode(COMPOSITE); + auto &hwInfo = device->getHwInfo(); auto &l0GfxCoreHelper = device->getNEODevice()->getRootDeviceEnvironment().getHelper(); auto &gfxCoreHelper = device->getGfxCoreHelper(); diff --git a/level_zero/core/test/unit_tests/sources/fabric/test_fabric.cpp b/level_zero/core/test/unit_tests/sources/fabric/test_fabric.cpp index 6752c66c09..111c351de3 100644 --- a/level_zero/core/test/unit_tests/sources/fabric/test_fabric.cpp +++ b/level_zero/core/test/unit_tests/sources/fabric/test_fabric.cpp @@ -37,7 +37,7 @@ class MockFabricDeviceInterface { using FabricVertexFixture = Test; -TEST_F(FabricVertexFixture, WhenDevicesAreCreatedThenVerifyFabricVerticesAreCreated) { +TEST_F(FabricVertexFixture, whenDevicesAreCreatedThenVerifyFabricVerticesAreCreated) { uint32_t count = 0; EXPECT_EQ(ZE_RESULT_SUCCESS, L0::zeFabricVertexGetExp(driverHandle->toHandle(), &count, nullptr)); @@ -156,7 +156,7 @@ TEST_F(FabricVertexFixture, givenFabricVerticesAreCreatedWhenzeFabricVertexGetPr } } -TEST(FabricEngineInstanceTest, GivenSubDeviceWhenFabricVerticesAreCreatedThenSkipCreationForSubDevice) { +TEST(FabricEngineInstanceTest, givenSubDeviceWhenFabricVerticesAreCreatedThenSkipCreationForSubDevice) { auto hwInfo = *NEO::defaultHwInfo.get(); auto executionEnvironment = NEO::MockDevice::prepareExecutionEnvironment(&hwInfo, 0u); @@ -182,7 +182,7 @@ TEST(FabricEngineInstanceTest, GivenSubDeviceWhenFabricVerticesAreCreatedThenSki EXPECT_EQ(count, 0u); } -TEST_F(FabricVertexFixture, GivenDevicesAreCreatedWhenZeDeviceGetFabricVertexExpIsCalledThenExpectValidVertices) { +TEST_F(FabricVertexFixture, givenDevicesAreCreatedWhenZeDeviceGetFabricVertexExpIsCalledThenExpectValidVertices) { for (auto l0Device : driverHandle->devices) { ze_fabric_vertex_handle_t hVertex = nullptr; @@ -197,7 +197,7 @@ TEST_F(FabricVertexFixture, GivenDevicesAreCreatedWhenZeDeviceGetFabricVertexExp } } -TEST_F(FabricVertexFixture, GivenDevicesAreCreatedWhenFabricVertexIsNotSetToDeviceThenZeDeviceGetFabricVertexExpReturnsError) { +TEST_F(FabricVertexFixture, givenDevicesAreCreatedWhenFabricVertexIsNotSetToDeviceThenZeDeviceGetFabricVertexExpReturnsError) { auto l0Device = driverHandle->devices[0]; ze_fabric_vertex_handle_t hVertex = nullptr; @@ -212,67 +212,20 @@ TEST_F(FabricVertexFixture, GivenDevicesAreCreatedWhenFabricVertexIsNotSetToDevi EXPECT_EQ(hVertex, nullptr); } -class FabricVertexFlatDeviceTestFixture : public MultiDeviceFixtureFlatHierarchy, - public ::testing::Test { - void SetUp() override { - NEO::debugManager.flags.ZE_AFFINITY_MASK.set("0,1.1,2"); - MultiDeviceFixtureFlatHierarchy::setUp(); - } - - void TearDown() override { - MultiDeviceFixtureFlatHierarchy::tearDown(); - } +TEST(FabricVertexTestFixture, givenCompositeHierarchyWhenFabricVerticesGetExpIsCalledCorrectVerticesAreReturned) { DebugManagerStateRestore restorer; -}; + NEO::debugManager.flags.ZE_AFFINITY_MASK.set("0,1.1,2"); + MultiDeviceFixtureCompositeHierarchy multiDeviceFixture{}; + multiDeviceFixture.setUp(); -TEST_F(FabricVertexFlatDeviceTestFixture, GivenFlatHierarchyWhenFabricVerticesGetExpIsCalledCorrectVerticesAreReturned) { uint32_t count = 0; std::vector phVertices; - EXPECT_EQ(driverHandle->fabricVertexGetExp(&count, nullptr), ZE_RESULT_SUCCESS); - // only 2 vertexes for mask "0,1.1,2": - // 0 and 2 - // 1.1 is ignored in FlatHierarchy - uint32_t expectedVertexes = 2u; - EXPECT_EQ(count, expectedVertexes); - - // Requesting for a reduced count - phVertices.resize(count); - EXPECT_EQ(driverHandle->fabricVertexGetExp(&count, phVertices.data()), ZE_RESULT_SUCCESS); - - ze_device_handle_t hDevice{}; - // Device 0 associated with value 0 in mask - EXPECT_EQ(L0::zeFabricVertexGetDeviceExp(phVertices[0], &hDevice), ZE_RESULT_SUCCESS); - DeviceImp *deviceImp = static_cast(hDevice); - EXPECT_FALSE(deviceImp->isSubdevice); - - // Device 1 associated with value 2 in mask - EXPECT_EQ(L0::zeFabricVertexGetDeviceExp(phVertices[1], &hDevice), ZE_RESULT_SUCCESS); - deviceImp = static_cast(hDevice); - EXPECT_FALSE(deviceImp->isSubdevice); -} - -class FabricVertexTestFixture : public MultiDeviceFixture, - public ::testing::Test { - void SetUp() override { - NEO::debugManager.flags.ZE_AFFINITY_MASK.set("0,1.1,2"); - MultiDeviceFixture::setUp(); - } - - void TearDown() override { - MultiDeviceFixture::tearDown(); - } - DebugManagerStateRestore restorer; -}; - -TEST_F(FabricVertexTestFixture, GivenCompositeHierarchyWhenFabricVerticesGetExpIsCalledCorrectVerticesAreReturned) { - uint32_t count = 0; - std::vector phVertices; - EXPECT_EQ(driverHandle->fabricVertexGetExp(&count, nullptr), ZE_RESULT_SUCCESS); + EXPECT_EQ(multiDeviceFixture.driverHandle->fabricVertexGetExp(&count, nullptr), ZE_RESULT_SUCCESS); uint32_t expectedVertexes = 3u; EXPECT_EQ(count, expectedVertexes); phVertices.resize(count); - EXPECT_EQ(driverHandle->fabricVertexGetExp(&count, phVertices.data()), ZE_RESULT_SUCCESS); + EXPECT_EQ(multiDeviceFixture.driverHandle->fabricVertexGetExp(&count, phVertices.data()), ZE_RESULT_SUCCESS); // Device 0 associated with value 0 in mask ze_device_handle_t hDevice{}; @@ -282,7 +235,7 @@ TEST_F(FabricVertexTestFixture, GivenCompositeHierarchyWhenFabricVerticesGetExpI uint32_t countSubDevices = 0; EXPECT_EQ(L0::zeFabricVertexGetSubVerticesExp(phVertices[0], &countSubDevices, nullptr), ZE_RESULT_SUCCESS); - EXPECT_EQ(countSubDevices, numSubDevices); + EXPECT_EQ(countSubDevices, multiDeviceFixture.numSubDevices); std::vector phSubvertices(countSubDevices); EXPECT_EQ(L0::zeFabricVertexGetSubVerticesExp(phVertices[0], &countSubDevices, phSubvertices.data()), ZE_RESULT_SUCCESS); @@ -311,24 +264,65 @@ TEST_F(FabricVertexTestFixture, GivenCompositeHierarchyWhenFabricVerticesGetExpI phSubvertices.clear(); countSubDevices = 0; EXPECT_EQ(L0::zeFabricVertexGetSubVerticesExp(phVertices[2], &countSubDevices, nullptr), ZE_RESULT_SUCCESS); - EXPECT_EQ(countSubDevices, numSubDevices); + EXPECT_EQ(countSubDevices, multiDeviceFixture.numSubDevices); + + multiDeviceFixture.tearDown(); } -TEST_F(FabricVertexTestFixture, GivenFlatHierarchyWhenFabricVerticesGetExpIsCalledCorrectVerticesAreReturned) { +TEST(FabricVertexTestFixture, givenFlatHierarchyWhenFabricVerticesGetExpIsCalledCorrectVerticesAreReturned) { + DebugManagerStateRestore restorer; + NEO::debugManager.flags.ZE_AFFINITY_MASK.set("0,1.1,2"); + MultiDeviceFixtureFlatHierarchy multiDeviceFixture{}; + multiDeviceFixture.setUp(); + uint32_t count = 0; std::vector phVertices; - this->driverHandle->deviceHierarchyMode = L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_FLAT; - EXPECT_EQ(driverHandle->fabricVertexGetExp(&count, nullptr), ZE_RESULT_SUCCESS); - uint32_t expectedVertexes = 5u; + EXPECT_EQ(multiDeviceFixture.driverHandle->fabricVertexGetExp(&count, nullptr), ZE_RESULT_SUCCESS); + // only 2 vertexes for mask "0,1.1,2": + // 0 and 2 + // 1.1 is ignored in FlatHierarchy + uint32_t expectedVertexes = 2u; + EXPECT_EQ(count, expectedVertexes); + + // Requesting for a reduced count + phVertices.resize(count); + EXPECT_EQ(multiDeviceFixture.driverHandle->fabricVertexGetExp(&count, phVertices.data()), ZE_RESULT_SUCCESS); + + ze_device_handle_t hDevice{}; + // Device 0 associated with value 0 in mask + EXPECT_EQ(L0::zeFabricVertexGetDeviceExp(phVertices[0], &hDevice), ZE_RESULT_SUCCESS); + DeviceImp *deviceImp = static_cast(hDevice); + EXPECT_FALSE(deviceImp->isSubdevice); + + // Device 1 associated with value 2 in mask + EXPECT_EQ(L0::zeFabricVertexGetDeviceExp(phVertices[1], &hDevice), ZE_RESULT_SUCCESS); + deviceImp = static_cast(hDevice); + EXPECT_FALSE(deviceImp->isSubdevice); + + multiDeviceFixture.tearDown(); +} + +TEST(FabricVertexTestFixture, givenCombinedHierarchyWhenFabricVerticesGetExpIsCalledCorrectVerticesAreReturned2) { + DebugManagerStateRestore restorer; + NEO::debugManager.flags.ZE_AFFINITY_MASK.set("0,1.1,2"); + MultiDeviceFixtureCombinedHierarchy multiDeviceFixture{}; + multiDeviceFixture.setUp(); + + uint32_t count = 0; + std::vector phVertices; + EXPECT_EQ(multiDeviceFixture.driverHandle->fabricVertexGetExp(&count, nullptr), ZE_RESULT_SUCCESS); + uint32_t expectedVertexes = 2u; EXPECT_EQ(count, expectedVertexes); phVertices.resize(count); - EXPECT_EQ(driverHandle->fabricVertexGetExp(&count, phVertices.data()), ZE_RESULT_SUCCESS); + EXPECT_EQ(multiDeviceFixture.driverHandle->fabricVertexGetExp(&count, phVertices.data()), ZE_RESULT_SUCCESS); + + multiDeviceFixture.tearDown(); } using FabricEdgeFixture = Test; -TEST_F(FabricEdgeFixture, GivenFabricVerticesAreCreatedWhenZeFabricEdgeGetExpIsCalledThenReturnSuccess) { +TEST_F(FabricEdgeFixture, givenFabricVerticesAreCreatedWhenZeFabricEdgeGetExpIsCalledThenReturnSuccess) { // initialize uint32_t count = 0; @@ -364,7 +358,7 @@ TEST_F(FabricEdgeFixture, GivenFabricVerticesAreCreatedWhenZeFabricEdgeGetExpIsC edgeHandles.data())); } -TEST_F(FabricEdgeFixture, GivenFabricVerticesAreCreatedForIndirectEdgesWhenZeFabricEdgeGetExpIsCalledThenReturnSuccess) { +TEST_F(FabricEdgeFixture, givenFabricVerticesAreCreatedForIndirectEdgesWhenZeFabricEdgeGetExpIsCalledThenReturnSuccess) { // initialize uint32_t count = 0; std::vector phVertices; @@ -417,7 +411,7 @@ TEST_F(FabricEdgeFixture, GivenFabricVerticesAreCreatedForIndirectEdgesWhenZeFab driverHandle->fabricIndirectEdges.clear(); } -TEST_F(FabricEdgeFixture, GivenFabricEdgesAreCreatedWhenZeFabricEdgeGetVerticesExpIsCalledThenReturnCorrectVertices) { +TEST_F(FabricEdgeFixture, givenFabricEdgesAreCreatedWhenZeFabricEdgeGetVerticesExpIsCalledThenReturnCorrectVertices) { // initialize uint32_t count = 0; std::vector phVertices; @@ -449,7 +443,7 @@ TEST_F(FabricEdgeFixture, GivenFabricEdgesAreCreatedWhenZeFabricEdgeGetVerticesE EXPECT_EQ(hVertexB, driverHandle->fabricVertices[1]); } -TEST_F(FabricEdgeFixture, GivenFabricEdgesAreCreatedWhenZeFabricEdgeGetPropertiesExpIsCalledThenReturnCorrectProperties) { +TEST_F(FabricEdgeFixture, givenFabricEdgesAreCreatedWhenZeFabricEdgeGetPropertiesExpIsCalledThenReturnCorrectProperties) { // initialize uint32_t count = 0; std::vector phVertices; @@ -482,7 +476,7 @@ TEST_F(FabricEdgeFixture, GivenFabricEdgesAreCreatedWhenZeFabricEdgeGetPropertie EXPECT_EQ(getProperties.latency, 20u); } -TEST_F(FabricEdgeFixture, GivenMdfiLinksAreAvailableWhenEdgesAreCreatedThenVerifyThatBiDirectionalEdgesAreNotCreated) { +TEST_F(FabricEdgeFixture, givenMdfiLinksAreAvailableWhenEdgesAreCreatedThenVerifyThatBiDirectionalEdgesAreNotCreated) { // initialize uint32_t count = 0; std::vector phVertices; diff --git a/level_zero/tools/test/unit_tests/sources/sysman/mocks/test_sysman_device_info.cpp b/level_zero/tools/test/unit_tests/sources/sysman/mocks/test_sysman_device_info.cpp index 89c843cd40..44a69a6538 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/mocks/test_sysman_device_info.cpp +++ b/level_zero/tools/test/unit_tests/sources/sysman/mocks/test_sysman_device_info.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2023 Intel Corporation + * Copyright (C) 2022-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -14,7 +14,7 @@ namespace L0 { namespace ult { -TEST_F(SysmanMultiDeviceInfoFixture, GivenDeviceWithMultipleTilesWhenOnlyTileOneIsEnabledThenGetSysmanDeviceInfoReturnsExpectedValues) { +TEST_F(SysmanMultiDeviceInfoFixture, givenDeviceWithMultipleTilesWhenOnlyTileOneIsEnabledThenGetSysmanDeviceInfoReturnsExpectedValues) { neoDevice->deviceBitfield.reset(); neoDevice->deviceBitfield.set(1); uint32_t subdeviceId = 0; @@ -24,7 +24,7 @@ TEST_F(SysmanMultiDeviceInfoFixture, GivenDeviceWithMultipleTilesWhenOnlyTileOne EXPECT_TRUE(onSubdevice); } -TEST_F(SysmanMultiDeviceInfoFixture, GivenDeviceWithMultipleTilesWhenOnlyTileOneIsEnabledAndMultiArchIsDisabledThenGetSysmanDeviceInfoReturnsExpectedValues) { +TEST_F(SysmanMultiDeviceInfoFixture, givenDeviceWithMultipleTilesWhenOnlyTileOneIsEnabledAndMultiArchIsDisabledThenGetSysmanDeviceInfoReturnsExpectedValues) { neoDevice->deviceBitfield.reset(); neoDevice->deviceBitfield.set(1); uint32_t subdeviceId = 0; @@ -34,7 +34,8 @@ TEST_F(SysmanMultiDeviceInfoFixture, GivenDeviceWithMultipleTilesWhenOnlyTileOne EXPECT_FALSE(onSubdevice); } -TEST_F(SysmanMultiDeviceInfoFixture, GivenDeviceWithMultipleTilesEnabledThenGetSysmanDeviceInfoReturnsExpectedValues) { +TEST_F(SysmanMultiDeviceInfoFixture, givenDeviceWithMultipleTilesEnabledAndCompositeHierarchyThenGetSysmanDeviceInfoReturnsExpectedValues) { + neoDevice->getExecutionEnvironment()->setDeviceHierarchyMode(NEO::DeviceHierarchyMode::COMPOSITE); uint32_t subDeviceCount = 0; std::vector deviceHandles; Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, nullptr); diff --git a/opencl/source/api/api.cpp b/opencl/source/api/api.cpp index acad42b76a..93d8c21bfb 100644 --- a/opencl/source/api/api.cpp +++ b/opencl/source/api/api.cpp @@ -259,7 +259,7 @@ cl_int CL_API_CALL clGetDeviceIDs(cl_platform_id platform, cl_uint retNum = 0; for (auto platformDeviceIndex = 0u; platformDeviceIndex < numDev; platformDeviceIndex++) { - bool exposeSubDevices = pPlatform->peekExecutionEnvironment()->isExposingSubDevicesAsDevices(); + bool exposeSubDevices = pPlatform->peekExecutionEnvironment()->getDeviceHierarchyMode() != COMPOSITE; ClDevice *device = pPlatform->getClDevice(platformDeviceIndex); UNRECOVERABLE_IF(device == nullptr); diff --git a/opencl/source/cl_device/cl_device.cpp b/opencl/source/cl_device/cl_device.cpp index ee4f815a28..badb5470b6 100644 --- a/opencl/source/cl_device/cl_device.cpp +++ b/opencl/source/cl_device/cl_device.cpp @@ -51,7 +51,7 @@ ClDevice::ClDevice(Device &device, ClDevice &rootClDevice, Platform *platform) : pClSubDevice->decRefApi(); pClSubDevice->internalParentDevice = this; - if (!device.getExecutionEnvironment()->isExposingSubDevicesAsDevices()) { + if (device.getExecutionEnvironment()->getDeviceHierarchyMode() == COMPOSITE) { auto &deviceInfo = pClSubDevice->deviceInfo; deviceInfo.parentDevice = this; deviceInfo.partitionType[0] = CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN; diff --git a/opencl/test/unit_test/device/sub_device_tests.cpp b/opencl/test/unit_test/device/sub_device_tests.cpp index 197c5fc787..6beda2a18e 100644 --- a/opencl/test/unit_test/device/sub_device_tests.cpp +++ b/opencl/test/unit_test/device/sub_device_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2024 Intel Corporation + * Copyright (C) 2019-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -104,42 +104,45 @@ TEST(SubDevicesTest, givenDeviceWithSubDevicesWhenSubDeviceApiRefCountsAreChange EXPECT_EQ(baseDefaultDeviceInternalRefCount, defaultDevice->getRefInternalCount()); } -TEST(SubDevicesTest, givenDeviceWithSubDevicesAndSubDevicesAsDevicesIsSetWhenSubDeviceApiRefCountsAreChangedThenChangeIsNotPropagatedToRootDevice) { +TEST(SubDevicesTest, givenDeviceWithFlatOrCombinedHierarchyWhenSubDeviceApiRefCountsAreChangedThenChangeIsNotPropagatedToRootDevice) { DebugManagerStateRestore restorer; debugManager.flags.CreateMultipleSubDevices.set(2); UnitTestSetter::disableHeaplessStateInit(restorer); VariableBackup mockDeviceFlagBackup(&MockDevice::createSingleDevice, false); - initPlatform(); - platform()->peekExecutionEnvironment()->setExposeSubDevicesAsDevices(1); - auto nonDefaultPlatform = std::make_unique(*platform()->peekExecutionEnvironment()); - nonDefaultPlatform->initializeWithNewDevices(); - auto device = nonDefaultPlatform->getClDevice(0); - auto defaultDevice = platform()->getClDevice(0); + DeviceHierarchyMode deviceHierarchyModes[] = {FLAT, COMBINED}; + for (auto deviceHierarchyMode : deviceHierarchyModes) { + initPlatform(); + platform()->peekExecutionEnvironment()->setDeviceHierarchyMode(deviceHierarchyMode); + auto nonDefaultPlatform = std::make_unique(*platform()->peekExecutionEnvironment()); + nonDefaultPlatform->initializeWithNewDevices(); + auto device = nonDefaultPlatform->getClDevice(0); + auto defaultDevice = platform()->getClDevice(0); - auto subDevice = device->getSubDevice(1); - auto baseDeviceApiRefCount = device->getRefApiCount(); - auto baseDeviceInternalRefCount = device->getRefInternalCount(); - auto baseSubDeviceApiRefCount = subDevice->getRefApiCount(); - auto baseSubDeviceInternalRefCount = subDevice->getRefInternalCount(); - auto baseDefaultDeviceApiRefCount = defaultDevice->getRefApiCount(); - auto baseDefaultDeviceInternalRefCount = defaultDevice->getRefInternalCount(); + auto subDevice = device->getSubDevice(1); + auto baseDeviceApiRefCount = device->getRefApiCount(); + auto baseDeviceInternalRefCount = device->getRefInternalCount(); + auto baseSubDeviceApiRefCount = subDevice->getRefApiCount(); + auto baseSubDeviceInternalRefCount = subDevice->getRefInternalCount(); + auto baseDefaultDeviceApiRefCount = defaultDevice->getRefApiCount(); + auto baseDefaultDeviceInternalRefCount = defaultDevice->getRefInternalCount(); - subDevice->retainApi(); - EXPECT_EQ(baseDeviceApiRefCount, device->getRefApiCount()); - EXPECT_EQ(baseDeviceInternalRefCount, device->getRefInternalCount()); - EXPECT_EQ(baseSubDeviceApiRefCount, subDevice->getRefApiCount()); - EXPECT_EQ(baseSubDeviceInternalRefCount, subDevice->getRefInternalCount()); - EXPECT_EQ(baseDefaultDeviceApiRefCount, defaultDevice->getRefApiCount()); - EXPECT_EQ(baseDefaultDeviceInternalRefCount, defaultDevice->getRefInternalCount()); + subDevice->retainApi(); + EXPECT_EQ(baseDeviceApiRefCount, device->getRefApiCount()); + EXPECT_EQ(baseDeviceInternalRefCount, device->getRefInternalCount()); + EXPECT_EQ(baseSubDeviceApiRefCount, subDevice->getRefApiCount()); + EXPECT_EQ(baseSubDeviceInternalRefCount, subDevice->getRefInternalCount()); + EXPECT_EQ(baseDefaultDeviceApiRefCount, defaultDevice->getRefApiCount()); + EXPECT_EQ(baseDefaultDeviceInternalRefCount, defaultDevice->getRefInternalCount()); - subDevice->releaseApi(); - EXPECT_EQ(baseDeviceApiRefCount, device->getRefApiCount()); - EXPECT_EQ(baseDeviceInternalRefCount, device->getRefInternalCount()); - EXPECT_EQ(baseSubDeviceApiRefCount, subDevice->getRefApiCount()); - EXPECT_EQ(baseSubDeviceInternalRefCount, subDevice->getRefInternalCount()); - EXPECT_EQ(baseDefaultDeviceApiRefCount, defaultDevice->getRefApiCount()); - EXPECT_EQ(baseDefaultDeviceInternalRefCount, defaultDevice->getRefInternalCount()); + subDevice->releaseApi(); + EXPECT_EQ(baseDeviceApiRefCount, device->getRefApiCount()); + EXPECT_EQ(baseDeviceInternalRefCount, device->getRefInternalCount()); + EXPECT_EQ(baseSubDeviceApiRefCount, subDevice->getRefApiCount()); + EXPECT_EQ(baseSubDeviceInternalRefCount, subDevice->getRefInternalCount()); + EXPECT_EQ(baseDefaultDeviceApiRefCount, defaultDevice->getRefApiCount()); + EXPECT_EQ(baseDefaultDeviceInternalRefCount, defaultDevice->getRefInternalCount()); + } } TEST(SubDevicesTest, givenDeviceWithSubDevicesWhenSubDeviceInternalRefCountsAreChangedThenChangeIsPropagatedToRootDevice) { @@ -176,7 +179,6 @@ TEST(SubDevicesTest, givenClDeviceWithSubDevicesWhenSubDeviceInternalRefCountsAr debugManager.flags.CreateMultipleSubDevices.set(2); VariableBackup mockDeviceFlagBackup(&MockDevice::createSingleDevice, false); auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get())); - device->getExecutionEnvironment()->setExposeSubDevicesAsDevices(false); device->incRefInternal(); auto &subDevice = device->subDevices[0]; diff --git a/shared/source/device/device.cpp b/shared/source/device/device.cpp index d3892e410e..a458677479 100644 --- a/shared/source/device/device.cpp +++ b/shared/source/device/device.cpp @@ -93,7 +93,7 @@ bool Device::genericSubDevicesAllowed() { deviceBitfield = maxNBitValue(subDeviceCount); deviceBitfield &= deviceMask; numSubDevices = static_cast(deviceBitfield.count()); - if (numSubDevices == 1 && (!executionEnvironment->isCombinedDeviceHierarchy() || subDeviceCount == 1)) { + if (numSubDevices == 1 && (executionEnvironment->getDeviceHierarchyMode() != COMBINED || subDeviceCount == 1)) { numSubDevices = 0; } diff --git a/shared/source/execution_environment/execution_environment.cpp b/shared/source/execution_environment/execution_environment.cpp index 8d511b2c7c..0b0f176792 100644 --- a/shared/source/execution_environment/execution_environment.cpp +++ b/shared/source/execution_environment/execution_environment.cpp @@ -220,7 +220,7 @@ void ExecutionEnvironment::parseAffinityMask() { } // If the user has requested FLAT or COMBINED device hierarchy models, then report all the sub devices as devices. - bool exposeSubDevicesAsApiDevices = isExposingSubDevicesAsDevices(); + bool exposeSubDevices = this->deviceHierarchyMode != COMPOSITE; // Reserve at least for a size equal to rootDeviceEnvironments.size() times four, // which is enough for typical configurations @@ -231,7 +231,7 @@ void ExecutionEnvironment::parseAffinityMask() { mapOfIndices.reserve(reservedSizeForIndices); uint32_t hwSubDevicesCount = 0u; - if (exposeSubDevicesAsApiDevices) { + if (exposeSubDevices) { for (uint32_t currentRootDevice = 0u; currentRootDevice < numRootDevices; currentRootDevice++) { auto hwInfo = rootDeviceEnvironments[currentRootDevice]->getHardwareInfo(); @@ -258,7 +258,7 @@ void ExecutionEnvironment::parseAffinityMask() { if (entryIndex >= numDevices) { continue; - } else if (exposeSubDevicesAsApiDevices) { + } else if (exposeSubDevices) { // tiles as devices // so ignore X.Y if (subEntries.size() > 1) { @@ -312,17 +312,17 @@ void ExecutionEnvironment::sortNeoDevices() { std::sort(rootDeviceEnvironments.begin(), rootDeviceEnvironments.end(), comparePciIdBusNumber); } -void ExecutionEnvironment::setDeviceHierarchy(const GfxCoreHelper &gfxCoreHelper) { +void ExecutionEnvironment::setDeviceHierarchyMode(const GfxCoreHelper &gfxCoreHelper) { NEO::EnvironmentVariableReader envReader; - std::string hierarchyModel = envReader.getSetting("ZE_FLAT_DEVICE_HIERARCHY", std::string(gfxCoreHelper.getDefaultDeviceHierarchy())); - if (strcmp(hierarchyModel.c_str(), "COMPOSITE") == 0) { - setExposeSubDevicesAsDevices(false); - } - if (strcmp(hierarchyModel.c_str(), "FLAT") == 0) { - setExposeSubDevicesAsDevices(true); - } - if (strcmp(hierarchyModel.c_str(), "COMBINED") == 0) { - setCombinedDeviceHierarchy(true); + std::string deviceHierarchyMode = envReader.getSetting("ZE_FLAT_DEVICE_HIERARCHY", std::string("")); + if (strcmp(deviceHierarchyMode.c_str(), "COMPOSITE") == 0) { + this->deviceHierarchyMode = COMPOSITE; + } else if (strcmp(deviceHierarchyMode.c_str(), "FLAT") == 0) { + this->deviceHierarchyMode = FLAT; + } else if (strcmp(deviceHierarchyMode.c_str(), "COMBINED") == 0) { + this->deviceHierarchyMode = COMBINED; + } else { + this->deviceHierarchyMode = gfxCoreHelper.getDefaultDeviceHierarchy(); } } diff --git a/shared/source/execution_environment/execution_environment.h b/shared/source/execution_environment/execution_environment.h index e4e9b67e39..c448e09af3 100644 --- a/shared/source/execution_environment/execution_environment.h +++ b/shared/source/execution_environment/execution_environment.h @@ -7,6 +7,7 @@ #pragma once #include "shared/source/debugger/debugger.h" +#include "shared/source/helpers/device_hierarchy_mode.h" #include "shared/source/utilities/reference_tracked_object.h" #include @@ -38,7 +39,11 @@ class ExecutionEnvironment : public ReferenceTrackedObject void adjustCcsCount(); void adjustCcsCount(const uint32_t rootDeviceIndex) const; void sortNeoDevices(); - void setDeviceHierarchy(const GfxCoreHelper &gfxCoreHelper); + void setDeviceHierarchyMode(const GfxCoreHelper &gfxCoreHelper); + void setDeviceHierarchyMode(const DeviceHierarchyMode deviceHierarchyMode) { + this->deviceHierarchyMode = deviceHierarchyMode; + } + DeviceHierarchyMode getDeviceHierarchyMode() const { return deviceHierarchyMode; } void adjustRootDeviceEnvironments(); void prepareForCleanup() const; void configureCcsMode(); @@ -50,15 +55,6 @@ class ExecutionEnvironment : public ReferenceTrackedObject void setMetricsEnabled(bool value) { this->metricsEnabled = value; } - void setExposeSubDevicesAsDevices(bool value) { - this->subDevicesAsDevices = value; - } - void setCombinedDeviceHierarchy(bool value) { - this->subDevicesAsDevices = value; - this->combinedDeviceHierarchy = value; - } - bool isExposingSubDevicesAsDevices() const { return this->subDevicesAsDevices; } - bool isCombinedDeviceHierarchy() const { return this->combinedDeviceHierarchy; } void getErrorDescription(const char **ppString); bool getSubDeviceHierarchy(uint32_t index, std::tuple *subDeviceMap); bool areMetricsEnabled() { return this->metricsEnabled; } @@ -90,9 +86,8 @@ class ExecutionEnvironment : public ReferenceTrackedObject void restoreCcsMode(); bool metricsEnabled = false; bool fp64EmulationEnabled = false; - bool subDevicesAsDevices = false; - bool combinedDeviceHierarchy = false; + DeviceHierarchyMode deviceHierarchyMode = COMPOSITE; DebuggingMode debuggingEnabledMode = DebuggingMode::disabled; std::unordered_map rootDeviceNumCcsMap; std::mutex initializeDirectSubmissionControllerMutex; diff --git a/shared/source/helpers/CMakeLists.txt b/shared/source/helpers/CMakeLists.txt index 2008ea6327..56f4e4aa96 100644 --- a/shared/source/helpers/CMakeLists.txt +++ b/shared/source/helpers/CMakeLists.txt @@ -58,6 +58,7 @@ set(NEO_CORE_HELPERS ${CMAKE_CURRENT_SOURCE_DIR}/debug_helpers.h ${CMAKE_CURRENT_SOURCE_DIR}/deferred_deleter_helper.h ${CMAKE_CURRENT_SOURCE_DIR}/device_bitfield.h + ${CMAKE_CURRENT_SOURCE_DIR}/device_hierarchy_mode.h ${CMAKE_CURRENT_SOURCE_DIR}/driver_model_type.h ${CMAKE_CURRENT_SOURCE_DIR}/dirty_state_helpers.cpp ${CMAKE_CURRENT_SOURCE_DIR}/dirty_state_helpers.h diff --git a/shared/source/helpers/device_hierarchy_mode.h b/shared/source/helpers/device_hierarchy_mode.h new file mode 100644 index 0000000000..3c4b349d81 --- /dev/null +++ b/shared/source/helpers/device_hierarchy_mode.h @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +namespace NEO { +enum DeviceHierarchyMode { + COMPOSITE, + FLAT, + COMBINED +}; +}; diff --git a/shared/source/helpers/gfx_core_helper.cpp b/shared/source/helpers/gfx_core_helper.cpp index f416bcbe50..3049e5b4fa 100644 --- a/shared/source/helpers/gfx_core_helper.cpp +++ b/shared/source/helpers/gfx_core_helper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2024 Intel Corporation + * Copyright (C) 2018-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -18,11 +18,6 @@ namespace NEO { GfxCoreHelperCreateFunctionType gfxCoreHelperFactory[IGFX_MAX_CORE] = {}; -const char *deviceHierarchyComposite = "COMPOSITE"; -const char *deviceHierarchyFlat = "FLAT"; -const char *deviceHierarchyCombined = "COMBINED"; -const char *deviceHierarchyUnk = "UNK"; - std::unique_ptr GfxCoreHelper::create(const GFXCORE_FAMILY gfxCoreFamily) { auto createFunction = gfxCoreHelperFactory[gfxCoreFamily]; diff --git a/shared/source/helpers/gfx_core_helper.h b/shared/source/helpers/gfx_core_helper.h index 35326ce7a4..7aa0a50157 100644 --- a/shared/source/helpers/gfx_core_helper.h +++ b/shared/source/helpers/gfx_core_helper.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2024 Intel Corporation + * Copyright (C) 2018-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -8,6 +8,7 @@ #pragma once #include "shared/source/built_ins/sip_kernel_type.h" #include "shared/source/helpers/definitions/engine_group_types.h" +#include "shared/source/helpers/device_hierarchy_mode.h" #include "shared/source/helpers/engine_node_helper.h" #include "shared/source/helpers/options.h" #include "shared/source/utilities/stackvec.h" @@ -49,11 +50,6 @@ class AILConfiguration; using EngineInstancesContainer = StackVec; using GfxCoreHelperCreateFunctionType = std::unique_ptr (*)(); -extern const char *deviceHierarchyComposite; -extern const char *deviceHierarchyFlat; -extern const char *deviceHierarchyCombined; -extern const char *deviceHierarchyUnk; - class GfxCoreHelper { public: static std::unique_ptr create(const GFXCORE_FAMILY gfxCoreFamily); @@ -171,7 +167,7 @@ class GfxCoreHelper { virtual bool isRelaxedOrderingSupported() const = 0; virtual uint32_t calculateNumThreadsPerThreadGroup(uint32_t simd, uint32_t totalWorkItems, uint32_t grfCount, bool isHwLocalIdGeneration, const RootDeviceEnvironment &rootDeviceEnvironment) const = 0; virtual uint32_t overrideMaxWorkGroupSize(uint32_t maxWG) const = 0; - virtual char const *getDefaultDeviceHierarchy() const = 0; + virtual DeviceHierarchyMode getDefaultDeviceHierarchy() const = 0; static bool isWorkaroundRequired(uint32_t lowestSteppingWithBug, uint32_t steppingWithFix, const HardwareInfo &hwInfo, const ProductHelper &productHelper); virtual bool areSecondaryContextsSupported() const = 0; @@ -408,7 +404,7 @@ class GfxCoreHelperHw : public GfxCoreHelper { bool isRelaxedOrderingSupported() const override; uint32_t calculateNumThreadsPerThreadGroup(uint32_t simd, uint32_t totalWorkItems, uint32_t grfCount, bool isHwLocalIdGeneration, const RootDeviceEnvironment &rootDeviceEnvironment) const override; uint32_t overrideMaxWorkGroupSize(uint32_t maxWG) const override; - char const *getDefaultDeviceHierarchy() const override; + DeviceHierarchyMode getDefaultDeviceHierarchy() const override; bool areSecondaryContextsSupported() const override; uint32_t getContextGroupContextsCount() const override; diff --git a/shared/source/helpers/gfx_core_helper_base.inl b/shared/source/helpers/gfx_core_helper_base.inl index 92a99b7662..9f51d1d39f 100644 --- a/shared/source/helpers/gfx_core_helper_base.inl +++ b/shared/source/helpers/gfx_core_helper_base.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2024 Intel Corporation + * Copyright (C) 2019-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -681,8 +681,8 @@ uint32_t GfxCoreHelperHw::calculateNumThreadsPerThreadGroup(uint32_t } template -char const *GfxCoreHelperHw::getDefaultDeviceHierarchy() const { - return deviceHierarchyComposite; +DeviceHierarchyMode GfxCoreHelperHw::getDefaultDeviceHierarchy() const { + return COMPOSITE; } template diff --git a/shared/source/os_interface/device_factory.cpp b/shared/source/os_interface/device_factory.cpp index 6150c56e24..3534770914 100644 --- a/shared/source/os_interface/device_factory.cpp +++ b/shared/source/os_interface/device_factory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2024 Intel Corporation + * Copyright (C) 2018-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -137,7 +137,7 @@ bool DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(ExecutionE } } - executionEnvironment.setDeviceHierarchy(executionEnvironment.rootDeviceEnvironments[0]->getHelper()); + executionEnvironment.setDeviceHierarchyMode(executionEnvironment.rootDeviceEnvironments[0]->getHelper()); executionEnvironment.parseAffinityMask(); executionEnvironment.adjustCcsCount(); executionEnvironment.calculateMaxOsContextCount(); @@ -214,7 +214,7 @@ bool DeviceFactory::prepareDeviceEnvironments(ExecutionEnvironment &executionEnv return false; } - executionEnvironment.setDeviceHierarchy(executionEnvironment.rootDeviceEnvironments[0]->getHelper()); + executionEnvironment.setDeviceHierarchyMode(executionEnvironment.rootDeviceEnvironments[0]->getHelper()); executionEnvironment.sortNeoDevices(); executionEnvironment.parseAffinityMask(); executionEnvironment.adjustRootDeviceEnvironments(); diff --git a/shared/source/xe_hpc_core/gfx_core_helper_xe_hpc_core.cpp b/shared/source/xe_hpc_core/gfx_core_helper_xe_hpc_core.cpp index faa976f81f..cf52fb6ad7 100644 --- a/shared/source/xe_hpc_core/gfx_core_helper_xe_hpc_core.cpp +++ b/shared/source/xe_hpc_core/gfx_core_helper_xe_hpc_core.cpp @@ -299,8 +299,8 @@ bool GfxCoreHelperHw::isRelaxedOrderingSupported() const { } template <> -char const *GfxCoreHelperHw::getDefaultDeviceHierarchy() const { - return deviceHierarchyFlat; +DeviceHierarchyMode GfxCoreHelperHw::getDefaultDeviceHierarchy() const { + return FLAT; } } // namespace NEO diff --git a/shared/test/common/mocks/mock_device.cpp b/shared/test/common/mocks/mock_device.cpp index 1b41c3f8db..41b3947416 100644 --- a/shared/test/common/mocks/mock_device.cpp +++ b/shared/test/common/mocks/mock_device.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2024 Intel Corporation + * Copyright (C) 2018-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -121,7 +121,7 @@ ExecutionEnvironment *MockDevice::prepareExecutionEnvironment(const HardwareInfo UnitTestSetter::setCcsExposure(*executionEnvironment->rootDeviceEnvironments[i]); executionEnvironment->rootDeviceEnvironments[i]->initGmm(); } - executionEnvironment->setDeviceHierarchy(executionEnvironment->rootDeviceEnvironments[0]->getHelper()); + executionEnvironment->setDeviceHierarchyMode(executionEnvironment->rootDeviceEnvironments[0]->getHelper()); executionEnvironment->calculateMaxOsContextCount(); return executionEnvironment; } @@ -160,7 +160,7 @@ ExecutionEnvironment *MockDevice::prepareExecutionEnvironment(const HardwareInfo UnitTestSetter::setRcsExposure(*executionEnvironment->rootDeviceEnvironments[0]); UnitTestSetter::setCcsExposure(*executionEnvironment->rootDeviceEnvironments[0]); - executionEnvironment->setDeviceHierarchy(executionEnvironment->rootDeviceEnvironments[0]->getHelper()); + executionEnvironment->setDeviceHierarchyMode(executionEnvironment->rootDeviceEnvironments[0]->getHelper()); MockAubCenterFixture::setMockAubCenter(*executionEnvironment->rootDeviceEnvironments[0]); executionEnvironment->initializeMemoryManager(); diff --git a/shared/test/unit_test/device/neo_device_tests.cpp b/shared/test/unit_test/device/neo_device_tests.cpp index 2da0a45b56..5904c765b3 100644 --- a/shared/test/unit_test/device/neo_device_tests.cpp +++ b/shared/test/unit_test/device/neo_device_tests.cpp @@ -171,7 +171,7 @@ TEST(Device, WhenCreatingDeviceThenCapsInitilizedBeforeEnginesAreCreated) { executionEnvironment->rootDeviceEnvironments[i]->setHwInfoAndInitHelpers(&hwInfo); executionEnvironment->rootDeviceEnvironments[i]->initGmm(); } - executionEnvironment->setDeviceHierarchy(executionEnvironment->rootDeviceEnvironments[0]->getHelper()); + executionEnvironment->setDeviceHierarchyMode(executionEnvironment->rootDeviceEnvironments[0]->getHelper()); executionEnvironment->calculateMaxOsContextCount(); executionEnvironment->initializeMemoryManager(); diff --git a/shared/test/unit_test/execution_environment/execution_environment_tests.cpp b/shared/test/unit_test/execution_environment/execution_environment_tests.cpp index 8f80c28fb4..ec88d9a891 100644 --- a/shared/test/unit_test/execution_environment/execution_environment_tests.cpp +++ b/shared/test/unit_test/execution_environment/execution_environment_tests.cpp @@ -361,19 +361,21 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeMemoryManagerI executionEnvironment.initializeMemoryManager(); EXPECT_NE(nullptr, executionEnvironment.memoryManager); } -static_assert(sizeof(ExecutionEnvironment) == sizeof(std::unique_ptr) + - sizeof(std::vector) + - sizeof(std::unique_ptr) + + +static_assert(sizeof(ExecutionEnvironment) == sizeof(std::unique_ptr) + sizeof(std::unique_ptr) + - sizeof(std::unordered_map) + - 2 * sizeof(bool) + - sizeof(NEO::DebuggingMode) + - (is64bit ? 18 : 14) + - sizeof(std::mutex) + + sizeof(std::unique_ptr) + + sizeof(std::vector>) + sizeof(std::unordered_map>) + - sizeof(std::vector>) + sizeof(std::unordered_map) + - sizeof(std::mutex), + sizeof(std::mutex) + + 2 * sizeof(bool) + + sizeof(DeviceHierarchyMode) + + sizeof(DebuggingMode) + + sizeof(std::unordered_map) + + sizeof(std::mutex) + + sizeof(std::vector>) + + (is64bit ? 22 : 14), "New members detected in ExecutionEnvironment, please ensure that destruction sequence of objects is correct"); TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDestroyedThenDeleteSequenceIsSpecified) { @@ -547,7 +549,7 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenSettingFP64EmulationEnab EXPECT_TRUE(executionEnvironment.isFP64EmulationEnabled()); } -TEST(ExecutionEnvironment, givenCorrectZeAffinityMaskWhenExposeSubDevicesAsApiDevicesIsSetThenMapOfSubDeviceIndicesIsSet) { +TEST(ExecutionEnvironment, givenCorrectZeAffinityMaskWithFlatOrCombinedHierarchyThenMapOfSubDeviceIndicesIsSet) { DebugManagerStateRestore restore; debugManager.flags.CreateMultipleSubDevices.set(4); @@ -555,16 +557,20 @@ TEST(ExecutionEnvironment, givenCorrectZeAffinityMaskWhenExposeSubDevicesAsApiDe debugManager.flags.SetCommandStreamReceiver.set(1); auto hwInfo = *defaultHwInfo; - MockExecutionEnvironment executionEnvironment(&hwInfo); - executionEnvironment.incRefInternal(); - executionEnvironment.setExposeSubDevicesAsDevices(true); - DeviceFactory::createDevices(executionEnvironment); + DeviceHierarchyMode deviceHierarchyModes[] = {FLAT, COMBINED}; + for (auto deviceHierarchyMode : deviceHierarchyModes) { + MockExecutionEnvironment executionEnvironment(&hwInfo); + executionEnvironment.incRefInternal(); + executionEnvironment.setDeviceHierarchyMode(deviceHierarchyMode); - EXPECT_FALSE(executionEnvironment.mapOfSubDeviceIndices.empty()); + DeviceFactory::createDevices(executionEnvironment); + + EXPECT_FALSE(executionEnvironment.mapOfSubDeviceIndices.empty()); + } } -TEST(ExecutionEnvironment, givenIncorrectZeAffinityMaskWhenExposeSubDevicesAsApiDevicesIsSetThenMapOfSubDeviceIndicesIsEmpty) { +TEST(ExecutionEnvironment, givenIncorrectZeAffinityMaskWithFlatOrCombinedHierarchyThenMapOfSubDeviceIndicesIsEmpty) { DebugManagerStateRestore restore; debugManager.flags.CreateMultipleSubDevices.set(4); @@ -572,13 +578,17 @@ TEST(ExecutionEnvironment, givenIncorrectZeAffinityMaskWhenExposeSubDevicesAsApi debugManager.flags.SetCommandStreamReceiver.set(1); auto hwInfo = *defaultHwInfo; - MockExecutionEnvironment executionEnvironment(&hwInfo); - executionEnvironment.incRefInternal(); - executionEnvironment.setExposeSubDevicesAsDevices(true); - DeviceFactory::createDevices(executionEnvironment); + DeviceHierarchyMode deviceHierarchyModes[] = {FLAT, COMBINED}; + for (auto deviceHierarchyMode : deviceHierarchyModes) { + MockExecutionEnvironment executionEnvironment(&hwInfo); + executionEnvironment.incRefInternal(); + executionEnvironment.setDeviceHierarchyMode(deviceHierarchyMode); - EXPECT_TRUE(executionEnvironment.mapOfSubDeviceIndices.empty()); + DeviceFactory::createDevices(executionEnvironment); + + EXPECT_TRUE(executionEnvironment.mapOfSubDeviceIndices.empty()); + } } TEST(ExecutionEnvironment, givenBuiltinsSetWhenRootDeviceEnvironmentIsReleasedThenBuiltinsIsReset) { @@ -627,46 +637,6 @@ TEST(ExecutionEnvironmentWithAILTests, whenAILConfigurationFailsOnInitProcessExe EXPECT_FALSE(rootDeviceEnvironment->initAilConfiguration()); } -TEST(ExecutionEnvironmentDeviceHierarchy, givenExecutionEnvironmentWithDefaultDeviceHierarchyThenExecutionEnvironmentIsInitializedCorrectly) { - VariableBackup mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0); - MockExecutionEnvironment executionEnvironment; - executionEnvironment.rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(defaultHwInfo.get()); - auto &gfxCoreHelper = executionEnvironment.rootDeviceEnvironments[0]->getHelper(); - executionEnvironment.setDeviceHierarchy(gfxCoreHelper); - EXPECT_EQ((strcmp(gfxCoreHelper.getDefaultDeviceHierarchy(), "COMPOSITE") != 0), - executionEnvironment.isExposingSubDevicesAsDevices()); -} - -TEST(ExecutionEnvironmentDeviceHierarchy, givenExecutionEnvironmentWithCompositeDeviceHierarchyThenExposeSubDevicesAsDevicesIsFalse) { - VariableBackup mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0); - std::unordered_map mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "COMPOSITE"}}; - VariableBackup *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs); - MockExecutionEnvironment executionEnvironment; - executionEnvironment.rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(defaultHwInfo.get()); - executionEnvironment.setDeviceHierarchy(executionEnvironment.rootDeviceEnvironments[0]->getHelper()); - EXPECT_FALSE(executionEnvironment.isExposingSubDevicesAsDevices()); -} - -TEST(ExecutionEnvironmentDeviceHierarchy, givenExecutionEnvironmentWithFlatDeviceHierarchyThenExposeSubDevicesAsDevicesIsTrue) { - VariableBackup mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0); - std::unordered_map mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "FLAT"}}; - VariableBackup *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs); - MockExecutionEnvironment executionEnvironment; - executionEnvironment.rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(defaultHwInfo.get()); - executionEnvironment.setDeviceHierarchy(executionEnvironment.rootDeviceEnvironments[0]->getHelper()); - EXPECT_TRUE(executionEnvironment.isExposingSubDevicesAsDevices()); -} - -TEST(ExecutionEnvironmentDeviceHierarchy, givenExecutionEnvironmentWithCombinedDeviceHierarchyThenExposeSubDevicesAsDevicesIsTrue) { - VariableBackup mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0); - std::unordered_map mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "COMBINED"}}; - VariableBackup *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs); - MockExecutionEnvironment executionEnvironment; - executionEnvironment.rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(defaultHwInfo.get()); - executionEnvironment.setDeviceHierarchy(executionEnvironment.rootDeviceEnvironments[0]->getHelper()); - EXPECT_TRUE(executionEnvironment.isExposingSubDevicesAsDevices()); -} - TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenSetErrorDescriptionIsCalledThenGetErrorDescriptionGetsStringCorrectly) { std::string errorString = "we manually created error"; std::string errorString2 = "here's the next string to pass with arguments: "; diff --git a/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp b/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp index 52f9ac85eb..9890fe32bf 100644 --- a/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp +++ b/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Intel Corporation + * Copyright (C) 2022-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -1693,10 +1693,10 @@ HWTEST_F(GfxCoreHelperTest, givenFlagRemoveRestrictionsOnNumberOfThreadsInGpgpuT } } -HWTEST2_F(GfxCoreHelperTest, whenGetDefaultDeviceHierarchyThenReturnFlatHierarchy, IsNotXeHpcCore) { +HWTEST2_F(GfxCoreHelperTest, whenGetDefaultDeviceHierarchyThenReturnCompositeHierarchy, IsNotXeHpcCore) { const auto &gfxCoreHelper = getHelper(); auto defaultDeviceHierarchy = gfxCoreHelper.getDefaultDeviceHierarchy(); - EXPECT_STREQ("COMPOSITE", defaultDeviceHierarchy); + EXPECT_EQ(COMPOSITE, defaultDeviceHierarchy); } HWTEST_F(GfxCoreHelperTest, givenContextGroupDisabledWhenContextGroupContextsCountAndSecondaryContextsSupportQueriedThenZeroCountAndFalseIsReturned) { diff --git a/shared/test/unit_test/xe_hpc_core/gfx_core_helper_xe_hpc_core_tests.cpp b/shared/test/unit_test/xe_hpc_core/gfx_core_helper_xe_hpc_core_tests.cpp index f61d574c31..f2aa6b7b55 100644 --- a/shared/test/unit_test/xe_hpc_core/gfx_core_helper_xe_hpc_core_tests.cpp +++ b/shared/test/unit_test/xe_hpc_core/gfx_core_helper_xe_hpc_core_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2024 Intel Corporation + * Copyright (C) 2021-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -113,5 +113,5 @@ XE_HPC_CORETEST_F(GfxCoreHelperXeHpcCoreTest, whenGetDefaultDeviceHierarchyThenR auto &gfxCoreHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); auto defaultDeviceHierarchy = gfxCoreHelper.getDefaultDeviceHierarchy(); - EXPECT_STREQ("FLAT", defaultDeviceHierarchy); + EXPECT_EQ(FLAT, defaultDeviceHierarchy); }