Add support for global_operations in new sysman design

Related-To: LOCI-4135
Signed-off-by: Jitendra Sharma <jitendra.sharma@intel.com>
This commit is contained in:
Jitendra Sharma
2023-03-24 07:32:22 +00:00
committed by Compute-Runtime-Automation
parent 4c7bc2ca98
commit d29ed25f8b
35 changed files with 3241 additions and 23 deletions

View File

@@ -0,0 +1,15 @@
#
# Copyright (C) 2023 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
target_sources(${L0_STATIC_LIB_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/diagnostics.h
${CMAKE_CURRENT_SOURCE_DIR}/diagnostics.cpp
)
add_subdirectories()

View File

@@ -0,0 +1,48 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/sysman/source/diagnostics/diagnostics.h"
#include "shared/source/helpers/basic_math.h"
namespace L0 {
namespace Sysman {
DiagnosticsHandleContext::~DiagnosticsHandleContext() {
releaseDiagnosticsHandles();
}
void DiagnosticsHandleContext::releaseDiagnosticsHandles() {
for (Diagnostics *pDiagnostics : handleList) {
delete pDiagnostics;
}
handleList.clear();
}
void DiagnosticsHandleContext::init() {
}
ze_result_t DiagnosticsHandleContext::diagnosticsGet(uint32_t *pCount, zes_diag_handle_t *phDiagnostics) {
std::call_once(initDiagnosticsOnce, [this]() {
this->init();
this->diagnosticsInitDone = true;
});
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 Sysman
} // namespace L0

View File

@@ -0,0 +1,56 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "level_zero/api/sysman/zes_handles_struct.h"
#include <level_zero/zes_api.h>
#include <mutex>
#include <string>
#include <vector>
namespace L0 {
namespace Sysman {
struct OsSysman;
class Diagnostics : _zes_diag_handle_t {
public:
~Diagnostics() override {}
virtual ze_result_t diagnosticsGetProperties(zes_diag_properties_t *pProperties) = 0;
virtual ze_result_t diagnosticsGetTests(uint32_t *pCount, zes_diag_test_t *pTests) = 0;
virtual ze_result_t diagnosticsRunTests(uint32_t start, uint32_t end, zes_diag_result_t *pResult) = 0;
inline zes_diag_handle_t toHandle() { return this; }
static Diagnostics *fromHandle(zes_diag_handle_t handle) {
return static_cast<Diagnostics *>(handle);
}
};
struct DiagnosticsHandleContext {
DiagnosticsHandleContext(OsSysman *pOsSysman) : pOsSysman(pOsSysman){};
void releaseDiagnosticsHandles();
MOCKABLE_VIRTUAL ~DiagnosticsHandleContext();
MOCKABLE_VIRTUAL void init();
ze_result_t diagnosticsGet(uint32_t *pCount, zes_diag_handle_t *phDiagnostics);
std::vector<std::string> supportedDiagTests = {};
OsSysman *pOsSysman = nullptr;
std::vector<Diagnostics *> handleList = {};
bool isDiagnosticsInitDone() {
return diagnosticsInitDone;
}
private:
void createHandle(const std::string &diagTests);
std::once_flag initDiagnosticsOnce;
bool diagnosticsInitDone = false;
};
} // namespace Sysman
} // namespace L0