mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Add support for pci_ext_properties_t
Added API definition in ze_device.cpp, and added function declaration of getPciProperties() in device.h and device_imp.cpp Initially returns -1 for all values of ze_pci_speed_ext_t for now, simply because we do not have function to retrieve the information of the PCI speed. Related-To: LOCI-2669 Signed-off-by: Young Jin Yoon <young.jin.yoon@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
ade43e29a5
commit
32ccf30c61
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -224,6 +224,7 @@ zeGetDeviceProcAddrTable(
|
||||
pDdiTable->pfnGetGlobalTimestamps = zeDeviceGetGlobalTimestamps;
|
||||
pDdiTable->pfnReserveCacheExt = zeDeviceReserveCacheExt;
|
||||
pDdiTable->pfnSetCacheAdviceExt = zeDeviceSetCacheAdviceExt;
|
||||
pDdiTable->pfnPciGetPropertiesExt = zeDevicePciGetPropertiesExt;
|
||||
driver_ddiTable.core_ddiTable.Device = *pDdiTable;
|
||||
if (driver_ddiTable.enableTracing) {
|
||||
pDdiTable->pfnGet = zeDeviceGet_Tracing;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -139,3 +139,10 @@ zeDeviceSetCacheAdviceExt(
|
||||
ze_cache_ext_region_t cacheRegion) {
|
||||
return L0::Device::fromHandle(hDevice)->setCacheAdvice(ptr, regionSize, cacheRegion);
|
||||
}
|
||||
|
||||
ZE_APIEXPORT ze_result_t ZE_APICALL
|
||||
zeDevicePciGetPropertiesExt(
|
||||
ze_device_handle_t hDevice,
|
||||
ze_pci_ext_properties_t *pPciProperties) {
|
||||
return L0::Device::fromHandle(hDevice)->getPciProperties(pPciProperties);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -70,6 +70,7 @@ struct Device : _ze_device_handle_t {
|
||||
virtual ze_result_t getP2PProperties(ze_device_handle_t hPeerDevice,
|
||||
ze_device_p2p_properties_t *pP2PProperties) = 0;
|
||||
virtual ze_result_t getKernelProperties(ze_device_module_properties_t *pKernelProperties) = 0;
|
||||
virtual ze_result_t getPciProperties(ze_pci_ext_properties_t *pPciProperties) = 0;
|
||||
virtual ze_result_t getMemoryProperties(uint32_t *pCount, ze_device_memory_properties_t *pMemProperties) = 0;
|
||||
virtual ze_result_t getMemoryAccessProperties(ze_device_memory_access_properties_t *pMemAccessProperties) = 0;
|
||||
virtual ze_result_t getProperties(ze_device_properties_t *pDeviceProperties) = 0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -307,6 +307,26 @@ ze_result_t DeviceImp::getP2PProperties(ze_device_handle_t hPeerDevice,
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::getPciProperties(ze_pci_ext_properties_t *pPciProperties) {
|
||||
if (!driverInfo) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
auto pciBusInfo = driverInfo->getPciBusInfo();
|
||||
auto isPciValid = [&](auto pci) -> bool {
|
||||
return (pci.pciDomain != NEO::PhysicalDevicePciBusInfo::InvalidValue &&
|
||||
pci.pciBus != NEO::PhysicalDevicePciBusInfo::InvalidValue &&
|
||||
pci.pciDevice != NEO::PhysicalDevicePciBusInfo::InvalidValue &&
|
||||
pci.pciFunction != NEO::PhysicalDevicePciBusInfo::InvalidValue);
|
||||
};
|
||||
if (!isPciValid(pciBusInfo)) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
pPciProperties->address = {pciBusInfo.pciDomain, pciBusInfo.pciBus,
|
||||
pciBusInfo.pciDevice, pciBusInfo.pciFunction};
|
||||
pPciProperties->maxSpeed = {-1, -1, -1};
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::getMemoryProperties(uint32_t *pCount, ze_device_memory_properties_t *pMemProperties) {
|
||||
if (*pCount == 0) {
|
||||
*pCount = 1;
|
||||
@@ -787,6 +807,9 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, bool
|
||||
device->cacheReservation = CacheReservation::create(*device);
|
||||
device->maxNumHwThreads = NEO::HwHelper::getMaxThreadsForVfe(neoDevice->getHardwareInfo());
|
||||
|
||||
auto osInterface = neoDevice->getRootDeviceEnvironment().osInterface.get();
|
||||
device->driverInfo.reset(NEO::DriverInfo::create(&neoDevice->getHardwareInfo(), osInterface));
|
||||
|
||||
auto debugSurfaceSize = NEO::SipKernel::maxDbgSurfaceSize;
|
||||
std::vector<char> stateSaveAreaHeader;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -45,6 +45,7 @@ struct DeviceImp : public Device {
|
||||
ze_result_t getP2PProperties(ze_device_handle_t hPeerDevice,
|
||||
ze_device_p2p_properties_t *pP2PProperties) override;
|
||||
ze_result_t getKernelProperties(ze_device_module_properties_t *pKernelProperties) override;
|
||||
ze_result_t getPciProperties(ze_pci_ext_properties_t *pPciProperties) override;
|
||||
ze_result_t getMemoryProperties(uint32_t *pCount, ze_device_memory_properties_t *pMemProperties) override;
|
||||
ze_result_t getMemoryAccessProperties(ze_device_memory_access_properties_t *pMemAccessProperties) override;
|
||||
ze_result_t getProperties(ze_device_properties_t *pDeviceProperties) override;
|
||||
@@ -119,6 +120,7 @@ struct DeviceImp : public Device {
|
||||
NEO::SpinLock peerAllocationsMutex;
|
||||
std::map<NEO::SvmAllocationData *, NEO::MemAdviseFlags> memAdviseSharedAllocations;
|
||||
std::unique_ptr<NEO::AllocationsList> allocationsForReuse;
|
||||
std::unique_ptr<NEO::DriverInfo> driverInfo;
|
||||
void createSysmanHandle(bool isSubDevice);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -87,7 +87,8 @@ struct DriverHandleImp : public DriverHandle {
|
||||
{ZE_RELAXED_ALLOCATION_LIMITS_EXP_NAME, ZE_RELAXED_ALLOCATION_LIMITS_EXP_VERSION_CURRENT},
|
||||
{ZE_MODULE_PROGRAM_EXP_NAME, ZE_MODULE_PROGRAM_EXP_VERSION_CURRENT},
|
||||
{ZE_KERNEL_SCHEDULING_HINTS_EXP_NAME, ZE_SCHEDULING_HINTS_EXP_VERSION_CURRENT},
|
||||
{ZE_GLOBAL_OFFSET_EXP_NAME, ZE_GLOBAL_OFFSET_EXP_VERSION_CURRENT}};
|
||||
{ZE_GLOBAL_OFFSET_EXP_NAME, ZE_GLOBAL_OFFSET_EXP_VERSION_CURRENT},
|
||||
{ZE_PCI_PROPERTIES_EXT_NAME, ZE_PCI_PROPERTIES_EXT_VERSION_CURRENT}};
|
||||
|
||||
uint64_t uuidTimestamp = 0u;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -40,6 +40,7 @@ struct Mock<Device> : public Device {
|
||||
ADDMETHOD_NOBASE(getComputeProperties, ze_result_t, ZE_RESULT_SUCCESS, (ze_device_compute_properties_t * pComputeProperties));
|
||||
ADDMETHOD_NOBASE(getP2PProperties, ze_result_t, ZE_RESULT_SUCCESS, (ze_device_handle_t hPeerDevice, ze_device_p2p_properties_t *pP2PProperties));
|
||||
ADDMETHOD_NOBASE(getKernelProperties, ze_result_t, ZE_RESULT_SUCCESS, (ze_device_module_properties_t * pKernelProperties));
|
||||
ADDMETHOD_NOBASE(getPciProperties, ze_result_t, ZE_RESULT_SUCCESS, (ze_pci_ext_properties_t * pPciProperties));
|
||||
ADDMETHOD_NOBASE(getMemoryProperties, ze_result_t, ZE_RESULT_SUCCESS, (uint32_t * pCount, ze_device_memory_properties_t *pMemProperties));
|
||||
ADDMETHOD_NOBASE(getMemoryAccessProperties, ze_result_t, ZE_RESULT_SUCCESS, (ze_device_memory_access_properties_t * pMemAccessProperties));
|
||||
ADDMETHOD_NOBASE(getProperties, ze_result_t, ZE_RESULT_SUCCESS, (ze_device_properties_t * pDeviceProperties));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/mocks/mock_compilers.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_driver_info.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
#include "shared/test/common/mocks/mock_sip.h"
|
||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||
@@ -947,6 +948,54 @@ TEST_F(DeviceTest, givenCallToDevicePropertiesThenTimestampValidBitsAreCorrectly
|
||||
EXPECT_EQ(32u, deviceProps.kernelTimestampValidBits);
|
||||
}
|
||||
|
||||
TEST_F(DeviceTest, givenNullDriverInfowhenPciPropertiesIsCalledThenUninitializedErrorIsReturned) {
|
||||
auto deviceImp = static_cast<L0::DeviceImp *>(device);
|
||||
ze_pci_ext_properties_t pciProperties = {};
|
||||
|
||||
deviceImp->driverInfo.reset(nullptr);
|
||||
ze_result_t res = device->getPciProperties(&pciProperties);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, res);
|
||||
}
|
||||
|
||||
TEST_F(DeviceTest, givenValidPciExtPropertiesWhenPciPropertiesIsCalledThenSuccessIsReturned) {
|
||||
|
||||
auto deviceImp = static_cast<L0::DeviceImp *>(device);
|
||||
const NEO::PhysicalDevicePciBusInfo pciBusInfo(0, 1, 2, 3);
|
||||
NEO::DriverInfoMock *driverInfo = new DriverInfoMock();
|
||||
ze_pci_ext_properties_t pciProperties = {};
|
||||
|
||||
driverInfo->setPciBusInfo(pciBusInfo);
|
||||
deviceImp->driverInfo.reset(driverInfo);
|
||||
ze_result_t res = device->getPciProperties(&pciProperties);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
EXPECT_EQ(pciBusInfo.pciDomain, pciProperties.address.domain);
|
||||
EXPECT_EQ(pciBusInfo.pciBus, pciProperties.address.bus);
|
||||
EXPECT_EQ(pciBusInfo.pciDevice, pciProperties.address.device);
|
||||
EXPECT_EQ(pciBusInfo.pciFunction, pciProperties.address.function);
|
||||
}
|
||||
|
||||
TEST_F(DeviceTest, givenInvalidPciBusInfoWhenPciPropertiesIsCalledThenUninitializedErrorIsReturned) {
|
||||
constexpr uint32_t INVALID = NEO::PhysicalDevicePciBusInfo::InvalidValue;
|
||||
auto deviceImp = static_cast<L0::DeviceImp *>(device);
|
||||
ze_pci_ext_properties_t pciProperties = {};
|
||||
std::vector<NEO::PhysicalDevicePciBusInfo> pciBusInfos;
|
||||
|
||||
pciBusInfos.push_back(NEO::PhysicalDevicePciBusInfo(0, 1, 2, INVALID));
|
||||
pciBusInfos.push_back(NEO::PhysicalDevicePciBusInfo(0, 1, INVALID, 3));
|
||||
pciBusInfos.push_back(NEO::PhysicalDevicePciBusInfo(0, INVALID, 2, 3));
|
||||
pciBusInfos.push_back(NEO::PhysicalDevicePciBusInfo(INVALID, 1, 2, 3));
|
||||
|
||||
for (auto pciBusInfo : pciBusInfos) {
|
||||
NEO::DriverInfoMock *driverInfo = new DriverInfoMock();
|
||||
driverInfo->setPciBusInfo(pciBusInfo);
|
||||
deviceImp->driverInfo.reset(driverInfo);
|
||||
|
||||
ze_result_t res = device->getPciProperties(&pciProperties);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, res);
|
||||
}
|
||||
}
|
||||
TEST_F(DeviceTest, whenGetExternalMemoryPropertiesIsCalledThenSuccessIsReturnedAndNoPropertiesAreReturned) {
|
||||
ze_device_external_memory_properties_t externalMemoryProperties;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user