Merge remote-tracking branch 'rocmsmi/amd-staging' into HEAD
Change-Id: I65ed7f3a0d1b6e58bc8377932d7c39db21d1b422
This commit is contained in:
@@ -126,16 +126,20 @@ void TestFrequenciesRead::Run(void) {
|
||||
} else if (err == AMDSMI_STATUS_NOT_YET_IMPLEMENTED) {
|
||||
std::cout << "\t**Get " << name <<
|
||||
": Not implemented on this machine" << std::endl;
|
||||
// special driver issue, shouldn't normally occur
|
||||
} else if (err == AMDSMI_STATUS_UNEXPECTED_DATA) {
|
||||
std::cerr << "WARN: Clock file [" << FreqEnumToStr(t) << "] exists on device [" << i << "] but empty!" << std::endl;
|
||||
std::cerr << " Likely a driver issue!" << std::endl;
|
||||
} else {
|
||||
CHK_ERR_ASRT(err)
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Supported " << name << " clock frequencies: ";
|
||||
std::cout << f.num_supported << std::endl;
|
||||
print_frequencies(&f);
|
||||
// Verify api support checking functionality is working
|
||||
err = amdsmi_get_clk_freq(processor_handles_[i], t, nullptr);
|
||||
ASSERT_EQ(err, AMDSMI_STATUS_INVAL);
|
||||
}
|
||||
CHK_ERR_ASRT(err)
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Supported " << name << " clock frequencies: ";
|
||||
std::cout << f.num_supported << std::endl;
|
||||
print_frequencies(&f);
|
||||
// Verify api support checking functionality is working
|
||||
err = amdsmi_get_clk_freq(processor_handles_[i], t, nullptr);
|
||||
ASSERT_EQ(err, AMDSMI_STATUS_INVAL);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -104,8 +104,7 @@ void TestFrequenciesReadWrite::Run(void) {
|
||||
for (uint32_t dv_ind = 0; dv_ind < num_monitor_devs(); ++dv_ind) {
|
||||
PrintDeviceHeader(processor_handles_[dv_ind]);
|
||||
|
||||
for (uint32_t clk = (uint32_t)CLK_TYPE_FIRST;
|
||||
clk <= CLK_TYPE__MAX; ++clk) {
|
||||
for (uint32_t clk = CLK_TYPE_FIRST; clk <= CLK_TYPE__MAX; ++clk) {
|
||||
amdsmi_clk = (amdsmi_clk_type_t)clk;
|
||||
|
||||
auto freq_read = [&]() -> bool {
|
||||
@@ -121,14 +120,20 @@ void TestFrequenciesReadWrite::Run(void) {
|
||||
std::cout << "\t**Set " << FreqEnumToStr(amdsmi_clk) <<
|
||||
": Not supported on this machine" << std::endl;
|
||||
return false;
|
||||
} else {
|
||||
// CHK_ERR_ASRT(ret)
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "Initial frequency for clock " <<
|
||||
FreqEnumToStr(amdsmi_clk) << " is " << f.current << std::endl;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// special driver issue, shouldn't normally occur
|
||||
if (ret == AMDSMI_STATUS_UNEXPECTED_DATA) {
|
||||
std::cerr << "WARN: Clock file [" << FreqEnumToStr(amdsmi_clk) << "] exists on device [" << dv_ind << "] but empty!" << std::endl;
|
||||
std::cerr << " Likely a driver issue!" << std::endl;
|
||||
}
|
||||
|
||||
// CHK_ERR_ASRT(ret)
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "Initial frequency for clock " <<
|
||||
FreqEnumToStr(amdsmi_clk) << " is " << f.current << std::endl;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
auto freq_write = [&]() {
|
||||
@@ -152,19 +157,18 @@ void TestFrequenciesReadWrite::Run(void) {
|
||||
std::endl;
|
||||
}
|
||||
ret = amdsmi_set_clk_freq(processor_handles_[dv_ind], amdsmi_clk, freq_bitmask);
|
||||
//Certain ASICs does not allow to set particular clocks. If set function for a clock returns
|
||||
//permission error despite root access, manually set ret value to success and return
|
||||
if (ret == AMDSMI_STATUS_NO_PERM && geteuid() == 0) {
|
||||
std::cout << "\t**Set " << FreqEnumToStr(amdsmi_clk) <<
|
||||
": Not supported on this machine. Skipping..." << std::endl;
|
||||
ret = AMDSMI_STATUS_SUCCESS;
|
||||
return;
|
||||
} else if (ret == AMDSMI_STATUS_NOT_SUPPORTED) {
|
||||
// Certain ASICs does not allow to set particular clocks. If set function for a clock returns
|
||||
// permission error despite root access, manually set ret value to success and return
|
||||
//
|
||||
// Sometimes setting clock frequencies is completely not supported
|
||||
if ((ret == AMDSMI_STATUS_NO_PERM && geteuid() == 0) ||
|
||||
(ret == AMDSMI_STATUS_NOT_SUPPORTED)) {
|
||||
std::cout << "\t**Set " << FreqEnumToStr(amdsmi_clk) <<
|
||||
": Not supported on this machine. Skipping..." << std::endl;
|
||||
ret = AMDSMI_STATUS_SUCCESS;
|
||||
return;
|
||||
}
|
||||
|
||||
CHK_ERR_ASRT(ret)
|
||||
ret = amdsmi_get_clk_freq(processor_handles_[dv_ind], amdsmi_clk, &f);
|
||||
if (ret != AMDSMI_STATUS_SUCCESS) {
|
||||
@@ -187,7 +191,9 @@ void TestFrequenciesReadWrite::Run(void) {
|
||||
}
|
||||
|
||||
ret = amdsmi_set_gpu_perf_level(processor_handles_[dv_ind], AMDSMI_DEV_PERF_LEVEL_AUTO);
|
||||
if (ret != AMDSMI_STATUS_SUCCESS) {
|
||||
if (ret == AMDSMI_STATUS_NOT_SUPPORTED) {
|
||||
std::cout << "\t**Setting performance level is not supported on this machine. Skipping..." << std::endl;
|
||||
ret = AMDSMI_STATUS_SUCCESS;
|
||||
return;
|
||||
}
|
||||
};
|
||||
@@ -199,44 +205,6 @@ void TestFrequenciesReadWrite::Run(void) {
|
||||
}
|
||||
freq_write();
|
||||
CHK_ERR_ASRT(ret)
|
||||
#if 0
|
||||
ret = amdsmi_get_clk_freq(dv_ind, amdsmi_clk, &f);
|
||||
CHK_ERR_ASRT(ret)
|
||||
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "Initial frequency for clock " << amdsmi_clk << " is " <<
|
||||
f.current << std::endl;
|
||||
}
|
||||
// Set clocks to something other than the usual default of the lowest
|
||||
// frequency.
|
||||
freq_bitmask = 0b01100; // Try the 3rd and 4th clocks
|
||||
|
||||
std::string freq_bm_str =
|
||||
std::bitset<AMDSMI_MAX_NUM_FREQUENCIES>(freq_bitmask).to_string();
|
||||
|
||||
freq_bm_str.erase(0, std::min(freq_bm_str.find_first_not_of('0'),
|
||||
freq_bm_str.size()-1));
|
||||
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "Setting frequency mask for clock " << amdsmi_clk <<
|
||||
" to 0b" << freq_bm_str << " ..." << std::endl;
|
||||
}
|
||||
ret = amdsmi_set_clk_freq(dv_ind, amdsmi_clk, freq_bitmask);
|
||||
CHK_ERR_ASRT(ret)
|
||||
|
||||
ret = amdsmi_get_clk_freq(dv_ind, amdsmi_clk, &f);
|
||||
CHK_ERR_ASRT(ret)
|
||||
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "Frequency is now index " << f.current << std::endl;
|
||||
std::cout << "Resetting mask to all frequencies." << std::endl;
|
||||
}
|
||||
ret = amdsmi_set_clk_freq(dv_ind, amdsmi_clk, 0xFFFFFFFF);
|
||||
CHK_ERR_ASRT(ret)
|
||||
|
||||
ret = amdsmi_set_gpu_perf_level(dv_ind, AMDSMI_DEV_PERF_LEVEL_AUTO);
|
||||
CHK_ERR_ASRT(ret)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,8 +177,8 @@ void TestGpuMetricsRead::Run(void) {
|
||||
<< std::to_string(smu.pcie_link_speed) << '\n';
|
||||
std::cout << "gfx_activity_acc="
|
||||
<< std::dec << smu.gfx_activity_acc << '\n';
|
||||
std::cout << "mem_actvity_acc="
|
||||
<< std::dec << smu.mem_actvity_acc << '\n';
|
||||
std::cout << "mem_activity_acc="
|
||||
<< std::dec << smu.mem_activity_acc << '\n';
|
||||
|
||||
for (int i = 0; i < AMDSMI_NUM_HBM_INSTANCES; ++i) {
|
||||
std::cout << "temperature_hbm[" << i << "]=" << std::dec <<
|
||||
|
||||
@@ -112,6 +112,13 @@ void TestPowerCapReadWrite::Run(void) {
|
||||
max = info.max_power_cap;
|
||||
orig = info.default_power_cap;
|
||||
|
||||
// Check if power cap is within the range
|
||||
// skip the test otherwise
|
||||
if (orig < min || orig > max) {
|
||||
std::cout << "Power cap is not within the range. Skipping test for " << dv_ind << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
new_cap = (max + min)/2;
|
||||
|
||||
IF_VERB(STANDARD) {
|
||||
|
||||
@@ -126,6 +126,10 @@ void TestPowerReadWrite::Run(void) {
|
||||
if (ret == AMDSMI_STATUS_NOT_SUPPORTED) {
|
||||
std::cout << "The power profile presets settings is not supported. "
|
||||
<< std::endl;
|
||||
|
||||
// Verify api support checking functionality is working
|
||||
ret = amdsmi_get_gpu_power_profile_presets(processor_handles_[dv_ind], 0, nullptr);
|
||||
ASSERT_EQ(ret, AMDSMI_STATUS_NOT_SUPPORTED);
|
||||
continue;
|
||||
}
|
||||
CHK_ERR_ASRT(ret)
|
||||
|
||||
@@ -106,14 +106,12 @@ static void RunCustomTestProlog(TestBase *test) {
|
||||
}
|
||||
test->SetUp();
|
||||
test->Run();
|
||||
return;
|
||||
}
|
||||
static void RunCustomTestEpilog(TestBase *tst) {
|
||||
if (sRSMIGlvalues->verbosity >= TestBase::VERBOSE_STANDARD) {
|
||||
tst->DisplayResults();
|
||||
}
|
||||
tst->Close();
|
||||
return;
|
||||
}
|
||||
|
||||
// If the test case one big test, you should use RunGenericTest()
|
||||
@@ -125,7 +123,6 @@ static void RunCustomTestEpilog(TestBase *tst) {
|
||||
static void RunGenericTest(TestBase *test) {
|
||||
RunCustomTestProlog(test);
|
||||
RunCustomTestEpilog(test);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -63,10 +63,7 @@ $BLACKLIST_ALL_ASICS\
|
||||
# /sys/class/kfd/kfd/topology/nodes/*/properties
|
||||
FILTER[90400]=\
|
||||
$BLACKLIST_ALL_ASICS\
|
||||
"rsmitstReadOnly.TestVoltCurvRead:"\
|
||||
"rsmitstReadOnly.TestFrequenciesRead:"\
|
||||
"rsmitstReadWrite.TestFrequenciesReadWrite:"\
|
||||
"rsmitstReadWrite.TestPowerReadWrite"
|
||||
"rsmitstReadOnly.TestVoltCurvRead"
|
||||
FILTER[90401]=${FILTER[90400]}
|
||||
FILTER[90402]=${FILTER[90400]}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <cassert>
|
||||
|
||||
#include "amd_smi/amdsmi.h"
|
||||
#include "test_base.h"
|
||||
@@ -61,10 +61,9 @@ static const char kResultsLabel[] = "TEST RESULTS";
|
||||
// This one is used outside this file
|
||||
const char kSetupLabel[] = "TEST SETUP";
|
||||
|
||||
TestBase::TestBase() : setup_failed_(false), description_("") {
|
||||
}
|
||||
TestBase::~TestBase() {
|
||||
TestBase::TestBase() : setup_failed_(false) {
|
||||
}
|
||||
TestBase::~TestBase() = default;
|
||||
|
||||
void TestBase::MakeHeaderStr(const char *inStr,
|
||||
std::string *outStr) const {
|
||||
@@ -155,8 +154,6 @@ void TestBase::SetUp(uint64_t init_flags) {
|
||||
std::cout << "No AMD SMI tests can be run." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void TestBase::PrintDeviceHeader(amdsmi_processor_handle dv_ind) {
|
||||
@@ -254,7 +251,7 @@ void TestBase::set_description(std::string d) {
|
||||
size_t endlptr;
|
||||
|
||||
for (size_t i = le; i < description_.size(); i += le) {
|
||||
endlptr = description_.find_last_of(" ", i);
|
||||
endlptr = description_.find_last_of(' ', i);
|
||||
description_.replace(endlptr, 1, "\n");
|
||||
i = endlptr;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#ifndef TESTS_AMD_SMI_TEST_TEST_BASE_H_
|
||||
#define TESTS_AMD_SMI_TEST_TEST_BASE_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "amd_smi/amdsmi.h"
|
||||
@@ -150,9 +151,8 @@ class TestBase {
|
||||
"\t===> Abort is over-ridden due to dont_fail command line option." \
|
||||
<< std::endl; \
|
||||
return; \
|
||||
} else { \
|
||||
ASSERT_EQ(AMDSMI_STATUS_SUCCESS, (RET)); \
|
||||
} \
|
||||
ASSERT_EQ(AMDSMI_STATUS_SUCCESS, (RET)); \
|
||||
}
|
||||
|
||||
void MakeHeaderStr(const char *inStr, std::string *outStr);
|
||||
|
||||
@@ -43,13 +43,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "test_base.h"
|
||||
#include "test_common.h"
|
||||
|
||||
@@ -74,7 +74,7 @@ void DumpMonitorInfo(const TestBase *test);
|
||||
#endif
|
||||
|
||||
#define DISPLAY_AMDSMI_ERR(RET) { \
|
||||
if (RET != AMDSMI_STATUS_SUCCESS) { \
|
||||
if ((RET) != AMDSMI_STATUS_SUCCESS) { \
|
||||
const char *err_str; \
|
||||
std::cout << "\t===> ERROR: AMDSMI call returned " << (RET) << std::endl; \
|
||||
amdsmi_status_code_to_string((RET), &err_str); \
|
||||
@@ -91,7 +91,7 @@ void DumpMonitorInfo(const TestBase *test);
|
||||
} \
|
||||
}
|
||||
#define CHK_AMDSMI_PERM_ERR(RET) { \
|
||||
if (RET == AMDSMI_STATUS_NO_PERM) { \
|
||||
if ((RET) == AMDSMI_STATUS_NO_PERM) { \
|
||||
std::cout << "This command requires root access." << std::endl; \
|
||||
} else { \
|
||||
DISPLAY_AMDSMI_ERR(RET) \
|
||||
|
||||
Reference in New Issue
Block a user