Adding current voltage feature & gtest.
Signed-off-by: Divya Shikre <DivyaUday.Shikre@amd.com>
Change-Id: Ic555a3af265e603419e2875d1989a366abc82596
[ROCm/amdsmi commit: 2805ed16a4]
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* =============================================================================
|
||||
* ROC Runtime Conformance Release License
|
||||
* =============================================================================
|
||||
* The University of Illinois/NCSA
|
||||
* Open Source License (NCSA)
|
||||
*
|
||||
* Copyright (c) 2019, Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Developed by:
|
||||
*
|
||||
* AMD Research and AMD ROC Software Development
|
||||
*
|
||||
* Advanced Micro Devices, Inc.
|
||||
*
|
||||
* www.amd.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal with the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimers.
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimers in
|
||||
* the documentation and/or other materials provided with the distribution.
|
||||
* - Neither the names of <Name of Development Group, Name of Institution>,
|
||||
* nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this Software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS WITH THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "rocm_smi/rocm_smi.h"
|
||||
#include "rocm_smi_test/functional/volt_read.h"
|
||||
#include "rocm_smi_test/test_common.h"
|
||||
|
||||
|
||||
TestVoltRead::TestVoltRead() : TestBase() {
|
||||
set_title("RSMI Volt Read Test");
|
||||
set_description("The Voltage Read tests verifies that the voltage "
|
||||
"monitors can be read properly.");
|
||||
}
|
||||
|
||||
TestVoltRead::~TestVoltRead(void) {
|
||||
}
|
||||
|
||||
void TestVoltRead::SetUp(void) {
|
||||
TestBase::SetUp();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void TestVoltRead::DisplayTestInfo(void) {
|
||||
TestBase::DisplayTestInfo();
|
||||
}
|
||||
|
||||
void TestVoltRead::DisplayResults(void) const {
|
||||
TestBase::DisplayResults();
|
||||
return;
|
||||
}
|
||||
|
||||
void TestVoltRead::Close() {
|
||||
// This will close handles opened within rsmitst utility calls and call
|
||||
// rsmi_shut_down(), so it should be done after other hsa cleanup
|
||||
TestBase::Close();
|
||||
}
|
||||
|
||||
|
||||
void TestVoltRead::Run(void) {
|
||||
rsmi_status_t err;
|
||||
int64_t val_i64;
|
||||
|
||||
TestBase::Run();
|
||||
if (setup_failed_) {
|
||||
std::cout << "** SetUp Failed for this test. Skipping.**" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
rsmi_voltage_type_t type = RSMI_VOLT_TYPE_VDDGFX;
|
||||
|
||||
for (uint32_t i = 0; i < num_monitor_devs(); ++i) {
|
||||
PrintDeviceHeader(i);
|
||||
|
||||
auto print_volt_metric = [&](rsmi_voltage_metric_t met,
|
||||
std::string label) {
|
||||
err = rsmi_dev_volt_metric_get(i, type, met, &val_i64);
|
||||
|
||||
if (err != RSMI_STATUS_SUCCESS) {
|
||||
if (err == RSMI_STATUS_NOT_SUPPORTED) {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**" << label << ": " <<
|
||||
"Not supported on this machine" << std::endl;
|
||||
|
||||
// Verify api support checking functionality is working
|
||||
err = rsmi_dev_volt_metric_get(i, type, met, nullptr);
|
||||
ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
CHK_ERR_ASRT(err)
|
||||
}
|
||||
}
|
||||
// Verify api support checking functionality is working
|
||||
err = rsmi_dev_volt_metric_get(i, type, met, nullptr);
|
||||
ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS);
|
||||
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**" << label << ": " << val_i64 <<
|
||||
"mV" << std::endl;
|
||||
}
|
||||
};
|
||||
for (uint32_t i = RSMI_VOLT_TYPE_FIRST; i <= RSMI_VOLT_TYPE_LAST; ++i) {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t** **********" << GetVoltSensorNameStr(static_cast<rsmi_voltage_type_t>(i)) <<
|
||||
" Voltage **********" << std::endl;
|
||||
}
|
||||
print_volt_metric(RSMI_VOLT_CURRENT, "Current Voltage");
|
||||
print_volt_metric(RSMI_VOLT_MAX, "Voltage max value");
|
||||
print_volt_metric(RSMI_VOLT_MIN, "Voltage min value");
|
||||
print_volt_metric(RSMI_VOLT_MAX_CRIT,
|
||||
"Voltage critical max value");
|
||||
print_volt_metric(RSMI_VOLT_MIN_CRIT,
|
||||
"Voltage critical min value");
|
||||
print_volt_metric(RSMI_VOLT_AVERAGE, "Voltage critical max value");
|
||||
print_volt_metric(RSMI_VOLT_LOWEST, "Historical minimum temperature");
|
||||
print_volt_metric(RSMI_VOLT_HIGHEST, "Historical maximum temperature");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* =============================================================================
|
||||
* ROC Runtime Conformance Release License
|
||||
* =============================================================================
|
||||
* The University of Illinois/NCSA
|
||||
* Open Source License (NCSA)
|
||||
*
|
||||
* Copyright (c) 2019, Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Developed by:
|
||||
*
|
||||
* AMD Research and AMD ROC Software Development
|
||||
*
|
||||
* Advanced Micro Devices, Inc.
|
||||
*
|
||||
* www.amd.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal with the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimers.
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimers in
|
||||
* the documentation and/or other materials provided with the distribution.
|
||||
* - Neither the names of <Name of Development Group, Name of Institution>,
|
||||
* nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this Software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS WITH THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#ifndef TESTS_ROCM_SMI_TEST_FUNCTIONAL_VOLT_READ_H_
|
||||
#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_VOLT_READ_H_
|
||||
|
||||
#include "rocm_smi_test/test_base.h"
|
||||
|
||||
class TestVoltRead : public TestBase {
|
||||
public:
|
||||
TestVoltRead();
|
||||
|
||||
// @Brief: Destructor for test case of TestVOltRead
|
||||
virtual ~TestVoltRead();
|
||||
|
||||
// @Brief: Setup the environment for measurement
|
||||
virtual void SetUp();
|
||||
|
||||
// @Brief: Core measurement execution
|
||||
virtual void Run();
|
||||
|
||||
// @Brief: Clean up and retrive the resource
|
||||
virtual void Close();
|
||||
|
||||
// @Brief: Display results
|
||||
virtual void DisplayResults() const;
|
||||
|
||||
// @Brief: Display information about what this test does
|
||||
virtual void DisplayTestInfo(void);
|
||||
};
|
||||
|
||||
#endif // TESTS_ROCM_SMI_TEST_FUNCTIONAL_VOLT_READ_H_
|
||||
@@ -55,6 +55,7 @@
|
||||
#include "functional/fan_read.h"
|
||||
#include "functional/fan_read_write.h"
|
||||
#include "functional/temp_read.h"
|
||||
#include "functional/volt_read.h"
|
||||
#include "functional/volt_freq_curv_read.h"
|
||||
#include "functional/perf_level_read.h"
|
||||
#include "functional/overdrive_read.h"
|
||||
@@ -143,6 +144,10 @@ TEST(rsmitstReadOnly, TempRead) {
|
||||
TestTempRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(rsmitstReadOnly, VoltRead) {
|
||||
TestVoltRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(rsmitstReadOnly, TestVoltCurvRead) {
|
||||
TestVoltCurvRead tst;
|
||||
RunGenericTest(&tst);
|
||||
|
||||
@@ -119,6 +119,10 @@ static const struct option long_options[] = {
|
||||
};
|
||||
static const char* short_options = "i:v:m:fr";
|
||||
|
||||
static const std::map<uint32_t, std::string> kVoltSensorNameMap = {
|
||||
{RSMI_VOLT_TYPE_VDDGFX, "Vddgfx"},
|
||||
};
|
||||
|
||||
static void PrintHelp(void) {
|
||||
std::cout <<
|
||||
"Optional rsmitst Arguments:\n"
|
||||
@@ -184,7 +188,9 @@ const char *GetBlockNameStr(rsmi_gpu_block_t id) {
|
||||
const char *GetErrStateNameStr(rsmi_ras_err_state_t st) {
|
||||
return kErrStateNameMap.at(st);
|
||||
}
|
||||
|
||||
const std::string GetVoltSensorNameStr(rsmi_voltage_type_t st) {
|
||||
return kVoltSensorNameMap.at(st);
|
||||
}
|
||||
const char *FreqEnumToStr(rsmi_clk_type rsmi_clk) {
|
||||
static_assert(RSMI_CLK_TYPE_LAST == RSMI_CLK_TYPE_MEM,
|
||||
"FreqEnumToStr() needs to be updated");
|
||||
|
||||
@@ -65,6 +65,7 @@ void PrintTestHeader(uint32_t dv_ind);
|
||||
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);
|
||||
const std::string GetVoltSensorNameStr(rsmi_voltage_type_t st);
|
||||
|
||||
#if ENABLE_SMI
|
||||
void DumpMonitorInfo(const TestBase *test);
|
||||
|
||||
Fai riferimento in un nuovo problema
Block a user