Enable RDC topology feature

1.Add topology APIs
2.Add topology example for topology API usage

Change-Id: Ib79c06d0bac85119672f194ba685ebf25029979c
This commit is contained in:
stali
2024-09-27 10:48:32 +08:00
committed by Li, Star
orang tua 2c61dfe2ce
melakukan 8bcb5f7068
19 mengubah file dengan 798 tambahan dan 7 penghapusan
+4
Melihat File
@@ -152,6 +152,10 @@ class RdcAPIServiceImpl final : public ::rdc::RdcAPI::Service {
::grpc::Status UnRegisterPolicy(::grpc::ServerContext* context,
const ::rdc::UnRegisterPolicyRequest* request,
::rdc::UnRegisterPolicyResponse* reply) override;
::grpc::Status GetTopology(::grpc::ServerContext* context,
const ::rdc::GetTopologyRequest* request,
::rdc::GetTopologyResponse* reply) override;
::grpc::Status SetHealth(::grpc::ServerContext* context,
const ::rdc::SetHealthRequest* request,
+32 -2
Melihat File
@@ -854,7 +854,6 @@ bool RdcAPIServiceImpl::copy_gpu_usage_info(const rdc_gpu_usage_info_t& src,
}
int RdcAPIServiceImpl::PolicyCallback(rdc_policy_callback_response_t* userData) {
if (userData == nullptr) {
std::cerr << "The rdc_policy_callback returns null data\n";
return 1;
@@ -921,7 +920,6 @@ int RdcAPIServiceImpl::PolicyCallback(rdc_policy_callback_response_t* userData)
pthread_mutex_unlock(&ctx->mutex);
}
}
}
});
@@ -1035,5 +1033,37 @@ int RdcAPIServiceImpl::PolicyCallback(rdc_policy_callback_response_t* userData)
return ::grpc::Status::OK;
}
::grpc::Status RdcAPIServiceImpl::GetTopology(::grpc::ServerContext* context,
const ::rdc::GetTopologyRequest* request,
::rdc::GetTopologyResponse* reply) {
(void)(context);
if (!reply || !request) {
return ::grpc::Status(::grpc::StatusCode::INTERNAL, "Empty contents");
}
rdc_device_topology_t topology_results;
// call RDC topology API
rdc_status_t result =
rdc_device_topology_get(rdc_handle_, request->gpu_index(), &topology_results);
reply->set_status(result);
if (result != RDC_ST_OK) {
return ::grpc::Status::OK;
}
::rdc::Topology* topology = reply->mutable_toppology();
topology->set_num_of_gpus(topology_results.num_of_gpus);
topology->set_numa_node(topology_results.numa_node);
for (uint32_t i = 0; i < topology_results.num_of_gpus; ++i) {
::rdc::TopologyLinkInfo* linkinfos = topology->add_link_infos();
linkinfos->set_gpu_index(topology_results.link_infos[i].gpu_index);
linkinfos->set_weight(topology_results.link_infos[i].weight);
linkinfos->set_min_bandwidth(topology_results.link_infos[i].min_bandwidth);
linkinfos->set_max_bandwidth(topology_results.link_infos[i].max_bandwidth);
linkinfos->set_hops(topology_results.link_infos[i].hops);
linkinfos->set_link_type(
static_cast<::rdc::TopologyLinkInfo_LinkType>(topology_results.link_infos[i].link_type));
linkinfos->set_p2p_accessible(topology_results.link_infos[i].is_p2p_accessible);
}
return ::grpc::Status::OK;
}
} // namespace rdc
} // namespace amd