Add initial sysman stub as per latest spec

Change-Id: I6f36b9faa21e05a6954de0b50ea01240539441d1
Signed-off-by: Jitendra Sharma <jitendra.sharma@intel.com>
This commit is contained in:
Jitendra Sharma
2020-07-03 20:05:35 +05:30
parent 6b7b3a178f
commit 146fc900c3
40 changed files with 611 additions and 465 deletions

View File

@@ -8,6 +8,7 @@
#include <level_zero/zet_api.h>
#include "sysman/sysman.h"
#include "third_party/level_zero/zes_api_ext.h"
extern "C" {
@@ -129,6 +130,14 @@ zetSysmanPciGetStats(
return L0::Sysman::fromHandle(hSysman)->pciGetStats(pStats);
}
ZE_APIEXPORT ze_result_t ZE_APICALL
zesDeviceEnumPowerDomains(
zes_device_handle_t hDevice,
uint32_t *pCount,
zes_pwr_handle_t *phPower) {
return L0::SysmanDevice::fromHandle(hDevice)->powerGet(pCount, phPower);
}
__zedllexport ze_result_t __zecall
zetSysmanPowerGet(
zet_sysman_handle_t hSysman,

View File

@@ -32,6 +32,7 @@ struct DriverHandle;
struct BuiltinFunctionsLib;
struct ExecutionEnvironment;
struct MetricContext;
struct SysmanDevice;
struct Device : _ze_device_handle_t {
virtual uint32_t getRootDeviceIndex() = 0;
@@ -122,6 +123,8 @@ struct Device : _ze_device_handle_t {
size_t size, struct CommandList *commandList) = 0;
virtual NEO::GraphicsAllocation *allocateMemoryFromHostPtr(const void *buffer, size_t size) = 0;
virtual void setSysmanHandle(SysmanDevice *pSysmanDevice) = 0;
virtual SysmanDevice *getSysmanHandle() = 0;
};
} // namespace L0

View File

@@ -41,6 +41,7 @@
#include "level_zero/core/source/printf_handler/printf_handler.h"
#include "level_zero/core/source/sampler/sampler.h"
#include "level_zero/tools/source/metrics/metric.h"
#include "level_zero/tools/source/sysman/sysman.h"
#include "hw_helpers.h"
@@ -653,6 +654,7 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, uint3
->notifyNewDevice(osInterface ? osInterface->getDeviceHandle() : 0);
}
device->setSysmanHandle(L0::SysmanDeviceHandleContext::init(device->toHandle()));
return device;
}
@@ -678,6 +680,11 @@ DeviceImp::~DeviceImp() {
}
}
if (pSysmanDevice != nullptr) {
delete pSysmanDevice;
pSysmanDevice = nullptr;
}
if (neoDevice) {
neoDevice->decRefInternal();
}

View File

