mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 10:17:01 +08:00
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:
@@ -8,6 +8,7 @@
|
|||||||
#include <level_zero/zet_api.h>
|
#include <level_zero/zet_api.h>
|
||||||
|
|
||||||
#include "sysman/sysman.h"
|
#include "sysman/sysman.h"
|
||||||
|
#include "third_party/level_zero/zes_api_ext.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
@@ -129,6 +130,14 @@ zetSysmanPciGetStats(
|
|||||||
return L0::Sysman::fromHandle(hSysman)->pciGetStats(pStats);
|
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
|
__zedllexport ze_result_t __zecall
|
||||||
zetSysmanPowerGet(
|
zetSysmanPowerGet(
|
||||||
zet_sysman_handle_t hSysman,
|
zet_sysman_handle_t hSysman,
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ struct DriverHandle;
|
|||||||
struct BuiltinFunctionsLib;
|
struct BuiltinFunctionsLib;
|
||||||
struct ExecutionEnvironment;
|
struct ExecutionEnvironment;
|
||||||
struct MetricContext;
|
struct MetricContext;
|
||||||
|
struct SysmanDevice;
|
||||||
|
|
||||||
struct Device : _ze_device_handle_t {
|
struct Device : _ze_device_handle_t {
|
||||||
virtual uint32_t getRootDeviceIndex() = 0;
|
virtual uint32_t getRootDeviceIndex() = 0;
|
||||||
@@ -122,6 +123,8 @@ struct Device : _ze_device_handle_t {
|
|||||||
size_t size, struct CommandList *commandList) = 0;
|
size_t size, struct CommandList *commandList) = 0;
|
||||||
|
|
||||||
virtual NEO::GraphicsAllocation *allocateMemoryFromHostPtr(const void *buffer, size_t size) = 0;
|
virtual NEO::GraphicsAllocation *allocateMemoryFromHostPtr(const void *buffer, size_t size) = 0;
|
||||||
|
virtual void setSysmanHandle(SysmanDevice *pSysmanDevice) = 0;
|
||||||
|
virtual SysmanDevice *getSysmanHandle() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
#include "level_zero/core/source/printf_handler/printf_handler.h"
|
#include "level_zero/core/source/printf_handler/printf_handler.h"
|
||||||
#include "level_zero/core/source/sampler/sampler.h"
|
#include "level_zero/core/source/sampler/sampler.h"
|
||||||
#include "level_zero/tools/source/metrics/metric.h"
|
#include "level_zero/tools/source/metrics/metric.h"
|
||||||
|
#include "level_zero/tools/source/sysman/sysman.h"
|
||||||
|
|
||||||
#include "hw_helpers.h"
|
#include "hw_helpers.h"
|
||||||
|
|
||||||
@@ -653,6 +654,7 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, uint3
|
|||||||
->notifyNewDevice(osInterface ? osInterface->getDeviceHandle() : 0);
|
->notifyNewDevice(osInterface ? osInterface->getDeviceHandle() : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
device->setSysmanHandle(L0::SysmanDeviceHandleContext::init(device->toHandle()));
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -678,6 +680,11 @@ DeviceImp::~DeviceImp() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pSysmanDevice != nullptr) {
|
||||||
|
delete pSysmanDevice;
|
||||||
|
pSysmanDevice = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
if (neoDevice) {
|
if (neoDevice) {
|
||||||
neoDevice->decRefInternal();
|
neoDevice->decRefInternal();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
#include "level_zero/tools/source/tracing/tracing.h"
|
#include "level_zero/tools/source/tracing/tracing.h"
|
||||||
|
|
||||||
namespace L0 {
|
namespace L0 {
|
||||||
|
struct SysmanDevice;
|
||||||
struct DeviceImp : public Device {
|
struct DeviceImp : public Device {
|
||||||
uint32_t getRootDeviceIndex() override;
|
uint32_t getRootDeviceIndex() override;
|
||||||
ze_result_t canAccessPeer(ze_device_handle_t hPeerDevice, ze_bool_t *value) 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;
|
~DeviceImp() override;
|
||||||
NEO::GraphicsAllocation *allocateManagedMemoryFromHostPtr(void *buffer, size_t size, struct CommandList *commandList) override;
|
NEO::GraphicsAllocation *allocateManagedMemoryFromHostPtr(void *buffer, size_t size, struct CommandList *commandList) override;
|
||||||
NEO::GraphicsAllocation *allocateMemoryFromHostPtr(const void *buffer, size_t size) override;
|
NEO::GraphicsAllocation *allocateMemoryFromHostPtr(const void *buffer, size_t size) override;
|
||||||
|
void setSysmanHandle(SysmanDevice *pSysman) override;
|
||||||
|
SysmanDevice *getSysmanHandle() override;
|
||||||
|
|
||||||
NEO::Device *neoDevice = nullptr;
|
NEO::Device *neoDevice = nullptr;
|
||||||
bool isSubdevice = false;
|
bool isSubdevice = false;
|
||||||
@@ -110,6 +112,7 @@ struct DeviceImp : public Device {
|
|||||||
return ZE_RESULT_SUCCESS;
|
return ZE_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
NEO::GraphicsAllocation *debugSurface = nullptr;
|
NEO::GraphicsAllocation *debugSurface = nullptr;
|
||||||
|
SysmanDevice *pSysmanDevice = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|||||||
@@ -109,6 +109,8 @@ struct Mock<Device> : public Device {
|
|||||||
MOCK_CONST_METHOD0(getDebugSurface, NEO::GraphicsAllocation *());
|
MOCK_CONST_METHOD0(getDebugSurface, NEO::GraphicsAllocation *());
|
||||||
MOCK_METHOD3(allocateManagedMemoryFromHostPtr, NEO::GraphicsAllocation *(void *buffer, size_t size, struct L0::CommandList *commandList));
|
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_METHOD2(allocateMemoryFromHostPtr, NEO::GraphicsAllocation *(const void *buffer, size_t size));
|
||||||
|
MOCK_METHOD1(setSysmanHandle, void(SysmanDevice *));
|
||||||
|
MOCK_METHOD0(getSysmanHandle, SysmanDevice *());
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
|||||||
@@ -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})
|
||||||
@@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
namespace L0 {
|
namespace L0 {
|
||||||
|
|
||||||
class SysmanDevice {
|
class GlobalOperations {
|
||||||
public:
|
public:
|
||||||
virtual ~SysmanDevice(){};
|
virtual ~GlobalOperations(){};
|
||||||
virtual ze_result_t deviceGetProperties(zet_sysman_properties_t *pProperties) = 0;
|
virtual ze_result_t deviceGetProperties(zet_sysman_properties_t *pProperties) = 0;
|
||||||
virtual ze_result_t reset() = 0;
|
virtual ze_result_t reset() = 0;
|
||||||
virtual ze_result_t processesGetState(uint32_t *pCount, zet_process_state_t *pProcesses) = 0;
|
virtual ze_result_t processesGetState(uint32_t *pCount, zet_process_state_t *pProcesses) = 0;
|
||||||
@@ -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/basic_math.h"
|
||||||
#include "shared/source/helpers/debug_helpers.h"
|
#include "shared/source/helpers/debug_helpers.h"
|
||||||
@@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
namespace L0 {
|
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;
|
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) {
|
if (result != ZE_RESULT_SUCCESS) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ ze_result_t SysmanDeviceImp::processesGetState(uint32_t *pCount, zet_process_sta
|
|||||||
return result;
|
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);
|
Device *device = L0::Device::fromHandle(hCoreDevice);
|
||||||
ze_device_properties_t deviceProperties;
|
ze_device_properties_t deviceProperties;
|
||||||
device->getProperties(&deviceProperties);
|
device->getProperties(&deviceProperties);
|
||||||
@@ -50,26 +50,26 @@ ze_result_t SysmanDeviceImp::deviceGetProperties(zet_sysman_properties_t *pPrope
|
|||||||
return ZE_RESULT_SUCCESS;
|
return ZE_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
ze_result_t SysmanDeviceImp::reset() {
|
ze_result_t GlobalOperationsImp::reset() {
|
||||||
return pOsSysmanDevice->reset();
|
return pOsGlobalOperations->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SysmanDeviceImp::init() {
|
void GlobalOperationsImp::init() {
|
||||||
if (pOsSysmanDevice == nullptr) {
|
if (pOsGlobalOperations == nullptr) {
|
||||||
pOsSysmanDevice = OsSysmanDevice::create(pOsSysman);
|
pOsGlobalOperations = OsGlobalOperations::create(pOsSysman);
|
||||||
}
|
}
|
||||||
UNRECOVERABLE_IF(nullptr == pOsSysmanDevice);
|
UNRECOVERABLE_IF(nullptr == pOsGlobalOperations);
|
||||||
pOsSysmanDevice->getVendorName(sysmanProperties.vendorName);
|
pOsGlobalOperations->getVendorName(sysmanProperties.vendorName);
|
||||||
pOsSysmanDevice->getDriverVersion(sysmanProperties.driverVersion);
|
pOsGlobalOperations->getDriverVersion(sysmanProperties.driverVersion);
|
||||||
pOsSysmanDevice->getModelName(sysmanProperties.modelName);
|
pOsGlobalOperations->getModelName(sysmanProperties.modelName);
|
||||||
pOsSysmanDevice->getBrandName(sysmanProperties.brandName);
|
pOsGlobalOperations->getBrandName(sysmanProperties.brandName);
|
||||||
pOsSysmanDevice->getBoardNumber(sysmanProperties.boardNumber);
|
pOsGlobalOperations->getBoardNumber(sysmanProperties.boardNumber);
|
||||||
pOsSysmanDevice->getSerialNumber(sysmanProperties.serialNumber);
|
pOsGlobalOperations->getSerialNumber(sysmanProperties.serialNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
SysmanDeviceImp::~SysmanDeviceImp() {
|
GlobalOperationsImp::~GlobalOperationsImp() {
|
||||||
if (nullptr != pOsSysmanDevice) {
|
if (nullptr != pOsGlobalOperations) {
|
||||||
delete pOsSysmanDevice;
|
delete pOsGlobalOperations;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -10,27 +10,27 @@
|
|||||||
|
|
||||||
#include <level_zero/zet_api.h>
|
#include <level_zero/zet_api.h>
|
||||||
|
|
||||||
#include "os_sysman_device.h"
|
#include "global_operations.h"
|
||||||
#include "sysman_device.h"
|
#include "os_global_operations.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace L0 {
|
namespace L0 {
|
||||||
|
|
||||||
class SysmanDeviceImp : public SysmanDevice, NEO::NonCopyableOrMovableClass {
|
class GlobalOperationsImp : public GlobalOperations, NEO::NonCopyableOrMovableClass {
|
||||||
public:
|
public:
|
||||||
void init() override;
|
void init() override;
|
||||||
ze_result_t deviceGetProperties(zet_sysman_properties_t *pProperties) override;
|
ze_result_t deviceGetProperties(zet_sysman_properties_t *pProperties) override;
|
||||||
ze_result_t reset() override;
|
ze_result_t reset() override;
|
||||||
ze_result_t processesGetState(uint32_t *pCount, zet_process_state_t *pProcesses) 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 = {};
|
ze_device_handle_t hCoreDevice = {};
|
||||||
|
|
||||||
SysmanDeviceImp() = default;
|
GlobalOperationsImp() = default;
|
||||||
SysmanDeviceImp(OsSysman *pOsSysman, ze_device_handle_t hCoreDevice) : hCoreDevice(hCoreDevice),
|
GlobalOperationsImp(OsSysman *pOsSysman, ze_device_handle_t hCoreDevice) : hCoreDevice(hCoreDevice),
|
||||||
pOsSysman(pOsSysman){};
|
pOsSysman(pOsSysman){};
|
||||||
~SysmanDeviceImp() override;
|
~GlobalOperationsImp() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OsSysman *pOsSysman = nullptr;
|
OsSysman *pOsSysman = nullptr;
|
||||||
@@ -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})
|
||||||
@@ -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/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/linux/fs_access.h"
|
||||||
#include "level_zero/tools/source/sysman/sysman_device/sysman_device_imp.h"
|
|
||||||
#include <level_zero/zet_api.h>
|
#include <level_zero/zet_api.h>
|
||||||
|
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
@@ -19,13 +19,13 @@ namespace L0 {
|
|||||||
const std::string vendorIntel("Intel(R) Corporation");
|
const std::string vendorIntel("Intel(R) Corporation");
|
||||||
const std::string unknown("Unknown");
|
const std::string unknown("Unknown");
|
||||||
const std::string intelPciId("0x8086");
|
const std::string intelPciId("0x8086");
|
||||||
const std::string LinuxSysmanDeviceImp::deviceDir("device");
|
const std::string LinuxGlobalOperationsImp::deviceDir("device");
|
||||||
const std::string LinuxSysmanDeviceImp::vendorFile("device/vendor");
|
const std::string LinuxGlobalOperationsImp::vendorFile("device/vendor");
|
||||||
const std::string LinuxSysmanDeviceImp::deviceFile("device/device");
|
const std::string LinuxGlobalOperationsImp::deviceFile("device/device");
|
||||||
const std::string LinuxSysmanDeviceImp::subsystemVendorFile("device/subsystem_vendor");
|
const std::string LinuxGlobalOperationsImp::subsystemVendorFile("device/subsystem_vendor");
|
||||||
const std::string LinuxSysmanDeviceImp::driverFile("device/driver");
|
const std::string LinuxGlobalOperationsImp::driverFile("device/driver");
|
||||||
const std::string LinuxSysmanDeviceImp::functionLevelReset("device/reset");
|
const std::string LinuxGlobalOperationsImp::functionLevelReset("device/reset");
|
||||||
const std::string LinuxSysmanDeviceImp::clientsDir("clients");
|
const std::string LinuxGlobalOperationsImp::clientsDir("clients");
|
||||||
|
|
||||||
// Map engine entries(numeric values) present in /sys/class/drm/card<n>/clients/<client_n>/busy,
|
// Map engine entries(numeric values) present in /sys/class/drm/card<n>/clients/<client_n>/busy,
|
||||||
// with engine enum defined in leve-zero spec
|
// 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},
|
{3, ZET_ENGINE_TYPE_MEDIA},
|
||||||
{4, ZET_ENGINE_TYPE_COMPUTE}};
|
{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);
|
std::copy(unknown.begin(), unknown.end(), serialNumber);
|
||||||
serialNumber[unknown.size()] = '\0';
|
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);
|
std::copy(unknown.begin(), unknown.end(), boardNumber);
|
||||||
boardNumber[unknown.size()] = '\0';
|
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;
|
std::string strVal;
|
||||||
ze_result_t result = pSysfsAccess->read(subsystemVendorFile, strVal);
|
ze_result_t result = pSysfsAccess->read(subsystemVendorFile, strVal);
|
||||||
if (ZE_RESULT_SUCCESS != result) {
|
if (ZE_RESULT_SUCCESS != result) {
|
||||||
@@ -65,7 +65,7 @@ void LinuxSysmanDeviceImp::getBrandName(int8_t (&brandName)[ZET_STRING_PROPERTY_
|
|||||||
brandName[unknown.size()] = '\0';
|
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;
|
std::string strVal;
|
||||||
ze_result_t result = pSysfsAccess->read(deviceFile, strVal);
|
ze_result_t result = pSysfsAccess->read(deviceFile, strVal);
|
||||||
if (ZE_RESULT_SUCCESS != result) {
|
if (ZE_RESULT_SUCCESS != result) {
|
||||||
@@ -78,7 +78,7 @@ void LinuxSysmanDeviceImp::getModelName(int8_t (&modelName)[ZET_STRING_PROPERTY_
|
|||||||
modelName[strVal.size()] = '\0';
|
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;
|
std::string strVal;
|
||||||
ze_result_t result = pSysfsAccess->read(vendorFile, strVal);
|
ze_result_t result = pSysfsAccess->read(vendorFile, strVal);
|
||||||
if (ZE_RESULT_SUCCESS != result) {
|
if (ZE_RESULT_SUCCESS != result) {
|
||||||
@@ -95,7 +95,7 @@ void LinuxSysmanDeviceImp::getVendorName(int8_t (&vendorName)[ZET_STRING_PROPERT
|
|||||||
vendorName[unknown.size()] = '\0';
|
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);
|
std::copy(unknown.begin(), unknown.end(), driverVersion);
|
||||||
driverVersion[unknown.size()] = '\0';
|
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();
|
FsAccess *pFsAccess = &pLinuxSysmanImp->getFsAccess();
|
||||||
ProcfsAccess *pProcfsAccess = &pLinuxSysmanImp->getProcfsAccess();
|
ProcfsAccess *pProcfsAccess = &pLinuxSysmanImp->getProcfsAccess();
|
||||||
SysfsAccess *pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
|
SysfsAccess *pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
|
||||||
@@ -228,7 +228,7 @@ ze_result_t LinuxSysmanDeviceImp::reset() {
|
|||||||
// accumulated nanoseconds each client spent on engines.
|
// 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
|
// 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.
|
// 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;
|
std::vector<std::string> clientIds;
|
||||||
ze_result_t result = pSysfsAccess->scanDirEntries(clientsDir, clientIds);
|
ze_result_t result = pSysfsAccess->scanDirEntries(clientsDir, clientIds);
|
||||||
if (ZE_RESULT_SUCCESS != result) {
|
if (ZE_RESULT_SUCCESS != result) {
|
||||||
@@ -311,15 +311,15 @@ ze_result_t LinuxSysmanDeviceImp::scanProcessesState(std::vector<zet_process_sta
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
LinuxSysmanDeviceImp::LinuxSysmanDeviceImp(OsSysman *pOsSysman) {
|
LinuxGlobalOperationsImp::LinuxGlobalOperationsImp(OsSysman *pOsSysman) {
|
||||||
pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
|
pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
|
||||||
|
|
||||||
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
|
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
OsSysmanDevice *OsSysmanDevice::create(OsSysman *pOsSysman) {
|
OsGlobalOperations *OsGlobalOperations::create(OsSysman *pOsSysman) {
|
||||||
LinuxSysmanDeviceImp *pLinuxSysmanDeviceImp = new LinuxSysmanDeviceImp(pOsSysman);
|
LinuxGlobalOperationsImp *pLinuxGlobalOperationsImp = new LinuxGlobalOperationsImp(pOsSysman);
|
||||||
return static_cast<OsSysmanDevice *>(pLinuxSysmanDeviceImp);
|
return static_cast<OsGlobalOperations *>(pLinuxGlobalOperationsImp);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
@@ -6,14 +6,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#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/linux/os_sysman_imp.h"
|
||||||
#include "level_zero/tools/source/sysman/sysman_device/os_sysman_device.h"
|
|
||||||
|
|
||||||
namespace L0 {
|
namespace L0 {
|
||||||
|
|
||||||
class SysfsAccess;
|
class SysfsAccess;
|
||||||
|
|
||||||
class LinuxSysmanDeviceImp : public OsSysmanDevice, NEO::NonCopyableOrMovableClass {
|
class LinuxGlobalOperationsImp : public OsGlobalOperations, NEO::NonCopyableOrMovableClass {
|
||||||
public:
|
public:
|
||||||
void getSerialNumber(int8_t (&serialNumber)[ZET_STRING_PROPERTY_SIZE]) override;
|
void getSerialNumber(int8_t (&serialNumber)[ZET_STRING_PROPERTY_SIZE]) override;
|
||||||
void getBoardNumber(int8_t (&boardNumber)[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;
|
void getDriverVersion(int8_t (&driverVersion)[ZET_STRING_PROPERTY_SIZE]) override;
|
||||||
ze_result_t reset() override;
|
ze_result_t reset() override;
|
||||||
ze_result_t scanProcessesState(std::vector<zet_process_state_t> &pProcessList) override;
|
ze_result_t scanProcessesState(std::vector<zet_process_state_t> &pProcessList) override;
|
||||||
LinuxSysmanDeviceImp() = default;
|
LinuxGlobalOperationsImp() = default;
|
||||||
LinuxSysmanDeviceImp(OsSysman *pOsSysman);
|
LinuxGlobalOperationsImp(OsSysman *pOsSysman);
|
||||||
~LinuxSysmanDeviceImp() override = default;
|
~LinuxGlobalOperationsImp() override = default;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SysfsAccess *pSysfsAccess = nullptr;
|
SysfsAccess *pSysfsAccess = nullptr;
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
namespace L0 {
|
namespace L0 {
|
||||||
|
|
||||||
class OsSysmanDevice {
|
class OsGlobalOperations {
|
||||||
public:
|
public:
|
||||||
virtual void getSerialNumber(int8_t (&serialNumber)[ZET_STRING_PROPERTY_SIZE]) = 0;
|
virtual void getSerialNumber(int8_t (&serialNumber)[ZET_STRING_PROPERTY_SIZE]) = 0;
|
||||||
virtual void getBoardNumber(int8_t (&boardNumber)[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 void getDriverVersion(int8_t (&driverVersion)[ZET_STRING_PROPERTY_SIZE]) = 0;
|
||||||
virtual ze_result_t reset() = 0;
|
virtual ze_result_t reset() = 0;
|
||||||
virtual ze_result_t scanProcessesState(std::vector<zet_process_state_t> &pProcessList) = 0;
|
virtual ze_result_t scanProcessesState(std::vector<zet_process_state_t> &pProcessList) = 0;
|
||||||
static OsSysmanDevice *create(OsSysman *pOsSysman);
|
static OsGlobalOperations *create(OsSysman *pOsSysman);
|
||||||
virtual ~OsSysmanDevice() {}
|
virtual ~OsGlobalOperations() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
@@ -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})
|
||||||
|
|
||||||
@@ -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
|
||||||
@@ -18,7 +18,15 @@ ze_result_t LinuxSysmanImp::init() {
|
|||||||
pProcfsAccess = ProcfsAccess::create();
|
pProcfsAccess = ProcfsAccess::create();
|
||||||
UNRECOVERABLE_IF(nullptr == pProcfsAccess);
|
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();
|
NEO::OSInterface &OsInterface = pDevice->getOsInterface();
|
||||||
pDrm = OsInterface.get()->getDrm();
|
pDrm = OsInterface.get()->getDrm();
|
||||||
int myDeviceFd = pDrm->getFileDescriptor();
|
int myDeviceFd = pDrm->getFileDescriptor();
|
||||||
@@ -67,6 +75,10 @@ LinuxSysmanImp::LinuxSysmanImp(SysmanImp *pParentSysmanImp) {
|
|||||||
this->pParentSysmanImp = pParentSysmanImp;
|
this->pParentSysmanImp = pParentSysmanImp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LinuxSysmanImp::LinuxSysmanImp(SysmanDeviceImp *pParentSysmanDeviceImp) {
|
||||||
|
this->pParentSysmanDeviceImp = pParentSysmanDeviceImp;
|
||||||
|
}
|
||||||
|
|
||||||
LinuxSysmanImp::~LinuxSysmanImp() {
|
LinuxSysmanImp::~LinuxSysmanImp() {
|
||||||
if (nullptr != pSysfsAccess) {
|
if (nullptr != pSysfsAccess) {
|
||||||
delete pSysfsAccess;
|
delete pSysfsAccess;
|
||||||
@@ -91,4 +103,9 @@ OsSysman *OsSysman::create(SysmanImp *pParentSysmanImp) {
|
|||||||
return static_cast<OsSysman *>(pLinuxSysmanImp);
|
return static_cast<OsSysman *>(pLinuxSysmanImp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OsSysman *OsSysman::create(SysmanDeviceImp *pParentSysmanDeviceImp) {
|
||||||
|
LinuxSysmanImp *pLinuxSysmanImp = new LinuxSysmanImp(pParentSysmanDeviceImp);
|
||||||
|
return static_cast<OsSysman *>(pLinuxSysmanImp);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ namespace L0 {
|
|||||||
class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
|
class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
|
||||||
public:
|
public:
|
||||||
LinuxSysmanImp(SysmanImp *pParentSysmanImp);
|
LinuxSysmanImp(SysmanImp *pParentSysmanImp);
|
||||||
|
LinuxSysmanImp(SysmanDeviceImp *pParentSysmanDeviceImp);
|
||||||
~LinuxSysmanImp() override;
|
~LinuxSysmanImp() override;
|
||||||
|
|
||||||
ze_result_t init() override;
|
ze_result_t init() override;
|
||||||
@@ -29,14 +30,17 @@ class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
|
|||||||
NEO::Drm &getDrm();
|
NEO::Drm &getDrm();
|
||||||
PlatformMonitoringTech &getPlatformMonitoringTechAccess();
|
PlatformMonitoringTech &getPlatformMonitoringTechAccess();
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
LinuxSysmanImp() = delete;
|
|
||||||
SysmanImp *pParentSysmanImp = nullptr;
|
|
||||||
FsAccess *pFsAccess = nullptr;
|
FsAccess *pFsAccess = nullptr;
|
||||||
ProcfsAccess *pProcfsAccess = nullptr;
|
ProcfsAccess *pProcfsAccess = nullptr;
|
||||||
SysfsAccess *pSysfsAccess = nullptr;
|
SysfsAccess *pSysfsAccess = nullptr;
|
||||||
NEO::Drm *pDrm = nullptr;
|
|
||||||
PlatformMonitoringTech *pPmt = nullptr;
|
PlatformMonitoringTech *pPmt = nullptr;
|
||||||
|
|
||||||
|
private:
|
||||||
|
LinuxSysmanImp() = delete;
|
||||||
|
SysmanImp *pParentSysmanImp = nullptr;
|
||||||
|
SysmanDeviceImp *pParentSysmanDeviceImp = nullptr;
|
||||||
|
NEO::Drm *pDrm = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|||||||
@@ -11,12 +11,14 @@
|
|||||||
namespace L0 {
|
namespace L0 {
|
||||||
|
|
||||||
struct SysmanImp;
|
struct SysmanImp;
|
||||||
|
struct SysmanDeviceImp;
|
||||||
|
|
||||||
struct OsSysman {
|
struct OsSysman {
|
||||||
virtual ~OsSysman(){};
|
virtual ~OsSysman(){};
|
||||||
|
|
||||||
virtual ze_result_t init() = 0;
|
virtual ze_result_t init() = 0;
|
||||||
static OsSysman *create(SysmanImp *pSysmanImp);
|
static OsSysman *create(SysmanImp *pSysmanImp);
|
||||||
|
static OsSysman *create(SysmanDeviceImp *pSysmanImp);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "level_zero/tools/source/sysman/sysman.h"
|
#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.h"
|
||||||
#include "level_zero/core/source/driver/driver_handle_imp.h"
|
#include "level_zero/core/source/driver/driver_handle_imp.h"
|
||||||
#include "level_zero/tools/source/sysman/sysman_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;
|
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
|
} // namespace L0
|
||||||
|
|||||||
@@ -6,20 +6,23 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#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/engine/engine.h"
|
||||||
#include "level_zero/tools/source/sysman/fabric_port/fabric_port.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/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/memory/memory.h"
|
||||||
#include "level_zero/tools/source/sysman/pci/pci.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/power/power.h"
|
||||||
#include "level_zero/tools/source/sysman/ras/ras.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/scheduler/scheduler.h"
|
||||||
#include "level_zero/tools/source/sysman/standby/standby.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/tools/source/sysman/temperature/temperature.h"
|
||||||
#include <level_zero/zet_api.h>
|
#include <level_zero/zet_api.h>
|
||||||
#include <level_zero/zet_sysman.h>
|
#include <level_zero/zet_sysman.h>
|
||||||
|
|
||||||
|
#include "third_party/level_zero/zes_api_ext.h"
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
struct _zet_sysman_handle_t {};
|
struct _zet_sysman_handle_t {};
|
||||||
@@ -74,4 +77,18 @@ class SysmanHandleContext {
|
|||||||
std::unordered_map<zet_device_handle_t, zet_sysman_handle_t> handle_map;
|
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
|
} // namespace L0
|
||||||
|
|||||||
@@ -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})
|
|
||||||
@@ -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})
|
|
||||||
@@ -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})
|
|
||||||
|
|
||||||
@@ -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
|
|
||||||
@@ -9,22 +9,36 @@
|
|||||||
|
|
||||||
#include "level_zero/core/source/driver/driver.h"
|
#include "level_zero/core/source/driver/driver.h"
|
||||||
#include "level_zero/core/source/driver/driver_handle_imp.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/pci/pci_imp.h"
|
||||||
#include "level_zero/tools/source/sysman/scheduler/scheduler_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.h"
|
||||||
#include "level_zero/tools/source/sysman/sysman_device/sysman_device_imp.h"
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace L0 {
|
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) {
|
SysmanImp::SysmanImp(ze_device_handle_t hDevice) {
|
||||||
hCoreDevice = hDevice;
|
hCoreDevice = hDevice;
|
||||||
pOsSysman = OsSysman::create(this);
|
pOsSysman = OsSysman::create(this);
|
||||||
UNRECOVERABLE_IF(nullptr == pOsSysman);
|
UNRECOVERABLE_IF(nullptr == pOsSysman);
|
||||||
pPci = new PciImp(pOsSysman);
|
pPci = new PciImp(pOsSysman);
|
||||||
pSched = new SchedulerImp(pOsSysman);
|
pSched = new SchedulerImp(pOsSysman);
|
||||||
pSysmanDevice = new SysmanDeviceImp(pOsSysman, hCoreDevice);
|
pGlobalOperations = new GlobalOperationsImp(pOsSysman, hCoreDevice);
|
||||||
pFrequencyHandleContext = new FrequencyHandleContext(pOsSysman);
|
pFrequencyHandleContext = new FrequencyHandleContext(pOsSysman);
|
||||||
pStandbyHandleContext = new StandbyHandleContext(pOsSysman);
|
pStandbyHandleContext = new StandbyHandleContext(pOsSysman);
|
||||||
pMemoryHandleContext = new MemoryHandleContext(pOsSysman, hCoreDevice);
|
pMemoryHandleContext = new MemoryHandleContext(pOsSysman, hCoreDevice);
|
||||||
@@ -44,7 +58,7 @@ SysmanImp::~SysmanImp() {
|
|||||||
freeResource(pMemoryHandleContext);
|
freeResource(pMemoryHandleContext);
|
||||||
freeResource(pStandbyHandleContext);
|
freeResource(pStandbyHandleContext);
|
||||||
freeResource(pFrequencyHandleContext);
|
freeResource(pFrequencyHandleContext);
|
||||||
freeResource(pSysmanDevice);
|
freeResource(pGlobalOperations);
|
||||||
freeResource(pPci);
|
freeResource(pPci);
|
||||||
freeResource(pSched);
|
freeResource(pSched);
|
||||||
freeResource(pOsSysman);
|
freeResource(pOsSysman);
|
||||||
@@ -82,13 +96,13 @@ void SysmanImp::init() {
|
|||||||
if (pSched) {
|
if (pSched) {
|
||||||
pSched->init();
|
pSched->init();
|
||||||
}
|
}
|
||||||
if (pSysmanDevice) {
|
if (pGlobalOperations) {
|
||||||
pSysmanDevice->init();
|
pGlobalOperations->init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ze_result_t SysmanImp::deviceGetProperties(zet_sysman_properties_t *pProperties) {
|
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) {
|
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) {
|
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() {
|
ze_result_t SysmanImp::deviceReset() {
|
||||||
return pSysmanDevice->reset();
|
return pGlobalOperations->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
ze_result_t SysmanImp::deviceGetRepairStatus(zet_repair_status_t *pRepairStatus) {
|
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);
|
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) {
|
ze_result_t SysmanImp::frequencyGet(uint32_t *pCount, zet_sysman_freq_handle_t *phFrequency) {
|
||||||
return pFrequencyHandleContext->frequencyGet(pCount, phFrequency);
|
return pFrequencyHandleContext->frequencyGet(pCount, phFrequency);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ struct SysmanImp : Sysman, NEO::NonCopyableOrMovableClass {
|
|||||||
OsSysman *pOsSysman = nullptr;
|
OsSysman *pOsSysman = nullptr;
|
||||||
Pci *pPci = nullptr;
|
Pci *pPci = nullptr;
|
||||||
Scheduler *pSched = nullptr;
|
Scheduler *pSched = nullptr;
|
||||||
SysmanDevice *pSysmanDevice = nullptr;
|
GlobalOperations *pGlobalOperations = nullptr;
|
||||||
FrequencyHandleContext *pFrequencyHandleContext = nullptr;
|
FrequencyHandleContext *pFrequencyHandleContext = nullptr;
|
||||||
StandbyHandleContext *pStandbyHandleContext = nullptr;
|
StandbyHandleContext *pStandbyHandleContext = nullptr;
|
||||||
MemoryHandleContext *pMemoryHandleContext = 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
|
} // namespace L0
|
||||||
|
|||||||
@@ -18,4 +18,9 @@ OsSysman *OsSysman::create(SysmanImp *pParentSysmanImp) {
|
|||||||
return static_cast<OsSysman *>(pWddmSysmanImp);
|
return static_cast<OsSysman *>(pWddmSysmanImp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OsSysman *OsSysman::create(SysmanDeviceImp *pParentSysmanDeviceImp) {
|
||||||
|
WddmSysmanImp *pWddmSysmanImp = new WddmSysmanImp(pParentSysmanDeviceImp);
|
||||||
|
return static_cast<OsSysman *>(pWddmSysmanImp);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|||||||
@@ -15,13 +15,15 @@ namespace L0 {
|
|||||||
class WddmSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
|
class WddmSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
|
||||||
public:
|
public:
|
||||||
WddmSysmanImp(SysmanImp *pParentSysmanImp) : pParentSysmanImp(pParentSysmanImp){};
|
WddmSysmanImp(SysmanImp *pParentSysmanImp) : pParentSysmanImp(pParentSysmanImp){};
|
||||||
|
WddmSysmanImp(SysmanDeviceImp *pParentSysmanDeviceImp) : pParentSysmanDeviceImp(pParentSysmanDeviceImp){};
|
||||||
~WddmSysmanImp() override = default;
|
~WddmSysmanImp() override = default;
|
||||||
|
|
||||||
ze_result_t init() override;
|
ze_result_t init() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WddmSysmanImp() = delete;
|
WddmSysmanImp() = delete;
|
||||||
SysmanImp *pParentSysmanImp;
|
SysmanImp *pParentSysmanImp = nullptr;
|
||||||
|
SysmanDeviceImp *pParentSysmanDeviceImp = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|||||||
@@ -4,9 +4,12 @@
|
|||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
#
|
#
|
||||||
|
|
||||||
target_sources(${TARGET_NAME} PRIVATE
|
if(UNIX)
|
||||||
|
target_sources(${TARGET_NAME} PRIVATE
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman.cpp
|
||||||
)
|
${CMAKE_CURRENT_SOURCE_DIR}/mock_sysman_fixture.h
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectories()
|
add_subdirectories()
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ if(UNIX)
|
|||||||
target_sources(${TARGET_NAME}
|
target_sources(${TARGET_NAME}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/test_sysman_device.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/test_global_operations.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/mock_sysfs_sysman_device.h
|
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/mock_global_operations.h
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
@@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "level_zero/core/test/unit_tests/mock.h"
|
#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/global_operations/global_operations_imp.h"
|
||||||
#include "level_zero/tools/source/sysman/sysman_device/sysman_device_imp.h"
|
#include "level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.h"
|
||||||
|
|
||||||
#include "sysman/sysman.h"
|
#include "sysman/sysman.h"
|
||||||
|
|
||||||
@@ -38,10 +38,10 @@ const std::string engine1("1");
|
|||||||
const std::string engine2("2");
|
const std::string engine2("2");
|
||||||
const std::string engine3("3");
|
const std::string engine3("3");
|
||||||
|
|
||||||
class SysmanDeviceSysfsAccess : public SysfsAccess {};
|
class GlobalOperationsSysfsAccess : public SysfsAccess {};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Mock<SysmanDeviceSysfsAccess> : public SysfsAccess {
|
struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
|
||||||
ze_result_t getValString(const std::string file, std::string &val) {
|
ze_result_t getValString(const std::string file, std::string &val) {
|
||||||
if (file.compare(subsystemVendorFile) == 0) {
|
if (file.compare(subsystemVendorFile) == 0) {
|
||||||
val = "0x8086";
|
val = "0x8086";
|
||||||
@@ -91,17 +91,17 @@ struct Mock<SysmanDeviceSysfsAccess> : public SysfsAccess {
|
|||||||
return ZE_RESULT_SUCCESS;
|
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, std::string &val), (override));
|
||||||
MOCK_METHOD(ze_result_t, read, (const std::string file, uint64_t &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));
|
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:
|
public:
|
||||||
using LinuxSysmanDeviceImp::pLinuxSysmanImp;
|
using LinuxGlobalOperationsImp::pLinuxSysmanImp;
|
||||||
using LinuxSysmanDeviceImp::pSysfsAccess;
|
using LinuxGlobalOperationsImp::pSysfsAccess;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ult
|
} // namespace ult
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "mock_sysfs_sysman_device.h"
|
#include "mock_global_operations.h"
|
||||||
|
|
||||||
using ::testing::_;
|
using ::testing::_;
|
||||||
using ::testing::DoAll;
|
using ::testing::DoAll;
|
||||||
@@ -34,43 +34,43 @@ constexpr int64_t engines1 = 28u;
|
|||||||
constexpr int64_t engines2 = 4u;
|
constexpr int64_t engines2 = 4u;
|
||||||
constexpr uint32_t totalProcessStates = 2u; // Two process States for two pids
|
constexpr uint32_t totalProcessStates = 2u; // Two process States for two pids
|
||||||
const std::string expectedModelName("0x3ea5");
|
const std::string expectedModelName("0x3ea5");
|
||||||
class SysmanSysmanDeviceFixture : public DeviceFixture, public ::testing::Test {
|
class SysmanGlobalOperationsFixture : public DeviceFixture, public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr<SysmanImp> sysmanImp;
|
std::unique_ptr<SysmanImp> sysmanImp;
|
||||||
zet_sysman_handle_t hSysman;
|
zet_sysman_handle_t hSysman;
|
||||||
|
|
||||||
OsSysmanDevice *pOsSysmanDevice = nullptr;
|
OsGlobalOperations *pOsGlobalOperations = nullptr;
|
||||||
Mock<SysmanDeviceSysfsAccess> *pSysfsAccess = nullptr;
|
Mock<GlobalOperationsSysfsAccess> *pSysfsAccess = nullptr;
|
||||||
L0::SysmanDevice *pSysmanDevicePrev = nullptr;
|
L0::GlobalOperations *pGlobalOperationsPrev = nullptr;
|
||||||
L0::SysmanDeviceImp sysmanDeviceImp;
|
L0::GlobalOperationsImp globalOperationsImp;
|
||||||
PublicLinuxSysmanDeviceImp linuxSysmanDeviceImp;
|
PublicLinuxGlobalOperationsImp linuxGlobalOperationsImp;
|
||||||
|
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
DeviceFixture::SetUp();
|
DeviceFixture::SetUp();
|
||||||
sysmanImp = std::make_unique<SysmanImp>(device->toHandle());
|
sysmanImp = std::make_unique<SysmanImp>(device->toHandle());
|
||||||
pSysfsAccess = new NiceMock<Mock<SysmanDeviceSysfsAccess>>;
|
pSysfsAccess = new NiceMock<Mock<GlobalOperationsSysfsAccess>>;
|
||||||
linuxSysmanDeviceImp.pSysfsAccess = pSysfsAccess;
|
linuxGlobalOperationsImp.pSysfsAccess = pSysfsAccess;
|
||||||
pOsSysmanDevice = static_cast<OsSysmanDevice *>(&linuxSysmanDeviceImp);
|
pOsGlobalOperations = static_cast<OsGlobalOperations *>(&linuxGlobalOperationsImp);
|
||||||
|
|
||||||
ON_CALL(*pSysfsAccess, read(_, Matcher<std::string &>(_)))
|
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 &>(_)))
|
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(_, _))
|
ON_CALL(*pSysfsAccess, scanDirEntries(_, _))
|
||||||
.WillByDefault(::testing::Invoke(pSysfsAccess, &Mock<SysmanDeviceSysfsAccess>::getScannedDirEntries));
|
.WillByDefault(::testing::Invoke(pSysfsAccess, &Mock<GlobalOperationsSysfsAccess>::getScannedDirEntries));
|
||||||
|
|
||||||
pSysmanDevicePrev = sysmanImp->pSysmanDevice;
|
pGlobalOperationsPrev = sysmanImp->pGlobalOperations;
|
||||||
sysmanImp->pSysmanDevice = static_cast<SysmanDevice *>(&sysmanDeviceImp);
|
sysmanImp->pGlobalOperations = static_cast<GlobalOperations *>(&globalOperationsImp);
|
||||||
sysmanDeviceImp.pOsSysmanDevice = pOsSysmanDevice;
|
globalOperationsImp.pOsGlobalOperations = pOsGlobalOperations;
|
||||||
sysmanDeviceImp.hCoreDevice = sysmanImp->hCoreDevice;
|
globalOperationsImp.hCoreDevice = sysmanImp->hCoreDevice;
|
||||||
sysmanDeviceImp.init();
|
globalOperationsImp.init();
|
||||||
hSysman = sysmanImp->toHandle();
|
hSysman = sysmanImp->toHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TearDown() override {
|
void TearDown() override {
|
||||||
// restore state
|
// restore state
|
||||||
sysmanImp->pSysmanDevice = pSysmanDevicePrev;
|
sysmanImp->pGlobalOperations = pGlobalOperationsPrev;
|
||||||
sysmanDeviceImp.pOsSysmanDevice = nullptr;
|
globalOperationsImp.pOsGlobalOperations = nullptr;
|
||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
if (pSysfsAccess != nullptr) {
|
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;
|
zet_sysman_properties_t properties;
|
||||||
ze_result_t result = zetSysmanDeviceGetProperties(hSysman, &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()));
|
EXPECT_TRUE(0 == std::memcmp(properties.vendorName, vendorIntel.c_str(), vendorIntel.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SysmanSysmanDeviceFixture, GivenValidSysmanHandleWhileRetrievingInformationAboutHostProcessesUsingDeviceThenSuccessIsReturned) {
|
TEST_F(SysmanGlobalOperationsFixture, GivenValidSysmanHandleWhileRetrievingInformationAboutHostProcessesUsingDeviceThenSuccessIsReturned) {
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
ASSERT_EQ(ZE_RESULT_SUCCESS, zetSysmanProcessesGetState(hSysman, &count, nullptr));
|
ASSERT_EQ(ZE_RESULT_SUCCESS, zetSysmanProcessesGetState(hSysman, &count, nullptr));
|
||||||
EXPECT_EQ(count, totalProcessStates);
|
EXPECT_EQ(count, totalProcessStates);
|
||||||
@@ -109,7 +109,7 @@ TEST_F(SysmanSysmanDeviceFixture, GivenValidSysmanHandleWhileRetrievingInformati
|
|||||||
EXPECT_EQ(processes[1].memSize, memSize2);
|
EXPECT_EQ(processes[1].memSize, memSize2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SysmanSysmanDeviceFixture, GivenValidSysmanHandleWhileReadingNonExistingFileThenErrorIsReturned) {
|
TEST_F(SysmanGlobalOperationsFixture, GivenValidSysmanHandleWhileReadingNonExistingFileThenErrorIsReturned) {
|
||||||
std::vector<std::string> engineEntries;
|
std::vector<std::string> engineEntries;
|
||||||
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, pSysfsAccess->scanDirEntries("clients/7/busy", engineEntries));
|
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, pSysfsAccess->scanDirEntries("clients/7/busy", engineEntries));
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
@@ -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/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 "gmock/gmock.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "mock_sysfs_power.h"
|
#include "mock_sysfs_power.h"
|
||||||
#include "sysman/linux/os_sysman_imp.h"
|
|
||||||
#include "sysman/power/power_imp.h"
|
#include "sysman/power/power_imp.h"
|
||||||
|
|
||||||
using ::testing::_;
|
|
||||||
using ::testing::NiceMock;
|
|
||||||
|
|
||||||
namespace L0 {
|
namespace L0 {
|
||||||
namespace ult {
|
namespace ult {
|
||||||
|
|
||||||
constexpr uint64_t convertJouleToMicroJoule = 1000000u;
|
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 {
|
class SysmanPowerFixture : public DeviceFixture, public ::testing::Test {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -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()
|
|
||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include "test.h"
|
#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 L0 {
|
||||||
namespace ult {
|
namespace ult {
|
||||||
@@ -21,5 +21,70 @@ TEST_F(SysmanGetTest, whenCallingZetSysmanGetWithoutCallingZetInitThenUnitialize
|
|||||||
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, res);
|
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 ult
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
68
third_party/level_zero/zes_api_ext.h
vendored
Normal file
68
third_party/level_zero/zes_api_ext.h
vendored
Normal 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
|
||||||
Reference in New Issue
Block a user