diff --git a/level_zero/core/test/unit_tests/sources/driver/linux/test_driver_handle_imp_linux.cpp b/level_zero/core/test/unit_tests/sources/driver/linux/test_driver_handle_imp_linux.cpp index 2ad94cc9d7..33cc9a2b82 100644 --- a/level_zero/core/test/unit_tests/sources/driver/linux/test_driver_handle_imp_linux.cpp +++ b/level_zero/core/test/unit_tests/sources/driver/linux/test_driver_handle_imp_linux.cpp @@ -7,6 +7,7 @@ #include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/os_interface/device_factory.h" +#include "shared/source/os_interface/linux/drm_memory_operations_handler_bind.h" #include "shared/source/os_interface/linux/drm_neo.h" #include "shared/source/os_interface/os_interface.h" #include "shared/test/common/mocks/mock_compilers.h" @@ -37,6 +38,9 @@ class DriverLinuxFixture : public ::testing::Test { for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(&hwInfo); } + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = std::make_unique(*executionEnvironment->rootDeviceEnvironments[i], i); + } deviceFactory = std::make_unique(numRootDevices, numSubDevices, *executionEnvironment); for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { devices.push_back(std::unique_ptr(deviceFactory->rootDevices[i])); @@ -47,6 +51,11 @@ class DriverLinuxFixture : public ::testing::Test { osInterface->setDriverModel(std::make_unique(bdf[i], const_cast(devices[i]->getRootDeviceEnvironment()))); } executionEnvironment->sortNeoDevices(); + + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + NEO::DrmMemoryOperationsHandlerBind *drm = static_cast(executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface.get()); + EXPECT_EQ(drm->getRootDeviceIndex(), i); + } } void TearDown() override {} @@ -131,6 +140,9 @@ class DriverPciOrderWitSimilarBusLinuxFixture : public ::testing::Test { for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(&hwInfo); } + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = std::make_unique(*executionEnvironment->rootDeviceEnvironments[i], i); + } deviceFactory = std::make_unique(numRootDevices, numSubDevices, *executionEnvironment); for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { devices.push_back(std::unique_ptr(deviceFactory->rootDevices[i])); @@ -141,6 +153,11 @@ class DriverPciOrderWitSimilarBusLinuxFixture : public ::testing::Test { osInterface->setDriverModel(std::make_unique(bdf[i], const_cast(devices[i]->getRootDeviceEnvironment()))); } executionEnvironment->sortNeoDevices(); + + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + NEO::DrmMemoryOperationsHandlerBind *drm = static_cast(executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface.get()); + EXPECT_EQ(drm->getRootDeviceIndex(), i); + } } void TearDown() override {} @@ -182,6 +199,9 @@ class DriverPciOrderWitDifferentDeviceLinuxFixture : public ::testing::Test { for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(&hwInfo); } + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = std::make_unique(*executionEnvironment->rootDeviceEnvironments[i], i); + } deviceFactory = std::make_unique(numRootDevices, numSubDevices, *executionEnvironment); for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { devices.push_back(std::unique_ptr(deviceFactory->rootDevices[i])); @@ -192,6 +212,11 @@ class DriverPciOrderWitDifferentDeviceLinuxFixture : public ::testing::Test { osInterface->setDriverModel(std::make_unique(bdf[i], const_cast(devices[i]->getRootDeviceEnvironment()))); } executionEnvironment->sortNeoDevices(); + + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + NEO::DrmMemoryOperationsHandlerBind *drm = static_cast(executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface.get()); + EXPECT_EQ(drm->getRootDeviceIndex(), i); + } } void TearDown() override {} @@ -233,6 +258,9 @@ class DriverPciOrderWitSimilarBusAndDeviceLinuxFixture : public ::testing::Test for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(&hwInfo); } + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = std::make_unique(*executionEnvironment->rootDeviceEnvironments[i], i); + } deviceFactory = std::make_unique(numRootDevices, numSubDevices, *executionEnvironment); for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { devices.push_back(std::unique_ptr(deviceFactory->rootDevices[i])); @@ -243,6 +271,11 @@ class DriverPciOrderWitSimilarBusAndDeviceLinuxFixture : public ::testing::Test osInterface->setDriverModel(std::make_unique(bdf[i], const_cast(devices[i]->getRootDeviceEnvironment()))); } executionEnvironment->sortNeoDevices(); + + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + NEO::DrmMemoryOperationsHandlerBind *drm = static_cast(executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface.get()); + EXPECT_EQ(drm->getRootDeviceIndex(), i); + } } void TearDown() override {} @@ -284,6 +317,9 @@ class DriverPciOrderWitSimilarBDFLinuxFixture : public ::testing::Test { for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(&hwInfo); } + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = std::make_unique(*executionEnvironment->rootDeviceEnvironments[i], i); + } deviceFactory = std::make_unique(numRootDevices, numSubDevices, *executionEnvironment); for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { devices.push_back(std::unique_ptr(deviceFactory->rootDevices[i])); @@ -294,6 +330,11 @@ class DriverPciOrderWitSimilarBDFLinuxFixture : public ::testing::Test { osInterface->setDriverModel(std::make_unique(bdf[i], const_cast(devices[i]->getRootDeviceEnvironment()))); } executionEnvironment->sortNeoDevices(); + + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + NEO::DrmMemoryOperationsHandlerBind *drm = static_cast(executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface.get()); + EXPECT_EQ(drm->getRootDeviceIndex(), i); + } } void TearDown() override {} @@ -322,5 +363,103 @@ TEST_F(DriverPciOrderWitSimilarBDFLinuxFixture, GivenEnvironmentVariableForDevic delete driverHandle; } +class DriverPciOrderSortDoesNothing : public ::testing::Test { + public: + void SetUp() override { + DebugManagerStateRestore restorer; + DebugManager.flags.ZE_ENABLE_PCI_ID_DEVICE_ORDER.set(1); + + NEO::MockCompilerEnableGuard mock(true); + auto executionEnvironment = new NEO::ExecutionEnvironment(); + executionEnvironment->prepareRootDeviceEnvironments(numRootDevices); + NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get(); + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(&hwInfo); + } + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = std::make_unique(*executionEnvironment->rootDeviceEnvironments[i], i); + } + deviceFactory = std::make_unique(numRootDevices, numSubDevices, *executionEnvironment); + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + devices.push_back(std::unique_ptr(deviceFactory->rootDevices[i])); + } + for (auto i = 0u; i < devices.size(); i++) { + devices[i]->getExecutionEnvironment()->rootDeviceEnvironments[i]->osInterface = std::make_unique(); + auto osInterface = devices[i]->getExecutionEnvironment()->rootDeviceEnvironments[i]->osInterface.get(); + osInterface->setDriverModel(std::make_unique(bdf[i], const_cast(devices[i]->getRootDeviceEnvironment()))); + } + executionEnvironment->sortNeoDevices(); + + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + NEO::DrmMemoryOperationsHandlerBind *drm = static_cast(executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface.get()); + EXPECT_EQ(drm->getRootDeviceIndex(), i); + } + } + void TearDown() override {} + + static constexpr uint32_t numRootDevices = 2u; + static constexpr uint32_t numSubDevices = 2u; + std::vector> devices; + std::string bdf[numRootDevices] = {"0000:03:04.0", "0001:03:04.0"}; + std::string sortedBdf[numRootDevices] = {"0000:03:04.0", "0001:03:04.0"}; + std::unique_ptr deviceFactory; +}; + +TEST_F(DriverPciOrderSortDoesNothing, GivenEnvironmentVariableForDeviceOrderAccordingToPciSetThenVerifyCaseSortDoesNothing) { + NEO::MockCompilerEnableGuard mock(true); + DriverHandleImp *driverHandle = new DriverHandleImp; + + EXPECT_EQ(ZE_RESULT_SUCCESS, driverHandle->initialize(std::move(devices))); + + for (uint32_t i = 0; i < numRootDevices; i++) { + auto L0Device = driverHandle->devices[i]; + if (L0Device != nullptr) { + auto pDrm = L0Device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[L0Device->getRootDeviceIndex()]->osInterface->getDriverModel()->as(); + EXPECT_NE(pDrm, nullptr); + EXPECT_TRUE(!pDrm->getPciPath().compare(sortedBdf[i])); + } + } + delete driverHandle; +} + +class DriverWDDMLinuxFixture : public ::testing::Test { + public: + void SetUp() override { + NEO::MockCompilerEnableGuard mock(true); + executionEnvironment->prepareRootDeviceEnvironments(numRootDevices); + NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get(); + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(&hwInfo); + } + deviceFactory = std::make_unique(numRootDevices, numSubDevices, *executionEnvironment); + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + devices.push_back(std::unique_ptr(deviceFactory->rootDevices[i])); + } + for (auto i = 0u; i < devices.size(); i++) { + devices[i]->getExecutionEnvironment()->rootDeviceEnvironments[i]->osInterface.reset(new NEO::OSInterface()); + devices[i]->getExecutionEnvironment()->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::make_unique(512)); + } + } + void TearDown() override {} + + NEO::ExecutionEnvironment *executionEnvironment = new NEO::ExecutionEnvironment(); + static constexpr uint32_t numRootDevices = 5u; + static constexpr uint32_t numSubDevices = 2u; + std::vector> devices; + std::unique_ptr deviceFactory; +}; + +TEST_F(DriverWDDMLinuxFixture, ClearPciSortFlagToVerifyCodeCoverageOnly) { + NEO::MockCompilerEnableGuard mock(true); + DriverHandleImp *driverHandle = new DriverHandleImp; + EXPECT_EQ(ZE_RESULT_SUCCESS, driverHandle->initialize(std::move(devices))); + DebugManagerStateRestore restorer; + DebugManager.flags.ZE_ENABLE_PCI_ID_DEVICE_ORDER.set(0); + + executionEnvironment->sortNeoDevices(); + + delete driverHandle; +} + } // namespace ult } // namespace L0 diff --git a/shared/source/CMakeLists.txt b/shared/source/CMakeLists.txt index 435b372890..363dcd1f62 100644 --- a/shared/source/CMakeLists.txt +++ b/shared/source/CMakeLists.txt @@ -171,6 +171,7 @@ else() NEO_CORE_SRCS_HELPERS_WINDOWS NEO_CORE_GMM_HELPER_WINDOWS NEO_CORE_OS_INTERFACE_WDDM + NEO_CORE_EXECUTION_ENVIRONMENT_WDDM NEO_CORE_SKU_INFO_WINDOWS ) endif() diff --git a/shared/source/execution_environment/CMakeLists.txt b/shared/source/execution_environment/CMakeLists.txt index 2ff25b59e7..8d04ec85a8 100644 --- a/shared/source/execution_environment/CMakeLists.txt +++ b/shared/source/execution_environment/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2021 Intel Corporation +# Copyright (C) 2019-2022 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -10,8 +10,9 @@ set(NEO_CORE_EXECUTION_ENVIRONMENT ${CMAKE_CURRENT_SOURCE_DIR}/execution_environment.cpp ${CMAKE_CURRENT_SOURCE_DIR}/root_device_environment.cpp ${CMAKE_CURRENT_SOURCE_DIR}/root_device_environment.h + ${CMAKE_CURRENT_SOURCE_DIR}/execution_environment_${DRIVER_MODEL}.cpp ) add_subdirectories() -set_property(GLOBAL PROPERTY NEO_CORE_EXECUTION_ENVIRONMENT ${NEO_CORE_EXECUTION_ENVIRONMENT}) +set_property(GLOBAL PROPERTY NEO_CORE_EXECUTION_ENVIRONMENT ${NEO_CORE_EXECUTION_ENVIRONMENT}) \ No newline at end of file diff --git a/shared/source/execution_environment/execution_environment.h b/shared/source/execution_environment/execution_environment.h index 948f35d4ba..ef909caf51 100644 --- a/shared/source/execution_environment/execution_environment.h +++ b/shared/source/execution_environment/execution_environment.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2021 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -28,6 +28,8 @@ class ExecutionEnvironment : public ReferenceTrackedObject void prepareRootDeviceEnvironment(const uint32_t rootDeviceIndexForReInit); void parseAffinityMask(); void sortNeoDevices(); + void sortNeoDevicesDRM(); + void sortNeoDevicesWDDM(); void setDebuggingEnabled() { debuggingEnabled = true; } diff --git a/shared/source/execution_environment/execution_environment_drm.cpp b/shared/source/execution_environment/execution_environment_drm.cpp new file mode 100644 index 0000000000..e29ec83af3 --- /dev/null +++ b/shared/source/execution_environment/execution_environment_drm.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/execution_environment/execution_environment.h" + +namespace NEO { + +void ExecutionEnvironment::sortNeoDevices() { + return ExecutionEnvironment::sortNeoDevicesDRM(); +} + +} // namespace NEO diff --git a/shared/source/execution_environment/execution_environment_drm_or_wddm.cpp b/shared/source/execution_environment/execution_environment_drm_or_wddm.cpp new file mode 100644 index 0000000000..a2a407ab5f --- /dev/null +++ b/shared/source/execution_environment/execution_environment_drm_or_wddm.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/execution_environment/execution_environment.h" +#include "shared/source/execution_environment/root_device_environment.h" +#include "shared/source/os_interface/os_interface.h" + +namespace NEO { + +void ExecutionEnvironment::sortNeoDevices() { + + if (rootDeviceEnvironments[0]->osInterface->getDriverModel()->getDriverModelType() == DriverModelType::DRM) { + return ExecutionEnvironment::sortNeoDevicesDRM(); + } else { + return ExecutionEnvironment::sortNeoDevicesWDDM(); + } +} + +} // namespace NEO \ No newline at end of file diff --git a/shared/source/execution_environment/execution_environment_wddm.cpp b/shared/source/execution_environment/execution_environment_wddm.cpp new file mode 100644 index 0000000000..dd7b316c9c --- /dev/null +++ b/shared/source/execution_environment/execution_environment_wddm.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/execution_environment/execution_environment.h" + +namespace NEO { + +void ExecutionEnvironment::sortNeoDevices() { + return ExecutionEnvironment::sortNeoDevicesWDDM(); +} + +} // namespace NEO \ No newline at end of file diff --git a/shared/source/execution_environment/linux/CMakeLists.txt b/shared/source/execution_environment/linux/CMakeLists.txt index f464d2f2f7..27348cb36b 100644 --- a/shared/source/execution_environment/linux/CMakeLists.txt +++ b/shared/source/execution_environment/linux/CMakeLists.txt @@ -1,14 +1,20 @@ # -# Copyright (C) 2021 Intel Corporation +# Copyright (C) 2022 Intel Corporation # # SPDX-License-Identifier: MIT # -set(NEO_CORE_EXECUTION_ENVIRONMENT_LINUX - ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt - ${CMAKE_CURRENT_SOURCE_DIR}/execution_environment_linux.cpp -) - if(UNIX) + set(NEO_CORE_EXECUTION_ENVIRONMENT_LINUX + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/execution_environment_linux.cpp + ) + + set(NEO_CORE_EXECUTION_ENVIRONMENT_WDDM + ${CMAKE_CURRENT_SOURCE_DIR}/../windows/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/../windows/execution_environment_windows.cpp + ) + + set_property(GLOBAL PROPERTY NEO_CORE_EXECUTION_ENVIRONMENT_WDDM ${NEO_CORE_EXECUTION_ENVIRONMENT_WDDM}) set_property(GLOBAL PROPERTY NEO_CORE_EXECUTION_ENVIRONMENT_LINUX ${NEO_CORE_EXECUTION_ENVIRONMENT_LINUX}) endif() diff --git a/shared/source/execution_environment/linux/execution_environment_linux.cpp b/shared/source/execution_environment/linux/execution_environment_linux.cpp index 7e3ea5f94b..b96f0ee815 100644 --- a/shared/source/execution_environment/linux/execution_environment_linux.cpp +++ b/shared/source/execution_environment/linux/execution_environment_linux.cpp @@ -8,6 +8,7 @@ #include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/execution_environment/execution_environment.h" #include "shared/source/execution_environment/root_device_environment.h" +#include "shared/source/os_interface/linux/drm_memory_operations_handler_bind.h" #include "shared/source/os_interface/linux/drm_neo.h" #include "shared/source/os_interface/os_interface.h" @@ -15,7 +16,7 @@ namespace NEO { -bool comparePciIdBusNumber(std::unique_ptr &rootDeviceEnvironment1, std::unique_ptr &rootDeviceEnvironment2) { +bool comparePciIdBusNumberDRM(std::unique_ptr &rootDeviceEnvironment1, std::unique_ptr &rootDeviceEnvironment2) { // BDF sample format is : 00:02.0 rootDeviceEnvironment1.get()->osInterface->getDriverModel()->as()->queryAdapterBDF(); auto bdfDevice1 = rootDeviceEnvironment1.get()->osInterface->getDriverModel()->as()->getAdapterBDF(); @@ -40,10 +41,23 @@ bool comparePciIdBusNumber(std::unique_ptr &rootDeviceEnv return bdfDevice1.Function < bdfDevice2.Function; } -void ExecutionEnvironment::sortNeoDevices() { +void ExecutionEnvironment::sortNeoDevicesDRM() { const auto pciOrderVar = DebugManager.flags.ZE_ENABLE_PCI_ID_DEVICE_ORDER.get(); if (pciOrderVar) { - std::sort(rootDeviceEnvironments.begin(), rootDeviceEnvironments.end(), comparePciIdBusNumber); + std::vector presort_index; + for (uint32_t i = 0; i < rootDeviceEnvironments.size(); i++) { + NEO::DrmMemoryOperationsHandlerBind *drm = static_cast(rootDeviceEnvironments[i]->memoryOperationsInterface.get()); + presort_index.push_back(drm->getRootDeviceIndex()); + } + + std::sort(rootDeviceEnvironments.begin(), rootDeviceEnvironments.end(), comparePciIdBusNumberDRM); + + for (uint32_t i = 0; i < rootDeviceEnvironments.size(); i++) { + NEO::DrmMemoryOperationsHandlerBind *drm = static_cast(rootDeviceEnvironments[i]->memoryOperationsInterface.get()); + if (drm->getRootDeviceIndex() != presort_index[i]) { + drm->setRootDeviceIndex(presort_index[i]); + } + } } } diff --git a/shared/source/execution_environment/windows/CMakeLists.txt b/shared/source/execution_environment/windows/CMakeLists.txt index 37836e9110..a20fb0808a 100644 --- a/shared/source/execution_environment/windows/CMakeLists.txt +++ b/shared/source/execution_environment/windows/CMakeLists.txt @@ -1,14 +1,14 @@ # -# Copyright (C) 2021 Intel Corporation +# Copyright (C) 2021-2022 Intel Corporation # # SPDX-License-Identifier: MIT # -set(NEO_CORE_EXECUTION_ENVIRONMENT_WINDOWS - ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt - ${CMAKE_CURRENT_SOURCE_DIR}/execution_environment_windows.cpp -) - if(WIN32) + set(NEO_CORE_EXECUTION_ENVIRONMENT_WINDOWS + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/execution_environment_windows.cpp + ) + set_property(GLOBAL PROPERTY NEO_CORE_EXECUTION_ENVIRONMENT_WINDOWS ${NEO_CORE_EXECUTION_ENVIRONMENT_WINDOWS}) endif() diff --git a/shared/source/execution_environment/windows/execution_environment_windows.cpp b/shared/source/execution_environment/windows/execution_environment_windows.cpp index 2afd1c6c54..a4ab204833 100644 --- a/shared/source/execution_environment/windows/execution_environment_windows.cpp +++ b/shared/source/execution_environment/windows/execution_environment_windows.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -15,7 +15,7 @@ namespace NEO { -bool comparePciIdBusNumber(std::unique_ptr &rootDeviceEnvironment1, std::unique_ptr &rootDeviceEnvironment2) { +bool comparePciIdBusNumberWDDM(std::unique_ptr &rootDeviceEnvironment1, std::unique_ptr &rootDeviceEnvironment2) { // BDF sample format is : 00:02.0 auto bdfDevice1 = rootDeviceEnvironment1.get()->osInterface->getDriverModel()->as()->getAdapterBDF(); @@ -32,10 +32,10 @@ bool comparePciIdBusNumber(std::unique_ptr &rootDeviceEnv return bdfDevice1.Function < bdfDevice2.Function; } -void ExecutionEnvironment::sortNeoDevices() { +void ExecutionEnvironment::sortNeoDevicesWDDM() { const auto pciOrderVar = DebugManager.flags.ZE_ENABLE_PCI_ID_DEVICE_ORDER.get(); if (pciOrderVar) { - std::sort(rootDeviceEnvironments.begin(), rootDeviceEnvironments.end(), comparePciIdBusNumber); + std::sort(rootDeviceEnvironments.begin(), rootDeviceEnvironments.end(), comparePciIdBusNumberWDDM); } } diff --git a/shared/source/os_interface/linux/drm_memory_operations_handler_bind.h b/shared/source/os_interface/linux/drm_memory_operations_handler_bind.h index 35969c42ce..9682e3e000 100644 --- a/shared/source/os_interface/linux/drm_memory_operations_handler_bind.h +++ b/shared/source/os_interface/linux/drm_memory_operations_handler_bind.h @@ -27,6 +27,13 @@ class DrmMemoryOperationsHandlerBind : public DrmMemoryOperationsHandler { MemoryOperationsStatus evictUnusedAllocations(bool waitForCompletion, bool isLockNeeded) override; + uint32_t getRootDeviceIndex() { + return this->rootDeviceIndex; + } + void setRootDeviceIndex(uint32_t index) { + this->rootDeviceIndex = index; + } + protected: MOCKABLE_VIRTUAL int evictImpl(OsContext *osContext, GraphicsAllocation &gfxAllocation, DeviceBitfield deviceBitfield); MemoryOperationsStatus evictUnusedAllocationsImpl(std::vector &allocationsForEviction, bool waitForCompletion);