Enable RDC topology feature

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

Change-Id: Ib79c06d0bac85119672f194ba685ebf25029979c
Este commit está contenido en:
stali
2024-09-27 10:48:32 +08:00
cometido por Li, Star
padre 2c61dfe2ce
commit 8bcb5f7068
Se han modificado 19 ficheros con 798 adiciones y 7 borrados
+87
Ver fichero
@@ -602,6 +602,63 @@ typedef struct {
rdc_policy_action_t action; //!< Action to take
} rdc_policy_t;
typedef enum {
RDC_IOLINK_TYPE_UNDEFINED = 0, //!< unknown type.
RDC_IOLINK_TYPE_PCIEXPRESS = 1, //!< PCI Express
RDC_IOLINK_TYPE_XGMI = 2, //!< XGMI
RDCI_IOLINK_TYPE_NUMIOLINKTYPES, //!< Number of IO Link types
RDC_IOLINK_TYPE_SIZE = 0xFFFFFFFF //!< Max of IO Link types
} rdc_topology_link_type_t;
/**
* @brief The link information of the GPU connected to
*/
typedef struct {
uint32_t gpu_index;
// amdsmi_topo_get_link_weight
uint64_t weight; // the weight for a connection between 2 GPUs
// minimal and maximal io link bandwidth between 2 GPUs
// amdsmi_get_minmax_bandwidth_between_processors
uint64_t min_bandwidth;
uint64_t max_bandwidth;
// amdsmi_topo_get_link_type
uint64_t hops;
rdc_topology_link_type_t link_type;
// amdsmi_is_P2P_accessible
bool is_p2p_accessible;
} rdc_topology_link_info_t;
/**
* @brief The data in the data structure will be set to max value if it is N/A or error
*/
typedef struct {
uint32_t num_of_gpus; // The length of link_infos array
rdc_topology_link_info_t link_infos[RDC_MAX_NUM_DEVICES];
// amdsmi_topo_get_numa_node_number
uint32_t numa_node; // the NUMA CPU node number for a device
} rdc_device_topology_t;
typedef enum {
RDC_LINK_STATE_NOT_SUPPORTED = 0,
RDC_LINK_STATE_DISABLED,
RDC_LINK_STATE_DOWN,
RDC_LINK_STATE_UP
} rdc_link_state_t;
#define RDC_MAX_NUM_OF_LINKS 16
typedef struct {
int32_t gpu_index;
uint32_t num_of_links; // The size of the array link_states
rdc_topology_link_type_t link_types; // XGMI, PCIe, and so on
rdc_link_state_t link_states[RDC_MAX_NUM_OF_LINKS];
} rdc_gpu_link_status_t;
typedef struct {
int32_t num_of_gpus; // The size of gpus array
rdc_gpu_link_status_t gpus[RDC_MAX_NUM_DEVICES];
} rdc_link_status_t;
/**
* @brief type of health watches
*/
@@ -1428,6 +1485,36 @@ rdc_status_t rdc_health_check(rdc_handle_t p_rdc_handle, rdc_gpu_group_t group_i
*/
rdc_status_t rdc_health_clear(rdc_handle_t p_rdc_handle, rdc_gpu_group_t group_id);
/**
* @brief Get the topology of the device
*
* @details topology of the device
*
* @param[in] p_rdc_handle The RDC handler.
*
* @param[in] gpu_index The GPU gpu index.
*
* @param[out] results The device topology
*
* @retval ::RDC_ST_OK is returned upon successful call.
*/
rdc_status_t rdc_device_topology_get(rdc_handle_t p_rdc_handle, uint32_t gpu_index,
rdc_device_topology_t* results);
/**
* @brief Get the link status
*
* @details the link is up or down
*
* @param[in] p_rdc_handle The RDC handler.
*
*
* @param[out] resu
* lts The link up or down status
*
* @retval ::RDC_ST_OK is returned upon successful call.
*/
rdc_status_t rdc_link_status_get(rdc_handle_t p_rdc_handle, rdc_link_status_t* results);
#ifdef __cplusplus
}
#endif // __cplusplus
+6 -1
Ver fichero
@@ -45,7 +45,8 @@ class RdcHandler {
uint32_t* count) = 0;
virtual rdc_status_t rdc_device_get_attributes(uint32_t gpu_index,
rdc_device_attributes_t* p_rdc_attr) = 0;
virtual rdc_status_t rdc_device_get_component_version(rdc_component_t component, rdc_component_version_t* p_rdc_compv) = 0;
virtual rdc_status_t rdc_device_get_component_version(rdc_component_t component,
rdc_component_version_t* p_rdc_compv) = 0;
// Group API
virtual rdc_status_t rdc_group_gpu_create(rdc_group_type_t type, const char* group_name,
@@ -111,6 +112,10 @@ class RdcHandler {
virtual rdc_status_t rdc_health_get(rdc_gpu_group_t group_id, unsigned int* components) = 0;
virtual rdc_status_t rdc_health_check(rdc_gpu_group_t group_id, rdc_health_response_t *response) = 0;
virtual rdc_status_t rdc_health_clear(rdc_gpu_group_t group_id) = 0;
// topology API
virtual rdc_status_t rdc_device_topology_get(uint32_t gpu_index,
rdc_device_topology_t* results) = 0;
virtual rdc_status_t rdc_link_status_get(rdc_link_status_t* results) = 0;
virtual ~RdcHandler() {}
};
+48
Ver fichero
@@ -0,0 +1,48 @@
/*
Copyright (c) 2024 - 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 INCLUDE_RDC_LIB_RDCTOPOLOGYLINK_H_
#define INCLUDE_RDC_LIB_RDCTOPOLOGYLINK_H_
#include <memory>
#include <vector>
#include "rdc/rdc.h"
#include "rdc_lib/rdc_common.h"
namespace amd {
namespace rdc {
class RdcTopologyLink {
public:
virtual rdc_status_t rdc_device_topology_get(uint32_t gpu_index,
rdc_device_topology_t* results) = 0;
virtual rdc_status_t rdc_link_status_get(rdc_link_status_t* results) = 0;
virtual ~RdcTopologyLink() {}
};
typedef std::shared_ptr<RdcTopologyLink> RdcTopologyLinkPtr;
} // namespace rdc
} // namespace amd
#endif // INCLUDE_RDC_LIB_RDCTOPOLOGYLINK_H_
+7 -1
Ver fichero
@@ -32,6 +32,7 @@ THE SOFTWARE.
#include "rdc_lib/RdcModuleMgr.h"
#include "rdc_lib/RdcNotification.h"
#include "rdc_lib/RdcPolicy.h"
#include "rdc_lib/RdcTopologyLink.h"
#include "rdc_lib/RdcWatchTable.h"
namespace amd {
@@ -52,7 +53,8 @@ class RdcEmbeddedHandler final : public RdcHandler {
uint32_t* count) override;
rdc_status_t rdc_device_get_attributes(uint32_t gpu_index,
rdc_device_attributes_t* p_rdc_attr) override;
rdc_status_t rdc_device_get_component_version(rdc_component_t component, rdc_component_version_t* p_rdc_compv) override;
rdc_status_t rdc_device_get_component_version(rdc_component_t component,
rdc_component_version_t* p_rdc_compv) override;
// Group API
rdc_status_t rdc_group_gpu_create(rdc_group_type_t type, const char* group_name,
@@ -113,6 +115,9 @@ class RdcEmbeddedHandler final : public RdcHandler {
rdc_status_t rdc_health_get(rdc_gpu_group_t group_id, unsigned int* components) override;
rdc_status_t rdc_health_check(rdc_gpu_group_t group_id, rdc_health_response_t *response) override;
rdc_status_t rdc_health_clear(rdc_gpu_group_t group_id) override;
rdc_status_t rdc_device_topology_get(uint32_t gpu_index, rdc_device_topology_t* results) override;
rdc_status_t rdc_link_status_get(rdc_link_status_t* results) override;
explicit RdcEmbeddedHandler(rdc_operation_mode_t op_mode);
~RdcEmbeddedHandler() final;
@@ -128,6 +133,7 @@ class RdcEmbeddedHandler final : public RdcHandler {
RdcMetricsUpdaterPtr metrics_updater_;
RdcPolicyPtr policy_;
std::future<void> updater_;
RdcTopologyLinkPtr topologylink_;
};
} // namespace rdc
+5 -1
Ver fichero
@@ -49,7 +49,8 @@ class RdcStandaloneHandler : public RdcHandler {
uint32_t* count) override;
rdc_status_t rdc_device_get_attributes(uint32_t gpu_index,
rdc_device_attributes_t* p_rdc_attr) override;
rdc_status_t rdc_device_get_component_version(rdc_component_t component, rdc_component_version_t* p_rdc_compv) override;
rdc_status_t rdc_device_get_component_version(rdc_component_t component,
rdc_component_version_t* p_rdc_compv) override;
// Group RdcAPI
rdc_status_t rdc_group_gpu_create(rdc_group_type_t type, const char* group_name,
@@ -110,6 +111,9 @@ class RdcStandaloneHandler : public RdcHandler {
rdc_status_t rdc_health_get(rdc_gpu_group_t group_id, unsigned int* components) override;
rdc_status_t rdc_health_check(rdc_gpu_group_t group_id, rdc_health_response_t *response) override;
rdc_status_t rdc_health_clear(rdc_gpu_group_t group_id) override;
rdc_status_t rdc_device_topology_get(uint32_t gpu_index, rdc_device_topology_t* results) override;
rdc_status_t rdc_link_status_get(rdc_link_status_t* results) override;
explicit RdcStandaloneHandler(const char* ip_and_port, const char* root_ca,
const char* client_cert, const char* client_key);
+60
Ver fichero
@@ -0,0 +1,60 @@
/*
Copyright (c) 2024 - 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 INCLUDE_RDC_LIB_IMPL_RDCTOPOLINKYIMPL_H_
#define INCLUDE_RDC_LIB_IMPL_RDCTOPOLINKYIMPL_H_
#include <atomic>
#include <future>
#include <map>
#include <memory>
#include <mutex> // NOLINT
#include <string>
#include <utility>
#include <vector>
#include "amd_smi/amdsmi.h"
#include "rdc_lib/RdcGroupSettings.h"
#include "rdc_lib/RdcMetricFetcher.h"
#include "rdc_lib/RdcTopologyLink.h"
namespace amd {
namespace rdc {
class RdcTopologyLinkImpl : public RdcTopologyLink {
public:
RdcTopologyLinkImpl(const RdcGroupSettingsPtr& group_settings,
RdcMetricFetcherPtr metric_fetcher);
~RdcTopologyLinkImpl();
rdc_status_t rdc_device_topology_get(uint32_t gpu_index, rdc_device_topology_t* results) override;
rdc_status_t rdc_link_status_get(rdc_link_status_t* results) override;
private:
RdcGroupSettingsPtr group_settings_;
RdcMetricFetcherPtr metric_fetcher_;
};
} // namespace rdc
} // namespace amd
#endif // INCLUDE_RDC_LIB_IMPL_RDCTOPOLINKYIMPL_H_