mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
L0 Core Add Support For pci_speed_ext
This patch adds support for reading PCI bandwidth, generation and linkwidth information from sysfs nodes for the linux platform. Related-To: LOCI-2969 Signed-off-by: Joshua Santosh Ranjan <joshua.santosh.ranjan@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
061af9c284
commit
05a150f49f
@@ -334,7 +334,7 @@ ze_result_t DeviceImp::getPciProperties(ze_pci_ext_properties_t *pPciProperties)
|
||||
}
|
||||
pPciProperties->address = {pciBusInfo.pciDomain, pciBusInfo.pciBus,
|
||||
pciBusInfo.pciDevice, pciBusInfo.pciFunction};
|
||||
pPciProperties->maxSpeed = {-1, -1, -1};
|
||||
pPciProperties->maxSpeed = pciMaxSpeed;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -906,6 +906,13 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, bool
|
||||
device->neoDevice->getHardwareInfo().platform.eProductFamily, device, &cmdQueueDesc, true, NEO::EngineGroupType::Copy, resultValue);
|
||||
}
|
||||
|
||||
if (osInterface) {
|
||||
auto pciSpeedInfo = osInterface->getDriverModel()->getPciSpeedInfo();
|
||||
device->pciMaxSpeed.genVersion = pciSpeedInfo.genVersion;
|
||||
device->pciMaxSpeed.maxBandwidth = pciSpeedInfo.maxBandwidth;
|
||||
device->pciMaxSpeed.width = pciSpeedInfo.width;
|
||||
}
|
||||
|
||||
if (device->getSourceLevelDebugger()) {
|
||||
auto osInterface = neoDevice->getRootDeviceEnvironment().osInterface.get();
|
||||
device->getSourceLevelDebugger()
|
||||
|
||||
@@ -113,6 +113,7 @@ struct DeviceImp : public Device {
|
||||
std::unordered_map<uint32_t, bool> crossAccessEnabledDevices;
|
||||
DriverHandle *driverHandle = nullptr;
|
||||
CommandList *pageFaultCommandList = nullptr;
|
||||
ze_pci_speed_ext_t pciMaxSpeed = {-1, -1, -1};
|
||||
|
||||
bool resourcesReleased = false;
|
||||
void releaseResources();
|
||||
|
||||
@@ -42,6 +42,8 @@ struct MockDriverModel : NEO::DriverModel {
|
||||
bool isGpuHangDetected(NEO::OsContext &osContext) override {
|
||||
return false;
|
||||
}
|
||||
|
||||
PhyicalDevicePciSpeedInfo getPciSpeedInfo() const override { return {}; }
|
||||
};
|
||||
|
||||
struct MockDriverModelWDDM : NEO::DriverModel {
|
||||
@@ -55,6 +57,7 @@ struct MockDriverModelWDDM : NEO::DriverModel {
|
||||
size_t getMaxMemAllocSize() const override {
|
||||
return maxAllocSize;
|
||||
}
|
||||
PhyicalDevicePciSpeedInfo getPciSpeedInfo() const override { return {}; }
|
||||
|
||||
bool isGpuHangDetected(NEO::OsContext &osContext) override {
|
||||
return false;
|
||||
@@ -72,6 +75,7 @@ struct MockDriverModelDRM : NEO::DriverModel {
|
||||
size_t getMaxMemAllocSize() const override {
|
||||
return maxAllocSize;
|
||||
}
|
||||
PhyicalDevicePciSpeedInfo getPciSpeedInfo() const override { return {}; }
|
||||
|
||||
bool isGpuHangDetected(NEO::OsContext &osContext) override {
|
||||
return false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2020-2021 Intel Corporation
|
||||
# Copyright (C) 2020-2022 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -7,5 +7,7 @@
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_device.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_device_pci_speed_info.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_device_pci_speed_info.h
|
||||
)
|
||||
add_subdirectories()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2021 Intel Corporation
|
||||
# Copyright (C) 2021-2022 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -8,5 +8,6 @@ if(UNIX)
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_device_uuid.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_device_pci_speed_info_linux.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/sources/device/test_device_pci_speed_info.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
class PciSpeedInfoTestDriverModel : public MockDriverModel {
|
||||
public:
|
||||
PciSpeedInfoTestDriverModel() : MockDriverModel(0) {}
|
||||
|
||||
void setExpectedPciSpeedInfo(const PhyicalDevicePciSpeedInfo &pciSpeedInfo) {
|
||||
returnedSpeedInfo = pciSpeedInfo;
|
||||
}
|
||||
|
||||
NEO::PhyicalDevicePciSpeedInfo getPciSpeedInfo() const override {
|
||||
return returnedSpeedInfo;
|
||||
}
|
||||
NEO::PhysicalDevicePciBusInfo getPciBusInfo() const override {
|
||||
return NEO::PhysicalDevicePciBusInfo(0, 1, 2, 3);
|
||||
}
|
||||
PhyicalDevicePciSpeedInfo returnedSpeedInfo = {-1, -1, -1};
|
||||
};
|
||||
|
||||
void PciSpeedInfoTest::setPciSpeedInfo(NEO::ExecutionEnvironment *executionEnvironment, const NEO::PhyicalDevicePciSpeedInfo &pciSpeedInfo) {
|
||||
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(
|
||||
std::make_unique<PciSpeedInfoTestDriverModel>());
|
||||
PciSpeedInfoTestDriverModel *driverModel = static_cast<PciSpeedInfoTestDriverModel *>(executionEnvironment->rootDeviceEnvironments[0]->osInterface->getDriverModel());
|
||||
driverModel->setExpectedPciSpeedInfo(pciSpeedInfo);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -33,7 +33,7 @@ HWTEST2_F(TestDeviceUuid, GivenCorrectTelemetryNodesAreAvailableWhenRetrievingDe
|
||||
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsReadlink)> mockReadLink(&NEO::SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
|
||||
std::map<std::string, std::string> fileNameLinkMap = {
|
||||
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/i915-spi.2.auto/mtd/mtd0/mtd3/"},
|
||||
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/drm/renderD128"},
|
||||
{"/sys/class/intel_pmt/telem3", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem3/"},
|
||||
{"/sys/class/intel_pmt/telem1", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem1/"},
|
||||
{"/sys/class/intel_pmt/telem2", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem2/"},
|
||||
@@ -71,7 +71,7 @@ HWTEST2_F(TestDeviceUuid, GivenCorrectTelemetryNodesAreAvailableWhenRetrievingDe
|
||||
|
||||
fd -= 1;
|
||||
|
||||
if ((fd) < static_cast<int>(supportedFiles.size())) {
|
||||
if ((fd >= 0) && (fd < static_cast<int>(supportedFiles.size()))) {
|
||||
if (supportedFiles[fd].second == "dummy") {
|
||||
uint64_t data = 0xFEEDBEADDEABDEEF;
|
||||
memcpy(buf, &data, sizeof(data));
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/test/unit_tests/sources/device/test_device_pci_speed_info.h"
|
||||
|
||||
#include "shared/source/os_interface/driver_info.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
std::unique_ptr<NEO::UltDeviceFactory> PciSpeedInfoTest::createDevices(uint32_t numSubDevices, const NEO::PhyicalDevicePciSpeedInfo &pciSpeedInfo) {
|
||||
|
||||
DebugManager.flags.CreateMultipleSubDevices.set(numSubDevices);
|
||||
NEO::ExecutionEnvironment *executionEnvironment = new MockExecutionEnvironment(defaultHwInfo.get(), false, 1);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(new OSInterface);
|
||||
executionEnvironment->memoryManager.reset(new MockMemoryManagerOsAgnosticContext(*executionEnvironment));
|
||||
setPciSpeedInfo(executionEnvironment, pciSpeedInfo);
|
||||
return std::make_unique<UltDeviceFactory>(1, numSubDevices, *executionEnvironment);
|
||||
}
|
||||
|
||||
TEST_F(PciSpeedInfoTest, givenSuccessfulReadingOfSpeedValuesCorrectValuesAreReturned) {
|
||||
|
||||
NEO::PhyicalDevicePciSpeedInfo expectedSpeedInfo;
|
||||
expectedSpeedInfo.genVersion = 4;
|
||||
expectedSpeedInfo.width = 1024;
|
||||
expectedSpeedInfo.maxBandwidth = 4096;
|
||||
|
||||
auto deviceFactory = createDevices(2, expectedSpeedInfo);
|
||||
auto driverHandle = std::make_unique<DriverHandleImp>();
|
||||
ze_result_t returnValue = ZE_RESULT_SUCCESS;
|
||||
auto device = std::unique_ptr<L0::Device>(L0::Device::create(driverHandle.get(), deviceFactory->rootDevices[0], false, &returnValue));
|
||||
|
||||
ze_pci_ext_properties_t pciProperties = {};
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, device->getPciProperties(&pciProperties));
|
||||
EXPECT_EQ(4, pciProperties.maxSpeed.genVersion);
|
||||
EXPECT_EQ(1024, pciProperties.maxSpeed.width);
|
||||
EXPECT_EQ(4096, pciProperties.maxSpeed.maxBandwidth);
|
||||
|
||||
uint32_t subDeviceCount = 0;
|
||||
device->getSubDevices(&subDeviceCount, nullptr);
|
||||
EXPECT_EQ(subDeviceCount, 2u);
|
||||
std::vector<ze_device_handle_t> subDevices;
|
||||
subDevices.resize(subDeviceCount);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, device->getSubDevices(&subDeviceCount, subDevices.data()));
|
||||
for (auto subDevice : subDevices) {
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zeDevicePciGetPropertiesExt(subDevice, &pciProperties));
|
||||
EXPECT_EQ(4, pciProperties.maxSpeed.genVersion);
|
||||
EXPECT_EQ(1024, pciProperties.maxSpeed.width);
|
||||
EXPECT_EQ(4096, pciProperties.maxSpeed.maxBandwidth);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace NEO {
|
||||
struct PhyicalDevicePciSpeedInfo;
|
||||
struct UltDeviceFactory;
|
||||
class ExecutionEnvironment;
|
||||
} // namespace NEO
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
struct PciSpeedInfoTest : public ::testing::Test {
|
||||
std::unique_ptr<NEO::UltDeviceFactory> createDevices(uint32_t numSubDevices, const NEO::PhyicalDevicePciSpeedInfo &pciSpeedInfo);
|
||||
DebugManagerStateRestore restorer;
|
||||
|
||||
private:
|
||||
void setPciSpeedInfo(NEO::ExecutionEnvironment *executionEnvironment, const NEO::PhyicalDevicePciSpeedInfo &pciSpeedInfo);
|
||||
};
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,12 @@
|
||||
#
|
||||
# Copyright (C) 2022 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if(WIN32)
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_device_pci_speed_info_windows.cpp
|
||||
)
|
||||
endif()
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||
#include "shared/test/common/os_interface/windows/wddm_fixture.h"
|
||||
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/sources/device/test_device_pci_speed_info.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
class PciSpeedInfoTestDriverModel : public WddmMock {
|
||||
public:
|
||||
PciSpeedInfoTestDriverModel(RootDeviceEnvironment &rootDeviceEnvironment) : WddmMock(rootDeviceEnvironment) {}
|
||||
void setExpectedPciSpeedInfo(const PhyicalDevicePciSpeedInfo &pciSpeedInfo) {
|
||||
returnedSpeedInfo = pciSpeedInfo;
|
||||
}
|
||||
|
||||
PhyicalDevicePciSpeedInfo getPciSpeedInfo() const override {
|
||||
return returnedSpeedInfo;
|
||||
}
|
||||
PhysicalDevicePciBusInfo getPciBusInfo() const override {
|
||||
return NEO::PhysicalDevicePciBusInfo(0, 1, 2, 3);
|
||||
}
|
||||
|
||||
PhyicalDevicePciSpeedInfo returnedSpeedInfo = {-1, -1, -1};
|
||||
};
|
||||
|
||||
void PciSpeedInfoTest::setPciSpeedInfo(NEO::ExecutionEnvironment *executionEnvironment, const NEO::PhyicalDevicePciSpeedInfo &pciSpeedInfo) {
|
||||
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(
|
||||
std::make_unique<PciSpeedInfoTestDriverModel>(*executionEnvironment->rootDeviceEnvironments[0]));
|
||||
PciSpeedInfoTestDriverModel *driverModel = static_cast<PciSpeedInfoTestDriverModel *>(executionEnvironment->rootDeviceEnvironments[0]->osInterface->getDriverModel());
|
||||
driverModel->setExpectedPciSpeedInfo(pciSpeedInfo);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -366,6 +366,7 @@ class UnknownDriverModel : public DriverModel {
|
||||
PhysicalDevicePciBusInfo pciBusInfo(PhysicalDevicePciBusInfo::InvalidValue, PhysicalDevicePciBusInfo::InvalidValue, PhysicalDevicePciBusInfo::InvalidValue, PhysicalDevicePciBusInfo::InvalidValue);
|
||||
return pciBusInfo;
|
||||
}
|
||||
PhyicalDevicePciSpeedInfo getPciSpeedInfo() const override { return {}; }
|
||||
|
||||
bool isGpuHangDetected(OsContext &osContext) override {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user