Implementation for SWDEV-479728:[RDC] - Clock Speed/Power Cap Control
Change-Id: I767a71325527aa3c691e9607953ceafebacfb4d5
Signed-off-by: adapryor <Adam.pryor@amd.com>
[ROCm/rdc commit: df170c8801]
This commit is contained in:
@@ -147,6 +147,11 @@ typedef enum { INTEGER = 0, DOUBLE, STRING, BLOB } rdc_field_type_t;
|
||||
*/
|
||||
#define RDC_MAX_VERSION_STR_LENGTH 60
|
||||
|
||||
/**
|
||||
* @brief Max configuration can be collected using the configuration get
|
||||
*/
|
||||
#define RDC_MAX_CONFIG_SETTINGS 32
|
||||
|
||||
/**
|
||||
* These enums are used to specify a particular field to be retrieved.
|
||||
*/
|
||||
@@ -182,11 +187,11 @@ typedef enum {
|
||||
/**
|
||||
* @brief GPU usage related fields
|
||||
*/
|
||||
RDC_FI_GPU_UTIL = 500, //!< GPU Utilization
|
||||
RDC_FI_GPU_MEMORY_USAGE, //!< Memory usage of the GPU instance
|
||||
RDC_FI_GPU_MEMORY_TOTAL, //!< Total memory of the GPU instance
|
||||
RDC_FI_GPU_MM_ENC_UTIL, //!< Multimedia encoder busy percentage
|
||||
RDC_FI_GPU_MM_DEC_UTIL, //!< Multimedia decoder busy percentage
|
||||
RDC_FI_GPU_UTIL = 500, //!< GPU Utilization
|
||||
RDC_FI_GPU_MEMORY_USAGE, //!< Memory usage of the GPU instance
|
||||
RDC_FI_GPU_MEMORY_TOTAL, //!< Total memory of the GPU instance
|
||||
RDC_FI_GPU_MM_ENC_UTIL, //!< Multimedia encoder busy percentage
|
||||
RDC_FI_GPU_MM_DEC_UTIL, //!< Multimedia decoder busy percentage
|
||||
RDC_FI_GPU_MEMORY_ACTIVITY, //!< Memory busy percentage
|
||||
|
||||
/**
|
||||
@@ -251,16 +256,16 @@ typedef enum {
|
||||
RDC_FI_XGMI_6_READ_KB, //!< XGMI_6 accumulated data read size (KB)
|
||||
RDC_FI_XGMI_7_READ_KB, //!< XGMI_7 accumulated data read size (KB)
|
||||
|
||||
RDC_FI_XGMI_0_WRITE_KB, //!< XGMI_0 accumulated data write size (KB)
|
||||
RDC_FI_XGMI_1_WRITE_KB, //!< XGMI_1 accumulated data write size (KB)
|
||||
RDC_FI_XGMI_2_WRITE_KB, //!< XGMI_2 accumulated data write size (KB)
|
||||
RDC_FI_XGMI_3_WRITE_KB, //!< XGMI_3 accumulated data write size (KB)
|
||||
RDC_FI_XGMI_4_WRITE_KB, //!< XGMI_4 accumulated data write size (KB)
|
||||
RDC_FI_XGMI_5_WRITE_KB, //!< XGMI_5 accumulated data write size (KB)
|
||||
RDC_FI_XGMI_6_WRITE_KB, //!< XGMI_6 accumulated data write size (KB)
|
||||
RDC_FI_XGMI_7_WRITE_KB, //!< XGMI_7 accumulated data write size (KB)
|
||||
RDC_FI_XGMI_TOTAL_READ_KB, //!< XGMI_SUM accumulated data read size (KB)
|
||||
RDC_FI_XGMI_TOTAL_WRITE_KB, //!< XGMI_SUM accumulated data write size (KB)
|
||||
RDC_FI_XGMI_0_WRITE_KB, //!< XGMI_0 accumulated data write size (KB)
|
||||
RDC_FI_XGMI_1_WRITE_KB, //!< XGMI_1 accumulated data write size (KB)
|
||||
RDC_FI_XGMI_2_WRITE_KB, //!< XGMI_2 accumulated data write size (KB)
|
||||
RDC_FI_XGMI_3_WRITE_KB, //!< XGMI_3 accumulated data write size (KB)
|
||||
RDC_FI_XGMI_4_WRITE_KB, //!< XGMI_4 accumulated data write size (KB)
|
||||
RDC_FI_XGMI_5_WRITE_KB, //!< XGMI_5 accumulated data write size (KB)
|
||||
RDC_FI_XGMI_6_WRITE_KB, //!< XGMI_6 accumulated data write size (KB)
|
||||
RDC_FI_XGMI_7_WRITE_KB, //!< XGMI_7 accumulated data write size (KB)
|
||||
RDC_FI_XGMI_TOTAL_READ_KB, //!< XGMI_SUM accumulated data read size (KB)
|
||||
RDC_FI_XGMI_TOTAL_WRITE_KB, //!< XGMI_SUM accumulated data write size (KB)
|
||||
|
||||
/**
|
||||
* @brief ROC-profiler related fields
|
||||
@@ -340,14 +345,14 @@ typedef enum {
|
||||
/**
|
||||
* @brief RDC health related fields
|
||||
*/
|
||||
RDC_HEALTH_XGMI_ERROR = 3000, //!< XGMI one or more errors detected
|
||||
RDC_HEALTH_PCIE_REPLAY_COUNT, //!< Total PCIE replay count
|
||||
RDC_HEALTH_RETIRED_PAGE_NUM, //!< Retired page number
|
||||
RDC_HEALTH_PENDING_PAGE_NUM, //!< Pending page number
|
||||
RDC_HEALTH_RETIRED_PAGE_LIMIT, //!< The threshold of retired page
|
||||
RDC_HEALTH_UNCORRECTABLE_PAGE_LIMIT,//!< The threshold of uncorrectable page
|
||||
RDC_HEALTH_POWER_THROTTLE_TIME, //!< Power throttle status counter
|
||||
RDC_HEALTH_THERMAL_THROTTLE_TIME, //!< Total time in thermal throttle status (microseconds)
|
||||
RDC_HEALTH_XGMI_ERROR = 3000, //!< XGMI one or more errors detected
|
||||
RDC_HEALTH_PCIE_REPLAY_COUNT, //!< Total PCIE replay count
|
||||
RDC_HEALTH_RETIRED_PAGE_NUM, //!< Retired page number
|
||||
RDC_HEALTH_PENDING_PAGE_NUM, //!< Pending page number
|
||||
RDC_HEALTH_RETIRED_PAGE_LIMIT, //!< The threshold of retired page
|
||||
RDC_HEALTH_UNCORRECTABLE_PAGE_LIMIT, //!< The threshold of uncorrectable page
|
||||
RDC_HEALTH_POWER_THROTTLE_TIME, //!< Power throttle status counter
|
||||
RDC_HEALTH_THERMAL_THROTTLE_TIME, //!< Total time in thermal throttle status (microseconds)
|
||||
} rdc_field_t;
|
||||
|
||||
// even and odd numbers are used for correctable and uncorrectable errors
|
||||
@@ -517,7 +522,7 @@ typedef enum {
|
||||
*/
|
||||
typedef enum {
|
||||
RDC_AMDMSI_COMPONENT
|
||||
//If needed later, add them one by one
|
||||
// If needed later, add them one by one
|
||||
} rdc_component_t;
|
||||
|
||||
/**
|
||||
@@ -571,8 +576,8 @@ typedef struct {
|
||||
|
||||
typedef void (*rdc_callback_t)(void*, void*);
|
||||
typedef struct {
|
||||
rdc_callback_t callback; //!< Callback sends logs for running diagnostics
|
||||
void* cookie; //!< Cookie is used to identify different callbacks and supply them with data
|
||||
rdc_callback_t callback; //!< Callback sends logs for running diagnostics
|
||||
void* cookie; //!< Cookie is used to identify different callbacks and supply them with data
|
||||
} rdc_diag_callback_t;
|
||||
|
||||
/**
|
||||
@@ -599,7 +604,7 @@ typedef enum { RDC_POLICY_ACTION_NONE, RDC_POLICY_ACTION_GPU_RESET } rdc_policy_
|
||||
*/
|
||||
typedef struct {
|
||||
rdc_policy_condition_t condition; //!< condition to meet
|
||||
rdc_policy_action_t action; //!< Action to take
|
||||
rdc_policy_action_t action; //!< Action to take
|
||||
} rdc_policy_t;
|
||||
|
||||
typedef enum {
|
||||
@@ -663,12 +668,12 @@ typedef struct {
|
||||
* @brief type of health watches
|
||||
*/
|
||||
typedef enum {
|
||||
RDC_HEALTH_WATCH_PCIE = 0x1, //!< PCIe system watches
|
||||
RDC_HEALTH_WATCH_XGMI = 0x2, //!< XGMI system watches
|
||||
RDC_HEALTH_WATCH_MEM = 0x4, //!< Memory watches
|
||||
RDC_HEALTH_WATCH_INFOROM = 0x8, //!< Inforom watches
|
||||
RDC_HEALTH_WATCH_THERMAL = 0x10, //!< Temperature watches
|
||||
RDC_HEALTH_WATCH_POWER = 0x20, //!< Power watches
|
||||
RDC_HEALTH_WATCH_PCIE = 0x1, //!< PCIe system watches
|
||||
RDC_HEALTH_WATCH_XGMI = 0x2, //!< XGMI system watches
|
||||
RDC_HEALTH_WATCH_MEM = 0x4, //!< Memory watches
|
||||
RDC_HEALTH_WATCH_INFOROM = 0x8, //!< Inforom watches
|
||||
RDC_HEALTH_WATCH_THERMAL = 0x10, //!< Temperature watches
|
||||
RDC_HEALTH_WATCH_POWER = 0x20, //!< Power watches
|
||||
} rdc_health_system_t;
|
||||
|
||||
/**
|
||||
@@ -708,32 +713,56 @@ typedef enum {
|
||||
* @brief details of the health errors
|
||||
*/
|
||||
typedef struct {
|
||||
char msg[MAX_HEALTH_MSG_LENGTH]; //!< The test result details
|
||||
uint32_t code; //!< The low level error code
|
||||
char msg[MAX_HEALTH_MSG_LENGTH]; //!< The test result details
|
||||
uint32_t code; //!< The low level error code
|
||||
} rdc_health_detail_t;
|
||||
|
||||
/**
|
||||
* @brief details of the per health incidents
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t gpu_index; //!< which GPU in this group have the issue
|
||||
rdc_health_system_t component; //!< which components have the issue
|
||||
rdc_health_result_t health; //!< health diagnosis of this incident
|
||||
rdc_health_detail_t error; //!< The details of the error, rdc_health_error_code_t
|
||||
uint32_t gpu_index; //!< which GPU in this group have the issue
|
||||
rdc_health_system_t component; //!< which components have the issue
|
||||
rdc_health_result_t health; //!< health diagnosis of this incident
|
||||
rdc_health_detail_t error; //!< The details of the error, rdc_health_error_code_t
|
||||
} rdc_health_incidents_t;
|
||||
|
||||
|
||||
#define HEALTH_MAX_ERROR_ITEMS 64
|
||||
|
||||
/**
|
||||
* @brief The health responses for test cases
|
||||
*/
|
||||
typedef struct {
|
||||
rdc_health_result_t overall_health; //!< The overall health of this entire host
|
||||
unsigned int incidents_count; //!< The number of health incidents reported in this struct
|
||||
rdc_health_incidents_t incidents[HEALTH_MAX_ERROR_ITEMS]; //!< Report of the errors detected
|
||||
rdc_health_result_t overall_health; //!< The overall health of this entire host
|
||||
unsigned int incidents_count; //!< The number of health incidents reported in this struct
|
||||
rdc_health_incidents_t incidents[HEALTH_MAX_ERROR_ITEMS]; //!< Report of the errors detected
|
||||
} rdc_health_response_t;
|
||||
|
||||
/**
|
||||
* @brief property id's for the configuration set/get
|
||||
*/
|
||||
typedef enum {
|
||||
RDC_CFG_GFX_CLOCK_LIMIT,
|
||||
RDC_CFG_MEMORY_CLOCK_LIMIT,
|
||||
RDC_CFG_POWER_LIMIT
|
||||
} rdc_config_type_t;
|
||||
|
||||
/**
|
||||
* @brief Value mapped to rdc_config_type_t property id for the configuration set/get
|
||||
*/
|
||||
typedef struct {
|
||||
rdc_config_type_t type;
|
||||
uint64_t target_value;
|
||||
} rdc_config_setting_t;
|
||||
|
||||
/**
|
||||
* @brief Array of properties collected using the configuration get
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t total_settings;
|
||||
rdc_config_setting_t settings[RDC_MAX_CONFIG_SETTINGS];
|
||||
} rdc_config_setting_list_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize ROCm RDC.
|
||||
*
|
||||
@@ -972,7 +1001,8 @@ rdc_status_t rdc_device_get_attributes(rdc_handle_t p_rdc_handle, uint32_t gpu_i
|
||||
*
|
||||
* @retval ::RDC_ST_OK is returned upon successful call.
|
||||
*/
|
||||
rdc_status_t rdc_device_get_component_version(rdc_handle_t p_rdc_handle, rdc_component_t component, rdc_component_version_t* p_rdc_compv);
|
||||
rdc_status_t rdc_device_get_component_version(rdc_handle_t p_rdc_handle, rdc_component_t component,
|
||||
rdc_component_version_t* p_rdc_compv);
|
||||
|
||||
/**
|
||||
* @brief Create a group contains multiple GPUs
|
||||
@@ -1382,7 +1412,7 @@ typedef struct {
|
||||
unsigned int version;
|
||||
rdc_policy_condition_t condition; //!< the condition that is meet
|
||||
rdc_gpu_group_t group_id; //!< The group id trigger this callback
|
||||
int64_t value; //!< The current value that meet the condition
|
||||
int64_t value; //!< The current value that meet the condition
|
||||
} rdc_policy_callback_response_t;
|
||||
|
||||
/**
|
||||
@@ -1514,6 +1544,50 @@ rdc_status_t rdc_device_topology_get(rdc_handle_t p_rdc_handle, uint32_t gpu_ind
|
||||
* @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);
|
||||
/**
|
||||
* @brief Set one configuration
|
||||
*
|
||||
* @details Set the given configuration to all nodes belong to the given group
|
||||
*
|
||||
* @param[in] p_rdc_handle Node handle
|
||||
*
|
||||
* @param[in] group_id Group id to which node belongs
|
||||
*
|
||||
* @param[in] setting Configuration to be set for the nodes
|
||||
*
|
||||
* @retval RDC_ST_OK is returned upon successful call.
|
||||
*/
|
||||
rdc_status_t rdc_config_set(rdc_handle_t p_rdc_handle, rdc_gpu_group_t group_id,
|
||||
rdc_config_setting_t setting);
|
||||
|
||||
/**
|
||||
* @brief Get the configrations
|
||||
*
|
||||
* @details Get all the configurations for all nodes belong to the given group
|
||||
*
|
||||
* @param[in] p_rdc_handle Node handle
|
||||
*
|
||||
* @param[in] group_id Group id to which nodes belong
|
||||
*
|
||||
* @param[out] settings List of configurations returned.
|
||||
*
|
||||
* @retval RDC_ST_OK is returned upon successful call.
|
||||
*/
|
||||
rdc_status_t rdc_config_get(rdc_handle_t p_rdc_handle, rdc_gpu_group_t group_id,
|
||||
rdc_config_setting_list_t* settings);
|
||||
|
||||
/**
|
||||
* @brief Clear the setting
|
||||
*
|
||||
* @details Clear all the configurations for the nodes belongs to the given group
|
||||
*
|
||||
* @param[in] p_rdc_handle Node handle
|
||||
*
|
||||
* @param[in] group_id Group id to which nodes belong
|
||||
*
|
||||
* @retval RDC_ST_OK is returned upon successful call.
|
||||
*/
|
||||
rdc_status_t rdc_config_clear(rdc_handle_t p_rdc_handle, rdc_gpu_group_t group_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
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_RDCCONFIGSETTINGS_H_
|
||||
#define INCLUDE_RDC_LIB_RDCCONFIGSETTINGS_H_
|
||||
|
||||
#include <memory.h>
|
||||
|
||||
#include "rdc/rdc.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
class RdcConfigSettings {
|
||||
public:
|
||||
// Set one configure
|
||||
virtual rdc_status_t rdc_config_set(rdc_gpu_group_t group_id, rdc_config_setting_t setting) = 0;
|
||||
|
||||
// Get the setting
|
||||
virtual rdc_status_t rdc_config_get(rdc_gpu_group_t group_id,
|
||||
rdc_config_setting_list_t* settings) = 0;
|
||||
|
||||
// Clear the setting
|
||||
virtual rdc_status_t rdc_config_clear(rdc_gpu_group_t group_id) = 0;
|
||||
|
||||
virtual ~RdcConfigSettings() {}
|
||||
};
|
||||
typedef std::shared_ptr<RdcConfigSettings> RdcConfigSettingsPtr;
|
||||
} // namespace rdc
|
||||
} // namespace amd
|
||||
|
||||
#endif // INCLUDE_RDC_LIB_RDCCONFIGSETTINGS_H_
|
||||
@@ -81,18 +81,21 @@ class RdcHandler {
|
||||
// Diagnostic API
|
||||
virtual rdc_status_t rdc_diagnostic_run(rdc_gpu_group_t group_id, rdc_diag_level_t level,
|
||||
const char* config, size_t config_size,
|
||||
rdc_diag_response_t* response, rdc_diag_callback_t* callback) = 0;
|
||||
rdc_diag_response_t* response,
|
||||
rdc_diag_callback_t* callback) = 0;
|
||||
|
||||
virtual rdc_status_t rdc_test_case_run(rdc_gpu_group_t group_id, rdc_diag_test_cases_t test_case,
|
||||
const char* config, size_t config_size,
|
||||
rdc_diag_test_result_t* result, rdc_diag_callback_t* callback) = 0;
|
||||
rdc_diag_test_result_t* result,
|
||||
rdc_diag_callback_t* callback) = 0;
|
||||
|
||||
// Control API
|
||||
virtual rdc_status_t rdc_field_update_all(uint32_t wait_for_update) = 0;
|
||||
|
||||
// It is just a client interface under the GRPC framework and is not used as an RDC API.
|
||||
// The reason is that RdcEmbeddedHandler::get_mixed_component_version does not need to be called.
|
||||
virtual rdc_status_t get_mixed_component_version(mixed_component_t component, mixed_component_version_t* p_mixed_compv) = 0;
|
||||
virtual rdc_status_t get_mixed_component_version(mixed_component_t component,
|
||||
mixed_component_version_t* p_mixed_compv) = 0;
|
||||
// Policy API
|
||||
virtual rdc_status_t rdc_policy_set(rdc_gpu_group_t group_id, rdc_policy_t policy) = 0;
|
||||
|
||||
@@ -110,13 +113,24 @@ class RdcHandler {
|
||||
// Health API
|
||||
virtual rdc_status_t rdc_health_set(rdc_gpu_group_t group_id, unsigned int components) = 0;
|
||||
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_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;
|
||||
|
||||
// Set one configure
|
||||
virtual rdc_status_t rdc_config_set(rdc_gpu_group_t group_id, rdc_config_setting_t setting) = 0;
|
||||
|
||||
// Get the setting
|
||||
virtual rdc_status_t rdc_config_get(rdc_gpu_group_t group_id,
|
||||
rdc_config_setting_list_t* settings) = 0;
|
||||
|
||||
// Clear the setting
|
||||
virtual rdc_status_t rdc_config_clear(rdc_gpu_group_t group_id) = 0;
|
||||
|
||||
virtual ~RdcHandler() {}
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
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_RDCCONFIGSETTINGSIMPL_H_
|
||||
#define INCLUDE_RDC_LIB_IMPL_RDCCONFIGSETTINGSIMPL_H_
|
||||
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <mutex> // NOLINT
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "rdc_lib/RdcConfigSettings.h"
|
||||
#include "rdc_lib/RdcGroupSettings.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
class RdcConfigSettingsImpl : public RdcConfigSettings {
|
||||
public:
|
||||
// Set one configure
|
||||
rdc_status_t rdc_config_set(rdc_gpu_group_t group_id, rdc_config_setting_t setting) override;
|
||||
|
||||
// Get the setting
|
||||
rdc_status_t rdc_config_get(rdc_gpu_group_t group_id,
|
||||
rdc_config_setting_list_t* settings) override;
|
||||
|
||||
// clear the setting
|
||||
rdc_status_t rdc_config_clear(rdc_gpu_group_t group_id) override;
|
||||
|
||||
explicit RdcConfigSettingsImpl(const RdcGroupSettingsPtr& group_settings);
|
||||
|
||||
private:
|
||||
RdcGroupSettingsPtr group_settings_;
|
||||
std::unordered_map<rdc_gpu_group_t, std::unordered_map<rdc_config_type_t, rdc_config_setting_t>>
|
||||
cached_group_settings_;
|
||||
std::thread monitor_thread_;
|
||||
std::mutex mutex_; // Mutex for cached_group_settings_
|
||||
std::atomic<bool> is_running_; // Bool for if the thread should keep running
|
||||
std::condition_variable cv_;
|
||||
|
||||
// monitorSettings() is kicked off from the RdcConfigSettingsImpl constructor as it's own thread
|
||||
// Every minute, it will check if gpu settings from amdsmi are the same as inside
|
||||
// cached_group_settings_ If not, it sets the mismatched values to the value in
|
||||
// cached_group_settings_
|
||||
void monitorSettings();
|
||||
uint64_t wattsToMicrowatts(uint64_t watts) const;
|
||||
uint64_t microwattsToWatts(int microwatts) const;
|
||||
rdc_status_t get_group_info(rdc_gpu_group_t group_id, rdc_group_info_t* rdc_group_info);
|
||||
};
|
||||
|
||||
} // namespace rdc
|
||||
} // namespace amd
|
||||
|
||||
#endif // INCLUDE_RDC_LIB_IMPL_RDCCONFIGSETTINGSIMPL_H_
|
||||
@@ -25,6 +25,7 @@ THE SOFTWARE.
|
||||
#include <future> // NOLINT(build/c++11)
|
||||
|
||||
#include "rdc_lib/RdcCacheManager.h"
|
||||
#include "rdc_lib/RdcConfigSettings.h"
|
||||
#include "rdc_lib/RdcGroupSettings.h"
|
||||
#include "rdc_lib/RdcHandler.h"
|
||||
#include "rdc_lib/RdcMetricFetcher.h"
|
||||
@@ -86,17 +87,20 @@ class RdcEmbeddedHandler final : public RdcHandler {
|
||||
// Diagnostic API
|
||||
rdc_status_t rdc_diagnostic_run(rdc_gpu_group_t group_id, rdc_diag_level_t level,
|
||||
const char* config, size_t config_size,
|
||||
rdc_diag_response_t* response, rdc_diag_callback_t* callback) override;
|
||||
rdc_diag_response_t* response,
|
||||
rdc_diag_callback_t* callback) override;
|
||||
rdc_status_t rdc_test_case_run(rdc_gpu_group_t group_id, rdc_diag_test_cases_t test_case,
|
||||
const char* config, size_t config_size,
|
||||
rdc_diag_test_result_t* result, rdc_diag_callback_t* callback) override;
|
||||
rdc_diag_test_result_t* result,
|
||||
rdc_diag_callback_t* callback) override;
|
||||
|
||||
// Control API
|
||||
rdc_status_t rdc_field_update_all(uint32_t wait_for_update) override;
|
||||
|
||||
// It is just a client interface under the GRPC framework and is not used as an RDC API.
|
||||
// Pure virtual functions need to be overridden.
|
||||
rdc_status_t get_mixed_component_version(mixed_component_t component, mixed_component_version_t* p_mixed_compv) override;
|
||||
rdc_status_t get_mixed_component_version(mixed_component_t component,
|
||||
mixed_component_version_t* p_mixed_compv) override;
|
||||
// Policy API
|
||||
rdc_status_t rdc_policy_set(rdc_gpu_group_t group_id, rdc_policy_t policy) override;
|
||||
|
||||
@@ -106,19 +110,30 @@ class RdcEmbeddedHandler final : public RdcHandler {
|
||||
rdc_status_t rdc_policy_delete(rdc_gpu_group_t group_id,
|
||||
rdc_policy_condition_type_t condition_type) override;
|
||||
|
||||
rdc_status_t rdc_policy_register(rdc_gpu_group_t group_id, rdc_policy_register_callback callback) override;
|
||||
rdc_status_t rdc_policy_register(rdc_gpu_group_t group_id,
|
||||
rdc_policy_register_callback callback) override;
|
||||
|
||||
rdc_status_t rdc_policy_unregister(rdc_gpu_group_t group_id) override;
|
||||
|
||||
// Health API
|
||||
rdc_status_t rdc_health_set(rdc_gpu_group_t group_id, unsigned int components) override;
|
||||
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_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;
|
||||
|
||||
// Set one configure
|
||||
rdc_status_t rdc_config_set(rdc_gpu_group_t group_id, rdc_config_setting_t setting) override;
|
||||
|
||||
// Get the setting
|
||||
rdc_status_t rdc_config_get(rdc_gpu_group_t group_id,
|
||||
rdc_config_setting_list_t* settings) override;
|
||||
|
||||
// Clear the setting
|
||||
rdc_status_t rdc_config_clear(rdc_gpu_group_t group_id) override;
|
||||
|
||||
explicit RdcEmbeddedHandler(rdc_operation_mode_t op_mode);
|
||||
~RdcEmbeddedHandler() final;
|
||||
|
||||
@@ -132,6 +147,7 @@ class RdcEmbeddedHandler final : public RdcHandler {
|
||||
RdcWatchTablePtr watch_table_;
|
||||
RdcMetricsUpdaterPtr metrics_updater_;
|
||||
RdcPolicyPtr policy_;
|
||||
RdcConfigSettingsPtr config_handler_;
|
||||
std::future<void> updater_;
|
||||
RdcTopologyLinkPtr topologylink_;
|
||||
};
|
||||
|
||||
@@ -23,8 +23,8 @@ THE SOFTWARE.
|
||||
#define INCLUDE_RDC_LIB_IMPL_RDCSTANDALONEHANDLER_H_
|
||||
#include <grpcpp/grpcpp.h>
|
||||
|
||||
#include <memory>
|
||||
#include <future>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
|
||||
#include "rdc.grpc.pb.h" // NOLINT
|
||||
@@ -82,21 +82,35 @@ class RdcStandaloneHandler : public RdcHandler {
|
||||
// Diagnostic API
|
||||
rdc_status_t rdc_diagnostic_run(rdc_gpu_group_t group_id, rdc_diag_level_t level,
|
||||
const char* config, size_t config_size,
|
||||
rdc_diag_response_t* response, rdc_diag_callback_t* callback) override;
|
||||
rdc_diag_response_t* response,
|
||||
rdc_diag_callback_t* callback) override;
|
||||
rdc_status_t rdc_test_case_run(rdc_gpu_group_t group_id, rdc_diag_test_cases_t test_case,
|
||||
const char* config, size_t config_size,
|
||||
rdc_diag_test_result_t* result, rdc_diag_callback_t* callback) override;
|
||||
rdc_diag_test_result_t* result,
|
||||
rdc_diag_callback_t* callback) override;
|
||||
|
||||
// Control RdcAPI
|
||||
rdc_status_t rdc_field_update_all(uint32_t wait_for_update) override;
|
||||
|
||||
// Set one configure
|
||||
rdc_status_t rdc_config_set(rdc_gpu_group_t group_id, rdc_config_setting_t setting) override;
|
||||
|
||||
// Get the setting
|
||||
rdc_status_t rdc_config_get(rdc_gpu_group_t group_id,
|
||||
rdc_config_setting_list_t* settings) override;
|
||||
|
||||
// Clear the setting
|
||||
rdc_status_t rdc_config_clear(rdc_gpu_group_t group_id) override;
|
||||
|
||||
// It is just a client interface under the GRPC framework and is not used as an RDC API.
|
||||
// Pure virtual functions need to be overridden
|
||||
rdc_status_t get_mixed_component_version(mixed_component_t component, mixed_component_version_t* p_mixed_compv) override;
|
||||
rdc_status_t get_mixed_component_version(mixed_component_t component,
|
||||
mixed_component_version_t* p_mixed_compv) override;
|
||||
// Policy API
|
||||
rdc_status_t rdc_policy_set(rdc_gpu_group_t group_id, rdc_policy_t policy) override;
|
||||
|
||||
rdc_status_t rdc_policy_get(rdc_gpu_group_t group_id, uint32_t* count, rdc_policy_t policies[RDC_MAX_POLICY_SETTINGS]) override;
|
||||
rdc_status_t rdc_policy_get(rdc_gpu_group_t group_id, uint32_t* count,
|
||||
rdc_policy_t policies[RDC_MAX_POLICY_SETTINGS]) override;
|
||||
|
||||
rdc_status_t rdc_policy_delete(rdc_gpu_group_t group_id,
|
||||
rdc_policy_condition_type_t condition_type) override;
|
||||
@@ -109,7 +123,7 @@ class RdcStandaloneHandler : public RdcHandler {
|
||||
// Health API
|
||||
rdc_status_t rdc_health_set(rdc_gpu_group_t group_id, unsigned int components) override;
|
||||
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_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;
|
||||
|
||||
@@ -129,11 +143,10 @@ class RdcStandaloneHandler : public RdcHandler {
|
||||
|
||||
struct policy_thread_context {
|
||||
bool start;
|
||||
std::thread *t;
|
||||
std::thread* t;
|
||||
};
|
||||
|
||||
std::map<uint32_t, struct policy_thread_context> policy_threads_;
|
||||
|
||||
};
|
||||
|
||||
} // namespace rdc
|
||||
|
||||
مرجع در شماره جدید
Block a user