From b28fd75ea15aa3f5368c28d71e9656a03fd08f19 Mon Sep 17 00:00:00 2001 From: Jaime Arteaga Date: Sun, 18 Jul 2021 04:10:16 +0000 Subject: [PATCH] Set ZE_ENABLE_PCI_ID_DEVICE_ORDER as false by default This to avoid disruptions on performance data in multi-gpu systems where each gpu may perform differently, when comparing data before and after last refactor on ZE_ENABLE_PCI_ID_DEVICE_ORDER. Signed-off-by: Jaime Arteaga --- .../linux/test_driver_handle_imp_linux.cpp | 102 ++++++++++++++++++ .../test/unit_test/test_files/igdrcl.config | 2 +- .../debug_settings/release_variables.inl | 2 +- 3 files changed, 104 insertions(+), 2 deletions(-) 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 10afe81bc7..67f455e1db 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 @@ -169,5 +169,107 @@ TEST_F(DriverPciOrderWitSimilarBusLinuxFixture, GivenEnvironmentVariableForDevic delete driverHandle; } +class DriverPciOrderWitDifferentDeviceLinuxFixture : 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); + } + 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(); + } + void TearDown() override {} + + static constexpr uint32_t numRootDevices = 2u; + static constexpr uint32_t numSubDevices = 2u; + std::vector> devices; + std::string bdf[numRootDevices] = {"03:05.0", "03:04.0"}; + std::string sortedBdf[numRootDevices] = {"03:04.0", "03:05.0"}; + std::unique_ptr deviceFactory; +}; + +TEST_F(DriverPciOrderWitDifferentDeviceLinuxFixture, GivenEnvironmentVariableForDeviceOrderAccordingToPciSetWhenRetrievingNeoDevicesThenNeoDevicesAccordingToBusOrderRetrieved) { + 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 DriverPciOrderWitSimilarBusAndDeviceLinuxFixture : 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); + } + 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(); + } + void TearDown() override {} + + static constexpr uint32_t numRootDevices = 2u; + static constexpr uint32_t numSubDevices = 2u; + std::vector> devices; + std::string bdf[numRootDevices] = {"03:04.1", "03:04.0"}; + std::string sortedBdf[numRootDevices] = {"03:04.0", "03:04.1"}; + std::unique_ptr deviceFactory; +}; + +TEST_F(DriverPciOrderWitSimilarBusAndDeviceLinuxFixture, GivenEnvironmentVariableForDeviceOrderAccordingToPciSetWhenRetrievingNeoDevicesThenNeoDevicesAccordingToBusOrderRetrieved) { + 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; +} + } // namespace ult } // namespace L0 diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index 3f21300651..6badd63cf1 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -10,7 +10,7 @@ AUBDumpToggleFileName = unk OverrideGdiPath = unk AubDumpAddMmioRegistersList = unk ZE_AFFINITY_MASK = default -ZE_ENABLE_PCI_ID_DEVICE_ORDER = 1 +ZE_ENABLE_PCI_ID_DEVICE_ORDER = 0 AUBDumpFilterNamedKernelStartIdx = 0 AUBDumpFilterNamedKernelEndIdx = -1 AUBDumpSubCaptureMode = 0 diff --git a/shared/source/debug_settings/release_variables.inl b/shared/source/debug_settings/release_variables.inl index 6bc4390f19..5fe3072f36 100644 --- a/shared/source/debug_settings/release_variables.inl +++ b/shared/source/debug_settings/release_variables.inl @@ -13,4 +13,4 @@ DECLARE_DEBUG_VARIABLE(bool, MakeAllBuffersResident, false, "Make all buffers re DECLARE_DEBUG_VARIABLE(int32_t, OverrideDefaultFP64Settings, -1, "-1: dont override, 0: disable, 1: enable.") DECLARE_DEBUG_VARIABLE(int32_t, EnableCrossDeviceAccess, -1, "-1: default behavior, 0: disabled, 1: enabled, Allows one device to access another device's memory") DECLARE_DEBUG_VARIABLE(std::string, ZE_AFFINITY_MASK, std::string("default"), "Refer to the Level Zero Specification for a description") -DECLARE_DEBUG_VARIABLE(bool, ZE_ENABLE_PCI_ID_DEVICE_ORDER, true, "Refer to the Level Zero Specification for a description") +DECLARE_DEBUG_VARIABLE(bool, ZE_ENABLE_PCI_ID_DEVICE_ORDER, false, "Refer to the Level Zero Specification for a description")