SWDEV-209060 - Create the Skeleton RDC CLI and daemon
Create the skeleton implementation of rdc_client.so and rdci. Modify current rdcd to integrate the RDC API service: rdc.proto is changed to add a new RdcAPI service which defined the interfaces for the RDC API. RdcStandaloneHandler.cpp is added to send the request using gRPC to the rdcd. It is built into the rdc_client.so rdci.cc, RdciDisCoverySubSystem.cc and RdciSubSystem.cc are added to implement skeleton rdci. Currently, the discovery subsystem is supported. rdc_api_service.cc is added to the server as a skeleton to implement the RdcAPI service. Currently, only discovery API is implemented. Note: we disabled the rdc_rsmi_service, which will be removed in the future. The original rdc_client.so is renamed to rdc_client_smi.so which should also be removed in the future. Add the instruction how to run the rdcd and rdci in the build folder in the README.md. Change-Id: Id232f9f83787e5812d4a295dc8cf0daa7728b06c
This commit is contained in:
1 szülő
1ff1c7b617
commit
020f6939f7
21 files changed
+1296
-11
No files matched your search
@@ -174,6 +174,38 @@ set_property(TARGET ${RDC_LIB} PROPERTY
|
||||
set_property(TARGET ${RDC_LIB} PROPERTY
|
||||
VERSION "${SO_VERSION_STRING}")
|
||||
|
||||
# librdc_client.so set up
|
||||
file(GLOB PROTOBUF_GENERATED_INCLUDES "${PROTOB_OUT_DIR}/*.h")
|
||||
file(GLOB PROTOBUF_GENERATED_SRCS "${PROTOB_OUT_DIR}/*.cc")
|
||||
|
||||
set(RDCCLIENT_LIB "rdc_client")
|
||||
set(RDCCLIENT_LIB_COMPONENT "lib${RDCCLIENT_LIB}")
|
||||
set(RDCCLIENT_LIB_SRC_LIST "${SRC_DIR}/rdc_client/src/RdcStandaloneHandler.cc")
|
||||
set(RDCCLIENT_LIB_SRC_LIST ${RDCCLIENT_LIB_SRC_LIST} "${PROTOBUF_GENERATED_SRCS}")
|
||||
|
||||
set(RDCCLIENT_LIB_INC_LIST "${RDC_LIB_INC_DIR}/rdc/rdc.h")
|
||||
set(BRDCCLIENT_LIB_INC_LIST ${RDCCLIENT_LIB_INC_LIST} "${RDC_LIB_INC_DIR}/rdc_lib/rdc_common.h")
|
||||
set(RDCCLIENT_LIB_INC_LIST ${RDCCLIENT_LIB_INC_LIST} "${RDC_LIB_INC_DIR}/rdc_lib/RdcHandler.h")
|
||||
set(RDCCLIENT_LIB_INC_LIST ${RDCCLIENT_LIB_INC_LIST} "${RDC_LIB_INC_DIR}/rdc_lib/impl/RdcStandaloneHandler.h")
|
||||
|
||||
message("RDCCLIENT_LIB_INC_LIST=${RDCCLIENT_LIB_INC_LIST}")
|
||||
|
||||
add_library(${RDCCLIENT_LIB} SHARED ${RDCCLIENT_LIB_SRC_LIST} ${RDCCLIENT_LIB_INC_LIST})
|
||||
target_link_libraries(${RDCCLIENT_LIB} pthread rt grpc grpc++ grpc++_reflection
|
||||
dl protobuf)
|
||||
target_include_directories(${RDCCLIENT_LIB} PRIVATE
|
||||
"${PROJECT_SOURCE_DIR}"
|
||||
"${PROJECT_SOURCE_DIR}/include"
|
||||
"${PROTOB_OUT_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
|
||||
# TODO: set the properties for the library once we have one
|
||||
## Set the VERSION and SOVERSION values
|
||||
set_property(TARGET ${RDCCLIENT_LIB} PROPERTY
|
||||
SOVERSION "${VERSION_MAJOR}")
|
||||
set_property(TARGET ${RDCCLIENT_LIB} PROPERTY
|
||||
VERSION "${SO_VERSION_STRING}")
|
||||
|
||||
|
||||
## If the library is a release, strip the target library
|
||||
if ("${CMAKE_BUILD_TYPE}" STREQUAL Release)
|
||||
@@ -183,10 +215,13 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL Release)
|
||||
add_custom_command(
|
||||
TARGET ${RDC_LIB}
|
||||
POST_BUILD COMMAND ${CMAKE_STRIP} lib${RDC_LIB}.so)
|
||||
add_custom_command(
|
||||
TARGET ${RDCCLIENT_LIB}
|
||||
POST_BUILD COMMAND ${CMAKE_STRIP} lib${RDCCLIENT_LIB}.so)
|
||||
endif ()
|
||||
|
||||
## Add the install directives for the runtime library.
|
||||
install(TARGETS ${BOOTSTRAP_LIB} ${RDC_LIB}
|
||||
install(TARGETS ${BOOTSTRAP_LIB} ${RDC_LIB} ${RDCCLIENT_LIB}
|
||||
LIBRARY DESTINATION ${RDC_LIB_ROOT_PATH}${RDC}/lib
|
||||
COMPONENT ${RDC_LIB_COMPONENT})
|
||||
install(FILES ${SOURCE_DIR}/include/rdc/rdc.h
|
||||
|
||||
@@ -320,6 +320,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_CLIENT_ERROR:
|
||||
return "RDC Client error";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
/*
|
||||
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/impl/RdcStandaloneHandler.h"
|
||||
#include <grpcpp/grpcpp.h>
|
||||
#include "rdc.grpc.pb.h" // NOLINT
|
||||
|
||||
|
||||
amd::rdc::RdcHandler *make_handler(const char* ip_and_port) {
|
||||
return new amd::rdc::RdcStandaloneHandler(ip_and_port);
|
||||
}
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
RdcStandaloneHandler::RdcStandaloneHandler(const char* ip_and_port):
|
||||
stub_(::rdc::RdcAPI::NewStub(grpc::CreateChannel(ip_and_port,
|
||||
grpc::InsecureChannelCredentials()))) {
|
||||
}
|
||||
|
||||
rdc_status_t RdcStandaloneHandler::error_handle(::grpc::Status status,
|
||||
uint32_t rdc_status) {
|
||||
if (!status.ok()) {
|
||||
std::cout<< status.error_message() <<". Error code:"
|
||||
<< status.error_code() << std::endl;
|
||||
return RDC_ST_CLIENT_ERROR;
|
||||
}
|
||||
|
||||
if (rdc_status != RDC_ST_OK) {
|
||||
return static_cast<rdc_status_t>(rdc_status);
|
||||
}
|
||||
}
|
||||
|
||||
// JOB RdcAPI
|
||||
rdc_status_t RdcStandaloneHandler::rdc_job_start_stats(rdc_gpu_group_t groupId,
|
||||
char job_id[64], uint64_t update_freq, double max_keep_age,
|
||||
uint32_t max_keep_samples) {
|
||||
// TODO(bill_liu): implement
|
||||
(void)(groupId);
|
||||
(void)(job_id);
|
||||
(void)(update_freq);
|
||||
(void)(max_keep_age);
|
||||
(void)(max_keep_samples);
|
||||
|
||||
return RDC_ST_OK;
|
||||
}
|
||||
|
||||
rdc_status_t RdcStandaloneHandler::rdc_job_get_stats(char job_id[64],
|
||||
rdc_job_info_t* p_job_info) {
|
||||
// TODO(bill_liu): implement
|
||||
(void)(job_id);
|
||||
(void)(p_job_info);
|
||||
return RDC_ST_OK;
|
||||
}
|
||||
|
||||
rdc_status_t RdcStandaloneHandler::rdc_job_stop_stats(char job_id[64] ) {
|
||||
// TODO(bill_liu): implement
|
||||
(void)(job_id);
|
||||
return RDC_ST_OK;
|
||||
}
|
||||
|
||||
|
||||
// Discovery RdcAPI
|
||||
rdc_status_t RdcStandaloneHandler::rdc_get_all_devices(
|
||||
uint32_t gpu_index_list[RDC_MAX_NUM_DEVICES], uint32_t* count) {
|
||||
if (!count) {
|
||||
return RDC_ST_BAD_PARAMETER;
|
||||
}
|
||||
::rdc::Empty request;
|
||||
::rdc::GetAllDevicesResponse reply;
|
||||
::grpc::ClientContext context;
|
||||
|
||||
::grpc::Status status = stub_->GetAllDevices(&context, request, &reply);
|
||||
rdc_status_t err_status = error_handle(status, reply.status());
|
||||
if (err_status != RDC_ST_OK) return err_status;
|
||||
|
||||
if (reply.gpus_size() > RDC_MAX_NUM_DEVICES) {
|
||||
return RDC_ST_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
*count = reply.gpus_size();
|
||||
for (uint32_t i =0 ; i < *count; i++) {
|
||||
gpu_index_list[i] = reply.gpus(i);
|
||||
}
|
||||
|
||||
return RDC_ST_OK;
|
||||
}
|
||||
|
||||
rdc_status_t RdcStandaloneHandler::rdc_get_device_attributes(uint32_t gpu_index,
|
||||
rdc_device_attributes_t* p_rdc_attr) {
|
||||
if (!p_rdc_attr) {
|
||||
return RDC_ST_BAD_PARAMETER;
|
||||
}
|
||||
::rdc::GetDeviceAttributesRequest request;
|
||||
::rdc::GetDeviceAttributesResponse reply;
|
||||
::grpc::ClientContext context;
|
||||
|
||||
request.set_gpu_index(gpu_index);
|
||||
::grpc::Status status = stub_->
|
||||
GetDeviceAttributes(&context, request, &reply);
|
||||
rdc_status_t err_status = error_handle(status, reply.status());
|
||||
if (err_status != RDC_ST_OK) return err_status;
|
||||
|
||||
strncpy_with_null(p_rdc_attr->device_name,
|
||||
reply.attributes().device_name().c_str(), RDC_MAX_STR_LENGTH);
|
||||
|
||||
|
||||
return RDC_ST_OK;
|
||||
}
|
||||
|
||||
|
||||
// Group RdcAPI
|
||||
rdc_status_t RdcStandaloneHandler::rdc_group_gpu_create(rdc_group_type_t type,
|
||||
const char* group_name,
|
||||
rdc_gpu_group_t* p_rdc_group_id) {
|
||||
// TODO(bill_liu): implement
|
||||
(void)(type);
|
||||
(void)(group_name);
|
||||
(void)(p_rdc_group_id);
|
||||
return RDC_ST_OK;
|
||||
}
|
||||
|
||||
rdc_status_t RdcStandaloneHandler::rdc_group_gpu_add(rdc_gpu_group_t group_id,
|
||||
uint32_t gpu_index) {
|
||||
// TODO(bill_liu): implement
|
||||
(void)(group_id);
|
||||
(void)(gpu_index);
|
||||
return RDC_ST_OK;
|
||||
}
|
||||
|
||||
rdc_status_t RdcStandaloneHandler::rdc_group_field_create(
|
||||
uint32_t num_field_ids, uint32_t* field_ids,
|
||||
const char* field_group_name, rdc_field_grp_t* rdc_field_group_id) {
|
||||
// TODO(bill_liu): implement
|
||||
(void)(num_field_ids);
|
||||
(void)(field_ids);
|
||||
(void)(field_group_name);
|
||||
(void)(rdc_field_group_id);
|
||||
return RDC_ST_OK;
|
||||
}
|
||||
|
||||
rdc_status_t RdcStandaloneHandler::rdc_group_field_get_info(
|
||||
rdc_field_grp_t rdc_field_group_id,
|
||||
rdc_field_group_info_t* field_group_info) {
|
||||
// TODO(bill_liu): implement
|
||||
(void)(rdc_field_group_id);
|
||||
(void)(field_group_info);
|
||||
return RDC_ST_OK;
|
||||
}
|
||||
|
||||
rdc_status_t RdcStandaloneHandler::rdc_group_gpu_get_info(
|
||||
rdc_gpu_group_t p_rdc_group_id,
|
||||
rdc_group_info_t* p_rdc_group_info) {
|
||||
// TODO(bill_liu): implement
|
||||
(void)(p_rdc_group_id);
|
||||
(void)(p_rdc_group_info);
|
||||
return RDC_ST_OK;
|
||||
}
|
||||
|
||||
rdc_status_t RdcStandaloneHandler::rdc_group_gpu_destroy(
|
||||
rdc_gpu_group_t p_rdc_group_id) {
|
||||
// TODO(bill_liu): implement
|
||||
(void)(p_rdc_group_id);
|
||||
return RDC_ST_OK;
|
||||
}
|
||||
|
||||
rdc_status_t RdcStandaloneHandler::rdc_group_field_destroy(
|
||||
rdc_field_grp_t rdc_field_group_id) {
|
||||
// TODO(bill_liu): implement
|
||||
(void)(rdc_field_group_id);
|
||||
return RDC_ST_OK;
|
||||
}
|
||||
|
||||
// Field RdcAPI
|
||||
rdc_status_t RdcStandaloneHandler::rdc_watch_fields(rdc_gpu_group_t group_id,
|
||||
rdc_field_grp_t field_group_id, uint64_t update_freq,
|
||||
double max_keep_age, uint32_t max_keep_samples) {
|
||||
// TODO(bill_liu): implement
|
||||
(void)(group_id);
|
||||
(void)(field_group_id);
|
||||
(void)(update_freq);
|
||||
(void)(max_keep_age);
|
||||
(void)(max_keep_samples);
|
||||
return RDC_ST_OK;
|
||||
}
|
||||
|
||||
rdc_status_t RdcStandaloneHandler::rdc_get_latest_value_for_field(
|
||||
uint32_t gpu_index, uint32_t field, rdc_field_value* value) {
|
||||
// TODO(bill_liu): implement
|
||||
if (!value) {
|
||||
return RDC_ST_BAD_PARAMETER;
|
||||
}
|
||||
(void)(gpu_index);
|
||||
(void)(field);
|
||||
return RDC_ST_NOT_FOUND;
|
||||
}
|
||||
|
||||
rdc_status_t RdcStandaloneHandler::rdc_get_field_value_since(uint32_t gpu_index,
|
||||
uint32_t field, uint64_t since_time_stamp,
|
||||
uint64_t *next_since_time_stamp, rdc_field_value* value) {
|
||||
// TODO(bill_liu): implement
|
||||
if (!next_since_time_stamp || !value) {
|
||||
return RDC_ST_BAD_PARAMETER;
|
||||
}
|
||||
(void)(since_time_stamp);
|
||||
(void)(gpu_index);
|
||||
(void)(field);
|
||||
(void)(value);
|
||||
|
||||
return RDC_ST_NOT_FOUND;
|
||||
}
|
||||
|
||||
rdc_status_t RdcStandaloneHandler::rdc_unwatch_fields(rdc_gpu_group_t group_id,
|
||||
rdc_field_grp_t field_group_id) {
|
||||
// TODO(bill_liu): implement
|
||||
(void)(group_id);
|
||||
(void)(field_group_id);
|
||||
return RDC_ST_OK;
|
||||
}
|
||||
|
||||
|
||||
// Control RdcAPI
|
||||
rdc_status_t RdcStandaloneHandler::rdc_update_all_fields(
|
||||
uint32_t wait_for_update) {
|
||||
// TODO(bill_liu): implement
|
||||
(void)(wait_for_update);
|
||||
return RDC_ST_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace rdc
|
||||
} // namespace amd
|
||||
Reference in new issue
Block a user