@@ -15,7 +15,7 @@
#include "level_zero/tools/source/tracing/tracing.h"
namespace L0 {
struct SysmanDevice;
struct DeviceImp : public Device {
uint32_t getRootDeviceIndex() override;
ze_result_t canAccessPeer(ze_device_handle_t hPeerDevice, ze_bool_t *value) override;
@@ -78,6 +78,8 @@ struct DeviceImp : public Device {
~DeviceImp() override;
NEO::GraphicsAllocation *allocateManagedMemoryFromHostPtr(void *buffer, size_t size, struct CommandList *commandList) override;
NEO::GraphicsAllocation *allocateMemoryFromHostPtr(const void *buffer, size_t size) override;
void setSysmanHandle(SysmanDevice *pSysman) override;
SysmanDevice *getSysmanHandle() override;
NEO::Device *neoDevice = nullptr;
bool isSubdevice = false;
@@ -110,6 +112,7 @@ struct DeviceImp : public Device {
return ZE_RESULT_SUCCESS;
}
NEO::GraphicsAllocation *debugSurface = nullptr;
SysmanDevice *pSysmanDevice = nullptr;
};
} // namespace L0

View File

@@ -109,6 +109,8 @@ struct Mock<Device> : public Device {
MOCK_CONST_METHOD0(getDebugSurface, NEO::GraphicsAllocation *());
MOCK_METHOD3(allocateManagedMemoryFromHostPtr, NEO::GraphicsAllocation *(void *buffer, size_t size, struct L0::CommandList *commandList));
MOCK_METHOD2(allocateMemoryFromHostPtr, NEO::GraphicsAllocation *(const void *buffer, size_t size));
MOCK_METHOD1(setSysmanHandle, void(SysmanDevice *));
MOCK_METHOD0(getSysmanHandle, SysmanDevice *());
};
template <>

View File

@@ -0,0 +1,32 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(L0_SRCS_TOOLS_GLOBAL_OPERATIONS
${CMAKE_CURRENT_SOURCE_DIR}/global_operations.h
${CMAKE_CURRENT_SOURCE_DIR}/global_operations_imp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/global_operations_imp.h
${CMAKE_CURRENT_SOURCE_DIR}/os_global_operations.h
)
target_include_directories(${L0_STATIC_LIB_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/
)
target_sources(${L0_STATIC_LIB_NAME}
PRIVATE
${L0_SRCS_TOOLS_GLOBAL_OPERATIONS}
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
)
if(UNIX)
add_subdirectory(linux)
else()
add_subdirectory(windows)
endif()
# Make our source files visible to parent
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_GLOBAL_OPERATIONS ${L0_SRCS_TOOLS_GLOBAL_OPERATIONS})

View File

@@ -10,9 +10,9 @@
namespace L0 {
class SysmanDevice {
class GlobalOperations {
public:
virtual ~SysmanDevice(){};
virtual ~GlobalOperations(){};
virtual ze_result_t deviceGetProperties(zet_sysman_properties_t *pProperties) = 0;
virtual ze_result_t reset() = 0;
virtual ze_result_t processesGetState(uint32_t *pCount, zet_process_state_t *pProcesses) = 0;

View File

@@ -5,7 +5,7 @@
*
*/
#include "sysman_device_imp.h"
#include "global_operations_imp.h"
#include "shared/source/helpers/basic_math.h"
#include "shared/source/helpers/debug_helpers.h"
@@ -14,9 +14,9 @@
namespace L0 {
ze_result_t SysmanDeviceImp::processesGetState(uint32_t *pCount, zet_process_state_t *pProcesses) {
ze_result_t GlobalOperationsImp::processesGetState(uint32_t *pCount, zet_process_state_t *pProcesses) {
std::vector<zet_process_state_t> pProcessList;
ze_result_t result = pOsSysmanDevice->scanProcessesState(pProcessList);
ze_result_t result = pOsGlobalOperations->scanProcessesState(pProcessList);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
@@ -37,7 +37,7 @@ ze_result_t SysmanDeviceImp::processesGetState(uint32_t *pCount, zet_process_sta
return result;
}
ze_result_t SysmanDeviceImp::deviceGetProperties(zet_sysman_properties_t *pProperties) {
ze_result_t GlobalOperationsImp::deviceGetProperties(zet_sysman_properties_t *pProperties) {
Device *device = L0::Device::fromHandle(hCoreDevice);
ze_device_properties_t deviceProperties;
device->getProperties(&deviceProperties);
@@ -50,26 +50,26 @@ ze_result_t SysmanDeviceImp::deviceGetProperties(zet_sysman_properties_t *pPrope
return ZE_RESULT_SUCCESS;
}
ze_result_t SysmanDeviceImp::reset() {
return pOsSysmanDevice->reset();
ze_result_t GlobalOperationsImp::reset() {
return pOsGlobalOperations->reset();
}
void SysmanDeviceImp::init() {
if (pOsSysmanDevice == nullptr) {
pOsSysmanDevice = OsSysmanDevice::create(pOsSysman);
void GlobalOperationsImp::init() {
if (pOsGlobalOperations == nullptr) {
pOsGlobalOperations = OsGlobalOperations::create(pOsSysman);
}
UNRECOVERABLE_IF(nullptr == pOsSysmanDevice);
pOsSysmanDevice->getVendorName(sysmanProperties.vendorName);
pOsSysmanDevice->getDriverVersion(sysmanProperties.driverVersion);
pOsSysmanDevice->getModelName(sysmanProperties.modelName);
pOsSysmanDevice->getBrandName(sysmanProperties.brandName);
pOsSysmanDevice->getBoardNumber(sysmanProperties.boardNumber);
pOsSysmanDevice->getSerialNumber(sysmanProperties.serialNumber);
UNRECOVERABLE_IF(nullptr == pOsGlobalOperations);
pOsGlobalOperations->getVendorName(sysmanProperties.vendorName);
pOsGlobalOperations->getDriverVersion(sysmanProperties.driverVersion);
pOsGlobalOperations->getModelName(sysmanProperties.modelName);
pOsGlobalOperations->getBrandName(sysmanProperties.brandName);
pOsGlobalOperations->getBoardNumber(sysmanProperties.boardNumber);
pOsGlobalOperations->getSerialNumber(sysmanProperties.serialNumber);
}
SysmanDeviceImp::~SysmanDeviceImp() {
if (nullptr != pOsSysmanDevice) {
delete pOsSysmanDevice;
GlobalOperationsImp::~GlobalOperationsImp() {
if (nullptr != pOsGlobalOperations) {
delete pOsGlobalOperations;
}
}

View File

@@ -10,27 +10,27 @@
#include <level_zero/zet_api.h>
#include "os_sysman_device.h"
#include "sysman_device.h"
#include "global_operations.h"
#include "os_global_operations.h"
#include <vector>
namespace L0 {
class SysmanDeviceImp : public SysmanDevice, NEO::NonCopyableOrMovableClass {
class GlobalOperationsImp : public GlobalOperations, NEO::NonCopyableOrMovableClass {
public:
void init() override;
ze_result_t deviceGetProperties(zet_sysman_properties_t *pProperties) override;
ze_result_t reset() override;
ze_result_t processesGetState(uint32_t *pCount, zet_process_state_t *pProcesses) override;
OsSysmanDevice *pOsSysmanDevice = nullptr;
OsGlobalOperations *pOsGlobalOperations = nullptr;
ze_device_handle_t hCoreDevice = {};
SysmanDeviceImp() = default;
SysmanDeviceImp(OsSysman *pOsSysman, ze_device_handle_t hCoreDevice) : hCoreDevice(hCoreDevice),
GlobalOperationsImp() = default;
GlobalOperationsImp(OsSysman *pOsSysman, ze_device_handle_t hCoreDevice) : hCoreDevice(hCoreDevice),
pOsSysman(pOsSysman){};
~SysmanDeviceImp() override;
~GlobalOperationsImp() override;
private:
OsSysman *pOsSysman = nullptr;

View File

@@ -0,0 +1,21 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(L0_SRCS_TOOLS_GLOBAL_OPERATIONS_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/os_global_operations_imp.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/os_global_operations_imp.h
)
if(UNIX)
target_sources(${L0_STATIC_LIB_NAME}
PRIVATE
${L0_SRCS_TOOLS_GLOBAL_OPERATIONS_LINUX}
)
endif()
# Make our source files visible to parent
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_GLOBAL_OPERATIONS_LINUX ${L0_SRCS_TOOLS_GLOBAL_OPERATIONS_LINUX})

View File

@@ -5,11 +5,11 @@
*
*/
#include "level_zero/tools/source/sysman/sysman_device/linux/os_sysman_device_imp.h"
#include "level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.h"
#include "level_zero/core/source/device/device.h"
#include "level_zero/tools/source/sysman/global_operations/global_operations_imp.h"
#include "level_zero/tools/source/sysman/linux/fs_access.h"
#include "level_zero/tools/source/sysman/sysman_device/sysman_device_imp.h"
#include <level_zero/zet_api.h>
#include <csignal>
@@ -19,13 +19,13 @@ namespace L0 {
const std::string vendorIntel("Intel(R) Corporation");
const std::string unknown("Unknown");
const std::string intelPciId("0x8086");
const std::string LinuxSysmanDeviceImp::deviceDir("device");
const std::string LinuxSysmanDeviceImp::vendorFile("device/vendor");
const std::string LinuxSysmanDeviceImp::deviceFile("device/device");
const std::string LinuxSysmanDeviceImp::subsystemVendorFile("device/subsystem_vendor");
const std::string LinuxSysmanDeviceImp::driverFile("device/driver");
const std::string LinuxSysmanDeviceImp::functionLevelReset("device/reset");
const std::string LinuxSysmanDeviceImp::clientsDir("clients");
const std::string LinuxGlobalOperationsImp::deviceDir("device");
const std::string LinuxGlobalOperationsImp::vendorFile("device/vendor");
const std::string LinuxGlobalOperationsImp::deviceFile("device/device");
const std::string LinuxGlobalOperationsImp::subsystemVendorFile("device/subsystem_vendor");
const std::string LinuxGlobalOperationsImp::driverFile("device/driver");
const std::string LinuxGlobalOperationsImp::functionLevelReset("device/reset");
const std::string LinuxGlobalOperationsImp::clientsDir("clients");
// Map engine entries(numeric values) present in /sys/class/drm/card<n>/clients/<client_n>/busy,
// with engine enum defined in leve-zero spec
@@ -38,17 +38,17 @@ const std::map<int, zet_engine_type_t> engineMap = {
{3, ZET_ENGINE_TYPE_MEDIA},
{4, ZET_ENGINE_TYPE_COMPUTE}};
void LinuxSysmanDeviceImp::getSerialNumber(int8_t (&serialNumber)[ZET_STRING_PROPERTY_SIZE]) {
void LinuxGlobalOperationsImp::getSerialNumber(int8_t (&serialNumber)[ZET_STRING_PROPERTY_SIZE]) {
std::copy(unknown.begin(), unknown.end(), serialNumber);
serialNumber[unknown.size()] = '\0';
}
void LinuxSysmanDeviceImp::getBoardNumber(int8_t (&boardNumber)[ZET_STRING_PROPERTY_SIZE]) {
void LinuxGlobalOperationsImp::getBoardNumber(int8_t (&boardNumber)[ZET_STRING_PROPERTY_SIZE]) {
std::copy(unknown.begin(), unknown.end(), boardNumber);
boardNumber[unknown.size()] = '\0';
}
void LinuxSysmanDeviceImp::getBrandName(int8_t (&brandName)[ZET_STRING_PROPERTY_SIZE]) {
void LinuxGlobalOperationsImp::getBrandName(int8_t (&brandName)[ZET_STRING_PROPERTY_SIZE]) {
std::string strVal;
ze_result_t result = pSysfsAccess->read(subsystemVendorFile, strVal);
if (ZE_RESULT_SUCCESS != result) {
@@ -65,7 +65,7 @@ void LinuxSysmanDeviceImp::getBrandName(int8_t (&brandName)[ZET_STRING_PROPERTY_
brandName[unknown.size()] = '\0';
}
void LinuxSysmanDeviceImp::getModelName(int8_t (&modelName)[ZET_STRING_PROPERTY_SIZE]) {
void LinuxGlobalOperationsImp::getModelName(int8_t (&modelName)[ZET_STRING_PROPERTY_SIZE]) {
std::string strVal;
ze_result_t result = pSysfsAccess->read(deviceFile, strVal);
if (ZE_RESULT_SUCCESS != result) {
@@ -78,7 +78,7 @@ void LinuxSysmanDeviceImp::getModelName(int8_t (&modelName)[ZET_STRING_PROPERTY_
modelName[strVal.size()] = '\0';
}
void LinuxSysmanDeviceImp::getVendorName(int8_t (&vendorName)[ZET_STRING_PROPERTY_SIZE]) {
void LinuxGlobalOperationsImp::getVendorName(int8_t (&vendorName)[ZET_STRING_PROPERTY_SIZE]) {
std::string strVal;
ze_result_t result = pSysfsAccess->read(vendorFile, strVal);
if (ZE_RESULT_SUCCESS != result) {
@@ -95,7 +95,7 @@ void LinuxSysmanDeviceImp::getVendorName(int8_t (&vendorName)[ZET_STRING_PROPERT
vendorName[unknown.size()] = '\0';
}
void LinuxSysmanDeviceImp::getDriverVersion(int8_t (&driverVersion)[ZET_STRING_PROPERTY_SIZE]) {
void LinuxGlobalOperationsImp::getDriverVersion(int8_t (&driverVersion)[ZET_STRING_PROPERTY_SIZE]) {
std::copy(unknown.begin(), unknown.end(), driverVersion);
driverVersion[unknown.size()] = '\0';
}
@@ -120,7 +120,7 @@ static void getPidFdsForOpenDevice(ProcfsAccess *pProcfsAccess, SysfsAccess *pSy
}
}
ze_result_t LinuxSysmanDeviceImp::reset() {
ze_result_t LinuxGlobalOperationsImp::reset() {
FsAccess *pFsAccess = &pLinuxSysmanImp->getFsAccess();
ProcfsAccess *pProcfsAccess = &pLinuxSysmanImp->getProcfsAccess();
SysfsAccess *pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
@@ -228,7 +228,7 @@ ze_result_t LinuxSysmanDeviceImp::reset() {
// accumulated nanoseconds each client spent on engines.
// Thus we traverse each file in busy dir for non-zero time and if we find that file say 0,then we could say that
// this engine 0 is used by process.
ze_result_t LinuxSysmanDeviceImp::scanProcessesState(std::vector<zet_process_state_t> &pProcessList) {
ze_result_t LinuxGlobalOperationsImp::scanProcessesState(std::vector<zet_process_state_t> &pProcessList) {
std::vector<std::string> clientIds;
ze_result_t result = pSysfsAccess->scanDirEntries(clientsDir, clientIds);
if (ZE_RESULT_SUCCESS != result) {
@@ -311,15 +311,15 @@ ze_result_t LinuxSysmanDeviceImp::scanProcessesState(std::vector<zet_process_sta
return result;
}
LinuxSysmanDeviceImp::LinuxSysmanDeviceImp(OsSysman *pOsSysman) {
LinuxGlobalOperationsImp::LinuxGlobalOperationsImp(OsSysman *pOsSysman) {
pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
}
OsSysmanDevice *OsSysmanDevice::create(OsSysman *pOsSysman) {
LinuxSysmanDeviceImp *pLinuxSysmanDeviceImp = new LinuxSysmanDeviceImp(pOsSysman);
return static_cast<OsSysmanDevice *>(pLinuxSysmanDeviceImp);
OsGlobalOperations *OsGlobalOperations::create(OsSysman *pOsSysman) {
LinuxGlobalOperationsImp *pLinuxGlobalOperationsImp = new LinuxGlobalOperationsImp(pOsSysman);
return static_cast<OsGlobalOperations *>(pLinuxGlobalOperationsImp);
}
} // namespace L0

View File

@@ -6,14 +6,13 @@
*/
#pragma once
#include "level_zero/tools/source/sysman/global_operations/os_global_operations.h"
#include "level_zero/tools/source/sysman/linux/os_sysman_imp.h"
#include "level_zero/tools/source/sysman/sysman_device/os_sysman_device.h"
namespace L0 {
class SysfsAccess;
class LinuxSysmanDeviceImp : public OsSysmanDevice, NEO::NonCopyableOrMovableClass {
class LinuxGlobalOperationsImp : public OsGlobalOperations, NEO::NonCopyableOrMovableClass {
public:
void getSerialNumber(int8_t (&serialNumber)[ZET_STRING_PROPERTY_SIZE]) override;
void getBoardNumber(int8_t (&boardNumber)[ZET_STRING_PROPERTY_SIZE]) override;
@@ -23,9 +22,9 @@ class LinuxSysmanDeviceImp : public OsSysmanDevice, NEO::NonCopyableOrMovableCla
void getDriverVersion(int8_t (&driverVersion)[ZET_STRING_PROPERTY_SIZE]) override;
ze_result_t reset() override;
ze_result_t scanProcessesState(std::vector<zet_process_state_t> &pProcessList) override;
LinuxSysmanDeviceImp() = default;
LinuxSysmanDeviceImp(OsSysman *pOsSysman);
~LinuxSysmanDeviceImp() override = default;
LinuxGlobalOperationsImp() = default;
LinuxGlobalOperationsImp(OsSysman *pOsSysman);
~LinuxGlobalOperationsImp() override = default;
protected:
SysfsAccess *pSysfsAccess = nullptr;

View File

@@ -15,7 +15,7 @@
namespace L0 {
class OsSysmanDevice {
class OsGlobalOperations {
public:
virtual void getSerialNumber(int8_t (&serialNumber)[ZET_STRING_PROPERTY_SIZE]) = 0;
virtual void getBoardNumber(int8_t (&boardNumber)[ZET_STRING_PROPERTY_SIZE]) = 0;
@@ -25,8 +25,8 @@ class OsSysmanDevice {
virtual void getDriverVersion(int8_t (&driverVersion)[ZET_STRING_PROPERTY_SIZE]) = 0;
virtual ze_result_t reset() = 0;
virtual ze_result_t scanProcessesState(std::vector<zet_process_state_t> &pProcessList) = 0;
static OsSysmanDevice *create(OsSysman *pOsSysman);
virtual ~OsSysmanDevice() {}
static OsGlobalOperations *create(OsSysman *pOsSysman);
virtual ~OsGlobalOperations() {}
};
} // namespace L0

View File

@@ -0,0 +1,21 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(L0_SRCS_TOOLS_GLOBAL_OPERATIONS_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/os_global_operations_imp.cpp
)
if(WIN32)
target_sources(${L0_STATIC_LIB_NAME}
PRIVATE
${L0_SRCS_TOOLS_GLOBAL_OPERATIONS_WINDOWS}
)
endif()
# Make our source files visible to parent
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_GLOBAL_OPERATIONS_WINDOWS ${L0_SRCS_TOOLS_GLOBAL_OPERATIONS_WINDOWS})

View File

@@ -0,0 +1,66 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/tools/source/sysman/global_operations/os_global_operations.h"
#include "level_zero/tools/source/sysman/windows/os_sysman_imp.h"
namespace L0 {
class WddmGlobalOperationsImp : public OsGlobalOperations {
public:
void getSerialNumber(int8_t (&serialNumber)[ZET_STRING_PROPERTY_SIZE]) override;
void getBoardNumber(int8_t (&boardNumber)[ZET_STRING_PROPERTY_SIZE]) override;
void getBrandName(int8_t (&brandName)[ZET_STRING_PROPERTY_SIZE]) override;
void getModelName(int8_t (&modelName)[ZET_STRING_PROPERTY_SIZE]) override;
void getVendorName(int8_t (&vendorName)[ZET_STRING_PROPERTY_SIZE]) override;
void getDriverVersion(int8_t (&driverVersion)[ZET_STRING_PROPERTY_SIZE]) override;
ze_result_t reset() override;
ze_result_t scanProcessesState(std::vector<zet_process_state_t> &pProcessList) override;
WddmGlobalOperationsImp(OsSysman *pOsSysman);
~WddmGlobalOperationsImp() = default;
// Don't allow copies of the WddmGlobalOperationsImp object
WddmGlobalOperationsImp(const WddmGlobalOperationsImp &obj) = delete;
WddmGlobalOperationsImp &operator=(const WddmGlobalOperationsImp &obj) = delete;
};
void WddmGlobalOperationsImp::getSerialNumber(int8_t (&serialNumber)[ZET_STRING_PROPERTY_SIZE]) {
}
void WddmGlobalOperationsImp::getBoardNumber(int8_t (&boardNumber)[ZET_STRING_PROPERTY_SIZE]) {
}
void WddmGlobalOperationsImp::getBrandName(int8_t (&brandName)[ZET_STRING_PROPERTY_SIZE]) {
}
void WddmGlobalOperationsImp::getModelName(int8_t (&modelName)[ZET_STRING_PROPERTY_SIZE]) {
}
void WddmGlobalOperationsImp::getVendorName(int8_t (&vendorName)[ZET_STRING_PROPERTY_SIZE]) {
}
void WddmGlobalOperationsImp::getDriverVersion(int8_t (&driverVersion)[ZET_STRING_PROPERTY_SIZE]) {
}
ze_result_t WddmGlobalOperationsImp::reset() {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t WddmGlobalOperationsImp::scanProcessesState(std::vector<zet_process_state_t> &pProcessList) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
WddmGlobalOperationsImp::WddmGlobalOperationsImp(OsSysman *pOsSysman) {
}
OsGlobalOperations *OsGlobalOperations::create(OsSysman *pOsSysman) {
WddmGlobalOperationsImp *pWddmGlobalOperationsImp = new WddmGlobalOperationsImp(pOsSysman);
return static_cast<OsGlobalOperations *>(pWddmGlobalOperationsImp);
}
} // namespace L0

View File

@@ -18,7 +18,15 @@ ze_result_t LinuxSysmanImp::init() {
pProcfsAccess = ProcfsAccess::create();
UNRECOVERABLE_IF(nullptr == pProcfsAccess);
Device *pDevice = Device::fromHandle(pParentSysmanImp->hCoreDevice);
Device *pDevice = nullptr;
if (pParentSysmanImp != nullptr) {
pDevice = Device::fromHandle(pParentSysmanImp->hCoreDevice);
} else if (pParentSysmanDeviceImp != nullptr) {
pDevice = Device::fromHandle(pParentSysmanDeviceImp->hCoreDevice);
} else {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
UNRECOVERABLE_IF(nullptr == pDevice);
NEO::OSInterface &OsInterface = pDevice->getOsInterface();
pDrm = OsInterface.get()->getDrm();
int myDeviceFd = pDrm->getFileDescriptor();
@@ -67,6 +75,10 @@ LinuxSysmanImp::LinuxSysmanImp(SysmanImp *pParentSysmanImp) {
this->pParentSysmanImp = pParentSysmanImp;
}
LinuxSysmanImp::LinuxSysmanImp(SysmanDeviceImp *pParentSysmanDeviceImp) {
this->pParentSysmanDeviceImp = pParentSysmanDeviceImp;
}
LinuxSysmanImp::~LinuxSysmanImp() {
if (nullptr != pSysfsAccess) {
delete pSysfsAccess;
@@ -91,4 +103,9 @@ OsSysman *OsSysman::create(SysmanImp *pParentSysmanImp) {
return static_cast<OsSysman *>(pLinuxSysmanImp);
}
OsSysman *OsSysman::create(SysmanDeviceImp *pParentSysmanDeviceImp) {
LinuxSysmanImp *pLinuxSysmanImp = new LinuxSysmanImp(pParentSysmanDeviceImp);
return static_cast<OsSysman *>(pLinuxSysmanImp);
}
} // namespace L0

View File

@@ -19,6 +19,7 @@ namespace L0 {
class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
public:
LinuxSysmanImp(SysmanImp *pParentSysmanImp);
LinuxSysmanImp(SysmanDeviceImp *pParentSysmanDeviceImp);
~LinuxSysmanImp() override;
ze_result_t init() override;
@@ -29,14 +30,17 @@ class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
NEO::Drm &getDrm();
PlatformMonitoringTech &getPlatformMonitoringTechAccess();
private:
LinuxSysmanImp() = delete;
SysmanImp *pParentSysmanImp = nullptr;
protected:
FsAccess *pFsAccess = nullptr;
ProcfsAccess *pProcfsAccess = nullptr;
SysfsAccess *pSysfsAccess = nullptr;
NEO::Drm *pDrm = nullptr;
PlatformMonitoringTech *pPmt = nullptr;
private:
LinuxSysmanImp() = delete;
SysmanImp *pParentSysmanImp = nullptr;
SysmanDeviceImp *pParentSysmanDeviceImp = nullptr;
NEO::Drm *pDrm = nullptr;
};
} // namespace L0

View File

@@ -11,12 +11,14 @@
namespace L0 {
struct SysmanImp;
struct SysmanDeviceImp;
struct OsSysman {
virtual ~OsSysman(){};
virtual ze_result_t init() = 0;
static OsSysman *create(SysmanImp *pSysmanImp);
static OsSysman *create(SysmanDeviceImp *pSysmanImp);
};
} // namespace L0

View File

@@ -7,6 +7,7 @@
#include "level_zero/tools/source/sysman/sysman.h"
#include "level_zero/core/source/device/device_imp.h"
#include "level_zero/core/source/driver/driver.h"
#include "level_zero/core/source/driver/driver_handle_imp.h"
#include "level_zero/tools/source/sysman/sysman_imp.h"
@@ -51,4 +52,27 @@ ze_result_t SysmanHandleContext::sysmanGet(zet_device_handle_t hDevice, zet_sysm
return ZE_RESULT_SUCCESS;
}
SysmanDevice *SysmanDeviceHandleContext::init(ze_device_handle_t device) {
auto isSysmanEnabled = getenv("ZES_ENABLE_SYSMAN");
if (isSysmanEnabled == nullptr) {
return nullptr;
}
auto isSysmanEnabledAsInt = atoi(isSysmanEnabled);
if (isSysmanEnabledAsInt == 1) {
SysmanDeviceImp *sysman = new SysmanDeviceImp(device);
UNRECOVERABLE_IF(!sysman);
sysman->init();
return sysman;
}
return nullptr;
}
void DeviceImp::setSysmanHandle(SysmanDevice *pSysman) {
pSysmanDevice = pSysman;
}
SysmanDevice *DeviceImp::getSysmanHandle() {
return pSysmanDevice;
}
} // namespace L0

View File

@@ -6,20 +6,23 @@
*/
#pragma once
#include "level_zero/core/source/device/device.h"
#include "level_zero/tools/source/sysman/engine/engine.h"
#include "level_zero/tools/source/sysman/fabric_port/fabric_port.h"
#include "level_zero/tools/source/sysman/frequency/frequency.h"
#include "level_zero/tools/source/sysman/global_operations/global_operations.h"
#include "level_zero/tools/source/sysman/memory/memory.h"
#include "level_zero/tools/source/sysman/pci/pci.h"
#include "level_zero/tools/source/sysman/power/power.h"
#include "level_zero/tools/source/sysman/ras/ras.h"
#include "level_zero/tools/source/sysman/scheduler/scheduler.h"
#include "level_zero/tools/source/sysman/standby/standby.h"
#include "level_zero/tools/source/sysman/sysman_device/sysman_device.h"
#include "level_zero/tools/source/sysman/temperature/temperature.h"
#include <level_zero/zet_api.h>
#include <level_zero/zet_sysman.h>
#include "third_party/level_zero/zes_api_ext.h"
#include <unordered_map>
struct _zet_sysman_handle_t {};
@@ -74,4 +77,18 @@ class SysmanHandleContext {
std::unordered_map<zet_device_handle_t, zet_sysman_handle_t> handle_map;
};
struct SysmanDevice : _ze_device_handle_t {
static SysmanDevice *fromHandle(zes_device_handle_t handle) { return Device::fromHandle(handle)->getSysmanHandle(); }
virtual ze_result_t powerGet(uint32_t *pCount, zes_pwr_handle_t *phPower) = 0;
virtual ~SysmanDevice() = default;
};
class SysmanDeviceHandleContext {
public:
SysmanDeviceHandleContext() = delete;
static SysmanDevice *init(ze_device_handle_t device);
};
} // namespace L0

View File

@@ -1,32 +0,0 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(L0_SRCS_TOOLS_SYSMAN_DEVICE
${CMAKE_CURRENT_SOURCE_DIR}/sysman_device.h
${CMAKE_CURRENT_SOURCE_DIR}/sysman_device_imp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sysman_device_imp.h
${CMAKE_CURRENT_SOURCE_DIR}/os_sysman_device.h
)
target_include_directories(${L0_STATIC_LIB_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/
)
target_sources(${L0_STATIC_LIB_NAME}
PRIVATE
${L0_SRCS_TOOLS_SYSMAN_DEVICE}
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
)
if(UNIX)
add_subdirectory(linux)
else()
add_subdirectory(windows)
endif()
# Make our source files visible to parent
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_SYSMAN_DEVICE ${L0_SRCS_TOOLS_SYSMAN_DEVICE})

View File

@@ -1,21 +0,0 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(L0_SRCS_TOOLS_SYSMAN_DEVICE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/os_sysman_device_imp.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/os_sysman_device_imp.h
)
if(UNIX)
target_sources(${L0_STATIC_LIB_NAME}
PRIVATE
${L0_SRCS_TOOLS_SYSMAN_DEVICE_LINUX}
)
endif()
# Make our source files visible to parent
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_SYSMAN_DEVICE_LINUX ${L0_SRCS_TOOLS_SYSMAN_DEVICE_LINUX})

View File

@@ -1,21 +0,0 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(L0_SRCS_TOOLS_SYSMAN_DEVICE_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/os_sysman_device_imp.cpp
)
if(WIN32)
target_sources(${L0_STATIC_LIB_NAME}
PRIVATE
${L0_SRCS_TOOLS_SYSMAN_DEVICE_WINDOWS}
)
endif()
# Make our source files visible to parent
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_SYSMAN_DEVICE_WINDOWS ${L0_SRCS_TOOLS_SYSMAN_DEVICE_WINDOWS})

View File

@@ -1,65 +0,0 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/helpers/non_copyable_or_moveable.h"
#include "level_zero/tools/source/sysman/sysman_device/os_sysman_device.h"
#include "level_zero/tools/source/sysman/windows/os_sysman_imp.h"
namespace L0 {
class WddmSysmanDeviceImp : public OsSysmanDevice, NEO::NonCopyableOrMovableClass {
public:
void getSerialNumber(int8_t (&serialNumber)[ZET_STRING_PROPERTY_SIZE]) override;
void getBoardNumber(int8_t (&boardNumber)[ZET_STRING_PROPERTY_SIZE]) override;
void getBrandName(int8_t (&brandName)[ZET_STRING_PROPERTY_SIZE]) override;
void getModelName(int8_t (&modelName)[ZET_STRING_PROPERTY_SIZE]) override;
void getVendorName(int8_t (&vendorName)[ZET_STRING_PROPERTY_SIZE]) override;
void getDriverVersion(int8_t (&driverVersion)[ZET_STRING_PROPERTY_SIZE]) override;
ze_result_t reset() override;
ze_result_t scanProcessesState(std::vector<zet_process_state_t> &pProcessList) override;
WddmSysmanDeviceImp(OsSysman *pOsSysman);
~WddmSysmanDeviceImp() = default;
};
void WddmSysmanDeviceImp::getSerialNumber(int8_t (&serialNumber)[ZET_STRING_PROPERTY_SIZE]) {
}
void WddmSysmanDeviceImp::getBoardNumber(int8_t (&boardNumber)[ZET_STRING_PROPERTY_SIZE]) {
}
void WddmSysmanDeviceImp::getBrandName(int8_t (&brandName)[ZET_STRING_PROPERTY_SIZE]) {
}
void WddmSysmanDeviceImp::getModelName(int8_t (&modelName)[ZET_STRING_PROPERTY_SIZE]) {
}
void WddmSysmanDeviceImp::getVendorName(int8_t (&vendorName)[ZET_STRING_PROPERTY_SIZE]) {
}
void WddmSysmanDeviceImp::getDriverVersion(int8_t (&driverVersion)[ZET_STRING_PROPERTY_SIZE]) {
}
ze_result_t WddmSysmanDeviceImp::reset() {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t WddmSysmanDeviceImp::scanProcessesState(std::vector<zet_process_state_t> &pProcessList) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
WddmSysmanDeviceImp::WddmSysmanDeviceImp(OsSysman *pOsSysman) {
}
OsSysmanDevice *OsSysmanDevice::create(OsSysman *pOsSysman) {
WddmSysmanDeviceImp *pWddmSysmanDeviceImp = new WddmSysmanDeviceImp(pOsSysman);
return static_cast<OsSysmanDevice *>(pWddmSysmanDeviceImp);
}
} // namespace L0

View File

@@ -9,22 +9,36 @@
#include "level_zero/core/source/driver/driver.h"
#include "level_zero/core/source/driver/driver_handle_imp.h"
#include "level_zero/tools/source/sysman/global_operations/global_operations_imp.h"
#include "level_zero/tools/source/sysman/pci/pci_imp.h"
#include "level_zero/tools/source/sysman/scheduler/scheduler_imp.h"
#include "level_zero/tools/source/sysman/sysman.h"
#include "level_zero/tools/source/sysman/sysman_device/sysman_device_imp.h"
#include <vector>
namespace L0 {
SysmanDeviceImp::SysmanDeviceImp(ze_device_handle_t hDevice) {
hCoreDevice = hDevice;
pOsSysman = OsSysman::create(this);
UNRECOVERABLE_IF(nullptr == pOsSysman);
}
SysmanDeviceImp::~SysmanDeviceImp() {
freeResource(pOsSysman);
}
void SysmanDeviceImp::init() {
pOsSysman->init();
}
SysmanImp::SysmanImp(ze_device_handle_t hDevice) {
hCoreDevice = hDevice;
pOsSysman = OsSysman::create(this);
UNRECOVERABLE_IF(nullptr == pOsSysman);
pPci = new PciImp(pOsSysman);
pSched = new SchedulerImp(pOsSysman);
pSysmanDevice = new SysmanDeviceImp(pOsSysman, hCoreDevice);
pGlobalOperations = new GlobalOperationsImp(pOsSysman, hCoreDevice);
pFrequencyHandleContext = new FrequencyHandleContext(pOsSysman);
pStandbyHandleContext = new StandbyHandleContext(pOsSysman);
pMemoryHandleContext = new MemoryHandleContext(pOsSysman, hCoreDevice);
@@ -44,7 +58,7 @@ SysmanImp::~SysmanImp() {
freeResource(pMemoryHandleContext);
freeResource(pStandbyHandleContext);
freeResource(pFrequencyHandleContext);
freeResource(pSysmanDevice);
freeResource(pGlobalOperations);
freeResource(pPci);
freeResource(pSched);
freeResource(pOsSysman);
@@ -82,13 +96,13 @@ void SysmanImp::init() {
if (pSched) {
pSched->init();
}
if (pSysmanDevice) {
pSysmanDevice->init();
if (pGlobalOperations) {
pGlobalOperations->init();
}
}
ze_result_t SysmanImp::deviceGetProperties(zet_sysman_properties_t *pProperties) {
return pSysmanDevice->deviceGetProperties(pProperties);
return pGlobalOperations->deviceGetProperties(pProperties);
}
ze_result_t SysmanImp::schedulerGetCurrentMode(zet_sched_mode_t *pMode) {
@@ -141,11 +155,11 @@ ze_result_t SysmanImp::schedulerSetComputeUnitDebugMode(ze_bool_t *pNeedReboot)
}
ze_result_t SysmanImp::processesGetState(uint32_t *pCount, zet_process_state_t *pProcesses) {
return pSysmanDevice->processesGetState(pCount, pProcesses);
return pGlobalOperations->processesGetState(pCount, pProcesses);
}
ze_result_t SysmanImp::deviceReset() {
return pSysmanDevice->reset();
return pGlobalOperations->reset();
}
ze_result_t SysmanImp::deviceGetRepairStatus(zet_repair_status_t *pRepairStatus) {
@@ -172,6 +186,10 @@ ze_result_t SysmanImp::powerGet(uint32_t *pCount, zet_sysman_pwr_handle_t *phPow
return pPowerHandleContext->powerGet(pCount, phPower);
}
ze_result_t SysmanDeviceImp::powerGet(uint32_t *pCount, zes_pwr_handle_t *phPower) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t SysmanImp::frequencyGet(uint32_t *pCount, zet_sysman_freq_handle_t *phFrequency) {
return pFrequencyHandleContext->frequencyGet(pCount, phFrequency);
}

View File

@@ -31,7 +31,7 @@ struct SysmanImp : Sysman, NEO::NonCopyableOrMovableClass {
OsSysman *pOsSysman = nullptr;
Pci *pPci = nullptr;
Scheduler *pSched = nullptr;
SysmanDevice *pSysmanDevice = nullptr;
GlobalOperations *pGlobalOperations = nullptr;
FrequencyHandleContext *pFrequencyHandleContext = nullptr;
StandbyHandleContext *pStandbyHandleContext = nullptr;
MemoryHandleContext *pMemoryHandleContext = nullptr;
@@ -81,4 +81,29 @@ struct SysmanImp : Sysman, NEO::NonCopyableOrMovableClass {
}
};
struct SysmanDeviceImp : SysmanDevice, NEO::NonCopyableOrMovableClass {
SysmanDeviceImp(ze_device_handle_t hDevice);
~SysmanDeviceImp() override;
SysmanDeviceImp() = delete;
void init();
ze_device_handle_t hCoreDevice;
OsSysman *pOsSysman = nullptr;
PowerHandleContext *pPowerHandleContext = nullptr;
ze_result_t powerGet(uint32_t *pCount, zes_pwr_handle_t *phPower) override;
private:
template <typename T>
void inline freeResource(T *&resource) {
if (resource) {
delete resource;
resource = nullptr;
}
}
};
} // namespace L0

View File

@@ -18,4 +18,9 @@ OsSysman *OsSysman::create(SysmanImp *pParentSysmanImp) {
return static_cast<OsSysman *>(pWddmSysmanImp);
}
OsSysman *OsSysman::create(SysmanDeviceImp *pParentSysmanDeviceImp) {
WddmSysmanImp *pWddmSysmanImp = new WddmSysmanImp(pParentSysmanDeviceImp);
return static_cast<OsSysman *>(pWddmSysmanImp);
}
} // namespace L0

View File

@@ -15,13 +15,15 @@ namespace L0 {
class WddmSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
public:
WddmSysmanImp(SysmanImp *pParentSysmanImp) : pParentSysmanImp(pParentSysmanImp){};
WddmSysmanImp(SysmanDeviceImp *pParentSysmanDeviceImp) : pParentSysmanDeviceImp(pParentSysmanDeviceImp){};
~WddmSysmanImp() override = default;
ze_result_t init() override;
private:
WddmSysmanImp() = delete;
SysmanImp *pParentSysmanImp;
SysmanImp *pParentSysmanImp = nullptr;
SysmanDeviceImp *pParentSysmanDeviceImp = nullptr;
};
} // namespace L0

View File

@@ -4,9 +4,12 @@
# SPDX-License-Identifier: MIT
#
if(UNIX)
target_sources(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_sysman_fixture.h
)
endif()
add_subdirectories()

View File

@@ -8,7 +8,7 @@ if(UNIX)
target_sources(${TARGET_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/test_sysman_device.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/mock_sysfs_sysman_device.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/test_global_operations.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/mock_global_operations.h
)
endif()

View File

@@ -7,8 +7,8 @@
#pragma once
#include "level_zero/core/test/unit_tests/mock.h"
#include "level_zero/tools/source/sysman/sysman_device/linux/os_sysman_device_imp.h"
#include "level_zero/tools/source/sysman/sysman_device/sysman_device_imp.h"
#include "level_zero/tools/source/sysman/global_operations/global_operations_imp.h"
#include "level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.h"
#include "sysman/sysman.h"
@@ -38,10 +38,10 @@ const std::string engine1("1");
const std::string engine2("2");
const std::string engine3("3");
class SysmanDeviceSysfsAccess : public SysfsAccess {};
class GlobalOperationsSysfsAccess : public SysfsAccess {};
template <>
struct Mock<SysmanDeviceSysfsAccess> : public SysfsAccess {
struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
ze_result_t getValString(const std::string file, std::string &val) {
if (file.compare(subsystemVendorFile) == 0) {
val = "0x8086";
@@ -91,17 +91,17 @@ struct Mock<SysmanDeviceSysfsAccess> : public SysfsAccess {
return ZE_RESULT_SUCCESS;
}
Mock<SysmanDeviceSysfsAccess>() = default;
Mock<GlobalOperationsSysfsAccess>() = default;
MOCK_METHOD(ze_result_t, read, (const std::string file, std::string &val), (override));
MOCK_METHOD(ze_result_t, read, (const std::string file, uint64_t &val), (override));
MOCK_METHOD(ze_result_t, scanDirEntries, (const std::string path, std::vector<std::string> &list), (override));
};
class PublicLinuxSysmanDeviceImp : public L0::LinuxSysmanDeviceImp {
class PublicLinuxGlobalOperationsImp : public L0::LinuxGlobalOperationsImp {
public:
using LinuxSysmanDeviceImp::pLinuxSysmanImp;
using LinuxSysmanDeviceImp::pSysfsAccess;
using LinuxGlobalOperationsImp::pLinuxSysmanImp;
using LinuxGlobalOperationsImp::pSysfsAccess;
};
} // namespace ult

View File

@@ -9,7 +9,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "mock_sysfs_sysman_device.h"
#include "mock_global_operations.h"
using ::testing::_;
using ::testing::DoAll;
@@ -34,43 +34,43 @@ constexpr int64_t engines1 = 28u;
constexpr int64_t engines2 = 4u;
constexpr uint32_t totalProcessStates = 2u; // Two process States for two pids
const std::string expectedModelName("0x3ea5");
class SysmanSysmanDeviceFixture : public DeviceFixture, public ::testing::Test {
class SysmanGlobalOperationsFixture : public DeviceFixture, public ::testing::Test {
protected:
std::unique_ptr<SysmanImp> sysmanImp;
zet_sysman_handle_t hSysman;
OsSysmanDevice *pOsSysmanDevice = nullptr;
Mock<SysmanDeviceSysfsAccess> *pSysfsAccess = nullptr;
L0::SysmanDevice *pSysmanDevicePrev = nullptr;
L0::SysmanDeviceImp sysmanDeviceImp;
PublicLinuxSysmanDeviceImp linuxSysmanDeviceImp;
OsGlobalOperations *pOsGlobalOperations = nullptr;
Mock<GlobalOperationsSysfsAccess> *pSysfsAccess = nullptr;
L0::GlobalOperations *pGlobalOperationsPrev = nullptr;
L0::GlobalOperationsImp globalOperationsImp;
PublicLinuxGlobalOperationsImp linuxGlobalOperationsImp;
void SetUp() override {
DeviceFixture::SetUp();
sysmanImp = std::make_unique<SysmanImp>(device->toHandle());
pSysfsAccess = new NiceMock<Mock<SysmanDeviceSysfsAccess>>;
linuxSysmanDeviceImp.pSysfsAccess = pSysfsAccess;
pOsSysmanDevice = static_cast<OsSysmanDevice *>(&linuxSysmanDeviceImp);
pSysfsAccess = new NiceMock<Mock<GlobalOperationsSysfsAccess>>;
linuxGlobalOperationsImp.pSysfsAccess = pSysfsAccess;
pOsGlobalOperations = static_cast<OsGlobalOperations *>(&linuxGlobalOperationsImp);
ON_CALL(*pSysfsAccess, read(_, Matcher<std::string &>(_)))
.WillByDefault(::testing::Invoke(pSysfsAccess, &Mock<SysmanDeviceSysfsAccess>::getValString));
.WillByDefault(::testing::Invoke(pSysfsAccess, &Mock<GlobalOperationsSysfsAccess>::getValString));
ON_CALL(*pSysfsAccess, read(_, Matcher<uint64_t &>(_)))
.WillByDefault(::testing::Invoke(pSysfsAccess, &Mock<SysmanDeviceSysfsAccess>::getValUnsignedLong));
.WillByDefault(::testing::Invoke(pSysfsAccess, &Mock<GlobalOperationsSysfsAccess>::getValUnsignedLong));
ON_CALL(*pSysfsAccess, scanDirEntries(_, _))
.WillByDefault(::testing::Invoke(pSysfsAccess, &Mock<SysmanDeviceSysfsAccess>::getScannedDirEntries));
.WillByDefault(::testing::Invoke(pSysfsAccess, &Mock<GlobalOperationsSysfsAccess>::getScannedDirEntries));
pSysmanDevicePrev = sysmanImp->pSysmanDevice;
sysmanImp->pSysmanDevice = static_cast<SysmanDevice *>(&sysmanDeviceImp);
sysmanDeviceImp.pOsSysmanDevice = pOsSysmanDevice;
sysmanDeviceImp.hCoreDevice = sysmanImp->hCoreDevice;
sysmanDeviceImp.init();
pGlobalOperationsPrev = sysmanImp->pGlobalOperations;
sysmanImp->pGlobalOperations = static_cast<GlobalOperations *>(&globalOperationsImp);
globalOperationsImp.pOsGlobalOperations = pOsGlobalOperations;
globalOperationsImp.hCoreDevice = sysmanImp->hCoreDevice;
globalOperationsImp.init();
hSysman = sysmanImp->toHandle();
}
void TearDown() override {
// restore state
sysmanImp->pSysmanDevice = pSysmanDevicePrev;
sysmanDeviceImp.pOsSysmanDevice = nullptr;
sysmanImp->pGlobalOperations = pGlobalOperationsPrev;
globalOperationsImp.pOsGlobalOperations = nullptr;
// cleanup
if (pSysfsAccess != nullptr) {
@@ -81,7 +81,7 @@ class SysmanSysmanDeviceFixture : public DeviceFixture, public ::testing::Test {
}
};
TEST_F(SysmanSysmanDeviceFixture, GivenValidSysmanHandleWhenCallingzetSysmanDeviceGetPropertiesThenVerifyzetSysmanDeviceGetPropertiesCallSucceeds) {
TEST_F(SysmanGlobalOperationsFixture, GivenValidSysmanHandleWhenCallingzetGlobalOperationsGetPropertiesThenVerifyzetGlobalOperationsGetPropertiesCallSucceeds) {
zet_sysman_properties_t properties;
ze_result_t result = zetSysmanDeviceGetProperties(hSysman, &properties);
@@ -95,7 +95,7 @@ TEST_F(SysmanSysmanDeviceFixture, GivenValidSysmanHandleWhenCallingzetSysmanDevi
EXPECT_TRUE(0 == std::memcmp(properties.vendorName, vendorIntel.c_str(), vendorIntel.size()));
}
TEST_F(SysmanSysmanDeviceFixture, GivenValidSysmanHandleWhileRetrievingInformationAboutHostProcessesUsingDeviceThenSuccessIsReturned) {
TEST_F(SysmanGlobalOperationsFixture, GivenValidSysmanHandleWhileRetrievingInformationAboutHostProcessesUsingDeviceThenSuccessIsReturned) {
uint32_t count = 0;
ASSERT_EQ(ZE_RESULT_SUCCESS, zetSysmanProcessesGetState(hSysman, &count, nullptr));
EXPECT_EQ(count, totalProcessStates);
@@ -109,7 +109,7 @@ TEST_F(SysmanSysmanDeviceFixture, GivenValidSysmanHandleWhileRetrievingInformati
EXPECT_EQ(processes[1].memSize, memSize2);
}
TEST_F(SysmanSysmanDeviceFixture, GivenValidSysmanHandleWhileReadingNonExistingFileThenErrorIsReturned) {
TEST_F(SysmanGlobalOperationsFixture, GivenValidSysmanHandleWhileReadingNonExistingFileThenErrorIsReturned) {
std::vector<std::string> engineEntries;
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, pSysfsAccess->scanDirEntries("clients/7/busy", engineEntries));
}

View File

@@ -0,0 +1,67 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/os_interface/device_factory.h"
#include "shared/source/os_interface/linux/drm_neo.h"
#include "shared/source/os_interface/linux/os_interface.h"
#include "test.h"
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
#include "level_zero/tools/source/sysman/sysman.h"
#include "sysman/linux/os_sysman_imp.h"
using ::testing::_;
using ::testing::NiceMock;
using namespace NEO;
namespace L0 {
namespace ult {
class SysmanMockDrm : public Drm {
public:
const int mockFd = 33;
SysmanMockDrm(RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceId>(mockFd, ""), rootDeviceEnvironment) {}
};
class PublicLinuxSysmanImp : public L0::LinuxSysmanImp {
public:
using LinuxSysmanImp::pFsAccess;
using LinuxSysmanImp::pPmt;
using LinuxSysmanImp::pProcfsAccess;
using LinuxSysmanImp::pSysfsAccess;
};
class SysmanDeviceFixture : public DeviceFixture, public ::testing::Test {
public:
void SetUp() override {
DeviceFixture::SetUp();
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->osInterface = std::make_unique<NEO::OSInterface>();
auto osInterface = device->getOsInterface().get();
osInterface->setDrm(new SysmanMockDrm(const_cast<NEO::RootDeviceEnvironment &>(neoDevice->getRootDeviceEnvironment())));
setenv("ZES_ENABLE_SYSMAN", "1", 1);
device->setSysmanHandle(L0::SysmanDeviceHandleContext::init(device->toHandle()));
pSysmanDevice = device->getSysmanHandle();
pSysmanDeviceImp = static_cast<SysmanDeviceImp *>(pSysmanDevice);
pOsSysman = pSysmanDeviceImp->pOsSysman;
pLinuxSysmanImp = static_cast<PublicLinuxSysmanImp *>(pOsSysman);
}
void TearDown() override {
DeviceFixture::TearDown();
unsetenv("ZES_ENABLE_SYSMAN");
}
SysmanDevice *pSysmanDevice = nullptr;
SysmanDeviceImp *pSysmanDeviceImp = nullptr;
OsSysman *pOsSysman = nullptr;
PublicLinuxSysmanImp *pLinuxSysmanImp = nullptr;
};
} // namespace ult
} // namespace L0

View File

@@ -5,22 +5,34 @@
*
*/
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
#include "level_zero/tools/source/sysman/power/linux/os_power_imp.h"
#include "level_zero/tools/test/unit_tests/sources/sysman/mock_sysman_fixture.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "mock_sysfs_power.h"
#include "sysman/linux/os_sysman_imp.h"
#include "sysman/power/power_imp.h"
using ::testing::_;
using ::testing::NiceMock;
namespace L0 {
namespace ult {
constexpr uint64_t convertJouleToMicroJoule = 1000000u;
class SysmanDevicePowerGetTest : public SysmanDeviceFixture {
protected:
void SetUp() override {
SysmanDeviceFixture::SetUp();
}
void TearDown() override {
SysmanDeviceFixture::TearDown();
}
};
TEST_F(SysmanDevicePowerGetTest, GivenValidSysmanHandleWhenPowerGetNotImplementedThenErrorIsReturned) {
zes_device_handle_t hSysman = device->toHandle();
uint32_t count = 0;
EXPECT_EQ(zesDeviceEnumPowerDomains(hSysman, &count, nullptr), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
}
class SysmanPowerFixture : public DeviceFixture, public ::testing::Test {
protected:

View File

@@ -1,14 +0,0 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(WIN32)
target_sources(${TARGET_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_device.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_sysman_device.h
)
endif()

View File

@@ -1,44 +0,0 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "level_zero/core/test/unit_tests/mock.h"
#include "sysman/sysman.h"
#include "sysman/sysman_device/os_sysman_device.h"
#include "sysman/sysman_device/sysman_device_imp.h"
#include "sysman/sysman_imp.h"
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winconsistent-missing-override"
#endif
namespace L0 {
namespace ult {
template <>
struct Mock<OsSysmanDevice> : public OsSysmanDevice {
Mock<OsSysmanDevice>() = default;
MOCK_METHOD1(getSerialNumber, void(int8_t (&serialNumber)[ZET_STRING_PROPERTY_SIZE]));
MOCK_METHOD1(getBoardNumber, void(int8_t (&boardNumber)[ZET_STRING_PROPERTY_SIZE]));
MOCK_METHOD1(getBrandName, void(int8_t (&brandName)[ZET_STRING_PROPERTY_SIZE]));
MOCK_METHOD1(getModelName, void(int8_t (&modelName)[ZET_STRING_PROPERTY_SIZE]));
MOCK_METHOD1(getVendorName, void(int8_t (&vendorName)[ZET_STRING_PROPERTY_SIZE]));
MOCK_METHOD1(getDriverVersion, void(int8_t (&driverVersion)[ZET_STRING_PROPERTY_SIZE]));
MOCK_METHOD0(reset, ze_result_t());
MOCK_METHOD1(scanProcessesState, ze_result_t(std::vector<zet_process_state_t> &pProcessList));
};
} // namespace ult
} // namespace L0
#if defined(__clang__)
#pragma clang diagnostic pop
#endif

View File

@@ -1,149 +0,0 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "mock_sysman_device.h"
using ::testing::_;
using ::testing::DoAll;
using ::testing::InSequence;
using ::testing::Invoke;
using ::testing::NiceMock;
using ::testing::Return;
namespace L0 {
namespace ult {
ACTION_P(SetString, value) {
for (int i = 0; i < ZET_STRING_PROPERTY_SIZE; i++) {
arg0[i] = value[i];
}
}
ACTION_P(SetProcessList, value) {
arg0 = value;
}
constexpr uint32_t pid1 = 1711u;
constexpr uint32_t pid2 = 1722u;
constexpr uint32_t pid3 = 1733u;
constexpr int64_t memSize1 = 0;
constexpr int64_t memSize2 = 0;
constexpr int64_t memSize3 = 0;
constexpr int64_t engines1 = 12u;
constexpr int64_t engines2 = 10u;
constexpr int64_t engines3 = 4u;
class SysmanSysmanDeviceFixture : public DeviceFixture, public ::testing::Test {
protected:
SysmanImp *sysmanImp;
zet_sysman_handle_t hSysman;
Mock<OsSysmanDevice> *pOsSysmanDevice;
L0::SysmanDeviceImp *pSysmanDevice;
L0::SysmanDevice *pSysmanDevice_prev;
ze_device_handle_t hCoreDevice;
zet_process_state_t mockProcessState1 = {pid1, memSize1, engines1};
zet_process_state_t mockProcessState2 = {pid2, memSize2, engines2};
zet_process_state_t mockProcessState3 = {pid3, memSize3, engines3};
std::vector<zet_process_state_t> mockProcessStates{mockProcessState1, mockProcessState2, mockProcessState3};
void SetUp() override {
DeviceFixture::SetUp();
sysmanImp = new SysmanImp(device->toHandle());
pOsSysmanDevice = new NiceMock<Mock<OsSysmanDevice>>;
hCoreDevice = device->toHandle();
pSysmanDevice = new SysmanDeviceImp();
pSysmanDevice->hCoreDevice = hCoreDevice;
pSysmanDevice->pOsSysmanDevice = pOsSysmanDevice;
ON_CALL(*pOsSysmanDevice, getSerialNumber(_))
.WillByDefault(DoAll(
SetString("validserialnumber"),
Return()));
ON_CALL(*pOsSysmanDevice, getBoardNumber(_))
.WillByDefault(DoAll(
SetString("validboardnumber"),
Return()));
ON_CALL(*pOsSysmanDevice, getBrandName(_))
.WillByDefault(DoAll(
SetString("intel"),
Return()));
ON_CALL(*pOsSysmanDevice, getModelName(_))
.WillByDefault(DoAll(
SetString("skl"),
Return()));
ON_CALL(*pOsSysmanDevice, getVendorName(_))
.WillByDefault(DoAll(
SetString("intel"),
Return()));
ON_CALL(*pOsSysmanDevice, getDriverVersion(_))
.WillByDefault(DoAll(
SetString("5.0.0-37-generic SMP mod_unload"),
Return()));
ON_CALL(*pOsSysmanDevice, reset())
.WillByDefault(Return(ZE_RESULT_SUCCESS));
ON_CALL(*pOsSysmanDevice, scanProcessesState(_))
.WillByDefault(DoAll(
SetProcessList(mockProcessStates),
Return(ZE_RESULT_SUCCESS)));
pSysmanDevice_prev = sysmanImp->pSysmanDevice;
sysmanImp->pSysmanDevice = static_cast<L0::SysmanDevice *>(pSysmanDevice);
hSysman = sysmanImp->toHandle();
}
void TearDown() override {
// restore state
sysmanImp->pSysmanDevice = pSysmanDevice_prev;
// cleanup
if (pSysmanDevice != nullptr) {
delete pSysmanDevice;
pSysmanDevice = nullptr;
}
if (sysmanImp != nullptr) {
delete sysmanImp;
sysmanImp = nullptr;
}
DeviceFixture::TearDown();
}
};
TEST_F(SysmanSysmanDeviceFixture, GivenValidSysmanHandleWhenCallingzetSysmanDeviceGetPropertiesThenVerifyzetSysmanDeviceGetPropertiesCallSucceeds) {
zet_sysman_properties_t properties;
ze_result_t result = zetSysmanDeviceGetProperties(hSysman, &properties);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
}
TEST_F(SysmanSysmanDeviceFixture, GivenValidSysmanHandleWhileRetrievingInformationAboutHostProcessesUsingDeviceThenSuccessIsReturned) {
uint32_t count = 0;
ASSERT_EQ(ZE_RESULT_SUCCESS, zetSysmanProcessesGetState(hSysman, &count, nullptr));
EXPECT_EQ(count, 3u);
std::vector<zet_process_state_t> processes(count);
ASSERT_EQ(ZE_RESULT_SUCCESS, zetSysmanProcessesGetState(hSysman, &count, processes.data()));
EXPECT_EQ(count, 3u);
EXPECT_EQ(processes[0].processId, pid1);
EXPECT_EQ(processes[1].processId, pid2);
EXPECT_EQ(processes[2].processId, pid3);
EXPECT_EQ(processes[0].engines, engines1);
EXPECT_EQ(processes[1].engines, engines2);
EXPECT_EQ(processes[2].engines, engines3);
EXPECT_EQ(processes[0].memSize, memSize1);
EXPECT_EQ(processes[1].memSize, memSize2);
EXPECT_EQ(processes[2].memSize, memSize3);
}
} // namespace ult
} // namespace L0

View File

@@ -7,7 +7,7 @@
#include "test.h"
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
#include "level_zero/tools/test/unit_tests/sources/sysman/mock_sysman_fixture.h"
namespace L0 {
namespace ult {
@@ -21,5 +21,70 @@ TEST_F(SysmanGetTest, whenCallingZetSysmanGetWithoutCallingZetInitThenUnitialize
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, res);
}
using MockDeviceSysmanGetTest = Test<DeviceFixture>;
TEST_F(MockDeviceSysmanGetTest, GivenValidSysmanHandleSetInDeviceStructWhenGetThisSysmanHandleThenHandlesShouldBeSimilar) {
SysmanDeviceImp *sysman = new SysmanDeviceImp(device->toHandle());
device->setSysmanHandle(sysman);
EXPECT_EQ(sysman, device->getSysmanHandle());
}
TEST_F(SysmanDeviceFixture, GivenSysmanEnvironmentSetWhenEnumertatingSysmanHandlesThenValidSysmanHandleReceived) {
zes_device_handle_t hSysman = device->toHandle();
auto pSysmanDevice = L0::SysmanDeviceHandleContext::init(hSysman);
EXPECT_NE(pSysmanDevice, nullptr);
delete pSysmanDevice;
pSysmanDevice = nullptr;
}
TEST_F(SysmanDeviceFixture, GivenSysmanEnvironmentNotSetWhenEnumertatingSysmanHandlesThenNullSysmanHandleReceived) {
zes_device_handle_t hSysman = device->toHandle();
unsetenv("ZES_ENABLE_SYSMAN");
EXPECT_EQ(L0::SysmanDeviceHandleContext::init(hSysman), nullptr);
}
TEST_F(SysmanDeviceFixture, GivenSetValidDrmHandleForDeviceWhenDoingOsSysmanDeviceInitThenSameDrmHandleIsRetrieved) {
EXPECT_EQ(&pLinuxSysmanImp->getDrm(), device->getOsInterface().get()->getDrm());
}
TEST_F(SysmanDeviceFixture, GivenCreateFsAccessHandleWhenCallinggetFsAccessThenCreatedFsAccessHandleWillBeRetrieved) {
if (pLinuxSysmanImp->pFsAccess != nullptr) {
//delete previously allocated pFsAccess
delete pLinuxSysmanImp->pFsAccess;
pLinuxSysmanImp->pFsAccess = nullptr;
}
pLinuxSysmanImp->pFsAccess = FsAccess::create();
EXPECT_EQ(&pLinuxSysmanImp->getFsAccess(), pLinuxSysmanImp->pFsAccess);
}
TEST_F(SysmanDeviceFixture, GivenCreateSysfsAccessHandleWhenCallinggetSysfsAccessThenCreatedSysfsAccessHandleHandleWillBeRetrieved) {
if (pLinuxSysmanImp->pSysfsAccess != nullptr) {
//delete previously allocated pSysfsAccess
delete pLinuxSysmanImp->pSysfsAccess;
pLinuxSysmanImp->pSysfsAccess = nullptr;
}
pLinuxSysmanImp->pSysfsAccess = SysfsAccess::create("");
EXPECT_EQ(&pLinuxSysmanImp->getSysfsAccess(), pLinuxSysmanImp->pSysfsAccess);
}
TEST_F(SysmanDeviceFixture, GivenCreateProcfsAccessHandleWhenCallinggetProcfsAccessThenCreatedProcfsAccessHandleWillBeRetrieved) {
if (pLinuxSysmanImp->pProcfsAccess != nullptr) {
//delete previously allocated pProcfsAccess
delete pLinuxSysmanImp->pProcfsAccess;
pLinuxSysmanImp->pProcfsAccess = nullptr;
}
pLinuxSysmanImp->pProcfsAccess = ProcfsAccess::create();
EXPECT_EQ(&pLinuxSysmanImp->getProcfsAccess(), pLinuxSysmanImp->pProcfsAccess);
}
TEST_F(SysmanDeviceFixture, GivenPmtHandleWhenCallinggetPlatformMonitoringTechAccessThenCreatedPmtHandleWillBeRetrieved) {
if (pLinuxSysmanImp->pPmt != nullptr) {
//delete previously allocated pPmt
delete pLinuxSysmanImp->pPmt;
pLinuxSysmanImp->pPmt = nullptr;
}
pLinuxSysmanImp->pPmt = new PlatformMonitoringTech();
EXPECT_EQ(&pLinuxSysmanImp->getPlatformMonitoringTechAccess(), pLinuxSysmanImp->pPmt);
}
} // namespace ult
} // namespace L0

68
third_party/level_zero/zes_api_ext.h vendored Normal file
View File

@@ -0,0 +1,68 @@
/*
*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#ifndef _ZES_API_EXT_H
#define _ZES_API_EXT_H
#if defined(__cplusplus)
#pragma once
#endif
// 'core' API headers
#include "third_party/level_zero/ze_api_ext.h"
#if defined(__cplusplus)
extern "C" {
#endif
// Intel 'oneAPI' Level-Zero Sysman API common types
///////////////////////////////////////////////////////////////////////////////
/// @brief Handle to a driver instance
typedef ze_driver_handle_t zes_driver_handle_t;
///////////////////////////////////////////////////////////////////////////////
/// @brief Handle of device object
typedef ze_device_handle_t zes_device_handle_t;
///////////////////////////////////////////////////////////////////////////////
/// @brief Handle for a Sysman device power domain
typedef struct _zes_pwr_handle_t *zes_pwr_handle_t;
///////////////////////////////////////////////////////////////////////////////
/// @brief Get handle of power domains
///
/// @details
/// - The application may call this function from simultaneous threads.
/// - The implementation of this function should be lock-free.
///
/// @returns
/// - ::ZE_RESULT_SUCCESS
/// - ::ZE_RESULT_ERROR_UNINITIALIZED
/// - ::ZE_RESULT_ERROR_DEVICE_LOST
/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `nullptr == hDevice`
/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER
/// + `nullptr == pCount`
ZE_APIEXPORT ze_result_t ZE_APICALL
zesDeviceEnumPowerDomains(
zes_device_handle_t hDevice, ///< [in] Sysman handle of the device.
uint32_t *pCount, ///< [in,out] pointer to the number of components of this type.
///< if count is zero, then the driver will update the value with the total
///< number of components of this type.
///< if count is non-zero, then driver will only retrieve that number of components.
///< if count is larger than the number of components available, then the
///< driver will update the value with the correct number of components
///< that are returned.
zes_pwr_handle_t *phPower ///< [in,out][optional][range(0, *pCount)] array of handle of components of
///< this type
);
#if defined(__cplusplus)
} // extern "C"
#endif
#endif // _ZES_API_H