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
Cette révision appartient à :
révisé par
Chris Freehill
Parent
1ff1c7b617
révision
020f6939f7
@@ -143,6 +143,7 @@ add_subdirectory("server")
|
||||
add_subdirectory("client")
|
||||
add_subdirectory("rdc_libs")
|
||||
add_subdirectory("example")
|
||||
add_subdirectory("rdci")
|
||||
|
||||
# Turn on cmake "component install"
|
||||
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
|
||||
|
||||
@@ -1,2 +1,9 @@
|
||||
# rdc
|
||||
Radeon Data Center
|
||||
|
||||
## To run the rdcd and rdci from the build folder
|
||||
```
|
||||
sudo LD_LIBRARY_PATH=$PWD/rdc_libs/ ./server/rdcd
|
||||
LD_LIBRARY_PATH=$PWD/rdc_libs/ ./rdci/rdci discovery
|
||||
```
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
# Copyright (c) 2019 - 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
|
||||
@@ -63,7 +63,7 @@ endif()
|
||||
# TODO see if we really need this in the end
|
||||
include(utils)
|
||||
|
||||
set(CLIENT_LIB "rdc_client")
|
||||
set(CLIENT_LIB "rdc_client_smi")
|
||||
set(RDC "rdc")
|
||||
set(CLIENT_LIB_COMPONENT "lib${CLIENT_LIB}")
|
||||
set(SRC_DIR "${PROJECT_SOURCE_DIR}/client/src")
|
||||
|
||||
@@ -51,6 +51,7 @@ typedef enum {
|
||||
RDC_ST_BAD_PARAMETER, //!< A parameter is invalid
|
||||
RDC_ST_NOT_FOUND, //!< Cannot find the value
|
||||
RDC_ST_CONFLICT, //!< Conflict with current state
|
||||
RDC_ST_CLIENT_ERROR, //!< The RDC client error
|
||||
RDC_ST_MAX_LIMIT //!< Max limit recording for the object
|
||||
} rdc_status_t;
|
||||
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
#ifndef RDC_LIB_IMPL_RDCSTANDALONEHANDLER_H_
|
||||
#define RDC_LIB_IMPL_RDCSTANDALONEHANDLER_H_
|
||||
#include <grpcpp/grpcpp.h>
|
||||
#include <memory>
|
||||
#include "rdc.grpc.pb.h" // NOLINT
|
||||
#include "rdc_lib/RdcHandler.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
class RdcStandaloneHandler: public RdcHandler {
|
||||
public:
|
||||
// Job RdcAPI
|
||||
rdc_status_t 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) override;
|
||||
rdc_status_t rdc_job_get_stats(char jobId[64],
|
||||
rdc_job_info_t* p_job_info) override;
|
||||
rdc_status_t rdc_job_stop_stats(char job_id[64]) override;
|
||||
|
||||
// Discovery RdcAPI
|
||||
rdc_status_t rdc_get_all_devices(
|
||||
uint32_t gpu_index_list[RDC_MAX_NUM_DEVICES], uint32_t* count) override;
|
||||
rdc_status_t rdc_get_device_attributes(uint32_t gpu_index,
|
||||
rdc_device_attributes_t* p_rdc_attr) override;
|
||||
|
||||
// Group RdcAPI
|
||||
rdc_status_t rdc_group_gpu_create(rdc_group_type_t type,
|
||||
const char* group_name,
|
||||
rdc_gpu_group_t* p_rdc_group_id) override;
|
||||
rdc_status_t rdc_group_gpu_add(rdc_gpu_group_t groupId,
|
||||
uint32_t gpu_index) override;
|
||||
rdc_status_t 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) override;
|
||||
rdc_status_t rdc_group_field_get_info(
|
||||
rdc_field_grp_t rdc_field_group_id,
|
||||
rdc_field_group_info_t* field_group_info) override;
|
||||
rdc_status_t rdc_group_gpu_get_info(rdc_gpu_group_t p_rdc_group_id,
|
||||
rdc_group_info_t* p_rdc_group_info) override;
|
||||
rdc_status_t rdc_group_gpu_destroy(
|
||||
rdc_gpu_group_t p_rdc_group_id) override;
|
||||
rdc_status_t rdc_group_field_destroy(
|
||||
rdc_field_grp_t rdc_field_group_id) override;
|
||||
|
||||
// Field RdcAPI
|
||||
rdc_status_t 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) override;
|
||||
rdc_status_t rdc_get_latest_value_for_field(uint32_t gpu_index,
|
||||
uint32_t field, rdc_field_value* value) override;
|
||||
rdc_status_t 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) override;
|
||||
rdc_status_t rdc_unwatch_fields(rdc_gpu_group_t group_id,
|
||||
rdc_field_grp_t field_group_id) override;
|
||||
|
||||
// Control RdcAPI
|
||||
rdc_status_t rdc_update_all_fields(uint32_t wait_for_update) override;
|
||||
|
||||
explicit RdcStandaloneHandler(const char* ip_and_port);
|
||||
|
||||
private:
|
||||
// Helper function to handle the error
|
||||
rdc_status_t error_handle(::grpc::Status status, uint32_t rdc_status);
|
||||
std::unique_ptr<::rdc::RdcAPI::Stub> stub_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace rdc
|
||||
} // namespace amd
|
||||
|
||||
extern "C" {
|
||||
amd::rdc::RdcHandler *make_handler(const char* ip_port);
|
||||
}
|
||||
|
||||
#endif // RDC_LIB_IMPL_RDCSTANDALONEHANDLER_H_
|
||||
@@ -127,3 +127,235 @@ message VerifyConnectionResponse {
|
||||
uint64 echo_magic_num = 1;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/********************************** RdcAPI Service ************************/
|
||||
/****************************************************************************/
|
||||
|
||||
service RdcAPI {
|
||||
// Discovery API
|
||||
// rdc_status_t rdc_get_all_devices(uint32_t gpu_index_list[RDC_MAX_NUM_DEVICES], uint32_t* count)
|
||||
rpc GetAllDevices(Empty) returns (GetAllDevicesResponse) {}
|
||||
// rdc_status_t rdc_get_device_attributes(uint32_t gpu_index, rdc_device_attributes_t* p_rdc_attr)
|
||||
rpc GetDeviceAttributes(GetDeviceAttributesRequest) returns (GetDeviceAttributesResponse) {}
|
||||
|
||||
// Group API
|
||||
// rdc_status_t rdc_group_gpu_create(rdc_group_type_t type,
|
||||
// const char* group_name, rdc_gpu_group_t* p_rdc_group_id)
|
||||
rpc CreateGpuGroup(CreateGpuGroupRequest) returns (CreateGpuGroupResponse) {}
|
||||
|
||||
// rdc_status_t rdc_group_gpu_add(rdc_gpu_group_t groupId,
|
||||
// uint32_t gpu_index)
|
||||
rpc AddToGpuGroup(AddToGpuGroupRequest) returns (AddToGpuGroupResponse) {}
|
||||
|
||||
// rdc_status_t 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)
|
||||
rpc CreateFieldGroup(CreateFieldGroupRequest) returns (CreateFieldGroupResponse) {}
|
||||
|
||||
// rdc_status_t rdc_group_field_get_info(
|
||||
// rdc_field_grp_t rdc_field_group_id,
|
||||
// rdc_field_group_info_t* field_group_info)
|
||||
rpc GetFieldGroupInfo(GetFieldGroupInfoRequest) returns (GetFieldGroupInfoResponse) {}
|
||||
|
||||
// rdc_status_t rdc_group_gpu_get_info(
|
||||
// rdc_gpu_group_t p_rdc_group_id, rdc_group_info_t* p_rdc_group_info)
|
||||
rpc GetGpuGroupInfo(GetGpuGroupInfoRequest) returns (GetGpuGroupInfoResponse) {}
|
||||
|
||||
// rdc_status_t rdc_group_gpu_destroy(
|
||||
// rdc_gpu_group_t p_rdc_group_id)
|
||||
rpc DestroyGpuGroup(DestroyGpuGroupRequest) returns (DestroyGpuGroupResponse) {}
|
||||
|
||||
// rdc_status_t rdc_group_field_destroy(
|
||||
// rdc_field_grp_t rdc_field_group_id)
|
||||
rpc DestroyFieldGroup(DestroyFieldGroupRequest) returns (DestroyFieldGroupResponse) {}
|
||||
|
||||
// Field API
|
||||
// rdc_status_t 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)
|
||||
rpc WatchFields(WatchFieldsRequest) returns (WatchFieldsResponse) {}
|
||||
|
||||
// rdc_status_t rdc_get_latest_value_for_field(uint32_t gpu_index,
|
||||
// uint32_t field, rdc_field_value* value)
|
||||
rpc GetLatestFieldValue(GetLatestFieldValueRequest) returns (GetLatestFieldValueResponse) {}
|
||||
|
||||
// rdc_status_t 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)
|
||||
rpc GetFieldSince(GetFieldSinceRequest) returns (GetFieldSinceResponse) {}
|
||||
|
||||
// rdc_status_t rdc_unwatch_fields(rdc_gpu_group_t group_id,
|
||||
// rdc_field_grp_t field_group_id)
|
||||
rpc UnWatchFields(UnWatchFieldsRequest) returns (UnWatchFieldsResponse) {}
|
||||
|
||||
// rdc_status_t rdc_update_all_fields(uint32_t wait_for_update)
|
||||
rpc UpdateAllFields(UpdateAllFieldsRequest) returns (UpdateAllFieldsResponse) {}
|
||||
}
|
||||
|
||||
message Empty {
|
||||
}
|
||||
|
||||
message GetAllDevicesResponse {
|
||||
uint32 status = 1;
|
||||
repeated uint32 gpus = 2;
|
||||
}
|
||||
|
||||
message GetDeviceAttributesRequest {
|
||||
uint32 gpu_index = 1;
|
||||
}
|
||||
|
||||
message DeviceAttributes {
|
||||
string device_name = 1;
|
||||
}
|
||||
|
||||
message GetDeviceAttributesResponse {
|
||||
uint32 status = 1;
|
||||
DeviceAttributes attributes = 2;
|
||||
}
|
||||
|
||||
message CreateGpuGroupRequest {
|
||||
enum GpuGroupType {
|
||||
RDC_GROUP_DEFAULT = 0;
|
||||
RDC_GROUP_EMPTY = 1;
|
||||
}
|
||||
GpuGroupType type = 1;
|
||||
string group_name = 2;
|
||||
}
|
||||
|
||||
message CreateGpuGroupResponse {
|
||||
uint32 status = 1;
|
||||
uint32 group_id = 2;
|
||||
}
|
||||
|
||||
message AddToGpuGroupRequest {
|
||||
uint32 group_id = 1;
|
||||
uint32 gpu_index = 2;
|
||||
}
|
||||
|
||||
message AddToGpuGroupResponse {
|
||||
uint32 status = 1;
|
||||
}
|
||||
message CreateFieldGroupRequest {
|
||||
repeated uint32 field_ids = 1;
|
||||
string filed_group_name = 2;
|
||||
}
|
||||
|
||||
message CreateFieldGroupResponse {
|
||||
uint32 status = 1;
|
||||
uint32 field_group_id = 2;
|
||||
}
|
||||
|
||||
message GetFieldGroupInfoRequest {
|
||||
uint32 field_group_id = 1;
|
||||
}
|
||||
|
||||
message GetFieldGroupInfoResponse {
|
||||
uint32 status = 1;
|
||||
string filed_group_name = 2;
|
||||
repeated uint32 field_ids = 3;
|
||||
}
|
||||
|
||||
message GetGpuGroupInfoRequest {
|
||||
uint32 group_id = 1;
|
||||
}
|
||||
|
||||
message GetGpuGroupInfoResponse {
|
||||
uint32 status = 1;
|
||||
string group_name = 2;
|
||||
repeated uint32 entity_ids = 3;
|
||||
}
|
||||
|
||||
message DestroyGpuGroupRequest {
|
||||
uint32 group_id = 1;
|
||||
}
|
||||
|
||||
message DestroyGpuGroupResponse {
|
||||
uint32 status = 1;
|
||||
}
|
||||
|
||||
message DestroyFieldGroupRequest {
|
||||
uint32 field_group_id = 1;
|
||||
}
|
||||
|
||||
message DestroyFieldGroupResponse {
|
||||
uint32 status = 1;
|
||||
}
|
||||
|
||||
message WatchFieldsRequest {
|
||||
uint32 group_id = 1;
|
||||
uint32 field_group_id = 2;
|
||||
uint64 update_freq = 3;
|
||||
double max_keep_age = 4;
|
||||
uint32 max_keep_samples = 5;
|
||||
}
|
||||
|
||||
message WatchFieldsResponse {
|
||||
uint32 status = 1;
|
||||
}
|
||||
|
||||
message GetLatestFieldValueRequest {
|
||||
uint32 gpu_index = 1;
|
||||
uint32 field_id = 2;
|
||||
}
|
||||
|
||||
message GetLatestFieldValueResponse {
|
||||
uint32 status = 1;
|
||||
uint32 field_id = 2;
|
||||
uint32 rdc_status = 3;
|
||||
uint64 ts = 4;
|
||||
enum FieldType {
|
||||
INTEGER = 0;
|
||||
DOUBLE = 1;
|
||||
STRING = 2;
|
||||
BLOB = 3;
|
||||
};
|
||||
FieldType type = 5;
|
||||
oneof value {
|
||||
uint64 l_int = 6;
|
||||
double dbl = 7;
|
||||
string str = 8;
|
||||
}
|
||||
}
|
||||
|
||||
message GetFieldSinceRequest {
|
||||
uint32 gpu_index = 1;
|
||||
uint32 field_id = 2;
|
||||
uint64 since_time_stamp = 3;
|
||||
}
|
||||
|
||||
message GetFieldSinceResponse {
|
||||
uint32 status = 1;
|
||||
uint64 next_since_time_stamp = 2;
|
||||
uint32 field_id = 3;
|
||||
uint32 rdc_status = 4;
|
||||
uint64 ts = 5;
|
||||
enum FieldType {
|
||||
INTEGER = 0;
|
||||
DOUBLE = 1;
|
||||
STRING = 2;
|
||||
BLOB = 3;
|
||||
};
|
||||
FieldType type = 6;
|
||||
oneof value {
|
||||
uint64 l_int = 7;
|
||||
double dbl = 8;
|
||||
string str = 9;
|
||||
}
|
||||
}
|
||||
|
||||
message UnWatchFieldsRequest {
|
||||
uint32 group_id = 1;
|
||||
uint32 field_group_id = 2;
|
||||
}
|
||||
|
||||
message UnWatchFieldsResponse {
|
||||
uint32 status = 1;
|
||||
}
|
||||
|
||||
message UpdateAllFieldsRequest {
|
||||
uint32 wait_for_update = 1;
|
||||
}
|
||||
|
||||
message UpdateAllFieldsResponse {
|
||||
uint32 status = 1;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,86 @@
|
||||
# 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.
|
||||
|
||||
#
|
||||
# Minimum version of cmake required
|
||||
#
|
||||
cmake_minimum_required(VERSION 3.5.0)
|
||||
|
||||
message("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
|
||||
message(" Cmake rdci ")
|
||||
message("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
|
||||
|
||||
message("")
|
||||
message("Build Configuration:")
|
||||
message("-----------BuildType: " ${CMAKE_BUILD_TYPE})
|
||||
message("------------Compiler: " ${CMAKE_CXX_COMPILER})
|
||||
message("-------------Version: " ${CMAKE_CXX_COMPILER_VERSION})
|
||||
message("--------Proj Src Dir: " ${PROJECT_SOURCE_DIR})
|
||||
message("--------Proj Bld Dir: " ${PROJECT_BINARY_DIR})
|
||||
message("--------Proj Lib Dir: " ${PROJECT_BINARY_DIR}/lib)
|
||||
message("--------Proj Exe Dir: " ${PROJECT_BINARY_DIR}/bin)
|
||||
message("--------RSMI Lib Dir: " ${RSMI_LIB_DIR})
|
||||
message("--------RSMI Inc Dir: " ${RSMI_INC_DIR})
|
||||
message("")
|
||||
|
||||
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
CACHE STRING "Location of RDC example library source code.")
|
||||
# set(CMAKE_INSTALL_PREFIX "/"
|
||||
# CACHE STRING "Default installation directory.")
|
||||
# set(CPACK_PACKAGING_INSTALL_PREFIX "/"
|
||||
# CACHE STRING "Default packaging prefix.")
|
||||
#
|
||||
|
||||
## Compiler flags
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -m64")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -msse2 -std=c++11 -pthread ")
|
||||
# Use this instead of above for 32 bit
|
||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
|
||||
|
||||
if ("${CMAKE_BUILD_TYPE}" STREQUAL Release)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
||||
else ()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb -O0 -DDEBUG")
|
||||
endif ()
|
||||
|
||||
set(SRC_DIR "${PROJECT_SOURCE_DIR}/rdci/src")
|
||||
set(INC_DIR "${PROJECT_SOURCE_DIR}/rdci/include")
|
||||
set(LIB_BOOSTRAP_DIR "${PROJECT_BINARY_DIR}/rdc_libs")
|
||||
|
||||
include_directories(${INC_DIR} ${PROJECT_SOURCE_DIR}/include)
|
||||
|
||||
set(RDCI_SRC_LIST "${SRC_DIR}/rdci.cc")
|
||||
set(RDCI_SRC_LIST ${RDCI_SRC_LIST} "${SRC_DIR}/RdciDisCoverySubSystem.cc")
|
||||
set(RDCI_SRC_LIST ${RDCI_SRC_LIST} "${SRC_DIR}/RdciSubSystem.cc")
|
||||
message("RDCI_SRC_LIST=${RDCI_SRC_LIST}")
|
||||
set(RDCI_EXE "rdci")
|
||||
|
||||
link_directories(${LIB_BOOSTRAP_DIR})
|
||||
|
||||
add_executable(${RDCI_EXE} "${RDCI_SRC_LIST}")
|
||||
|
||||
target_link_libraries(${RDCI_EXE} pthread dl rdc_bootstrap)
|
||||
|
||||
|
||||
|
||||
|
||||
message("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
|
||||
message(" Finished Cmake rdci ")
|
||||
message("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
Copyright (c) 2019 - 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 RDCI_INCLUDE_RDCEXCEPTION_H_
|
||||
#define RDCI_INCLUDE_RDCEXCEPTION_H_
|
||||
|
||||
#include <exception>
|
||||
#include <string>
|
||||
#include "rdc/rdc.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
class RdcException : public std::exception {
|
||||
public:
|
||||
RdcException(rdc_status_t error, const std::string description) :
|
||||
err_(error), desc_(description) {}
|
||||
rdc_status_t error_code() const noexcept { return err_; }
|
||||
const char* what() const noexcept override { return desc_.c_str(); }
|
||||
|
||||
private:
|
||||
rdc_status_t err_;
|
||||
std::string desc_;
|
||||
};
|
||||
|
||||
} // namespace rdc
|
||||
} // namespace amd
|
||||
|
||||
#endif // RDCI_INCLUDE_RDCEXCEPTION_H_
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
#ifndef RDCI_INCLUDE_RDCIDISCOVERYSUBSYSTEM_H_
|
||||
#define RDCI_INCLUDE_RDCIDISCOVERYSUBSYSTEM_H_
|
||||
|
||||
#include "RdciSubSystem.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
class RdciDiscoverySubSystem: public RdciSubSystem {
|
||||
public:
|
||||
RdciDiscoverySubSystem();
|
||||
void parse_cmd_opts(int argc, char ** argv) override;
|
||||
void process() override;
|
||||
private:
|
||||
bool show_help_;
|
||||
void show_help() const;
|
||||
};
|
||||
|
||||
|
||||
} // namespace rdc
|
||||
} // namespace amd
|
||||
|
||||
|
||||
#endif // RDCI_INCLUDE_RDCIDISCOVERYSUBSYSTEM_H_
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
#ifndef RDCI_INCLUDE_RDCISUBSYSTEM_H_
|
||||
#define RDCI_INCLUDE_RDCISUBSYSTEM_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "rdc_lib/rdc_common.h"
|
||||
#include "rdc/rdc.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
class RdciSubSystem {
|
||||
public:
|
||||
RdciSubSystem();
|
||||
virtual void parse_cmd_opts(int argc, char ** argv) = 0;
|
||||
virtual void connect();
|
||||
|
||||
virtual void process() = 0;
|
||||
virtual ~RdciSubSystem();
|
||||
protected:
|
||||
rdc_handle_t rdc_handle_;
|
||||
std::string ip_port_;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<RdciSubSystem> RdciSubSystemPtr;
|
||||
|
||||
} // namespace rdc
|
||||
} // namespace amd
|
||||
|
||||
|
||||
#endif // RDCI_INCLUDE_RDCISUBSYSTEM_H_
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
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 <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include "rdc_lib/rdc_common.h"
|
||||
#include "rdc/rdc.h"
|
||||
#include "RdcException.h"
|
||||
#include "RdciDiscoverySubSystem.h"
|
||||
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
RdciDiscoverySubSystem::RdciDiscoverySubSystem() :show_help_(false) {
|
||||
}
|
||||
|
||||
void RdciDiscoverySubSystem::parse_cmd_opts(int argc, char ** argv) {
|
||||
const int HOST_OPTIONS = 1000;
|
||||
const struct option long_options[] = {
|
||||
{"host", required_argument, nullptr, HOST_OPTIONS },
|
||||
{"help", optional_argument, nullptr, 'h' },
|
||||
{ nullptr, 0 , nullptr, 0 }
|
||||
};
|
||||
|
||||
int option_index = 0;
|
||||
int opt = 0;
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "h",
|
||||
long_options, &option_index)) != -1) {
|
||||
switch (opt) {
|
||||
case HOST_OPTIONS:
|
||||
ip_port_ = optarg;
|
||||
break;
|
||||
case 'h':
|
||||
show_help_ = true;
|
||||
return;
|
||||
default:
|
||||
show_help();
|
||||
throw RdcException(RDC_ST_BAD_PARAMETER,
|
||||
"Unknown command line options");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RdciDiscoverySubSystem::show_help() const {
|
||||
std::cout << " discovery -- Used to discover and identify GPUs "
|
||||
<< "and their attributes.\n\n";
|
||||
std::cout << "Usage\n";
|
||||
std::cout << " rdci discovery [--host <IP/FQDN>:port]\n";
|
||||
std::cout << "\nFlags:\n";
|
||||
std::cout << " --host <IP/FQDN>:port Connects to "
|
||||
<< "specified IP or fully-qualified domain name.\n";
|
||||
std::cout << " The port "
|
||||
<< "must be specified.\n";
|
||||
std::cout << " Default: localhost:50051\n";
|
||||
std::cout << " -h --help Displays usage "
|
||||
<< "information and exits.\n";
|
||||
}
|
||||
|
||||
|
||||
void RdciDiscoverySubSystem::process() {
|
||||
if (show_help_) {
|
||||
return show_help();
|
||||
}
|
||||
|
||||
uint32_t gpu_index_list[RDC_MAX_NUM_DEVICES];
|
||||
uint32_t count = 0;
|
||||
rdc_status_t result = rdc_get_all_devices(rdc_handle_,
|
||||
gpu_index_list, &count);
|
||||
if (result != RDC_ST_OK) {
|
||||
throw RdcException(result, "Fail to get device information");
|
||||
}
|
||||
if (count == 0) {
|
||||
std::cout << "No GPUs find on the sytem\n";
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << count << " GPUs found.\n";
|
||||
std::cout << "------------------------------------------------"
|
||||
<< "-----------------\n";
|
||||
std::cout << "GPU Index\t Device Information\n";
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
rdc_device_attributes_t attribute;
|
||||
result = rdc_get_device_attributes(rdc_handle_,
|
||||
gpu_index_list[i], &attribute);
|
||||
if (result != RDC_ST_OK) {
|
||||
return;
|
||||
}
|
||||
std::cout << i << "\t\t" << attribute.device_name <<std::endl;
|
||||
}
|
||||
std::cout << "------------------------------------------------"
|
||||
<< "-----------------\n";
|
||||
}
|
||||
|
||||
|
||||
} // namespace rdc
|
||||
} // namespace amd
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
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 "RdciSubSystem.h"
|
||||
#include "RdcException.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
RdciSubSystem::RdciSubSystem():
|
||||
rdc_handle_(nullptr)
|
||||
, ip_port_("localhost:50051") { // default host
|
||||
rdc_status_t status = rdc_init(0);
|
||||
if (status != RDC_ST_OK) {
|
||||
throw RdcException(status, "RDC initialize fail");
|
||||
}
|
||||
}
|
||||
|
||||
void RdciSubSystem::connect() {
|
||||
rdc_status_t status = rdc_connect(ip_port_.c_str(), &rdc_handle_);
|
||||
if (status != RDC_ST_OK) {
|
||||
throw RdcException(status, "Fail to setup the connection");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RdciSubSystem::~RdciSubSystem() {
|
||||
if (rdc_handle_) {
|
||||
rdc_disconnect(rdc_handle_);
|
||||
rdc_handle_ = nullptr;
|
||||
}
|
||||
|
||||
rdc_shutdown();
|
||||
}
|
||||
|
||||
|
||||
} // namespace rdc
|
||||
} // namespace amd
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
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 <iostream>
|
||||
#include <string>
|
||||
#include "rdc_lib/rdc_common.h"
|
||||
#include "rdc/rdc.h"
|
||||
#include "RdcException.h"
|
||||
#include "RdciDiscoverySubSystem.h"
|
||||
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
const std::string usage_help =
|
||||
"Usage:\trdci <subsystem>\nsubsystem: discovery, dmon, group, "
|
||||
"fieldgroup, stats\n";
|
||||
|
||||
if (argc <= 1) {
|
||||
std::cout << usage_help;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
try {
|
||||
std::string subsystem_name = argv[1];
|
||||
amd::rdc::RdciSubSystemPtr subsystem;
|
||||
if (subsystem_name == "discovery") {
|
||||
subsystem.reset(new amd::rdc::RdciDiscoverySubSystem());
|
||||
} else {
|
||||
std::cout << usage_help;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
subsystem->parse_cmd_opts(argc, argv);
|
||||
|
||||
subsystem->connect();
|
||||
|
||||
subsystem->process();
|
||||
} catch (const amd::rdc::RdcException& e) {
|
||||
std::cout << "rdci Error: " << e.what() << std::endl;
|
||||
return e.error_code();
|
||||
} catch (...) {
|
||||
std::cout << "Unhandled exception." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
# Copyright (c) 2019 - 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
|
||||
@@ -46,7 +46,7 @@ set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
# CACHE STRING "Default installation directory.")
|
||||
# set(CPACK_PACKAGING_INSTALL_PREFIX "/"
|
||||
# CACHE STRING "Default packaging prefix.")
|
||||
#
|
||||
#
|
||||
|
||||
## Compiler flags
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -m64")
|
||||
@@ -68,10 +68,12 @@ file(GLOB PROTOBUF_GENERATED_INCLUDES "${PROTOB_OUT_DIR}/*.h")
|
||||
file(GLOB PROTOBUF_GENERATED_SRCS "${PROTOB_OUT_DIR}/*.cc")
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
"${PROJECT_SOURCE_DIR}/include"
|
||||
"${PROTOB_OUT_DIR}" "${RSMI_INC_DIR}")
|
||||
|
||||
set(SERVER_SRC_LIST "${SRC_DIR}/rdc_rsmi_service.cc")
|
||||
set(SERVER_SRC_LIST ${SERVER_SRC_LIST} "${SRC_DIR}/rdc_admin_service.cc")
|
||||
set(SERVER_SRC_LIST ${SERVER_SRC_LIST} "${SRC_DIR}/rdc_api_service.cc")
|
||||
set(SERVER_SRC_LIST ${SERVER_SRC_LIST} "${SRC_DIR}/rdc_server_main.cc")
|
||||
set(SERVER_SRC_LIST ${SERVER_SRC_LIST} "${SRC_DIR}/rdc_server_utils.cc")
|
||||
set(SERVER_SRC_LIST ${SERVER_SRC_LIST} "${PROTOBUF_GENERATED_SRCS}")
|
||||
@@ -86,7 +88,7 @@ add_executable(${SERVER_DAEMON_EXE} "${SERVER_SRC_LIST}")
|
||||
# target_include_directories(${SERVER_DAEMON_EXE} PUBLIC ${RSMI_INC_DIR})
|
||||
|
||||
target_link_libraries(${SERVER_DAEMON_EXE} pthread rt grpc grpc++
|
||||
cap grpc++_reflection dl protobuf rocm_smi64)
|
||||
cap grpc++_reflection dl protobuf rocm_smi64 rdc_bootstrap)
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SERVER_DAEMON_EXE}
|
||||
PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE GROUP_READ
|
||||
|
||||
Fichier exécutable
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
#ifndef SERVER_INCLUDE_RDC_RDC_API_SERVICE_H_
|
||||
#define SERVER_INCLUDE_RDC_RDC_API_SERVICE_H_
|
||||
|
||||
#include "rdc.grpc.pb.h" // NOLINT
|
||||
#include "rdc/rdc.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
class RdcAPIServiceImpl final : public ::rdc::RdcAPI::Service {
|
||||
public:
|
||||
RdcAPIServiceImpl();
|
||||
~RdcAPIServiceImpl();
|
||||
|
||||
rdc_status_t Initialize(uint64_t rdcd_init_flags = 0);
|
||||
|
||||
::grpc::Status GetAllDevices(::grpc::ServerContext* context,
|
||||
const ::rdc::Empty* request,
|
||||
::rdc::GetAllDevicesResponse* reply) override;
|
||||
|
||||
::grpc::Status GetDeviceAttributes(::grpc::ServerContext* context,
|
||||
const ::rdc::GetDeviceAttributesRequest* request,
|
||||
::rdc::GetDeviceAttributesResponse* reply) override;
|
||||
|
||||
private:
|
||||
rdc_handle_t rdc_handle_;
|
||||
};
|
||||
|
||||
} // namespace rdc
|
||||
} // namespace amd
|
||||
|
||||
#endif // SERVER_INCLUDE_RDC_RDC_API_SERVICE_H_
|
||||
@@ -29,6 +29,7 @@ THE SOFTWARE.
|
||||
|
||||
#include "rdc/rdc_rsmi_service.h"
|
||||
#include "rdc/rdc_admin_service.h"
|
||||
#include "rdc/rdc_api_service.h"
|
||||
|
||||
class RDCServer {
|
||||
public:
|
||||
@@ -45,6 +46,9 @@ class RDCServer {
|
||||
bool start_rdc_admin_service(void) const {return start_rdc_admin_service_;}
|
||||
void set_start_rdc_admin_service(bool s) {start_rdc_admin_service_ = s;}
|
||||
|
||||
bool start_api_service(void) const {return start_api_service_;}
|
||||
void set_start_api_service(bool s) {start_api_service_ = s;}
|
||||
|
||||
void ShutDown(void);
|
||||
|
||||
private:
|
||||
@@ -57,6 +61,9 @@ class RDCServer {
|
||||
|
||||
bool start_rdc_admin_service_;
|
||||
amd::rdc::RDCAdminServiceImpl *rdc_admin_service_;
|
||||
|
||||
bool start_api_service_;
|
||||
amd::rdc::RdcAPIServiceImpl *api_service_;
|
||||
};
|
||||
|
||||
#endif // SERVER_INCLUDE_RDC_RDC_SERVER_MAIN_H_
|
||||
|
||||
Fichier exécutable
+110
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
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 <assert.h>
|
||||
#include <grpcpp/grpcpp.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <csignal>
|
||||
|
||||
#include "rdc.grpc.pb.h" // NOLINT
|
||||
#include "rdc/rdc_api_service.h"
|
||||
#include "rdc/rdc.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
RdcAPIServiceImpl::RdcAPIServiceImpl():rdc_handle_(nullptr) {
|
||||
}
|
||||
|
||||
rdc_status_t RdcAPIServiceImpl::Initialize(uint64_t rdcd_init_flags) {
|
||||
rdc_status_t result = rdc_init(rdcd_init_flags);
|
||||
if (result != RDC_ST_OK) {
|
||||
std::cout << "RDC API initialize fail\n";
|
||||
return result;
|
||||
}
|
||||
|
||||
result = rdc_start_embedded(RDC_OPERATION_MODE_AUTO, &rdc_handle_);
|
||||
if (result != RDC_ST_OK) {
|
||||
std::cout << "RDC API start embedded fail\n";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
RdcAPIServiceImpl::~RdcAPIServiceImpl() {
|
||||
if (rdc_handle_) {
|
||||
rdc_stop_embedded(rdc_handle_);
|
||||
rdc_handle_ = nullptr;
|
||||
}
|
||||
rdc_shutdown();
|
||||
}
|
||||
|
||||
::grpc::Status RdcAPIServiceImpl::GetAllDevices(::grpc::ServerContext* context,
|
||||
const ::rdc::Empty* request,
|
||||
::rdc::GetAllDevicesResponse* reply) {
|
||||
(void)(context);
|
||||
(void)(request);
|
||||
if (!reply) {
|
||||
return ::grpc::Status(::grpc::StatusCode::INTERNAL, "Empty reply");
|
||||
}
|
||||
uint32_t gpu_index_list[RDC_MAX_NUM_DEVICES];
|
||||
uint32_t count = 0;
|
||||
rdc_status_t result = rdc_get_all_devices(rdc_handle_,
|
||||
gpu_index_list, &count);
|
||||
reply->set_status(result);
|
||||
if (result != RDC_ST_OK) {
|
||||
return ::grpc::Status::OK;
|
||||
}
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
reply->add_gpus(gpu_index_list[i]);
|
||||
}
|
||||
|
||||
return ::grpc::Status::OK;
|
||||
}
|
||||
|
||||
::grpc::Status RdcAPIServiceImpl::GetDeviceAttributes(
|
||||
::grpc::ServerContext* context,
|
||||
const ::rdc::GetDeviceAttributesRequest* request,
|
||||
::rdc::GetDeviceAttributesResponse* reply) {
|
||||
(void)(context);
|
||||
if (!reply || !request) {
|
||||
return ::grpc::Status(::grpc::StatusCode::INTERNAL, "Empty contents");
|
||||
}
|
||||
uint32_t gpu_index = request->gpu_index();
|
||||
rdc_device_attributes_t attribute;
|
||||
rdc_status_t result = rdc_get_device_attributes(rdc_handle_,
|
||||
gpu_index, &attribute);
|
||||
|
||||
::rdc::DeviceAttributes* attr = reply->mutable_attributes();
|
||||
attr->set_device_name(attribute.device_name);
|
||||
|
||||
reply->set_status(result);
|
||||
|
||||
return ::grpc::Status::OK;
|
||||
}
|
||||
|
||||
} // namespace rdc
|
||||
} // namespace amd
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ THE SOFTWARE.
|
||||
#include "rocm_smi/rocm_smi.h"
|
||||
#include "rdc/rdc_server_main.h"
|
||||
#include "rdc/rdc_rsmi_service.h"
|
||||
#include "rdc/rdc_api_service.h"
|
||||
#include "rdc/rdc_server_utils.h"
|
||||
|
||||
static bool sShutDownServer = false;
|
||||
@@ -86,6 +87,19 @@ RDCServer::Run() {
|
||||
}
|
||||
}
|
||||
|
||||
if (start_api_service()) {
|
||||
api_service_ = new amd::rdc::RdcAPIServiceImpl();
|
||||
builder.RegisterService(api_service_);
|
||||
|
||||
// TODO(bill_liu): pass flags from cnfg file
|
||||
rdc_status_t ret = api_service_->Initialize(0);
|
||||
|
||||
if (ret != RDC_ST_OK) {
|
||||
std::cerr << "Failed to start API service" << std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Finally assemble the server.
|
||||
// std::unique_ptr<::grpc::Server> server(builder.BuildAndStart());
|
||||
server_ = builder.BuildAndStart();
|
||||
@@ -316,8 +330,9 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
// TODO(cfreehil): Eventually, set these by reading a config file
|
||||
rdc_server.set_start_rsmi_service(true);
|
||||
rdc_server.set_start_rsmi_service(false);
|
||||
rdc_server.set_start_rdc_admin_service(true);
|
||||
rdc_server.set_start_api_service(true);
|
||||
|
||||
rdc_server.Run();
|
||||
|
||||
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur