Implement the rdc_lib API to support the job stats
Add the function to start and stop the job recording.
Add the function to get the job stats for each GPU and summary of multiple GPUs
Add the function to remove the jobs.
Add a class RdcLogger which can control the log level using the environment variable RDC_LOG.
This is similar to GRPC_VERBOSITY gRPC. When the customer has the issues, he can enable the verbose
log to help us to troubleshoot the issues.
Add the -u support in the rdci group, fieldgroup and dmon for connecting to rdcd without authentication.
Change-Id: I22c591823c1ee6485db106b911bed8271d1b2769
[ROCm/rdc commit: a547dc7efd]
This commit is contained in:
gecommit door
Chris Freehill
bovenliggende
aef3d29925
commit
0813e7052f
@@ -24,6 +24,7 @@ THE SOFTWARE.
|
||||
#include <map>
|
||||
#include "rdc/rdc.h"
|
||||
#include "rdc_lib/RdcHandler.h"
|
||||
#include "rdc_lib/RdcLogger.h"
|
||||
#include "rdc_lib/rdc_common.h"
|
||||
|
||||
static void* libHandler = nullptr;
|
||||
@@ -96,7 +97,7 @@ rdc_status_t rdc_start_embedded(rdc_operation_mode_t op_mode,
|
||||
|
||||
if (!libHandler) {
|
||||
error = dlerror();
|
||||
LOG_DEBUG("Fail to open librdc.so: " << error);
|
||||
RDC_LOG(RDC_ERROR, "Fail to open librdc.so: " << error);
|
||||
return RDC_ST_FAIL_LOAD_MODULE;
|
||||
}
|
||||
|
||||
@@ -104,7 +105,8 @@ rdc_status_t rdc_start_embedded(rdc_operation_mode_t op_mode,
|
||||
dlsym(libHandler, "make_handler");
|
||||
if (!func_make_handler) {
|
||||
error = dlerror();
|
||||
LOG_DEBUG("Fail to find function make_handler:" << error);
|
||||
RDC_LOG(RDC_ERROR,
|
||||
"Fail to find function make_handler:" << error);
|
||||
return RDC_ST_FAIL_LOAD_MODULE;
|
||||
}
|
||||
|
||||
@@ -144,15 +146,32 @@ rdc_status_t rdc_job_get_stats(rdc_handle_t p_rdc_handle, char job_id[64] ,
|
||||
}
|
||||
|
||||
rdc_status_t rdc_job_start_stats(rdc_handle_t p_rdc_handle,
|
||||
rdc_gpu_group_t groupId, char job_id[64], uint64_t update_freq,
|
||||
double max_keep_age, uint32_t max_keep_samples ) {
|
||||
rdc_gpu_group_t groupId, char job_id[64],
|
||||
uint64_t update_freq) {
|
||||
if (!p_rdc_handle) {
|
||||
return RDC_ST_INVALID_HANDLER;
|
||||
}
|
||||
|
||||
return static_cast<amd::rdc::RdcHandler*>(p_rdc_handle)->
|
||||
rdc_job_start_stats(groupId, job_id, update_freq,
|
||||
max_keep_age, max_keep_samples);
|
||||
rdc_job_start_stats(groupId, job_id, update_freq);
|
||||
}
|
||||
|
||||
rdc_status_t rdc_job_remove(rdc_handle_t p_rdc_handle, char job_id[64]) {
|
||||
if (!p_rdc_handle) {
|
||||
return RDC_ST_INVALID_HANDLER;
|
||||
}
|
||||
|
||||
return static_cast<amd::rdc::RdcHandler*>(p_rdc_handle)->
|
||||
rdc_job_remove(job_id);
|
||||
}
|
||||
|
||||
rdc_status_t rdc_job_remove_all(rdc_handle_t p_rdc_handle) {
|
||||
if (!p_rdc_handle) {
|
||||
return RDC_ST_INVALID_HANDLER;
|
||||
}
|
||||
|
||||
return static_cast<amd::rdc::RdcHandler*>(p_rdc_handle)->
|
||||
rdc_job_remove_all();
|
||||
}
|
||||
|
||||
|
||||
@@ -344,6 +363,8 @@ const char* rdc_status_string(rdc_status_t result) {
|
||||
return "The max limit reached";
|
||||
case RDC_ST_CONFLICT:
|
||||
return "Conflict with current state";
|
||||
case RDC_ST_ALREADY_EXIST:
|
||||
return "The value already exists";
|
||||
case RDC_ST_CLIENT_ERROR:
|
||||
return "RDC Client error";
|
||||
default:
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
Copyright (c) 2020 - 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.
|
||||
*/
|
||||
#include "rdc_lib/RdcLogger.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <chrono> // NOLINT
|
||||
#include "rdc_lib/rdc_common.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
RdcLogger::RdcLogger(std::ostream& os):
|
||||
os_(os) {
|
||||
char* verbose = getenv("RDC_LOG");
|
||||
if (verbose == nullptr) {
|
||||
log_level_ = RDC_ERROR;
|
||||
} else if (strcmp(verbose, "DEBUG") == 0) {
|
||||
log_level_ = RDC_DEBUG;
|
||||
} else if (strcmp(verbose, "INFO") == 0) {
|
||||
log_level_ = RDC_INFO;
|
||||
} else {
|
||||
log_level_ = RDC_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
std::string RdcLogger::get_log_header(uint32_t severity,
|
||||
const char* file, int line) {
|
||||
std::stringstream strstream;
|
||||
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>
|
||||
(std::chrono::system_clock::now().time_since_epoch()).count();
|
||||
strstream << std::fixed << std::setprecision(3) << (ms/1000.0) << " ";
|
||||
if (severity == RDC_DEBUG) {
|
||||
strstream << "DEBUG ";
|
||||
} else if (severity == RDC_INFO) {
|
||||
strstream << "INFO ";
|
||||
} else {
|
||||
strstream << "ERROR ";
|
||||
}
|
||||
|
||||
// extract out the file path as it may be very long.
|
||||
if (file != nullptr) {
|
||||
std::string file_str(file);
|
||||
auto found = file_str.find_last_of("/");
|
||||
if (found != std::string::npos) {
|
||||
file_str = file_str.substr(found+1);
|
||||
}
|
||||
strstream << file_str << "(" << line << "): ";
|
||||
}
|
||||
|
||||
return strstream.str();
|
||||
}
|
||||
|
||||
|
||||
} // namespace rdc
|
||||
} // namespace amd
|
||||
|
||||
Verwijs in nieuw issue
Block a user