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>
이 커밋은 다음에 포함됨:
Charis Poag
2023-10-04 16:18:32 -05:00
커밋한 사람 Galantsev, Dmitrii
부모 4e4ebde640
커밋 31a1fcce7d
9개의 변경된 파일294개의 추가작업 그리고 51개의 파일을 삭제
+41 -13
파일 보기
@@ -5,7 +5,7 @@
* The University of Illinois/NCSA
* Open Source License (NCSA)
*
* Copyright (c) 2019, Advanced Micro Devices, Inc.
* Copyright (c) 2019-2023, Advanced Micro Devices, Inc.
* All rights reserved.
*
* Developed by:
@@ -89,6 +89,7 @@ void TestPowerRead::Close() {
void TestPowerRead::Run(void) {
rsmi_status_t err;
uint64_t val_ui64, val2_ui64;
RSMI_POWER_TYPE type = RSMI_INVALID_POWER;
TestBase::Run();
if (setup_failed_) {
@@ -119,44 +120,71 @@ void TestPowerRead::Run(void) {
/* Average Power */
err = rsmi_dev_power_ave_get(i, 0, &val_ui64);
ASSERT_TRUE(err == RSMI_STATUS_SUCCESS
|| err == RSMI_STATUS_NOT_SUPPORTED);
if (err == RSMI_STATUS_NOT_SUPPORTED) {
std::cout <<
"\t**Average Power Usage: not supported on this device"
<< std::endl;
} else {
CHK_RSMI_PERM_ERR(err)
IF_VERB(STANDARD) {
std::cout << "\t**Average Power Usage: ";
CHK_RSMI_PERM_ERR(err)
if (err == RSMI_STATUS_SUCCESS) {
std::cout << static_cast<float>(val_ui64) / 1000 << " mW"
std::cout << static_cast<float>(val_ui64) / 1000 << " W"
<< std::endl;
}
// Verify api support checking functionality is working
err = rsmi_dev_power_ave_get(i, 0, nullptr);
ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS);
}
// Verify api support checking functionality is working
err = rsmi_dev_power_ave_get(i, 0, nullptr);
ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS);
}
/* Current Socket Power */
err = rsmi_dev_current_socket_power_get(i, &val_ui64);
ASSERT_TRUE(err == RSMI_STATUS_SUCCESS
|| err == RSMI_STATUS_NOT_SUPPORTED);
if (err == RSMI_STATUS_NOT_SUPPORTED) {
std::cout <<
"\t**Current Socket Power: not supported"
" on this device" << std::endl;
} else {
CHK_RSMI_PERM_ERR(err)
IF_VERB(STANDARD) {
std::cout << "\t**Current Socket Power: ";
CHK_RSMI_PERM_ERR(err)
if (err == RSMI_STATUS_SUCCESS) {
std::cout << static_cast<float>(val_ui64) / 1000 << " mW"
std::cout << static_cast<float>(val_ui64) / 1000 << " W"
<< std::endl;
}
// Verify api support checking functionality is working
err = rsmi_dev_current_socket_power_get(i, nullptr);
// std::cout << "err = " << amd::smi::getRSMIStatusString(err);
ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS);
}
// Verify api support checking functionality is working
err = rsmi_dev_current_socket_power_get(i, nullptr);
ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS);
}
/* Generic Power */
err = rsmi_dev_power_get(i, &val_ui64, &type);
ASSERT_TRUE(err == RSMI_STATUS_SUCCESS
|| err == RSMI_STATUS_NOT_SUPPORTED);
if (err == RSMI_STATUS_NOT_SUPPORTED) {
std::cout <<
"\t**Generic Power: not supported"
" on this device" << std::endl;
} else {
CHK_RSMI_PERM_ERR(err)
IF_VERB(STANDARD) {
std::cout << "\t**Generic Power: ";
if (err == RSMI_STATUS_SUCCESS) {
std::cout << "[" << amd::smi::power_type_string(type) << "] "
<< static_cast<float>(val_ui64) / 1000 << " W"
<< std::endl;
}
}
// Verify api support checking functionality is working
err = rsmi_dev_power_get(i, nullptr, nullptr);
ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS);
}
std::cout << "\n";
}
+1 -1
파일 보기
@@ -5,7 +5,7 @@
* The University of Illinois/NCSA
* Open Source License (NCSA)
*
* Copyright (c) 2019, Advanced Micro Devices, Inc.
* Copyright (c) 2019-2023, Advanced Micro Devices, Inc.
* All rights reserved.
*
* Developed by:
+5
파일 보기
@@ -54,6 +54,7 @@
#include "rocm_smi_test/test_base.h"
#include "rocm_smi_test/test_common.h"
#include "rocm_smi/rocm_smi.h"
#include "rocm_smi/rocm_smi_utils.h"
static const std::map<rsmi_dev_perf_level_t, const char *>
kDevPerfLvlNameMap = {
@@ -227,6 +228,10 @@ const char *FreqEnumToStr(rsmi_clk_type rsmi_clk) {
}
}
void printRSMIError(rsmi_status_t err) {
std::cout << "err = " << amd::smi::getRSMIStatusString(err);
}
#if ENABLE_SMI
void DumpMonitorInfo(const TestBase *test) {
int ret = 0;
+2
파일 보기
@@ -98,4 +98,6 @@ void DumpMonitorInfo(const TestBase *test);
} \
}
void printRSMIError(rsmi_status_t err);
#endif // TESTS_ROCM_SMI_TEST_TEST_COMMON_H_