Use templates for module population
Also add stddef.h workaround for old GCC.
RHEL-8 still uses GCC 8.5 and templates are not well supported.
Change-Id: Ia4dae23892ec63682ea848c46ba81de85cf6d209
Signed-off-by: Galantsev, Dmitrii <dmitrii.galantsev@amd.com>
[ROCm/rdc commit: f9e80cc37a]
Este commit está contenido en:
@@ -22,14 +22,12 @@ THE SOFTWARE.
|
||||
#ifndef INCLUDE_RDC_LIB_RDCLIBRARYLOADER_H_
|
||||
#define INCLUDE_RDC_LIB_RDCLIBRARYLOADER_H_
|
||||
#include <dlfcn.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <map>
|
||||
#include <mutex> // NOLINT(build/c++11)
|
||||
|
||||
#include "rdc/rdc.h"
|
||||
#include "rdc_lib/RdcException.h"
|
||||
#include "rdc_lib/RdcLogger.h"
|
||||
#include "rdc_lib/rdc_common.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
@@ -37,6 +35,7 @@ class RdcLibraryLoader {
|
||||
public:
|
||||
RdcLibraryLoader();
|
||||
|
||||
// throws RdcException if lib not found
|
||||
rdc_status_t load(const char* filename);
|
||||
|
||||
template <typename T>
|
||||
@@ -57,7 +56,7 @@ class RdcLibraryLoader {
|
||||
template <typename T>
|
||||
rdc_status_t RdcLibraryLoader::load_symbol(T* func_handler, const char* func_name) {
|
||||
if (!libHandler_) {
|
||||
RDC_LOG(RDC_ERROR, "Must load the library before load the symbol");
|
||||
RDC_LOG(RDC_ERROR, "Must load the library before loading the symbol");
|
||||
return RDC_ST_FAIL_LOAD_MODULE;
|
||||
}
|
||||
|
||||
@@ -83,9 +82,14 @@ rdc_status_t RdcLibraryLoader::load(const char* filename, T* func_make_handler)
|
||||
return RDC_ST_FAIL_LOAD_MODULE;
|
||||
}
|
||||
|
||||
rdc_status_t status = load(filename);
|
||||
if (status != RDC_ST_OK) {
|
||||
return status;
|
||||
try {
|
||||
rdc_status_t status = load(filename);
|
||||
if (status != RDC_ST_OK) {
|
||||
return status;
|
||||
}
|
||||
} catch (RdcException& e) {
|
||||
RDC_LOG(RDC_ERROR, e.what());
|
||||
return e.error_code();
|
||||
}
|
||||
|
||||
return load_symbol(func_make_handler, "make_handler");
|
||||
|
||||
@@ -25,6 +25,19 @@ THE SOFTWARE.
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#define RDC_ERROR 0
|
||||
#define RDC_INFO 1
|
||||
#define RDC_DEBUG 2
|
||||
|
||||
#define RDC_LOG(debug_level, msg) \
|
||||
do { \
|
||||
auto& logger = amd::rdc::RdcLogger::getLogger(); \
|
||||
if (logger.should_log((debug_level))) { \
|
||||
logger.get_ostream() << logger.get_log_header((debug_level), __FILE__, __LINE__) << msg \
|
||||
<< std::endl; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
class RdcLogger {
|
||||
|
||||
@@ -24,16 +24,15 @@ THE SOFTWARE.
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "rdc/rdc.h"
|
||||
#include "rdc_lib/RdcDiagnostic.h"
|
||||
#include "rdc_lib/RdcTelemetry.h"
|
||||
#include "rdc_lib/rdc_common.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
class RdcModuleMgr {
|
||||
public:
|
||||
virtual ~RdcModuleMgr() = default;
|
||||
virtual RdcTelemetryPtr get_telemetry_module() = 0;
|
||||
virtual RdcDiagnosticPtr get_diagnostic_module() = 0;
|
||||
};
|
||||
|
||||
@@ -28,7 +28,6 @@ THE SOFTWARE.
|
||||
#include <vector>
|
||||
|
||||
#include "rdc_lib/RdcDiagnostic.h"
|
||||
#include "rdc_lib/RdcMetricFetcher.h"
|
||||
#include "rdc_lib/RdcTelemetryLibInterface.h"
|
||||
|
||||
namespace amd {
|
||||
@@ -52,7 +51,7 @@ class RdcDiagnosticModule : public RdcDiagnostic {
|
||||
rdc_status_t rdc_diag_init(uint64_t flags) override;
|
||||
rdc_status_t rdc_diag_destroy() override;
|
||||
|
||||
explicit RdcDiagnosticModule(RdcMetricFetcherPtr& fetcher);
|
||||
explicit RdcDiagnosticModule(std::list<RdcDiagnosticPtr> diagnostic_modules);
|
||||
|
||||
private:
|
||||
//< Helper function to dispatch fields to module
|
||||
|
||||
@@ -22,7 +22,7 @@ THE SOFTWARE.
|
||||
#ifndef INCLUDE_RDC_LIB_IMPL_RDCMODULEMGRIMPL_H_
|
||||
#define INCLUDE_RDC_LIB_IMPL_RDCMODULEMGRIMPL_H_
|
||||
|
||||
#include <memory>
|
||||
#include <list>
|
||||
|
||||
#include "rdc_lib/RdcMetricFetcher.h"
|
||||
#include "rdc_lib/RdcModuleMgr.h"
|
||||
@@ -38,6 +38,22 @@ class RdcModuleMgrImpl : public RdcModuleMgr {
|
||||
explicit RdcModuleMgrImpl(const RdcMetricFetcherPtr& fetcher);
|
||||
|
||||
private:
|
||||
// Modules
|
||||
std::list<RdcDiagnosticPtr> diagnostic_modules_;
|
||||
std::list<RdcTelemetryPtr> telemetry_modules_;
|
||||
|
||||
// base case
|
||||
template <typename T>
|
||||
rdc_status_t insert_modules();
|
||||
|
||||
// recursive case
|
||||
template <typename T, typename R, typename... TArgs>
|
||||
rdc_status_t insert_modules();
|
||||
|
||||
// pass shared_ptr instead of creating it
|
||||
template <typename T>
|
||||
rdc_status_t insert_modules(std::shared_ptr<T> ptr);
|
||||
|
||||
// Function module
|
||||
RdcTelemetryPtr rdc_telemetry_module_;
|
||||
RdcDiagnosticPtr rdc_diagnostic_module_;
|
||||
|
||||
@@ -23,7 +23,6 @@ THE SOFTWARE.
|
||||
#define INCLUDE_RDC_LIB_IMPL_RDCRVSLIB_H_
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "rdc/rdc.h"
|
||||
#include "rdc_lib/RdcDiagnostic.h"
|
||||
@@ -51,7 +50,6 @@ class RdcRVSLib : public RdcDiagnostic {
|
||||
rdc_status_t rdc_diag_destroy() override;
|
||||
|
||||
RdcRVSLib();
|
||||
|
||||
~RdcRVSLib() override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -49,7 +49,7 @@ class RdcRocpLib : public RdcTelemetry {
|
||||
rdc_status_t rdc_telemetry_fields_unwatch(rdc_gpu_field_t* fields,
|
||||
uint32_t fields_count) override;
|
||||
|
||||
explicit RdcRocpLib(const char* lib_name);
|
||||
RdcRocpLib();
|
||||
|
||||
~RdcRocpLib();
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ THE SOFTWARE.
|
||||
#define INCLUDE_RDC_LIB_IMPL_RDCSMILIB_H_
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "rdc_lib/RdcDiagnostic.h"
|
||||
#include "rdc_lib/RdcMetricFetcher.h"
|
||||
|
||||
@@ -47,7 +47,7 @@ class RdcTelemetryModule : public RdcTelemetry {
|
||||
|
||||
rdc_status_t rdc_telemetry_fields_unwatch(rdc_gpu_field_t* fields, uint32_t fields_count);
|
||||
|
||||
explicit RdcTelemetryModule(RdcMetricFetcherPtr fetcher);
|
||||
explicit RdcTelemetryModule(std::list<RdcTelemetryPtr> telemetry_modules);
|
||||
|
||||
private:
|
||||
//< Helper function to dispatch fields to module
|
||||
|
||||
@@ -28,19 +28,6 @@ THE SOFTWARE.
|
||||
|
||||
#include "rdc/rdc.h"
|
||||
|
||||
#define RDC_ERROR 0
|
||||
#define RDC_INFO 1
|
||||
#define RDC_DEBUG 2
|
||||
|
||||
#define RDC_LOG(debug_level, msg) \
|
||||
do { \
|
||||
auto& logger = amd::rdc::RdcLogger::getLogger(); \
|
||||
if (logger.should_log((debug_level))) { \
|
||||
logger.get_ostream() << logger.get_log_header((debug_level), __FILE__, __LINE__) << msg \
|
||||
<< std::endl; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
//<! The key to identify the field with <gpu_id, field_id>
|
||||
typedef std::pair<uint32_t, rdc_field_t> RdcFieldKey;
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2021 - present Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
#ifndef RDC_MODULES_RDC_DIAGNOSTIC_RDCDIAGNOSTICLIB_H_
|
||||
#define RDC_MODULES_RDC_DIAGNOSTIC_RDCDIAGNOSTICLIB_H_
|
||||
#include "rdc/rdc.h"
|
||||
#include "rdc_lib/RdcTelemetryLibInterface.h"
|
||||
|
||||
#endif // RDC_MODULES_RDC_DIAGNOSTIC_RDCDIAGNOSTICLIB_H_
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2021 - present Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
#ifndef RDC_MODULES_RDC_DIAGNOSTIC_RDCDIAGNOSTICLIB_H_
|
||||
#define RDC_MODULES_RDC_DIAGNOSTIC_RDCDIAGNOSTICLIB_H_
|
||||
#include "rdc/rdc.h"
|
||||
#include "rdc_lib/RdcDiagnosticLibInterface.h"
|
||||
|
||||
#endif // RDC_MODULES_RDC_DIAGNOSTIC_RDCDIAGNOSTICLIB_H_
|
||||
@@ -22,6 +22,8 @@ THE SOFTWARE.
|
||||
|
||||
#include "rdc_lib/RdcLibraryLoader.h"
|
||||
|
||||
#include "rdc_lib/RdcException.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
@@ -39,7 +41,9 @@ rdc_status_t RdcLibraryLoader::load(const char* filename) {
|
||||
libHandler_ = dlopen(filename, RTLD_LAZY);
|
||||
if (!libHandler_) {
|
||||
char* error = dlerror();
|
||||
RDC_LOG(RDC_ERROR, "Fail to open " << filename << ": " << error);
|
||||
throw RdcException(
|
||||
RDC_ST_FAIL_LOAD_MODULE,
|
||||
std::string("Fail to open ") + std::string(filename) + ": " + std::string(error));
|
||||
return RDC_ST_FAIL_LOAD_MODULE;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,17 +21,11 @@ THE SOFTWARE.
|
||||
*/
|
||||
#include "rdc_lib/impl/RdcDiagnosticModule.h"
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "rdc_lib/RdcLogger.h"
|
||||
#include "rdc_lib/RdcMetricFetcher.h"
|
||||
#include "rdc_lib/impl/RdcRVSLib.h"
|
||||
#include "rdc_lib/impl/RdcRasLib.h"
|
||||
#include "rdc_lib/impl/RdcRocrLib.h"
|
||||
#include "rdc_lib/impl/RdcSmiLib.h"
|
||||
#include "rdc/rdc.h"
|
||||
#include "rdc_lib/rdc_common.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
@@ -122,32 +116,16 @@ rdc_status_t RdcDiagnosticModule::RdcDiagnosticModule::rdc_diag_destroy() {
|
||||
return RDC_ST_OK;
|
||||
}
|
||||
|
||||
RdcDiagnosticModule::RdcDiagnosticModule(RdcMetricFetcherPtr& fetcher) {
|
||||
const RdcSmiLibPtr smi_module = std::make_shared<RdcSmiLib>(fetcher);
|
||||
const RdcRocrLibPtr rocr_module = std::make_shared<RdcRocrLib>();
|
||||
const RdcRasLibPtr ras_module = std::make_shared<RdcRasLib>();
|
||||
const RdcRVSLibPtr rvs_module = std::make_shared<RdcRVSLib>();
|
||||
if (smi_module) {
|
||||
diagnostic_modules_.push_back(smi_module);
|
||||
}
|
||||
if (rocr_module) {
|
||||
diagnostic_modules_.push_back(rocr_module);
|
||||
}
|
||||
if (ras_module) {
|
||||
diagnostic_modules_.push_back(ras_module);
|
||||
}
|
||||
if (rvs_module) {
|
||||
diagnostic_modules_.push_back(rvs_module);
|
||||
}
|
||||
|
||||
auto ite = diagnostic_modules_.begin();
|
||||
for (; ite != diagnostic_modules_.end(); ite++) {
|
||||
RdcDiagnosticModule::RdcDiagnosticModule(std::list<RdcDiagnosticPtr> diagnostic_modules)
|
||||
: diagnostic_modules_(diagnostic_modules) {
|
||||
// find test cases
|
||||
for (auto& ite : diagnostic_modules_) {
|
||||
rdc_diag_test_cases_t test_cases[MAX_TEST_CASES];
|
||||
uint32_t test_count = 0;
|
||||
rdc_status_t status = (*ite)->rdc_diag_test_cases_query(test_cases, &test_count);
|
||||
rdc_status_t status = ite->rdc_diag_test_cases_query(test_cases, &test_count);
|
||||
if (status == RDC_ST_OK) {
|
||||
for (uint32_t index = 0; index < test_count; index++) {
|
||||
testcases_to_module_.insert({test_cases[index], (*ite)});
|
||||
testcases_to_module_.insert({test_cases[index], ite});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,37 +21,86 @@ THE SOFTWARE.
|
||||
*/
|
||||
#include "rdc_lib/impl/RdcModuleMgrImpl.h"
|
||||
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
#include "rdc/rdc.h"
|
||||
#include "rdc_lib/RdcException.h"
|
||||
#include "rdc_lib/RdcTelemetry.h"
|
||||
#include "rdc_lib/impl/RdcDiagnosticModule.h"
|
||||
#include "rdc_lib/impl/RdcRVSLib.h"
|
||||
#include "rdc_lib/impl/RdcRasLib.h"
|
||||
#include "rdc_lib/impl/RdcRocrLib.h"
|
||||
#include "rdc_lib/impl/RdcSmiLib.h"
|
||||
#include "rdc_lib/impl/RdcTelemetryModule.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
RdcModuleMgrImpl::RdcModuleMgrImpl(const RdcMetricFetcherPtr& fetcher) : fetcher_(fetcher) {}
|
||||
// pass shared_ptr instead of creating it
|
||||
template <typename T>
|
||||
rdc_status_t RdcModuleMgrImpl::insert_modules(std::shared_ptr<T> ptr) {
|
||||
static_assert(std::is_base_of_v<RdcDiagnostic, T> || std::is_base_of_v<RdcTelemetryModule, T>);
|
||||
RDC_LOG(RDC_DEBUG, "Inserting module: " << typeid(T).name());
|
||||
// same module can service multiple subsystems
|
||||
// e.g. Diagnostics and Telemetry
|
||||
if constexpr (std::is_base_of_v<RdcDiagnostic, T>) {
|
||||
diagnostic_modules_.push_back(ptr);
|
||||
}
|
||||
if constexpr (std::is_base_of_v<RdcTelemetry, T>) {
|
||||
telemetry_modules_.push_back(ptr);
|
||||
}
|
||||
return RDC_ST_OK;
|
||||
}
|
||||
|
||||
// base case
|
||||
template <typename T>
|
||||
rdc_status_t RdcModuleMgrImpl::insert_modules() {
|
||||
static_assert(std::is_base_of_v<RdcDiagnostic, T> || std::is_base_of_v<RdcTelemetryModule, T>);
|
||||
try {
|
||||
auto ptr = std::make_shared<T>();
|
||||
return insert_modules(ptr);
|
||||
} catch (RdcException& e) {
|
||||
RDC_LOG(RDC_ERROR, "Failed to insert module: " << typeid(T).name() << "\n" << e.what());
|
||||
return e.error_code();
|
||||
}
|
||||
}
|
||||
|
||||
// recursive case
|
||||
template <typename T, typename R, typename... TArgs>
|
||||
rdc_status_t RdcModuleMgrImpl::insert_modules() {
|
||||
rdc_status_t status = insert_modules<T>();
|
||||
rdc_status_t status_recursive = insert_modules<R, TArgs...>();
|
||||
if (status == RDC_ST_OK) {
|
||||
status = status_recursive;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
RdcModuleMgrImpl::RdcModuleMgrImpl(const RdcMetricFetcherPtr& fetcher) : fetcher_(fetcher) {
|
||||
// this module has a unique constructor and must be initialized explicitly
|
||||
try {
|
||||
auto smi_module = std::make_shared<RdcSmiLib>(fetcher);
|
||||
insert_modules(smi_module);
|
||||
} catch (RdcException& e) {
|
||||
RDC_LOG(RDC_ERROR, "Failed to insert module: " << typeid(RdcSmiLib).name() << "\n" << e.what());
|
||||
}
|
||||
|
||||
// all other modules get initialized by insert_modules
|
||||
insert_modules<RdcRasLib, RdcRVSLib, RdcRocrLib>();
|
||||
}
|
||||
|
||||
RdcTelemetryPtr RdcModuleMgrImpl::get_telemetry_module() {
|
||||
if (rdc_telemetry_module_) {
|
||||
return rdc_telemetry_module_;
|
||||
if (rdc_telemetry_module_ == nullptr) {
|
||||
rdc_telemetry_module_.reset(new RdcTelemetryModule(telemetry_modules_));
|
||||
}
|
||||
|
||||
if (!rdc_telemetry_module_) {
|
||||
rdc_telemetry_module_.reset(new RdcTelemetryModule(fetcher_));
|
||||
}
|
||||
|
||||
return rdc_telemetry_module_;
|
||||
}
|
||||
|
||||
RdcDiagnosticPtr RdcModuleMgrImpl::get_diagnostic_module() {
|
||||
if (rdc_diagnostic_module_) {
|
||||
return rdc_diagnostic_module_;
|
||||
if (rdc_diagnostic_module_ == nullptr) {
|
||||
rdc_diagnostic_module_.reset(new RdcDiagnosticModule(diagnostic_modules_));
|
||||
}
|
||||
|
||||
if (!rdc_diagnostic_module_) {
|
||||
rdc_diagnostic_module_.reset(new RdcDiagnosticModule(fetcher_));
|
||||
}
|
||||
|
||||
return rdc_diagnostic_module_;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,10 +21,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
#include "rdc_lib/impl/RdcRVSLib.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "rdc_lib/RdcLogger.h"
|
||||
#include "rdc_lib/rdc_common.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
@@ -69,7 +66,7 @@ RdcRVSLib::RdcRVSLib()
|
||||
}
|
||||
|
||||
RdcRVSLib::~RdcRVSLib() {
|
||||
if (diag_destroy_) {
|
||||
if (diag_destroy_ != nullptr) {
|
||||
diag_destroy_();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,6 @@ THE SOFTWARE.
|
||||
*/
|
||||
#include "rdc_lib/impl/RdcRasLib.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "rdc_lib/RdcLogger.h"
|
||||
#include "rdc_lib/rdc_common.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
|
||||
@@ -25,22 +25,20 @@ THE SOFTWARE.
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include "rdc_lib/RdcLogger.h"
|
||||
#include "rdc_lib/rdc_common.h"
|
||||
#include "rdc_lib/RdcException.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
// TODO: Add init and destroy calls support
|
||||
RdcRocpLib::RdcRocpLib(const char* lib_name)
|
||||
RdcRocpLib::RdcRocpLib()
|
||||
: telemetry_fields_query_(nullptr),
|
||||
telemetry_fields_value_get_(nullptr),
|
||||
telemetry_fields_watch_(nullptr),
|
||||
telemetry_fields_unwatch_(nullptr) {
|
||||
rdc_status_t status = lib_loader_.load(lib_name);
|
||||
rdc_status_t status = lib_loader_.load("librdc_rocp.so");
|
||||
if (status != RDC_ST_OK) {
|
||||
RDC_LOG(RDC_ERROR, "Rocp related function will not work.");
|
||||
return;
|
||||
@@ -49,6 +47,7 @@ RdcRocpLib::RdcRocpLib(const char* lib_name)
|
||||
status = set_rocmtools_path();
|
||||
if (status != RDC_ST_OK) {
|
||||
RDC_LOG(RDC_ERROR, "Rocp related function will not work.");
|
||||
throw RdcException(RDC_ST_FAIL_LOAD_MODULE, "rocmtools path could not be set");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ THE SOFTWARE.
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "rdc_lib/RdcException.h"
|
||||
#include "rdc_lib/RdcLogger.h"
|
||||
#include "rdc_lib/rdc_common.h"
|
||||
|
||||
|
||||
@@ -24,10 +24,7 @@ THE SOFTWARE.
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "rdc_lib/RdcLogger.h"
|
||||
#include "rdc_lib/rdc_common.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
@@ -21,10 +21,9 @@ THE SOFTWARE.
|
||||
*/
|
||||
#include "rdc_lib/impl/RdcTelemetryModule.h"
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include "rdc_lib/RdcLogger.h"
|
||||
#include "rdc_lib/RdcException.h"
|
||||
#include "rdc_lib/RdcMetricFetcher.h"
|
||||
#include "rdc_lib/impl/RdcRasLib.h"
|
||||
#include "rdc_lib/impl/RdcSmiLib.h"
|
||||
@@ -91,14 +90,8 @@ rdc_status_t RdcTelemetryModule::rdc_telemetry_fields_unwatch(rdc_gpu_field_t* f
|
||||
return RDC_ST_OK;
|
||||
}
|
||||
|
||||
RdcTelemetryModule::RdcTelemetryModule(RdcMetricFetcherPtr fetcher) {
|
||||
const RdcSmiLibPtr smi_module = std::make_shared<RdcSmiLib>(fetcher);
|
||||
const RdcRasLibPtr ras_module = std::make_shared<RdcRasLib>();
|
||||
telemetry_modules_.push_back(smi_module);
|
||||
if (ras_module) {
|
||||
telemetry_modules_.push_back(ras_module);
|
||||
}
|
||||
|
||||
RdcTelemetryModule::RdcTelemetryModule(std::list<RdcTelemetryPtr> telemetry_modules)
|
||||
: telemetry_modules_(telemetry_modules) {
|
||||
auto ite = telemetry_modules_.begin();
|
||||
for (; ite != telemetry_modules_.end(); ite++) {
|
||||
uint32_t field_ids[MAX_NUM_FIELDS];
|
||||
|
||||
@@ -15,7 +15,6 @@ set(RDC_ROCP_LIB_INC_LIST
|
||||
"${RDC_LIB_INC_DIR}/RdcDiagnosticLibInterface.h"
|
||||
"${RDC_LIB_INC_DIR}/rdc_common.h"
|
||||
"${RDC_LIB_INC_DIR}/RdcLogger.h"
|
||||
"${INC_DIR}/RdcTelemetryLib.h"
|
||||
"${INC_DIR}/RdcRocpBase.h")
|
||||
|
||||
if(BUILD_ROCPTEST)
|
||||
|
||||
@@ -20,13 +20,13 @@ set(RDC_ROCR_LIB_SRC_LIST
|
||||
set(RDC_ROCR_LIB_INC_LIST
|
||||
"${INC_DIR}/MemoryAccess.h"
|
||||
"${INC_DIR}/MemoryTest.h"
|
||||
"${INC_DIR}/RdcDiagnosticLib.h"
|
||||
"${INC_DIR}/RdcRocrBase.h"
|
||||
"${INC_DIR}/TestBase.h"
|
||||
"${INC_DIR}/base_rocr_utils.h"
|
||||
"${INC_DIR}/common.h"
|
||||
"${PROJECT_SOURCE_DIR}/include/rdc/rdc.h"
|
||||
"${RDC_LIB_INC_DIR}/RdcLogger.h"
|
||||
"${RDC_LIB_INC_DIR}/RdcDiagnosticLibInterface.h"
|
||||
"${RDC_LIB_INC_DIR}/rdc_common.h")
|
||||
|
||||
if(BUILD_ROCRTEST)
|
||||
|
||||
@@ -19,13 +19,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
#include "rdc_modules/rdc_rocr/RdcDiagnosticLib.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "rdc_lib/RdcDiagnosticLibInterface.h"
|
||||
#include "rdc_lib/rdc_common.h"
|
||||
#include "rdc_modules/rdc_rocr/ComputeQueueTest.h"
|
||||
#include "rdc_modules/rdc_rocr/MemoryAccess.h"
|
||||
|
||||
@@ -14,6 +14,7 @@ set(RDC_RVS_LIB_SRC_LIST
|
||||
set(RDC_RVS_LIB_INC_LIST
|
||||
"${PROJECT_SOURCE_DIR}/include/rdc/rdc.h"
|
||||
"${RDC_LIB_INC_DIR}/RdcDiagnostic.h"
|
||||
"${RDC_LIB_INC_DIR}/RdcDiagnosticLibInterface.h"
|
||||
"${RDC_LIB_INC_DIR}/rdc_common.h"
|
||||
"${RDC_LIB_INC_DIR}/RdcLogger.h"
|
||||
"${INC_DIR}/RvsBase.h"
|
||||
|
||||
@@ -21,10 +21,8 @@ THE SOFTWARE.
|
||||
*/
|
||||
#include <string.h>
|
||||
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "rdc/rdc.h"
|
||||
#include "rdc_lib/RdcDiagnosticLibInterface.h"
|
||||
#include "rdc_lib/RdcLogger.h"
|
||||
#include "rdc_lib/rdc_common.h"
|
||||
#include "rdc_modules/rdc_rvs/RvsBase.h"
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
Copyright (c) 2019 - present Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
@@ -222,7 +221,6 @@ void RDCServer::Run() {
|
||||
}
|
||||
|
||||
// Finally assemble the server.
|
||||
// std::unique_ptr<::grpc::Server> server(builder.BuildAndStart());
|
||||
server_ = builder.BuildAndStart();
|
||||
|
||||
std::cout << "Server listening on " << server_address_.c_str() << std::endl;
|
||||
|
||||
Referencia en una nueva incidencia
Block a user