Correct TestPerfLevelReadWrite test

Enums referenced in the test did not match what's in rocm_smi.h.
Added static assert to try to catch this. Also moved enum string
map to test_common.cc/h where other such maps are.

Also, fixed some cpplint issues.

Change-Id: I683553248ceb2fabb28ce1a1208bc9744aaf88d6


[ROCm/rocm_smi_lib commit: 7e17684532]
This commit is contained in:
Chris Freehill
2020-12-16 14:58:41 -06:00
orang tua 9f37923767
melakukan c401b025fe
5 mengubah file dengan 36 tambahan dan 25 penghapusan
@@ -58,7 +58,8 @@
TestGpuMetricsRead::TestGpuMetricsRead() : TestBase() {
set_title("RSMI GPU Metrics Read Test");
set_description("The GPU Metrics tests verifies that the gpu metrics info can be read properly.");
set_description("The GPU Metrics tests verifies that "
"the gpu metrics info can be read properly.");
}
TestGpuMetricsRead::~TestGpuMetricsRead(void) {
@@ -179,7 +180,6 @@ void TestGpuMetricsRead::Run(void) {
// Verify api support checking functionality is working
err = rsmi_dev_gpu_metrics_info_get(i, nullptr);
ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS);
}
}
}
@@ -50,6 +50,7 @@
#include <string>
#include <map>
#include <bitset>
#include <algorithm>
#include "gtest/gtest.h"
#include "rocm_smi/rocm_smi.h"
@@ -74,8 +75,8 @@ static const std::map<rsmi_dev_perf_level_t, const char *>
TestPerfDeterminism::TestPerfDeterminism() : TestBase() {
set_title("RSMI Performance Determinism Test");
set_description("The Performance Determinism tests verifies Enabling/Disabling "
"performance determinism mode.");
set_description("The Performance Determinism tests verifies "
"Enabling/Disabling performance determinism mode.");
}
TestPerfDeterminism::~TestPerfDeterminism(void) {
@@ -54,21 +54,6 @@
#include "rocm_smi_test/functional/perf_level_read_write.h"
#include "rocm_smi_test/test_common.h"
static const std::map<rsmi_dev_perf_level_t, const char *>
kDevPerfLvlNameMap = {
{RSMI_DEV_PERF_LEVEL_AUTO, "RSMI_DEV_PERF_LEVEL_AUTO"},
{RSMI_DEV_PERF_LEVEL_LOW, "RSMI_DEV_PERF_LEVEL_LOW"},
{RSMI_DEV_PERF_LEVEL_HIGH, "RSMI_DEV_PERF_LEVEL_HIGH"},
{RSMI_DEV_PERF_LEVEL_MANUAL, "RSMI_DEV_PERF_LEVEL_MANUAL"},
{RSMI_DEV_PERF_LEVEL_STABLE_STD, "RSMI_DEV_PERF_LEVEL_STABLE_STD"},
{RSMI_DEV_PERF_LEVEL_STABLE_MIN_MCLK,
"RSMI_DEV_PERF_LEVEL_STABLE_MIN_MCLK"},
{RSMI_DEV_PERF_LEVEL_STABLE_MIN_SCLK,
"RSMI_DEV_PERF_LEVEL_STABLE_MIN_SCLK"},
{RSMI_DEV_PERF_LEVEL_STABLE_PEAK, "RSMI_DEV_PERF_LEVEL_STABLE_PEAK"},
{RSMI_DEV_PERF_LEVEL_UNKNOWN, "RSMI_DEV_PERF_LEVEL_UNKNOWN"},
};
TestPerfLevelReadWrite::TestPerfLevelReadWrite() : TestBase() {
set_title("RSMI Performance Level Read/Write Test");
@@ -121,7 +106,7 @@ void TestPerfLevelReadWrite::Run(void) {
IF_VERB(STANDARD) {
std::cout << "\t**Original Perf Level:" <<
kDevPerfLvlNameMap.at(orig_pfl) << std::endl;
GetPerfLevelStr(orig_pfl) << std::endl;
}
uint32_t pfl_i = static_cast<uint32_t>(RSMI_DEV_PERF_LEVEL_FIRST);
@@ -132,7 +117,7 @@ void TestPerfLevelReadWrite::Run(void) {
IF_VERB(STANDARD) {
std::cout << "Set Performance Level to " <<
kDevPerfLvlNameMap.at(static_cast<rsmi_dev_perf_level_t>(pfl_i)) <<
GetPerfLevelStr(static_cast<rsmi_dev_perf_level_t>(pfl_i)) <<
" ..." << std::endl;
}
ret = rsmi_dev_perf_level_set(dv_ind,
@@ -141,12 +126,12 @@ void TestPerfLevelReadWrite::Run(void) {
ret = rsmi_dev_perf_level_get(dv_ind, &pfl);
CHK_ERR_ASRT(ret)
IF_VERB(STANDARD) {
std::cout << "\t**New Perf Level:" << kDevPerfLvlNameMap.at(pfl) <<
std::endl;
std::cout << "\t**New Perf Level:" << GetPerfLevelStr(pfl) <<
std::endl;
}
}
IF_VERB(STANDARD) {
std::cout << "Reset Perf level to " << kDevPerfLvlNameMap.at(orig_pfl) <<
std::cout << "Reset Perf level to " << GetPerfLevelStr(orig_pfl) <<
" ..." << std::endl;
}
ret = rsmi_dev_perf_level_set(dv_ind, orig_pfl);
@@ -155,7 +140,7 @@ void TestPerfLevelReadWrite::Run(void) {
CHK_ERR_ASRT(ret)
IF_VERB(STANDARD) {
std::cout << "\t**New Perf Level:" << kDevPerfLvlNameMap.at(pfl) <<
std::cout << "\t**New Perf Level:" << GetPerfLevelStr(pfl) <<
std::endl;
}
}
@@ -55,6 +55,27 @@
#include "rocm_smi_test/test_common.h"
#include "rocm_smi/rocm_smi.h"
static const std::map<rsmi_dev_perf_level_t, const char *>
kDevPerfLvlNameMap = {
{RSMI_DEV_PERF_LEVEL_AUTO, "RSMI_DEV_PERF_LEVEL_AUTO"},
{RSMI_DEV_PERF_LEVEL_LOW, "RSMI_DEV_PERF_LEVEL_LOW"},
{RSMI_DEV_PERF_LEVEL_HIGH, "RSMI_DEV_PERF_LEVEL_HIGH"},
{RSMI_DEV_PERF_LEVEL_MANUAL, "RSMI_DEV_PERF_LEVEL_MANUAL"},
{RSMI_DEV_PERF_LEVEL_STABLE_STD, "RSMI_DEV_PERF_LEVEL_STABLE_STD"},
{RSMI_DEV_PERF_LEVEL_STABLE_PEAK, "RSMI_DEV_PERF_LEVEL_STABLE_PEAK"},
{RSMI_DEV_PERF_LEVEL_STABLE_MIN_MCLK,
"RSMI_DEV_PERF_LEVEL_STABLE_MIN_MCLK"},
{RSMI_DEV_PERF_LEVEL_STABLE_MIN_SCLK,
"RSMI_DEV_PERF_LEVEL_STABLE_MIN_SCLK"},
{RSMI_DEV_PERF_LEVEL_DETERMINISM, "RSMI_DEV_PERF_LEVEL_DETERMINISM"},
{RSMI_DEV_PERF_LEVEL_UNKNOWN, "RSMI_DEV_PERF_LEVEL_UNKNOWN"},
};
// If the assert below fails, the map above needs to be updated to match
// rsmi_dev_perf_level_t.
static_assert(RSMI_DEV_PERF_LEVEL_LAST == RSMI_DEV_PERF_LEVEL_DETERMINISM,
"kDevPerfLvlNameMap needs to be updated");
static const std::map<rsmi_gpu_block_t, const char *> kBlockNameMap = {
{RSMI_GPU_BLOCK_UMC, "UMC"},
{RSMI_GPU_BLOCK_SDMA, "SDMA"},
@@ -181,6 +202,9 @@ uint32_t ProcessCmdline(RSMITstGlobals* test, int arg_cnt, char** arg_list) {
return 0;
}
const char *GetPerfLevelStr(rsmi_dev_perf_level_t lvl) {
return kDevPerfLvlNameMap.at(lvl);
}
const char *GetBlockNameStr(rsmi_gpu_block_t id) {
return kBlockNameMap.at(id);
}
@@ -63,6 +63,7 @@ struct RSMITstGlobals {
uint32_t ProcessCmdline(RSMITstGlobals* test, int arg_cnt, char** arg_list);
void PrintTestHeader(uint32_t dv_ind);
const char *GetPerfLevelStr(rsmi_dev_perf_level_t lvl);
const char *GetBlockNameStr(rsmi_gpu_block_t id);
const char *GetErrStateNameStr(rsmi_ras_err_state_t st);
const char *FreqEnumToStr(rsmi_clk_type rsmi_clk);