Use sysfs file to get average power instead of debugfs

This commit is contained in:
Chris Freehill
2018-10-29 17:59:24 -05:00
parent 767fa53d8c
commit 62ba2f578e
8 changed files with 12 additions and 19 deletions
+2 -2
View File
@@ -446,7 +446,7 @@ rsmi_status_t rsmi_dev_gpu_clk_freq_set(uint32_t dv_ind,
* @param[in] dv_ind a device index
*
* @param[inout] name a pointer to a caller provided char buffer to which the
* speed will be written
* name will be written
*
* @param[in] len the length of the caller provided buffer @p name.
*
@@ -588,7 +588,7 @@ rsmi_status_t rsmi_dev_fan_speed_set(uint32_t dv_ind, uint32_t sensor_ind,
*
* @details Given a device index @p dv_ind and a pointer to a uint64_t
* @p power, this function will write the current average power consumption to
* the uint64_t in milliwatts pointed to by @p power. This function requires
* the uint64_t in microwatts pointed to by @p power. This function requires
* root privilege.
*
* @param[in] dv_ind a device index
+1
View File
@@ -63,6 +63,7 @@ enum MonitorTypes {
kMonPowerCap,
kMonPowerCapMax,
kMonPowerCapMin,
kMonPowerAve,
kMonTempMax,
kMonTempMin,
kMonTempMaxHyst,
-1
View File
@@ -55,7 +55,6 @@ namespace smi {
enum PowerMonTypes {
kPowerMaxGPUPower,
kPowerAveGPUPower,
};
+2 -3
View File
@@ -851,11 +851,10 @@ rsmi_dev_power_ave_get(uint32_t dv_ind, uint32_t sensor_ind, uint64_t *power) {
if (power == nullptr) {
return RSMI_STATUS_INVALID_ARGS;
}
(void)sensor_ind; // Not used yet
// ++sensor_ind; // power sysfs files have 1-based indices
++sensor_ind; // power sysfs files have 1-based indices
rsmi_status_t ret;
ret = get_power_mon_value(amd::smi::kPowerAveGPUPower, dv_ind, power);
ret = get_dev_mon_value(amd::smi::kMonPowerAve, dv_ind, sensor_ind, power);
return ret;
CATCH
+2 -1
View File
@@ -74,7 +74,7 @@ static const char *kMonNameFName = "name";
static const char *kMonPowerCapName = "power#_cap";
static const char *kMonPowerCapMaxName = "power#_cap_max";
static const char *kMonPowerCapMinName = "power#_cap_min";
static const char *kMonPowerAveName = "power#_average";
static const char *kMonTempMaxName = "temp#_max";
static const char *kMonTempMinName = "temp#_min";
static const char *kMonTempMaxHystName = "temp#_max_hyst";
@@ -99,6 +99,7 @@ static const std::map<MonitorTypes, const char *> kMonitorNameMap = {
{kMonPowerCap, kMonPowerCapName},
{kMonPowerCapMax, kMonPowerCapMaxName},
{kMonPowerCapMin, kMonPowerCapMinName},
{kMonPowerAve, kMonPowerAveName},
{kMonTempMax, kMonTempMaxName},
{kMonTempMin, kMonTempMinName},
{kMonTempMaxHyst, kMonTempMaxHystName},
-6
View File
@@ -66,7 +66,6 @@ static const char *kPowerMonPMName = "amdgpu_pm_info";
// Using this map in case we add other files from dri directory to parse.
static const std::map<PowerMonTypes, const char *> kMonitorNameMap = {
{kPowerMaxGPUPower, kPowerMonPMName},
{kPowerAveGPUPower, kPowerMonPMName},
};
PowerMon::PowerMon(std::string path, RocmSMI_env_vars const *e) :
@@ -87,10 +86,6 @@ static int parse_power_str(std::string s, PowerMonTypes type, uint64_t *val) {
search_str = "(max GPU)";
break;
case kPowerAveGPUPower:
search_str = "(average GPU)";
break;
default:
assert(!"Invalid search Power type requested");
return EINVAL;
@@ -118,7 +113,6 @@ static int parse_power_str(std::string s, PowerMonTypes type, uint64_t *val) {
switch (type) {
case kPowerMaxGPUPower:
case kPowerAveGPUPower:
l_ss >> num_units;
l_ss >> sz;
assert(sz == "W"); // We only expect Watts at this time
@@ -641,8 +641,8 @@ void TestSanity::Run(void) {
std::cout << "\t**Power Cap Range: " << val2_ui64 << " to " <<
val_ui64 << " uW" << std::endl;
}
#if 0 // Same as above (disable for now)
err = rsmi_dev_power_ave_get(i, &val_ui64);
err = rsmi_dev_power_ave_get(i, 0, &val_ui64);
IF_VERB(STANDARD) {
std::cout << "\t**Averge Power Usage: ";
CHK_RSMI_PERM_ERR(err)
@@ -651,7 +651,6 @@ void TestSanity::Run(void) {
}
std::cout << "\t=======" << std::endl;
}
#endif
}
IF_VERB(STANDARD) {
std::cout << "***** Testing write api's" << std::endl;
+3 -3
View File
@@ -42,8 +42,8 @@
* DEALINGS WITH THE SOFTWARE.
*
*/
#ifndef ROCM_SMI_LIB_TESTS_ROCM_SMI_TEST_FUNCTIONAL_RSMI_SANITY_H_
#define ROCM_SMI_LIB_TESTS_ROCM_SMI_TEST_FUNCTIONAL_RSMI_SANITY_H_
#ifndef TESTS_ROCM_SMI_TEST_FUNCTIONAL_RSMI_SANITY_H_
#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_RSMI_SANITY_H_
#include "rocm_smi_test/test_base.h"
@@ -70,4 +70,4 @@ class TestSanity : public TestBase {
virtual void DisplayTestInfo(void);
};
#endif // ROCM_SMI_LIB_TESTS_ROCM_SMI_TEST_FUNCTIONAL_RSMI_SANITY_H_
#endif // TESTS_ROCM_SMI_TEST_FUNCTIONAL_RSMI_SANITY_H_