fix rootDeviceIndex issue for PCI reorder

Signed-off-by: John Falkowski <john.falkowski@intel.com>
This commit is contained in:
John Falkowski
2022-04-21 03:52:57 +00:00
committed by Compute-Runtime-Automation
parent 192ffa4c26
commit d797d79f97
3 changed files with 123 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Intel Corporation
* Copyright (C) 2021-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -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"
@@ -43,7 +44,21 @@ bool comparePciIdBusNumber(std::unique_ptr<RootDeviceEnvironment> &rootDeviceEnv
void ExecutionEnvironment::sortNeoDevices() {
const auto pciOrderVar = DebugManager.flags.ZE_ENABLE_PCI_ID_DEVICE_ORDER.get();
if (pciOrderVar) {
std::vector<uint32_t> presort_index;
for (uint32_t i = 0; i < rootDeviceEnvironments.size(); i++) {
NEO::DrmMemoryOperationsHandlerBind *drm = static_cast<DrmMemoryOperationsHandlerBind *>(rootDeviceEnvironments[i]->memoryOperationsInterface.get());
presort_index.push_back(drm->getRootDeviceIndex());
}
std::sort(rootDeviceEnvironments.begin(), rootDeviceEnvironments.end(), comparePciIdBusNumber);
for (uint32_t i = 0; i < rootDeviceEnvironments.size(); i++) {
NEO::DrmMemoryOperationsHandlerBind *drm = static_cast<DrmMemoryOperationsHandlerBind *>(rootDeviceEnvironments[i]->memoryOperationsInterface.get());
if (drm->getRootDeviceIndex() != presort_index[i]) {
drm->setRootDeviceIndex(presort_index[i]);
}
}
}
}