Add rsmi_dev_power_get
* Updates:
- [API] Added rsmi_dev_power_get(uint32_t dv_ind,
uint64_t *power,
RSMI_POWER_TYPE
*type)
provides generic get to average or
current power & provides backwards
compatibility
- Added a utility function to get MonitorTypes
(monitor_type_string(type)) &
RSMI_POWER_TYPE (power_type_string(type))
strings
- [Tests] Added rsmi_dev_power_get tests and
provided better verification of return values for
all power APIs
- [Tests] Updated power outputs to show correct
units
- [example] Now uses avg, current, and generic
power functions with type output response
Change-Id: I5ca06ca37fd5f61e100f2835b664d6cdd1ca42e6
Signed-off-by: Charis Poag <Charis.Poag@amd.com>
[ROCm/amdsmi commit: 31a1fcce7d]
This commit is contained in:
committed by
Galantsev, Dmitrii
parent
52f3e90525
commit
d54164d733
@@ -697,6 +697,15 @@ typedef enum {
|
||||
RSMI_UTILIZATION_COUNTER_LAST = RSMI_COARSE_GRAIN_MEM_ACTIVITY
|
||||
} RSMI_UTILIZATION_COUNTER_TYPE;
|
||||
|
||||
/**
|
||||
* @brief Power types
|
||||
*/
|
||||
typedef enum {
|
||||
RSMI_AVERAGE_POWER = 0, //!< Average Power
|
||||
RSMI_CURRENT_POWER, //!< Current / Instant Power
|
||||
RSMI_INVALID_POWER = 0xFFFFFFFF //!< Invalid / Undetected Power
|
||||
} RSMI_POWER_TYPE;
|
||||
|
||||
/**
|
||||
* @brief The utilization counter data
|
||||
*/
|
||||
@@ -1729,6 +1738,40 @@ rsmi_dev_power_ave_get(uint32_t dv_ind, uint32_t sensor_ind, uint64_t *power);
|
||||
rsmi_status_t
|
||||
rsmi_dev_current_socket_power_get(uint32_t dv_ind, uint64_t *socket_power);
|
||||
|
||||
/**
|
||||
* @brief A generic get which attempts to retieve current socket power
|
||||
* (also known as instant power) of the device index provided, if not
|
||||
* supported tries to get average power consumed by device. Current
|
||||
* socket power is typically supported by newer devices, whereas average
|
||||
* power is generally reported on older devices. This function
|
||||
* aims to provide backwards compatability depending on device support.
|
||||
*
|
||||
* @details Given a device index @p dv_ind, a pointer to a uint64_t
|
||||
* @p power, and @p type this function will write the current socket or
|
||||
* average power (in microwatts) to the uint64_t pointed to by @p power and
|
||||
* a pointer to its @p type RSMI_POWER_TYPE read.
|
||||
*
|
||||
* @param[in] dv_ind a device index
|
||||
*
|
||||
* @param[inout] power a pointer to uint64_t to which the current or average
|
||||
* power will be written to. If this parameter is nullptr,
|
||||
* this function will return ::RSMI_STATUS_INVALID_ARGS if the function is
|
||||
* supported with the provided, arguments and ::RSMI_STATUS_NOT_SUPPORTED
|
||||
* if it is not supported with the provided arguments.
|
||||
*
|
||||
* @param[inout] type a pointer to RSMI_POWER_TYPE object. Returns the type
|
||||
* of power retrieved from the device. Current power is ::RSMI_CURRENT_POWER
|
||||
* and average power is ::RSMI_AVERAGE_POWER. If an error occurs,
|
||||
* returns an invalid power type ::RSMI_INVALID_POWER.
|
||||
*
|
||||
* @retval ::RSMI_STATUS_SUCCESS call was successful
|
||||
* @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not
|
||||
* support this function with the given arguments
|
||||
* @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid
|
||||
*/
|
||||
rsmi_status_t rsmi_dev_power_get(uint32_t dv_ind, uint64_t *power,
|
||||
RSMI_POWER_TYPE *type);
|
||||
|
||||
/**
|
||||
* @brief Get the energy accumulator counter of the device with provided
|
||||
* device index.
|
||||
|
||||
@@ -110,6 +110,8 @@ bool isSystemBigEndian();
|
||||
std::string getBuildType();
|
||||
std::string getMyLibPath();
|
||||
int subDirectoryCountInPath(const std::string path);
|
||||
std::string monitor_type_string(amd::smi::MonitorTypes type);
|
||||
std::string power_type_string(RSMI_POWER_TYPE type);
|
||||
template <typename T>
|
||||
std::string print_int_as_hex(T i, bool showHexNotation=true) {
|
||||
std::stringstream ss;
|
||||
|
||||
Reference in New Issue
Block a user