mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
sysman: add diagnostics boilerplate code
Signed-off-by: Vilvaraj, T J Vivek <t.j.vivek.vilvaraj@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
d264dc858f
commit
457d05420d
25
level_zero/tools/source/sysman/diagnostics/CMakeLists.txt
Normal file
25
level_zero/tools/source/sysman/diagnostics/CMakeLists.txt
Normal file
@@ -0,0 +1,25 @@
|
||||
#
|
||||
# Copyright (C) 2020-2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(L0_SRCS_TOOLS_SYSMAN_DIAGNOSTICS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/diagnostics.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/diagnostics.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/diagnostics_imp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/diagnostics_imp.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_diagnostics.h
|
||||
)
|
||||
|
||||
target_sources(${L0_STATIC_LIB_NAME}
|
||||
PRIVATE
|
||||
${L0_SRCS_TOOLS_SYSMAN_DIAGNOSTICS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
)
|
||||
|
||||
add_subdirectories()
|
||||
|
||||
# Make our source files visible to parent
|
||||
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_SYSMAN_DIAGNOSTICS ${L0_SRCS_TOOLS_SYSMAN_DIAGNOSTICS})
|
||||
|
||||
47
level_zero/tools/source/sysman/diagnostics/diagnostics.cpp
Normal file
47
level_zero/tools/source/sysman/diagnostics/diagnostics.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/basic_math.h"
|
||||
|
||||
#include "level_zero/tools/source/sysman/diagnostics/diagnostics_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
class OsDiagnostics;
|
||||
DiagnosticsHandleContext::~DiagnosticsHandleContext() {
|
||||
for (Diagnostics *pDiagnostics : handleList) {
|
||||
delete pDiagnostics;
|
||||
}
|
||||
handleList.clear();
|
||||
}
|
||||
|
||||
void DiagnosticsHandleContext::createHandle() {
|
||||
Diagnostics *pDiagnostics = new DiagnosticsImp(pOsSysman);
|
||||
if (pDiagnostics->isDiagnosticsEnabled == true) {
|
||||
handleList.push_back(pDiagnostics);
|
||||
} else {
|
||||
delete pDiagnostics;
|
||||
}
|
||||
}
|
||||
|
||||
void DiagnosticsHandleContext::init() {
|
||||
createHandle();
|
||||
}
|
||||
|
||||
ze_result_t DiagnosticsHandleContext::diagnosticsGet(uint32_t *pCount, zes_diag_handle_t *phDiagnostics) {
|
||||
uint32_t handleListSize = static_cast<uint32_t>(handleList.size());
|
||||
uint32_t numToCopy = std::min(*pCount, handleListSize);
|
||||
if (0 == *pCount || *pCount > handleListSize) {
|
||||
*pCount = handleListSize;
|
||||
}
|
||||
if (nullptr != phDiagnostics) {
|
||||
for (uint32_t i = 0; i < numToCopy; i++) {
|
||||
phDiagnostics[i] = handleList[i]->toHandle();
|
||||
}
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
} // namespace L0
|
||||
49
level_zero/tools/source/sysman/diagnostics/diagnostics.h
Normal file
49
level_zero/tools/source/sysman/diagnostics/diagnostics.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <level_zero/zes_api.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct _zes_diag_handle_t {
|
||||
virtual ~_zes_diag_handle_t() = default;
|
||||
};
|
||||
|
||||
namespace L0 {
|
||||
|
||||
struct OsSysman;
|
||||
|
||||
class Diagnostics : _zes_diag_handle_t {
|
||||
public:
|
||||
virtual ~Diagnostics() {}
|
||||
virtual ze_result_t diagnosticsGetProperties(zes_diag_properties_t *pProperties) = 0;
|
||||
inline zes_diag_handle_t toHandle() { return this; }
|
||||
|
||||
static Diagnostics *fromHandle(zes_diag_handle_t handle) {
|
||||
return static_cast<Diagnostics *>(handle);
|
||||
}
|
||||
bool isDiagnosticsEnabled = false;
|
||||
};
|
||||
|
||||
struct DiagnosticsHandleContext {
|
||||
DiagnosticsHandleContext(OsSysman *pOsSysman) : pOsSysman(pOsSysman){};
|
||||
~DiagnosticsHandleContext();
|
||||
|
||||
void init();
|
||||
|
||||
ze_result_t diagnosticsGet(uint32_t *pCount, zes_diag_handle_t *phDiagnostics);
|
||||
|
||||
OsSysman *pOsSysman = nullptr;
|
||||
std::vector<Diagnostics *> handleList = {};
|
||||
|
||||
private:
|
||||
void createHandle();
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "diagnostics_imp.h"
|
||||
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
|
||||
#include "os_diagnostics.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace L0 {
|
||||
|
||||
ze_result_t DiagnosticsImp::diagnosticsGetProperties(zes_diag_properties_t *pProperties) {
|
||||
pOsDiagnostics->osGetDiagProperties(pProperties);
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
void DiagnosticsImp::init() {
|
||||
this->isDiagnosticsEnabled = pOsDiagnostics->isDiagnosticsSupported();
|
||||
}
|
||||
|
||||
DiagnosticsImp::DiagnosticsImp(OsSysman *pOsSysman) {
|
||||
pOsDiagnostics = OsDiagnostics::create(pOsSysman);
|
||||
UNRECOVERABLE_IF(nullptr == pOsDiagnostics);
|
||||
init();
|
||||
}
|
||||
|
||||
DiagnosticsImp::~DiagnosticsImp() {
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
31
level_zero/tools/source/sysman/diagnostics/diagnostics_imp.h
Normal file
31
level_zero/tools/source/sysman/diagnostics/diagnostics_imp.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
||||
#include "shared/source/helpers/string.h"
|
||||
|
||||
#include "level_zero/tools/source/sysman/diagnostics/diagnostics.h"
|
||||
#include "level_zero/tools/source/sysman/diagnostics/os_diagnostics.h"
|
||||
#include <level_zero/zes_api.h>
|
||||
|
||||
namespace L0 {
|
||||
|
||||
class OsDiagnostics;
|
||||
|
||||
class DiagnosticsImp : public Diagnostics, NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
ze_result_t diagnosticsGetProperties(zes_diag_properties_t *pProperties) override;
|
||||
DiagnosticsImp() = default;
|
||||
DiagnosticsImp(OsSysman *pOsSysman);
|
||||
~DiagnosticsImp() override;
|
||||
std::unique_ptr<OsDiagnostics> pOsDiagnostics = nullptr;
|
||||
|
||||
void init();
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# Copyright (C) 2020-2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(L0_SRCS_TOOLS_SYSMAN_DIAGNOSTICS_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_diagnostics_imp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_diagnostics_imp.h
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
target_sources(${L0_STATIC_LIB_NAME}
|
||||
PRIVATE
|
||||
${L0_SRCS_TOOLS_SYSMAN_DIAGNOSTICS_LINUX}
|
||||
)
|
||||
endif()
|
||||
|
||||
# Make our source files visible to parent
|
||||
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_SYSMAN_DIAGNOSTICS_LINUX ${L0_SRCS_TOOLS_SYSMAN_DIAGNOSTICS_LINUX})
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/tools/source/sysman/diagnostics/linux/os_diagnostics_imp.h"
|
||||
|
||||
#include "shared/source/helpers/string.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
bool LinuxDiagnosticsImp::isDiagnosticsSupported(void) {
|
||||
if (pFwInterface != nullptr) {
|
||||
isFWInitalized = ((ZE_RESULT_SUCCESS == pFwInterface->fwDeviceInit()) ? true : false);
|
||||
return this->isFWInitalized;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void LinuxDiagnosticsImp::osGetDiagProperties(zes_diag_properties_t *pProperties) {
|
||||
return;
|
||||
}
|
||||
|
||||
LinuxDiagnosticsImp::LinuxDiagnosticsImp(OsSysman *pOsSysman) {
|
||||
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
|
||||
pFwInterface = pLinuxSysmanImp->getFwUtilInterface();
|
||||
}
|
||||
|
||||
std::unique_ptr<OsDiagnostics> OsDiagnostics::create(OsSysman *pOsSysman) {
|
||||
std::unique_ptr<LinuxDiagnosticsImp> pLinuxDiagnosticsImp = std::make_unique<LinuxDiagnosticsImp>(pOsSysman);
|
||||
return pLinuxDiagnosticsImp;
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
||||
|
||||
#include "sysman/diagnostics/diagnostics_imp.h"
|
||||
#include "sysman/diagnostics/os_diagnostics.h"
|
||||
#include "sysman/linux/os_sysman_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
class LinuxDiagnosticsImp : public OsDiagnostics, NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
bool isDiagnosticsSupported(void) override;
|
||||
void osGetDiagProperties(zes_diag_properties_t *pProperties) override;
|
||||
LinuxDiagnosticsImp() = default;
|
||||
LinuxDiagnosticsImp(OsSysman *pOsSysman);
|
||||
~LinuxDiagnosticsImp() override = default;
|
||||
|
||||
protected:
|
||||
FirmwareUtil *pFwInterface = nullptr;
|
||||
bool isFWInitalized = false;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
27
level_zero/tools/source/sysman/diagnostics/os_diagnostics.h
Normal file
27
level_zero/tools/source/sysman/diagnostics/os_diagnostics.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/tools/source/sysman/os_sysman.h"
|
||||
#include <level_zero/zes_api.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace L0 {
|
||||
|
||||
class OsDiagnostics {
|
||||
public:
|
||||
virtual bool isDiagnosticsSupported(void) = 0;
|
||||
virtual void osGetDiagProperties(zes_diag_properties_t *pProperties) = 0;
|
||||
static std::unique_ptr<OsDiagnostics> create(OsSysman *pOsSysman);
|
||||
virtual ~OsDiagnostics() {}
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# Copyright (C) 2020-2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(L0_SRCS_TOOLS_SYSMAN_DIAGNOSTICS_WINDOWS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_diagnostics_imp.cpp
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
target_sources(${L0_STATIC_LIB_NAME}
|
||||
PRIVATE
|
||||
${L0_SRCS_TOOLS_SYSMAN_DIAGNOSTICS_WINDOWS}
|
||||
)
|
||||
endif()
|
||||
|
||||
# Make our source files visible to parent
|
||||
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_SYSMAN_DIAGNOSTICS_WINDOWS ${L0_SRCS_TOOLS_SYSMAN_DIAGNOSTICS_WINDOWS})
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/tools/source/sysman/diagnostics/windows/os_diagnostics_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
bool WddmDiagnosticsImp::isDiagnosticsSupported(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void WddmDiagnosticsImp::osGetDiagProperties(zes_diag_properties_t *pProperties){};
|
||||
|
||||
std::unique_ptr<OsDiagnostics> OsDiagnostics::create(OsSysman *pOsSysman) {
|
||||
std::unique_ptr<WddmDiagnosticsImp> pWddmDiagnosticsImp = std::make_unique<WddmDiagnosticsImp>();
|
||||
return pWddmDiagnosticsImp;
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
||||
|
||||
#include "sysman/diagnostics/os_diagnostics.h"
|
||||
#include "sysman/windows/os_sysman_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
class WddmDiagnosticsImp : public OsDiagnostics {
|
||||
public:
|
||||
bool isDiagnosticsSupported(void) override;
|
||||
void osGetDiagProperties(zes_diag_properties_t *pProperties) override;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
Reference in New Issue
Block a user