From 91d7476581e28a54e3004cbbf3448a545423b993 Mon Sep 17 00:00:00 2001 From: Chris Freehill Date: Sat, 9 Feb 2019 12:18:49 -0600 Subject: [PATCH 1/2] Add dont_fail option to not fail entire test on a single failure [ROCm/amdsmi commit: dd450e963ced3cf7a1b3ce0a593e56c31e34aa0f] --- projects/amdsmi/src/rocm_smi.cc | 7 ++++++- .../tests/rocm_smi_test/functional/rsmi_sanity.cc | 12 +++++++++++- projects/amdsmi/tests/rocm_smi_test/main.cc | 3 ++- projects/amdsmi/tests/rocm_smi_test/test_base.h | 8 +++++++- projects/amdsmi/tests/rocm_smi_test/test_common.cc | 14 +++++++++++--- projects/amdsmi/tests/rocm_smi_test/test_common.h | 1 + 6 files changed, 38 insertions(+), 7 deletions(-) diff --git a/projects/amdsmi/src/rocm_smi.cc b/projects/amdsmi/src/rocm_smi.cc index 7e0f13e68c..aa1a8f8e08 100755 --- a/projects/amdsmi/src/rocm_smi.cc +++ b/projects/amdsmi/src/rocm_smi.cc @@ -551,7 +551,12 @@ static rsmi_status_t get_frequencies(amd::smi::DevInfoTypes type, } } - assert(f->current < f->num_supported); + // Some older drivers will not have the current frequency set + // assert(f->current < f->num_supported); + if (f->current >= f->num_supported) { + return RSMI_STATUS_NOT_SUPPORTED; + } + return RSMI_STATUS_SUCCESS; CATCH } diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/rsmi_sanity.cc b/projects/amdsmi/tests/rocm_smi_test/functional/rsmi_sanity.cc index 569375a542..d5539b8b59 100755 --- a/projects/amdsmi/tests/rocm_smi_test/functional/rsmi_sanity.cc +++ b/projects/amdsmi/tests/rocm_smi_test/functional/rsmi_sanity.cc @@ -56,6 +56,7 @@ static const uint32_t kNumBufferElements = 256; static uint32_t gVerbosity = 3; +static bool gDontFail = false; #define DISPLAY_RSMI_ERR(RET) { \ if (RET != RSMI_STATUS_SUCCESS) { \ @@ -77,7 +78,15 @@ static uint32_t gVerbosity = 3; #define CHK_ERR_ASRT(RET) { \ DISPLAY_RSMI_ERR(RET) \ - ASSERT_EQ((RET), RSMI_STATUS_SUCCESS); \ + if (gDontFail && ((RET) != RSMI_STATUS_SUCCESS)) { \ + std::cout << "========> TEST FAILURE."; \ + DISPLAY_RSMI_ERR(RET); \ + std::cout << \ + "Abort is over-ridden due to dont_fail command line option." \ + << std::endl; \ + } else { \ + ASSERT_EQ(RSMI_STATUS_SUCCESS, (RET)); \ + } \ } #define CHK_RSMI_PERM_ERR(RET) { \ @@ -599,6 +608,7 @@ void TestSanity::SetUp(void) { TestBase::SetUp(); gVerbosity = verbosity(); + gDontFail = dont_fail(); err = rsmi_init(0); ASSERT_EQ(err, RSMI_STATUS_SUCCESS); diff --git a/projects/amdsmi/tests/rocm_smi_test/main.cc b/projects/amdsmi/tests/rocm_smi_test/main.cc index 20f13ec56a..6c30ccb94e 100755 --- a/projects/amdsmi/tests/rocm_smi_test/main.cc +++ b/projects/amdsmi/tests/rocm_smi_test/main.cc @@ -60,6 +60,7 @@ static void SetFlags(TestBase *test) { test->set_num_iteration(sRSMIGlvalues->num_iterations); test->set_verbosity(sRSMIGlvalues->verbosity); + test->set_dont_fail(sRSMIGlvalues->dont_fail); } @@ -113,7 +114,7 @@ int main(int argc, char** argv) { settings.verbosity = 1; settings.monitor_verbosity = 1; settings.num_iterations = 1; - + settings.dont_fail = false; if (ProcessCmdline(&settings, argc, argv)) { return 1; diff --git a/projects/amdsmi/tests/rocm_smi_test/test_base.h b/projects/amdsmi/tests/rocm_smi_test/test_base.h index 4b1a6f56ba..497686f3f2 100755 --- a/projects/amdsmi/tests/rocm_smi_test/test_base.h +++ b/projects/amdsmi/tests/rocm_smi_test/test_base.h @@ -87,19 +87,25 @@ class TestBase { std::string title(void) const { return title_; } - void set_verbosity(uint32_t v) { verbosity_ = v; } uint32_t verbosity(void) const { return verbosity_; } + void set_dont_fail(bool f) { + dont_fail_ = f; + } + bool dont_fail(void) const { + return dont_fail_; + } private: uint64_t num_iteration_; ///< Number of times to execute test std::string description_; std::string title_; ///< Displayed title of test uint32_t verbosity_; ///< How much additional output to produce + bool dont_fail_; ///< Don't quit test on individual failure if true }; #endif // TESTS_ROCM_SMI_TEST_TEST_BASE_H_ diff --git a/projects/amdsmi/tests/rocm_smi_test/test_common.cc b/projects/amdsmi/tests/rocm_smi_test/test_common.cc index 642604b48f..950566f2af 100755 --- a/projects/amdsmi/tests/rocm_smi_test/test_common.cc +++ b/projects/amdsmi/tests/rocm_smi_test/test_common.cc @@ -57,17 +57,21 @@ static const struct option long_options[] = { {"iterations", required_argument, nullptr, 'i'}, {"verbose", required_argument, nullptr, 'v'}, {"monitor_verbose", required_argument, nullptr, 'm'}, + {"dont_fail", no_argument, nullptr, 'f'}, + {"rsmitst_help", no_argument, nullptr, 'r'}, {nullptr, 0, nullptr, 0} }; -static const char* short_options = "i:v:m:r"; +static const char* short_options = "i:v:m:fr"; static void PrintHelp(void) { std::cout << - "Optional RocRTst Arguments:\n" + "Optional rsmitst Arguments:\n" + "--dont_fail, -f if set, don't fail test when individual test fails; " + "default is to fail when an individual test fails\n" "--iterations, -i ; override default, " "which varies for each test\n" - "--rocrtst_help, -r print this help message\n" + "--rsmitst_help, -r print this help message\n" "--verbosity, -v \n" " Verbosity levels:\n" " 0 -- minimal; just summary information\n" @@ -113,6 +117,10 @@ uint32_t ProcessCmdline(RSMITstGlobals* test, int arg_cnt, char** arg_list) { PrintHelp(); return 1; + case 'f': + test->dont_fail = true; + break; + default: PrintHelp(); return 1; diff --git a/projects/amdsmi/tests/rocm_smi_test/test_common.h b/projects/amdsmi/tests/rocm_smi_test/test_common.h index 8512ffe2f9..fc0dce8a53 100755 --- a/projects/amdsmi/tests/rocm_smi_test/test_common.h +++ b/projects/amdsmi/tests/rocm_smi_test/test_common.h @@ -55,6 +55,7 @@ struct RSMITstGlobals { uint32_t verbosity; uint32_t monitor_verbosity; uint32_t num_iterations; + bool dont_fail; }; uint32_t ProcessCmdline(RSMITstGlobals* test, int arg_cnt, char** arg_list); From fe7d53dc3326136d25e859634f65cff8c34adb2f Mon Sep 17 00:00:00 2001 From: Chris Freehill Date: Mon, 11 Feb 2019 22:53:24 -0600 Subject: [PATCH 2/2] Break down monolithic test into many smaller tests Also, added boot up default power profile, and modified to accomodate new profile format [ROCm/amdsmi commit: 17bf80dcb212203663b9dcb7bcf5f85223346be9] --- projects/amdsmi/include/rocm_smi/rocm_smi.h | 6 +- projects/amdsmi/src/rocm_smi.cc | 14 +- .../rocm_smi_test/functional/bdfid_read.cc | 104 +++ .../rocm_smi_test/functional/bdfid_read.h | 73 ++ .../rocm_smi_test/functional/fan_read.cc | 118 ++++ .../tests/rocm_smi_test/functional/fan_read.h | 73 ++ .../functional/fan_read_write.cc | 153 ++++ .../rocm_smi_test/functional/fan_read_write.h | 73 ++ .../functional/frequencies_read.cc | 142 ++++ .../functional/frequencies_read.h | 73 ++ .../functional/frequencies_read_write.cc | 145 ++++ .../functional/frequencies_read_write.h | 73 ++ .../rocm_smi_test/functional/gpu_busy_read.cc | 114 +++ .../rocm_smi_test/functional/gpu_busy_read.h | 73 ++ .../functional/overdrive_read.cc | 103 +++ .../rocm_smi_test/functional/overdrive_read.h | 73 ++ .../functional/overdrive_read_write.cc | 120 ++++ .../functional/overdrive_read_write.h | 73 ++ .../functional/pci_bw_read_write.cc | 141 ++++ .../functional/pci_bw_read_write.h | 73 ++ .../functional/perf_level_read.cc | 104 +++ .../functional/perf_level_read.h | 73 ++ .../functional/perf_level_read_write.cc | 153 ++++ .../functional/perf_level_read_write.h | 73 ++ .../functional/power_cap_read_write.cc | 136 ++++ .../functional/power_cap_read_write.h | 73 ++ .../rocm_smi_test/functional/power_read.cc | 118 ++++ .../rocm_smi_test/functional/power_read.h | 73 ++ .../functional/power_read_write.cc | 187 +++++ .../functional/power_read_write.h | 73 ++ .../rocm_smi_test/functional/rsmi_sanity.cc | 660 +----------------- .../rocm_smi_test/functional/temp_read.cc | 139 ++++ .../rocm_smi_test/functional/temp_read.h | 73 ++ .../functional/volt_freq_curv_read.cc | 181 +++++ .../functional/volt_freq_curv_read.h | 73 ++ projects/amdsmi/tests/rocm_smi_test/main.cc | 82 ++- .../amdsmi/tests/rocm_smi_test/test_base.cc | 38 + .../amdsmi/tests/rocm_smi_test/test_base.h | 33 +- .../amdsmi/tests/rocm_smi_test/test_common.cc | 15 +- .../amdsmi/tests/rocm_smi_test/test_common.h | 28 + 40 files changed, 3521 insertions(+), 681 deletions(-) create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/bdfid_read.cc create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/bdfid_read.h create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/fan_read.cc create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/fan_read.h create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/fan_read_write.cc create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/fan_read_write.h create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read.cc create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read.h create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read_write.cc create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read_write.h create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/gpu_busy_read.cc create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/gpu_busy_read.h create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/overdrive_read.cc create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/overdrive_read.h create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/overdrive_read_write.cc create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/overdrive_read_write.h create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/pci_bw_read_write.cc create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/pci_bw_read_write.h create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read.cc create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read.h create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read_write.cc create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read_write.h create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/power_cap_read_write.cc create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/power_cap_read_write.h create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/power_read.cc create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/power_read.h create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/power_read_write.cc create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/power_read_write.h create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/temp_read.cc create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/temp_read.h create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/volt_freq_curv_read.cc create mode 100755 projects/amdsmi/tests/rocm_smi_test/functional/volt_freq_curv_read.h diff --git a/projects/amdsmi/include/rocm_smi/rocm_smi.h b/projects/amdsmi/include/rocm_smi/rocm_smi.h index a5686daf96..c5586e7628 100755 --- a/projects/amdsmi/include/rocm_smi/rocm_smi.h +++ b/projects/amdsmi/include/rocm_smi/rocm_smi.h @@ -49,6 +49,8 @@ extern "C" { #endif // __cplusplus +#include +#include /** \file rocm_smi.h * Main header file for the ROCm SMI library. @@ -196,8 +198,8 @@ typedef enum { //!< 3D Full Screen Power Profile RSMI_PWR_PROF_PRST_3D_FULL_SCR_MASK = 0x20, - - RSMI_PWR_PROF_PRST_LAST = RSMI_PWR_PROF_PRST_3D_FULL_SCR_MASK, + RSMI_PWR_PROF_PRST_BOOTUP_DEFAULT = 0x40, //!< Default Boot Up Profile + RSMI_PWR_PROF_PRST_LAST = RSMI_PWR_PROF_PRST_BOOTUP_DEFAULT, //!< Invalid power profile RSMI_PWR_PROF_PRST_INVALID = 0xFFFFFFFFFFFFFFFF diff --git a/projects/amdsmi/src/rocm_smi.cc b/projects/amdsmi/src/rocm_smi.cc index aa1a8f8e08..2c8f5dae58 100755 --- a/projects/amdsmi/src/rocm_smi.cc +++ b/projects/amdsmi/src/rocm_smi.cc @@ -238,15 +238,15 @@ static void od_value_pair_str_to_range(std::string in_line, rsmi_range *rg) { * Parse a string of the form " <|*>" */ static rsmi_power_profile_preset_masks -power_prof_string_to_int(std::string pow_prof_line, bool *is_curr) { +power_prof_string_to_int(std::string pow_prof_line, bool *is_curr, + uint32_t *prof_ind) { std::istringstream fs(pow_prof_line); - uint32_t ind; std::string mode; size_t tmp; rsmi_power_profile_preset_masks ret = RSMI_PWR_PROF_PRST_INVALID; - fs >> ind; + fs >> *prof_ind; fs >> mode; while (1) { @@ -266,6 +266,7 @@ power_prof_string_to_int(std::string pow_prof_line, bool *is_curr) { } const std::unordered_map> mode_map { + {"BOOTUP_DEFAULT", [&](){ ret = RSMI_PWR_PROF_PRST_BOOTUP_DEFAULT; }}, {"3D_FULL_SCREEN", [&](){ ret = RSMI_PWR_PROF_PRST_3D_FULL_SCR_MASK; }}, {"POWER_SAVING", [&](){ ret = RSMI_PWR_PROF_PRST_POWER_SAVING_MASK; }}, {"VIDEO", [&](){ ret = RSMI_PWR_PROF_PRST_VIDEO_MASK; }}, @@ -584,16 +585,17 @@ static rsmi_status_t get_power_profiles(uint32_t dv_ind, p->available_profiles = 0; rsmi_power_profile_preset_masks prof; + uint32_t prof_ind; for (uint32_t i = 1; i < val_vec.size(); ++i) { - prof = power_prof_string_to_int(val_vec[i], ¤t); + prof = power_prof_string_to_int(val_vec[i], ¤t, &prof_ind); if (prof == RSMI_PWR_PROF_PRST_INVALID) { - return RSMI_STATUS_NOT_SUPPORTED; + continue; } if (ind_map != nullptr) { - (*ind_map)[prof] = i-1; + (*ind_map)[prof] = prof_ind; } p->available_profiles |= prof; diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/bdfid_read.cc b/projects/amdsmi/tests/rocm_smi_test/functional/bdfid_read.cc new file mode 100755 index 0000000000..2e443f699e --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/bdfid_read.cc @@ -0,0 +1,104 @@ +/* + * ============================================================================= + * 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 , + * 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 +#include + +#include +#include + +#include "gtest/gtest.h" +#include "rocm_smi/rocm_smi.h" +#include "rocm_smi_test/functional/bdfid_read.h" +#include "rocm_smi_test/test_common.h" + +TestBDFIDRead::TestBDFIDRead() : TestBase() { + set_title("RSMI BDFID Read Test"); + set_description("The BDFID Read tests verifies that the BDFID " + "value can be read properly."); +} + +TestBDFIDRead::~TestBDFIDRead(void) { +} + +void TestBDFIDRead::SetUp(void) { + TestBase::SetUp(); + + return; +} + +void TestBDFIDRead::DisplayTestInfo(void) { + TestBase::DisplayTestInfo(); +} + +void TestBDFIDRead::DisplayResults(void) const { + TestBase::DisplayResults(); + return; +} + +void TestBDFIDRead::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 TestBDFIDRead::Run(void) { + rsmi_status_t err; + uint64_t val_ui64; + + TestBase::Run(); + + for (uint32_t i = 0; i < num_monitor_devs(); ++i) { + PrintDeviceHeader(i); + + err = rsmi_dev_pci_id_get(i, &val_ui64); + CHK_ERR_ASRT(err) + IF_VERB(STANDARD) { + std::cout << "\t**PCI ID (BDFID): 0x" << std::hex << val_ui64; + std::cout << " (" << std::dec << val_ui64 << ")" << std::endl; + } + } +} diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/bdfid_read.h b/projects/amdsmi/tests/rocm_smi_test/functional/bdfid_read.h new file mode 100755 index 0000000000..d22934ed75 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/bdfid_read.h @@ -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 , + * 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_BDFID_READ_H_ +#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_BDFID_READ_H_ + +#include "rocm_smi_test/test_base.h" + +class TestBDFIDRead : public TestBase { + public: + TestBDFIDRead(); + + // @Brief: Destructor for test case of TestBDFIDRead + virtual ~TestBDFIDRead(); + + // @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_BDFID_READ_H_ diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/fan_read.cc b/projects/amdsmi/tests/rocm_smi_test/functional/fan_read.cc new file mode 100755 index 0000000000..0e0d6ba35d --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/fan_read.cc @@ -0,0 +1,118 @@ +/* + * ============================================================================= + * 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 , + * 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 +#include + +#include + +#include "gtest/gtest.h" +#include "rocm_smi/rocm_smi.h" +#include "rocm_smi_test/functional/fan_read.h" +#include "rocm_smi_test/test_common.h" + +TestFanRead::TestFanRead() : TestBase() { + set_title("RSMI Fan Read Test"); + set_description("The Fan Read tests verifies that the fan monitors can be " + "read properly."); +} + +TestFanRead::~TestFanRead(void) { +} + +void TestFanRead::SetUp(void) { + TestBase::SetUp(); + + return; +} + +void TestFanRead::DisplayTestInfo(void) { + TestBase::DisplayTestInfo(); +} + +void TestFanRead::DisplayResults(void) const { + TestBase::DisplayResults(); + return; +} + +void TestFanRead::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 TestFanRead::Run(void) { + uint64_t val_ui64; + rsmi_status_t err; + int64_t val_i64; + + TestBase::Run(); + + for (uint32_t i = 0; i < num_monitor_devs(); ++i) { + PrintDeviceHeader(i); + + IF_VERB(STANDARD) { + std::cout << "\t**Current Fan Speed: "; + } + err = rsmi_dev_fan_speed_get(i, 0, &val_i64); + CHK_ERR_ASRT(err) + err = rsmi_dev_fan_speed_max_get(i, 0, &val_ui64); + CHK_ERR_ASRT(err) + IF_VERB(STANDARD) { + std::cout << val_i64/static_cast(val_ui64)*100; + std::cout << "% ("<< val_i64 << "/" << val_ui64 << ")" << std::endl; + } + + IF_VERB(STANDARD) { + std::cout << "\t**Current fan RPMs: "; + } + err = rsmi_dev_fan_rpms_get(i, 0, &val_i64); + CHK_ERR_ASRT(err) + IF_VERB(STANDARD) { + std::cout << val_i64 << std::endl; + } + } +} diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/fan_read.h b/projects/amdsmi/tests/rocm_smi_test/functional/fan_read.h new file mode 100755 index 0000000000..13f5886203 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/fan_read.h @@ -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 , + * 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_FAN_READ_H_ +#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_FAN_READ_H_ + +#include "rocm_smi_test/test_base.h" + +class TestFanRead : public TestBase { + public: + TestFanRead(); + + // @Brief: Destructor for test case of TestFanRead + virtual ~TestFanRead(); + + // @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_FAN_READ_H_ diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/fan_read_write.cc b/projects/amdsmi/tests/rocm_smi_test/functional/fan_read_write.cc new file mode 100755 index 0000000000..ca53f2945e --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/fan_read_write.cc @@ -0,0 +1,153 @@ +/* + * ============================================================================= + * 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 , + * 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 +#include + +#include + +#include "gtest/gtest.h" +#include "rocm_smi/rocm_smi.h" +#include "rocm_smi_test/functional/fan_read_write.h" +#include "rocm_smi_test/test_common.h" + +TestFanReadWrite::TestFanReadWrite() : TestBase() { + set_title("RSMI Fan Read/Write Test"); + set_description("The Fan Read tests verifies that the fan monitors can be " + "read and controlled properly."); +} + +TestFanReadWrite::~TestFanReadWrite(void) { +} + +void TestFanReadWrite::SetUp(void) { + TestBase::SetUp(); + + return; +} + +void TestFanReadWrite::DisplayTestInfo(void) { + TestBase::DisplayTestInfo(); +} + +void TestFanReadWrite::DisplayResults(void) const { + TestBase::DisplayResults(); + return; +} + +void TestFanReadWrite::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 TestFanReadWrite::Run(void) { + rsmi_status_t ret; + int64_t orig_speed; + int64_t new_speed; + int64_t cur_speed; + + TestBase::Run(); + + for (uint32_t dv_ind = 0; dv_ind < num_monitor_devs(); ++dv_ind) { + PrintDeviceHeader(dv_ind); + + ret = rsmi_dev_fan_speed_get(dv_ind, 0, &orig_speed); + CHK_ERR_ASRT(ret) + IF_VERB(STANDARD) { + std::cout << "Original fan speed: " << orig_speed << std::endl; + } + + if (orig_speed == 0) { + std::cout << "***System fan speed value is 0. Skip fan test." << + std::endl; + return; + } + + new_speed = 1.1 * orig_speed; + + IF_VERB(STANDARD) { + std::cout << "Setting fan speed to " << new_speed << std::endl; + } + + ret = rsmi_dev_fan_speed_set(dv_ind, 0, new_speed); + CHK_ERR_ASRT(ret) + + sleep(4); + + ret = rsmi_dev_fan_speed_get(dv_ind, 0, &cur_speed); + CHK_ERR_ASRT(ret) + + IF_VERB(STANDARD) { + std::cout << "New fan speed: " << cur_speed << std::endl; + } + + // EXPECT_TRUE((cur_speed > 0.95 * new_speed && + // cur_speed < 1.1 * new_speed) || + // cur_speed > 0.95 * RSMI_MAX_FAN_SPEED); + if (!((cur_speed > 0.95 * new_speed && cur_speed < 1.1 * new_speed) || + (cur_speed > 0.95 * RSMI_MAX_FAN_SPEED))) { + std::cout << "WARNING: Fan speed is not within the expected range!" << + std::endl; + } + + IF_VERB(STANDARD) { + std::cout << "Resetting fan control to auto..." << std::endl; + } + + ret = rsmi_dev_fan_reset(dv_ind, 0); + CHK_ERR_ASRT(ret) + + sleep(3); + + ret = rsmi_dev_fan_speed_get(dv_ind, 0, &cur_speed); + CHK_ERR_ASRT(ret) + + IF_VERB(STANDARD) { + std::cout << "End fan speed: " << cur_speed << std::endl; + } + } +} diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/fan_read_write.h b/projects/amdsmi/tests/rocm_smi_test/functional/fan_read_write.h new file mode 100755 index 0000000000..ef1b44abc9 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/fan_read_write.h @@ -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 , + * 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_FAN_READ_WRITE_H_ +#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_FAN_READ_WRITE_H_ + +#include "rocm_smi_test/test_base.h" + +class TestFanReadWrite : public TestBase { + public: + TestFanReadWrite(); + + // @Brief: Destructor for test case of TestFanReadWrite + virtual ~TestFanReadWrite(); + + // @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_FAN_READ_WRITE_H_ diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read.cc b/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read.cc new file mode 100755 index 0000000000..bcdc68f39c --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read.cc @@ -0,0 +1,142 @@ +/* + * ============================================================================= + * 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 , + * 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 +#include + +#include +#include + +#include "gtest/gtest.h" +#include "rocm_smi/rocm_smi.h" +#include "rocm_smi_test/functional/frequencies_read.h" +#include "rocm_smi_test/test_common.h" + +TestFrequenciesRead::TestFrequenciesRead() : TestBase() { + set_title("RSMI Frequencies Read Test"); + set_description("The Frequency Read tests verifies that the " + "available and current frequency levels can be read properly."); +} + +TestFrequenciesRead::~TestFrequenciesRead(void) { +} + +void TestFrequenciesRead::SetUp(void) { + TestBase::SetUp(); + + return; +} + +void TestFrequenciesRead::DisplayTestInfo(void) { + TestBase::DisplayTestInfo(); +} + +void TestFrequenciesRead::DisplayResults(void) const { + TestBase::DisplayResults(); + return; +} + +void TestFrequenciesRead::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(); +} + + +static void print_frequencies(rsmi_frequencies *f, uint32_t *l = nullptr) { + assert(f != nullptr); + for (uint32_t j = 0; j < f->num_supported; ++j) { + std::cout << "\t** " << j << ": " << f->frequency[j]; + if (l != nullptr) { + std::cout << "T/s; x" << l[j]; + } else { + std::cout << "Hz"; + } + + if (j == f->current) { + std::cout << " *"; + } + std::cout << std::endl; + } +} + +void TestFrequenciesRead::Run(void) { + rsmi_status_t err; + rsmi_frequencies f; + rsmi_pcie_bandwidth b; + + TestBase::Run(); + + for (uint32_t i = 0; i < num_monitor_devs(); ++i) { + PrintDeviceHeader(i); + + err = rsmi_dev_gpu_clk_freq_get(i, RSMI_CLK_TYPE_MEM, &f); + CHK_ERR_ASRT(err) + IF_VERB(STANDARD) { + std::cout << "\t**Supported GPU Memory clock frequencies: "; + std::cout << f.num_supported << std::endl; + print_frequencies(&f); + } + err = rsmi_dev_pci_bandwidth_get(i, &b); + if (err == RSMI_STATUS_NOT_YET_IMPLEMENTED) { + std::cout << "\t**Get PCIE Bandwidth: Not supported on this machine" + << std::endl; + } else { + CHK_ERR_ASRT(err) + IF_VERB(STANDARD) { + std::cout << "\t**Supported PCIe bandwidths: "; + std::cout << b.transfer_rate.num_supported << std::endl; + print_frequencies(&b.transfer_rate, b.lanes); + } + } + err = rsmi_dev_gpu_clk_freq_get(i, RSMI_CLK_TYPE_SYS, &f); + CHK_ERR_ASRT(err) + IF_VERB(STANDARD) { + std::cout << "\t**Supported GPU clock frequencies: "; + std::cout << f.num_supported << std::endl; + print_frequencies(&f); + } + } +} diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read.h b/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read.h new file mode 100755 index 0000000000..ff39a8aa2d --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read.h @@ -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 , + * 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_FREQUENCIES_READ_H_ +#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_FREQUENCIES_READ_H_ + +#include "rocm_smi_test/test_base.h" + +class TestFrequenciesRead : public TestBase { + public: + TestFrequenciesRead(); + + // @Brief: Destructor for test case of TestFrequenciesRead + virtual ~TestFrequenciesRead(); + + // @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_FREQUENCIES_READ_H_ diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read_write.cc b/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read_write.cc new file mode 100755 index 0000000000..c52357aa27 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read_write.cc @@ -0,0 +1,145 @@ +/* + * ============================================================================= + * 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 , + * 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 +#include + +#include +#include +#include +#include +#include + +#include "gtest/gtest.h" +#include "rocm_smi/rocm_smi.h" +#include "rocm_smi_test/functional/frequencies_read_write.h" +#include "rocm_smi_test/test_common.h" + + +TestFrequenciesReadWrite::TestFrequenciesReadWrite() : TestBase() { + set_title("RSMI Frequencies Read/Write Test"); + set_description("The Frequencies tests verify that the frequency " + "settings can be read and controlled properly."); +} + +TestFrequenciesReadWrite::~TestFrequenciesReadWrite(void) { +} + +void TestFrequenciesReadWrite::SetUp(void) { + TestBase::SetUp(); + + return; +} + +void TestFrequenciesReadWrite::DisplayTestInfo(void) { + TestBase::DisplayTestInfo(); +} + +void TestFrequenciesReadWrite::DisplayResults(void) const { + TestBase::DisplayResults(); + return; +} + +void TestFrequenciesReadWrite::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 TestFrequenciesReadWrite::Run(void) { + rsmi_status_t ret; + rsmi_frequencies f; + uint32_t freq_bitmask; + rsmi_clk_type rsmi_clk; + + TestBase::Run(); + + for (uint32_t dv_ind = 0; dv_ind < num_monitor_devs(); ++dv_ind) { + PrintDeviceHeader(dv_ind); + + for (uint32_t clk = (uint32_t)RSMI_CLK_TYPE_FIRST; + clk <= RSMI_CLK_TYPE_LAST; ++clk) { + rsmi_clk = (rsmi_clk_type)clk; + + ret = rsmi_dev_gpu_clk_freq_get(dv_ind, rsmi_clk, &f); + CHK_ERR_ASRT(ret) + + IF_VERB(STANDARD) { + std::cout << "Initial frequency for clock " << rsmi_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(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 " << rsmi_clk << + " to 0b" << freq_bm_str << " ..." << std::endl; + } + ret = rsmi_dev_gpu_clk_freq_set(dv_ind, rsmi_clk, freq_bitmask); + CHK_ERR_ASRT(ret) + + ret = rsmi_dev_gpu_clk_freq_get(dv_ind, rsmi_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 = rsmi_dev_gpu_clk_freq_set(dv_ind, rsmi_clk, 0xFFFFFFFF); + CHK_ERR_ASRT(ret) + + ret = rsmi_dev_perf_level_set(dv_ind, RSMI_DEV_PERF_LEVEL_AUTO); + CHK_ERR_ASRT(ret) + } + } +} diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read_write.h b/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read_write.h new file mode 100755 index 0000000000..feca897463 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read_write.h @@ -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 , + * 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_FREQUENCIES_READ_WRITE_H_ +#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_FREQUENCIES_READ_WRITE_H_ + +#include "rocm_smi_test/test_base.h" + +class TestFrequenciesReadWrite : public TestBase { + public: + TestFrequenciesReadWrite(); + + // @Brief: Destructor for test case of TestFrequenciesReadWrite + virtual ~TestFrequenciesReadWrite(); + + // @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_FREQUENCIES_READ_WRITE_H_ diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/gpu_busy_read.cc b/projects/amdsmi/tests/rocm_smi_test/functional/gpu_busy_read.cc new file mode 100755 index 0000000000..6055041455 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/gpu_busy_read.cc @@ -0,0 +1,114 @@ +/* + * ============================================================================= + * 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 , + * 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 +#include + +#include +#include + +#include "gtest/gtest.h" +#include "rocm_smi/rocm_smi.h" +#include "rocm_smi_test/functional/gpu_busy_read.h" +#include "rocm_smi_test/test_common.h" + +TestGPUBusyRead::TestGPUBusyRead() : TestBase() { + set_title("RSMI GPU Busy Read Test"); + set_description("The GPU Busy Read tests verifies that the gpu busy " + "percentage can be read properly."); +} + +TestGPUBusyRead::~TestGPUBusyRead(void) { +} + +void TestGPUBusyRead::SetUp(void) { + TestBase::SetUp(); + + return; +} + +void TestGPUBusyRead::DisplayTestInfo(void) { + TestBase::DisplayTestInfo(); +} + +void TestGPUBusyRead::DisplayResults(void) const { + TestBase::DisplayResults(); + return; +} + +void TestGPUBusyRead::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 TestGPUBusyRead::Run(void) { + rsmi_status_t err; + uint32_t val_ui32; + + TestBase::Run(); + + for (uint32_t i = 0; i < num_monitor_devs(); ++i) { + PrintDeviceHeader(i); + + err = rsmi_dev_busy_percent_get(i, &val_ui32); + if (err != RSMI_STATUS_SUCCESS) { + if (err == RSMI_STATUS_FILE_ERROR) { + IF_VERB(STANDARD) { + std::cout << "\t**GPU Busy Percent: Not supported on this machine" + << std::endl; + } + } else { + CHK_ERR_ASRT(err) + } + } else { + IF_VERB(STANDARD) { + std::cout << "\t**GPU Busy Percent (Percent Idle):" << std::dec << + val_ui32 << " (" << 100 - val_ui32 << ")" << std::endl; + } + } + } +} diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/gpu_busy_read.h b/projects/amdsmi/tests/rocm_smi_test/functional/gpu_busy_read.h new file mode 100755 index 0000000000..c341d0ebc5 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/gpu_busy_read.h @@ -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 , + * 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_GPU_BUSY_READ_H_ +#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_GPU_BUSY_READ_H_ + +#include "rocm_smi_test/test_base.h" + +class TestGPUBusyRead : public TestBase { + public: + TestGPUBusyRead(); + + // @Brief: Destructor for test case of TestGPUBusyRead + virtual ~TestGPUBusyRead(); + + // @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_GPU_BUSY_READ_H_ diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/overdrive_read.cc b/projects/amdsmi/tests/rocm_smi_test/functional/overdrive_read.cc new file mode 100755 index 0000000000..cd4bfc9c8d --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/overdrive_read.cc @@ -0,0 +1,103 @@ +/* + * ============================================================================= + * 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 , + * 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 +#include + +#include +#include + +#include "gtest/gtest.h" +#include "rocm_smi/rocm_smi.h" +#include "rocm_smi_test/functional/overdrive_read.h" +#include "rocm_smi_test/test_common.h" + +TestOverdriveRead::TestOverdriveRead() : TestBase() { + set_title("RSMI Overdrive Read Test"); + set_description("The Overdrive Read tests verifies that the " + "current overdrive level can be read properly."); +} + +TestOverdriveRead::~TestOverdriveRead(void) { +} + +void TestOverdriveRead::SetUp(void) { + TestBase::SetUp(); + + return; +} + +void TestOverdriveRead::DisplayTestInfo(void) { + TestBase::DisplayTestInfo(); +} + +void TestOverdriveRead::DisplayResults(void) const { + TestBase::DisplayResults(); + return; +} + +void TestOverdriveRead::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 TestOverdriveRead::Run(void) { + rsmi_status_t err; + uint32_t val_ui32; + + TestBase::Run(); + + for (uint32_t i = 0; i < num_monitor_devs(); ++i) { + PrintDeviceHeader(i); + + err = rsmi_dev_overdrive_level_get(i, &val_ui32); + CHK_ERR_ASRT(err) + IF_VERB(STANDARD) { + std::cout << "\t**OverDrive Level:" << val_ui32 << std::endl; + } + } +} diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/overdrive_read.h b/projects/amdsmi/tests/rocm_smi_test/functional/overdrive_read.h new file mode 100755 index 0000000000..a9e02826a8 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/overdrive_read.h @@ -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 , + * 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_OVERDRIVE_READ_H_ +#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_OVERDRIVE_READ_H_ + +#include "rocm_smi_test/test_base.h" + +class TestOverdriveRead : public TestBase { + public: + TestOverdriveRead(); + + // @Brief: Destructor for test case of TestOverdriveRead + virtual ~TestOverdriveRead(); + + // @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_OVERDRIVE_READ_H_ diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/overdrive_read_write.cc b/projects/amdsmi/tests/rocm_smi_test/functional/overdrive_read_write.cc new file mode 100755 index 0000000000..44a467ccec --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/overdrive_read_write.cc @@ -0,0 +1,120 @@ +/* + * ============================================================================= + * 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 , + * 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 +#include + +#include + +#include "gtest/gtest.h" +#include "rocm_smi/rocm_smi.h" +#include "rocm_smi_test/functional/overdrive_read_write.h" +#include "rocm_smi_test/test_common.h" + +TestOverdriveReadWrite::TestOverdriveReadWrite() : TestBase() { + set_title("RSMI Overdrive Read/Write Test"); + set_description("The Fan Read tests verifies that the overdrive settings " + "can be read and controlled properly."); +} + +TestOverdriveReadWrite::~TestOverdriveReadWrite(void) { +} + +void TestOverdriveReadWrite::SetUp(void) { + TestBase::SetUp(); + + return; +} + +void TestOverdriveReadWrite::DisplayTestInfo(void) { + TestBase::DisplayTestInfo(); +} + +void TestOverdriveReadWrite::DisplayResults(void) const { + TestBase::DisplayResults(); + return; +} + +void TestOverdriveReadWrite::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 TestOverdriveReadWrite::Run(void) { + rsmi_status_t ret; + uint32_t val; + + TestBase::Run(); + + for (uint32_t dv_ind = 0; dv_ind < num_monitor_devs(); ++dv_ind) { + PrintDeviceHeader(dv_ind); + + IF_VERB(STANDARD) { + std::cout << "Set Overdrive level to 0%..." << std::endl; + } + ret = rsmi_dev_overdrive_level_set(dv_ind, 0); + CHK_ERR_ASRT(ret) + IF_VERB(STANDARD) { + std::cout << "Set Overdrive level to 10%..." << std::endl; + } + ret = rsmi_dev_overdrive_level_set(dv_ind, 10); + CHK_ERR_ASRT(ret) + ret = rsmi_dev_overdrive_level_get(dv_ind, &val); + CHK_ERR_ASRT(ret) + IF_VERB(STANDARD) { + std::cout << "\t**New OverDrive Level:" << val << std::endl; + std::cout << "Reset Overdrive level to 0%..." << std::endl; + } + ret = rsmi_dev_overdrive_level_set(dv_ind, 0); + CHK_ERR_ASRT(ret) + ret = rsmi_dev_overdrive_level_get(dv_ind, &val); + CHK_ERR_ASRT(ret) + IF_VERB(STANDARD) { + std::cout << "\t**New OverDrive Level:" << val << std::endl; + } + } +} diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/overdrive_read_write.h b/projects/amdsmi/tests/rocm_smi_test/functional/overdrive_read_write.h new file mode 100755 index 0000000000..8530f93203 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/overdrive_read_write.h @@ -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 , + * 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_OVERDRIVE_READ_WRITE_H_ +#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_OVERDRIVE_READ_WRITE_H_ + +#include "rocm_smi_test/test_base.h" + +class TestOverdriveReadWrite : public TestBase { + public: + TestOverdriveReadWrite(); + + // @Brief: Destructor for test case of TestOverdriveReadWrite + virtual ~TestOverdriveReadWrite(); + + // @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_OVERDRIVE_READ_WRITE_H_ diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/pci_bw_read_write.cc b/projects/amdsmi/tests/rocm_smi_test/functional/pci_bw_read_write.cc new file mode 100755 index 0000000000..e80a2f31cc --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/pci_bw_read_write.cc @@ -0,0 +1,141 @@ +/* + * ============================================================================= + * 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 , + * 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 +#include + +#include +#include +#include +#include + +#include "gtest/gtest.h" +#include "rocm_smi/rocm_smi.h" +#include "rocm_smi_test/functional/pci_bw_read_write.h" +#include "rocm_smi_test/test_common.h" + + +TestPciBWReadWrite::TestPciBWReadWrite() : TestBase() { + set_title("RSMI PCIe Bandwidth Read/Write Test"); + set_description("The PCIe Bandwidth tests verify that the PCIe bandwidth " + "settings can be read and controlled properly."); +} + +TestPciBWReadWrite::~TestPciBWReadWrite(void) { +} + +void TestPciBWReadWrite::SetUp(void) { + TestBase::SetUp(); + + return; +} + +void TestPciBWReadWrite::DisplayTestInfo(void) { + TestBase::DisplayTestInfo(); +} + +void TestPciBWReadWrite::DisplayResults(void) const { + TestBase::DisplayResults(); + return; +} + +void TestPciBWReadWrite::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 TestPciBWReadWrite::Run(void) { + rsmi_status_t ret; + rsmi_pcie_bandwidth bw; + uint32_t freq_bitmask; + + TestBase::Run(); + + for (uint32_t dv_ind = 0; dv_ind < num_monitor_devs(); ++dv_ind) { + PrintDeviceHeader(dv_ind); + + ret = rsmi_dev_pci_bandwidth_get(dv_ind, &bw); + CHK_ERR_ASRT(ret) + + IF_VERB(STANDARD) { + std::cout << "Initial PCIe is " << bw.transfer_rate.current << std::endl; + } + + // First set the bitmask to all supported bandwidths + freq_bitmask = ~(~0 << bw.transfer_rate.num_supported); + + // Then, set the bitmask to all bandwidths besides the initial BW + freq_bitmask ^= (1 << bw.transfer_rate.current); + + std::string freq_bm_str = + std::bitset(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 bandwidth mask to " << "0b" << freq_bm_str << + " ..." << std::endl; + } + ret = rsmi_dev_pci_bandwidth_set(dv_ind, freq_bitmask); + CHK_ERR_ASRT(ret) + + ret = rsmi_dev_pci_bandwidth_get(dv_ind, &bw); + CHK_ERR_ASRT(ret) + + IF_VERB(STANDARD) { + std::cout << "Bandwidth is now index " << bw.transfer_rate.current << + std::endl; + std::cout << "Resetting mask to all bandwidths." << std::endl; + } + ret = rsmi_dev_pci_bandwidth_set(dv_ind, 0xFFFFFFFF); + CHK_ERR_ASRT(ret) + + ret = rsmi_dev_perf_level_set(dv_ind, RSMI_DEV_PERF_LEVEL_AUTO); + CHK_ERR_ASRT(ret) + } +} diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/pci_bw_read_write.h b/projects/amdsmi/tests/rocm_smi_test/functional/pci_bw_read_write.h new file mode 100755 index 0000000000..0cd7cb2f53 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/pci_bw_read_write.h @@ -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 , + * 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_PCI_BW_READ_WRITE_H_ +#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_PCI_BW_READ_WRITE_H_ + +#include "rocm_smi_test/test_base.h" + +class TestPciBWReadWrite : public TestBase { + public: + TestPciBWReadWrite(); + + // @Brief: Destructor for test case of TestPciBWReadWrite + virtual ~TestPciBWReadWrite(); + + // @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_PCI_BW_READ_WRITE_H_ diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read.cc b/projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read.cc new file mode 100755 index 0000000000..303bdd1592 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read.cc @@ -0,0 +1,104 @@ +/* + * ============================================================================= + * 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 , + * 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 +#include + +#include +#include + +#include "gtest/gtest.h" +#include "rocm_smi/rocm_smi.h" +#include "rocm_smi_test/functional/perf_level_read.h" +#include "rocm_smi_test/test_common.h" + +TestPerfLevelRead::TestPerfLevelRead() : TestBase() { + set_title("RSMI Performance Level Read Test"); + set_description("The Performance Level Read tests verifies that the " + "performance level monitors can be read properly."); +} + +TestPerfLevelRead::~TestPerfLevelRead(void) { +} + +void TestPerfLevelRead::SetUp(void) { + TestBase::SetUp(); + + return; +} + +void TestPerfLevelRead::DisplayTestInfo(void) { + TestBase::DisplayTestInfo(); +} + +void TestPerfLevelRead::DisplayResults(void) const { + TestBase::DisplayResults(); + return; +} + +void TestPerfLevelRead::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 TestPerfLevelRead::Run(void) { + rsmi_status_t err; + rsmi_dev_perf_level pfl; + + TestBase::Run(); + + for (uint32_t i = 0; i < num_monitor_devs(); ++i) { + PrintDeviceHeader(i); + + err = rsmi_dev_perf_level_get(i, &pfl); + CHK_ERR_ASRT(err) + IF_VERB(STANDARD) { + std::cout << "\t**Performance Level:" << std::dec << (uint32_t)pfl << + std::endl; + } + } +} diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read.h b/projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read.h new file mode 100755 index 0000000000..78c11dcc40 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read.h @@ -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 , + * 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_PERF_LEVEL_READ_H_ +#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_PERF_LEVEL_READ_H_ + +#include "rocm_smi_test/test_base.h" + +class TestPerfLevelRead : public TestBase { + public: + TestPerfLevelRead(); + + // @Brief: Destructor for test case of TestPerfLevelRead + virtual ~TestPerfLevelRead(); + + // @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_PERF_LEVEL_READ_H_ diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read_write.cc b/projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read_write.cc new file mode 100755 index 0000000000..8d3ca30016 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read_write.cc @@ -0,0 +1,153 @@ +/* + * ============================================================================= + * 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 , + * 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 +#include + +#include +#include + +#include "gtest/gtest.h" +#include "rocm_smi/rocm_smi.h" +#include "rocm_smi_test/functional/perf_level_read_write.h" +#include "rocm_smi_test/test_common.h" + +static const std::map 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"); + set_description("The Performance Level tests verify that the performance " + "level settings can be read and controlled properly."); +} + +TestPerfLevelReadWrite::~TestPerfLevelReadWrite(void) { +} + +void TestPerfLevelReadWrite::SetUp(void) { + TestBase::SetUp(); + + return; +} + +void TestPerfLevelReadWrite::DisplayTestInfo(void) { + TestBase::DisplayTestInfo(); +} + +void TestPerfLevelReadWrite::DisplayResults(void) const { + TestBase::DisplayResults(); + return; +} + +void TestPerfLevelReadWrite::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 TestPerfLevelReadWrite::Run(void) { + rsmi_status_t ret; + rsmi_dev_perf_level pfl, orig_pfl; + + TestBase::Run(); + + for (uint32_t dv_ind = 0; dv_ind < num_monitor_devs(); ++dv_ind) { + PrintDeviceHeader(dv_ind); + + ret = rsmi_dev_perf_level_get(dv_ind, &orig_pfl); + CHK_ERR_ASRT(ret) + + IF_VERB(STANDARD) { + std::cout << "\t**Original Perf Level:" << + kDevPerfLvlNameMap.at(orig_pfl) << std::endl; + } + + uint32_t pfl_i = static_cast(RSMI_DEV_PERF_LEVEL_FIRST); + for (; pfl_i <= static_cast(RSMI_DEV_PERF_LEVEL_LAST); pfl_i++) { + if (pfl_i == static_cast(orig_pfl)) { + continue; + } + + IF_VERB(STANDARD) { + std::cout << "Set Performance Level to " << + kDevPerfLvlNameMap.at(static_cast(pfl_i)) << + " ..." << std::endl; + } + ret = rsmi_dev_perf_level_set(dv_ind, + static_cast(pfl_i)); + CHK_ERR_ASRT(ret) + 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 << "Reset Perf level to " << kDevPerfLvlNameMap.at(orig_pfl) << + " ..." << std::endl; + ret = rsmi_dev_perf_level_set(dv_ind, orig_pfl); + CHK_ERR_ASRT(ret) + 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; + } + } +} diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read_write.h b/projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read_write.h new file mode 100755 index 0000000000..7d082fa9f1 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read_write.h @@ -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 , + * 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_PERF_LEVEL_READ_WRITE_H_ +#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_PERF_LEVEL_READ_WRITE_H_ + +#include "rocm_smi_test/test_base.h" + +class TestPerfLevelReadWrite : public TestBase { + public: + TestPerfLevelReadWrite(); + + // @Brief: Destructor for test case of TestPerfLevelReadWrite + virtual ~TestPerfLevelReadWrite(); + + // @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_PERF_LEVEL_READ_WRITE_H_ diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/power_cap_read_write.cc b/projects/amdsmi/tests/rocm_smi_test/functional/power_cap_read_write.cc new file mode 100755 index 0000000000..aef8337631 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/power_cap_read_write.cc @@ -0,0 +1,136 @@ +/* + * ============================================================================= + * 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 , + * 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 +#include + +#include +#include +#include +#include + +#include "gtest/gtest.h" +#include "rocm_smi/rocm_smi.h" +#include "rocm_smi_test/functional/power_cap_read_write.h" +#include "rocm_smi_test/test_common.h" + + +TestPowerCapReadWrite::TestPowerCapReadWrite() : TestBase() { + set_title("RSMI Power Cap Read/Write Test"); + set_description("The Power Cap tests verify that the power profile " + "settings can be read and written properly."); +} + +TestPowerCapReadWrite::~TestPowerCapReadWrite(void) { +} + +void TestPowerCapReadWrite::SetUp(void) { + TestBase::SetUp(); + + return; +} + +void TestPowerCapReadWrite::DisplayTestInfo(void) { + TestBase::DisplayTestInfo(); +} + +void TestPowerCapReadWrite::DisplayResults(void) const { + TestBase::DisplayResults(); + return; +} + +void TestPowerCapReadWrite::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 TestPowerCapReadWrite::Run(void) { + rsmi_status_t ret; + uint64_t orig, min, max, new_cap; + + TestBase::Run(); + + for (uint32_t dv_ind = 0; dv_ind < num_monitor_devs(); ++dv_ind) { + PrintDeviceHeader(dv_ind); + + ret = rsmi_dev_power_cap_range_get(dv_ind, 0, &max, &min); + CHK_ERR_ASRT(ret) + + ret = rsmi_dev_power_cap_get(dv_ind, 0, &orig); + CHK_ERR_ASRT(ret) + + new_cap = (max + min)/2; + + IF_VERB(STANDARD) { + std::cout << "Original Power Cap: " << orig << " uW" << std::endl; + std::cout << "Power Cap Range: " << max << " uW to " << min << + " uW" << std::endl; + std::cout << "Setting new cap to " << new_cap << "..." << std::endl; + } + ret = rsmi_dev_power_cap_set(dv_ind, 0, new_cap); + CHK_ERR_ASRT(ret) + + ret = rsmi_dev_power_cap_get(dv_ind, 0, &new_cap); + CHK_ERR_ASRT(ret) + + // TODO(cfreehil) add some kind of assertion to verify new_cap is correct + // (or within a range) + IF_VERB(STANDARD) { + std::cout << "New Power Cap: " << new_cap << " uW" << std::endl; + std::cout << "Resetting cap to " << orig << "..." << std::endl; + } + + ret = rsmi_dev_power_cap_set(dv_ind, 0, orig); + CHK_ERR_ASRT(ret) + + ret = rsmi_dev_power_cap_get(dv_ind, 0, &new_cap); + CHK_ERR_ASRT(ret) + + IF_VERB(STANDARD) { + std::cout << "Current Power Cap: " << new_cap << " uW" << std::endl; + } + } +} diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/power_cap_read_write.h b/projects/amdsmi/tests/rocm_smi_test/functional/power_cap_read_write.h new file mode 100755 index 0000000000..1a8e02ccbf --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/power_cap_read_write.h @@ -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 , + * 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_POWER_CAP_READ_WRITE_H_ +#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_POWER_CAP_READ_WRITE_H_ + +#include "rocm_smi_test/test_base.h" + +class TestPowerCapReadWrite : public TestBase { + public: + TestPowerCapReadWrite(); + + // @Brief: Destructor for test case of TestPowerCapReadWrite + virtual ~TestPowerCapReadWrite(); + + // @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_POWER_CAP_READ_WRITE_H_ diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/power_read.cc b/projects/amdsmi/tests/rocm_smi_test/functional/power_read.cc new file mode 100755 index 0000000000..f3396caf39 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/power_read.cc @@ -0,0 +1,118 @@ +/* + * ============================================================================= + * 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 , + * 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 +#include + +#include +#include + +#include "gtest/gtest.h" +#include "rocm_smi/rocm_smi.h" +#include "rocm_smi_test/functional/power_read.h" +#include "rocm_smi_test/test_common.h" + +TestPowerRead::TestPowerRead() : TestBase() { + set_title("RSMI Power Read Test"); + set_description("The Power Read tests verifies that " + "power related values can be read properly."); +} + +TestPowerRead::~TestPowerRead(void) { +} + +void TestPowerRead::SetUp(void) { + TestBase::SetUp(); + + return; +} + +void TestPowerRead::DisplayTestInfo(void) { + TestBase::DisplayTestInfo(); +} + +void TestPowerRead::DisplayResults(void) const { + TestBase::DisplayResults(); + return; +} + +void TestPowerRead::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 TestPowerRead::Run(void) { + rsmi_status_t err; + uint64_t val_ui64, val2_ui64; + + TestBase::Run(); + + for (uint32_t i = 0; i < num_monitor_devs(); ++i) { + PrintDeviceHeader(i); + + err = rsmi_dev_power_cap_get(i, 0, &val_ui64); + CHK_ERR_ASRT(err) + IF_VERB(STANDARD) { + std::cout << "\t**Current Power Cap: " << val_ui64 << "uW" <(val_ui64)/1000 << " W" << std::endl; + } + } + } +} diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/power_read.h b/projects/amdsmi/tests/rocm_smi_test/functional/power_read.h new file mode 100755 index 0000000000..f9d5b83e33 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/power_read.h @@ -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 , + * 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_POWER_READ_H_ +#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_POWER_READ_H_ + +#include "rocm_smi_test/test_base.h" + +class TestPowerRead : public TestBase { + public: + TestPowerRead(); + + // @Brief: Destructor for test case of TestPowerRead + virtual ~TestPowerRead(); + + // @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_POWER_READ_H_ diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/power_read_write.cc b/projects/amdsmi/tests/rocm_smi_test/functional/power_read_write.cc new file mode 100755 index 0000000000..cf29e8f069 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/power_read_write.cc @@ -0,0 +1,187 @@ +/* + * ============================================================================= + * 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 , + * 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 +#include + +#include +#include +#include +#include + +#include "gtest/gtest.h" +#include "rocm_smi/rocm_smi.h" +#include "rocm_smi_test/functional/power_read_write.h" +#include "rocm_smi_test/test_common.h" + + +TestPowerReadWrite::TestPowerReadWrite() : TestBase() { + set_title("RSMI Power Profiles Read/Write Test"); + set_description("The Power Profiles tests verify that the power profile " + "settings can be read and controlled properly."); +} + +TestPowerReadWrite::~TestPowerReadWrite(void) { +} + +void TestPowerReadWrite::SetUp(void) { + TestBase::SetUp(); + + return; +} + +void TestPowerReadWrite::DisplayTestInfo(void) { + TestBase::DisplayTestInfo(); +} + +void TestPowerReadWrite::DisplayResults(void) const { + TestBase::DisplayResults(); + return; +} + +void TestPowerReadWrite::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(); +} + +static const char * +power_profile_string(rsmi_power_profile_preset_masks profile) { + switch (profile) { + case RSMI_PWR_PROF_PRST_CUSTOM_MASK: + return "CUSTOM"; + case RSMI_PWR_PROF_PRST_VIDEO_MASK: + return "VIDEO"; + case RSMI_PWR_PROF_PRST_POWER_SAVING_MASK: + return "POWER SAVING"; + case RSMI_PWR_PROF_PRST_COMPUTE_MASK: + return "COMPUTE"; + case RSMI_PWR_PROF_PRST_VR_MASK: + return "VR"; + case RSMI_PWR_PROF_PRST_3D_FULL_SCR_MASK: + return "3D FULL SCREEN"; + case RSMI_PWR_PROF_PRST_BOOTUP_DEFAULT: + return "BOOTUP DEFAULT"; + default: + return "UNKNOWN"; + } +} + +void TestPowerReadWrite::Run(void) { + rsmi_status_t ret; + rsmi_power_profile_status status; + + TestBase::Run(); + + for (uint32_t dv_ind = 0; dv_ind < num_monitor_devs(); ++dv_ind) { + PrintDeviceHeader(dv_ind); + + ret = rsmi_dev_power_profile_presets_get(dv_ind, 0, &status); + CHK_ERR_ASRT(ret) + + IF_VERB(STANDARD) { + std::cout << "The available power profiles are:" << std::endl; + uint64_t tmp = 1; + while (tmp <= RSMI_PWR_PROF_PRST_LAST) { + if ((tmp & status.available_profiles) == tmp) { + std::cout << "\t" << + power_profile_string((rsmi_power_profile_preset_masks)tmp) << + std::endl; + } + tmp = tmp << 1; + } + std::cout << "The current power profile is: " << + power_profile_string(status.current) << std::endl; + } + + rsmi_power_profile_preset_masks orig_profile = status.current; + + // Try setting the profile to a different power profile + rsmi_bit_field diff_profiles; + rsmi_power_profile_preset_masks new_prof; + diff_profiles = status.available_profiles & (~status.current); + + if (diff_profiles & RSMI_PWR_PROF_PRST_COMPUTE_MASK) { + new_prof = RSMI_PWR_PROF_PRST_COMPUTE_MASK; + } else if (diff_profiles & RSMI_PWR_PROF_PRST_VIDEO_MASK) { + new_prof = RSMI_PWR_PROF_PRST_VIDEO_MASK; + } else if (diff_profiles & RSMI_PWR_PROF_PRST_VR_MASK) { + new_prof = RSMI_PWR_PROF_PRST_VR_MASK; + } else if (diff_profiles & RSMI_PWR_PROF_PRST_POWER_SAVING_MASK) { + new_prof = RSMI_PWR_PROF_PRST_POWER_SAVING_MASK; + } else if (diff_profiles & RSMI_PWR_PROF_PRST_3D_FULL_SCR_MASK) { + new_prof = RSMI_PWR_PROF_PRST_3D_FULL_SCR_MASK; + } else { + std::cout << + "No other non-custom power profiles to set to. Exiting." << std::endl; + return; + } + + ret = rsmi_dev_power_profile_set(dv_ind, 0, new_prof); + CHK_ERR_ASRT(ret) + + rsmi_dev_perf_level pfl; + ret = rsmi_dev_perf_level_get(dv_ind, &pfl); + CHK_ERR_ASRT(ret) + ASSERT_EQ(pfl, RSMI_DEV_PERF_LEVEL_MANUAL); + + ret = rsmi_dev_power_profile_presets_get(dv_ind, 0, &status); + CHK_ERR_ASRT(ret) + + ASSERT_EQ(status.current, new_prof); + + ret = rsmi_dev_perf_level_set(dv_ind, RSMI_DEV_PERF_LEVEL_AUTO); + CHK_ERR_ASRT(ret) + + ret = rsmi_dev_perf_level_get(dv_ind, &pfl); + CHK_ERR_ASRT(ret) + ASSERT_EQ(pfl, RSMI_DEV_PERF_LEVEL_AUTO); + + ret = rsmi_dev_power_profile_presets_get(dv_ind, 0, &status); + CHK_ERR_ASRT(ret) + + ASSERT_EQ(status.current, orig_profile); + } +} diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/power_read_write.h b/projects/amdsmi/tests/rocm_smi_test/functional/power_read_write.h new file mode 100755 index 0000000000..55dc13b035 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/power_read_write.h @@ -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 , + * 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_POWER_READ_WRITE_H_ +#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_POWER_READ_WRITE_H_ + +#include "rocm_smi_test/test_base.h" + +class TestPowerReadWrite : public TestBase { + public: + TestPowerReadWrite(); + + // @Brief: Destructor for test case of TestPowerReadWrite + virtual ~TestPowerReadWrite(); + + // @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_POWER_READ_WRITE_H_ diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/rsmi_sanity.cc b/projects/amdsmi/tests/rocm_smi_test/functional/rsmi_sanity.cc index d5539b8b59..0f4683018f 100755 --- a/projects/amdsmi/tests/rocm_smi_test/functional/rsmi_sanity.cc +++ b/projects/amdsmi/tests/rocm_smi_test/functional/rsmi_sanity.cc @@ -55,69 +55,8 @@ #include "gtest/gtest.h" static const uint32_t kNumBufferElements = 256; -static uint32_t gVerbosity = 3; -static bool gDontFail = false; -#define DISPLAY_RSMI_ERR(RET) { \ - if (RET != RSMI_STATUS_SUCCESS) { \ - const char *err_str; \ - std::cout << "RSMI call returned " << (RET); \ - rsmi_status_string((RET), &err_str); \ - std::cout << " (" << err_str << ")" << std::endl; \ - std::cout << " at " << __FILE__ << ":" << std::dec << __LINE__ << \ - std::endl; \ - } \ -} - -#define CHK_ERR_RET(RET) { \ - DISPLAY_RSMI_ERR(RET) \ - if ((RET) != RSMI_STATUS_SUCCESS) { \ - return (RET); \ - } \ -} - -#define CHK_ERR_ASRT(RET) { \ - DISPLAY_RSMI_ERR(RET) \ - if (gDontFail && ((RET) != RSMI_STATUS_SUCCESS)) { \ - std::cout << "========> TEST FAILURE."; \ - DISPLAY_RSMI_ERR(RET); \ - std::cout << \ - "Abort is over-ridden due to dont_fail command line option." \ - << std::endl; \ - } else { \ - ASSERT_EQ(RSMI_STATUS_SUCCESS, (RET)); \ - } \ -} - -#define CHK_RSMI_PERM_ERR(RET) { \ - if (RET == RSMI_STATUS_PERMISSION) { \ - std::cout << "This command requires root access." << std::endl; \ - } else { \ - DISPLAY_RSMI_ERR(RET) \ - } \ -} - -#define ALT_ASSERT_EQ(A, B) { \ - if ((A) != (B)) { \ - std::cout << "ASSERT failure: Expected " << #A << " == " << #B << \ - ", but got " << #A << " = " << (A) << ", and " << #B << " = " << \ - (B) << std::endl; \ - std::cout << " at " << __FILE__ << ":" << std::dec << \ - __LINE__ << std::endl; \ - return RSMI_STATUS_UNKNOWN_ERROR; \ - } \ -} - -#define IF_VERB(VB) if (gVerbosity && gVerbosity >= (TestBase::VERBOSE_##VB)) - -static void print_test_header(const char *str, uint32_t dv_ind) { - IF_VERB(STANDARD) { - std::cout << "********************************" << std::endl; - std::cout << "*** " << str << std::endl; - std::cout << "********************************" << std::endl; - std::cout << "Device index: " << dv_ind << std::endl; - } -} +#if 0 // reorg test 1 static const char * power_profile_string(rsmi_power_profile_preset_masks profile) { @@ -138,79 +77,6 @@ power_profile_string(rsmi_power_profile_preset_masks profile) { return "UNKNOWN"; } } -static rsmi_status_t test_power_profile(uint32_t dv_ind) { - rsmi_status_t ret; - rsmi_power_profile_status status; - - print_test_header("Power Profile", dv_ind); - - ret = rsmi_dev_power_profile_presets_get(dv_ind, 0, &status); - CHK_ERR_RET(ret) - - IF_VERB(STANDARD) { - std::cout << "The available power profiles are:" << std::endl; - uint64_t tmp = 1; - while (tmp <= RSMI_PWR_PROF_PRST_LAST) { - if ((tmp & status.available_profiles) == tmp) { - std::cout << "\t" << - power_profile_string((rsmi_power_profile_preset_masks)tmp) << - std::endl; - } - tmp = tmp << 1; - } - std::cout << "The current power profile is: " << - power_profile_string(status.current) << std::endl; - } - - rsmi_power_profile_preset_masks orig_profile = status.current; - - // Try setting the profile to a different power profile - rsmi_bit_field diff_profiles; - rsmi_power_profile_preset_masks new_prof; - diff_profiles = status.available_profiles & (~status.current); - - if (diff_profiles & RSMI_PWR_PROF_PRST_COMPUTE_MASK) { - new_prof = RSMI_PWR_PROF_PRST_COMPUTE_MASK; - } else if (diff_profiles & RSMI_PWR_PROF_PRST_VIDEO_MASK) { - new_prof = RSMI_PWR_PROF_PRST_VIDEO_MASK; - } else if (diff_profiles & RSMI_PWR_PROF_PRST_VR_MASK) { - new_prof = RSMI_PWR_PROF_PRST_VR_MASK; - } else if (diff_profiles & RSMI_PWR_PROF_PRST_POWER_SAVING_MASK) { - new_prof = RSMI_PWR_PROF_PRST_POWER_SAVING_MASK; - } else if (diff_profiles & RSMI_PWR_PROF_PRST_3D_FULL_SCR_MASK) { - new_prof = RSMI_PWR_PROF_PRST_3D_FULL_SCR_MASK; - } else { - std::cout << "No other non-custom power profiles to set to" << std::endl; - return ret; - } - - ret = rsmi_dev_power_profile_set(dv_ind, 0, new_prof); - CHK_ERR_RET(ret) - - rsmi_dev_perf_level pfl; - ret = rsmi_dev_perf_level_get(dv_ind, &pfl); - CHK_ERR_RET(ret) - ALT_ASSERT_EQ(pfl, RSMI_DEV_PERF_LEVEL_MANUAL); - - ret = rsmi_dev_power_profile_presets_get(dv_ind, 0, &status); - CHK_ERR_RET(ret) - - ALT_ASSERT_EQ(status.current, new_prof); - - ret = rsmi_dev_perf_level_set(dv_ind, RSMI_DEV_PERF_LEVEL_AUTO); - CHK_ERR_RET(ret) - - ret = rsmi_dev_perf_level_get(dv_ind, &pfl); - CHK_ERR_RET(ret) - ALT_ASSERT_EQ(pfl, RSMI_DEV_PERF_LEVEL_AUTO); - - ret = rsmi_dev_power_profile_presets_get(dv_ind, 0, &status); - CHK_ERR_RET(ret) - - ALT_ASSERT_EQ(status.current, orig_profile); - - return ret; -} static rsmi_status_t test_power_cap(uint32_t dv_ind) { rsmi_status_t ret; @@ -257,100 +123,6 @@ static rsmi_status_t test_power_cap(uint32_t dv_ind) { return ret; } -static rsmi_status_t test_set_overdrive(uint32_t dv_ind) { - rsmi_status_t ret; - uint32_t val; - - print_test_header("Overdrive Control", dv_ind); - IF_VERB(STANDARD) { - std::cout << "Set Overdrive level to 0%..." << std::endl; - } - ret = rsmi_dev_overdrive_level_set(dv_ind, 0); - CHK_ERR_RET(ret) - IF_VERB(STANDARD) { - std::cout << "Set Overdrive level to 10%..." << std::endl; - } - ret = rsmi_dev_overdrive_level_set(dv_ind, 10); - CHK_ERR_RET(ret) - ret = rsmi_dev_overdrive_level_get(dv_ind, &val); - CHK_ERR_RET(ret) - IF_VERB(STANDARD) { - std::cout << "\t**New OverDrive Level:" << val << std::endl; - std::cout << "Reset Overdrive level to 0%..." << std::endl; - } - ret = rsmi_dev_overdrive_level_set(dv_ind, 0); - CHK_ERR_RET(ret) - ret = rsmi_dev_overdrive_level_get(dv_ind, &val); - CHK_ERR_RET(ret) - IF_VERB(STANDARD) { - std::cout << "\t**New OverDrive Level:" << val << std::endl; - } - return ret; -} - -static rsmi_status_t test_set_fan_speed(uint32_t dv_ind) { - rsmi_status_t ret; - int64_t orig_speed; - int64_t new_speed; - int64_t cur_speed; - - print_test_header("Fan Speed Control", dv_ind); - - ret = rsmi_dev_fan_speed_get(dv_ind, 0, &orig_speed); - CHK_ERR_RET(ret) - IF_VERB(STANDARD) { - std::cout << "Original fan speed: " << orig_speed << std::endl; - } - - if (orig_speed == 0) { - std::cout << "***System fan speed value is 0. Skip fan test." << std::endl; - return RSMI_STATUS_SUCCESS; - } - - new_speed = 1.1 * orig_speed; - - IF_VERB(STANDARD) { - std::cout << "Setting fan speed to " << new_speed << std::endl; - } - - ret = rsmi_dev_fan_speed_set(dv_ind, 0, new_speed); - CHK_ERR_RET(ret) - - sleep(4); - - ret = rsmi_dev_fan_speed_get(dv_ind, 0, &cur_speed); - CHK_ERR_RET(ret) - - IF_VERB(STANDARD) { - std::cout << "New fan speed: " << cur_speed << std::endl; - } - - // EXPECT_TRUE((cur_speed > 0.95 * new_speed && cur_speed < 1.1 * new_speed) || - // cur_speed > 0.95 * RSMI_MAX_FAN_SPEED); - if (!((cur_speed > 0.95 * new_speed && cur_speed < 1.1 * new_speed) || - (cur_speed > 0.95 * RSMI_MAX_FAN_SPEED))) { - std::cout << "WARNING: Fan speed is not within the expected range!" << - std::endl; - } - - IF_VERB(STANDARD) { - std::cout << "Resetting fan control to auto..." << std::endl; - } - - ret = rsmi_dev_fan_reset(dv_ind, 0); - CHK_ERR_RET(ret) - - sleep(3); - - ret = rsmi_dev_fan_speed_get(dv_ind, 0, &cur_speed); - CHK_ERR_RET(ret) - - IF_VERB(STANDARD) { - std::cout << "End fan speed: " << cur_speed << std::endl; - } - return ret; -} - static const std::map kDevPerfLvlNameMap = { {RSMI_DEV_PERF_LEVEL_AUTO, "RSMI_DEV_PERF_LEVEL_AUTO"}, {RSMI_DEV_PERF_LEVEL_LOW, "RSMI_DEV_PERF_LEVEL_LOW"}, @@ -366,156 +138,6 @@ static const std::map kDevPerfLvlNameMap = { {RSMI_DEV_PERF_LEVEL_UNKNOWN, "RSMI_DEV_PERF_LEVEL_UNKNOWN"}, }; -static rsmi_status_t test_set_perf_level(uint32_t dv_ind) { - rsmi_status_t ret; - - rsmi_dev_perf_level pfl, orig_pfl; - - print_test_header("Performance Level Control", dv_ind); - - ret = rsmi_dev_perf_level_get(dv_ind, &orig_pfl); - CHK_ERR_RET(ret) - - IF_VERB(STANDARD) { - std::cout << "\t**Original Perf Level:" << - kDevPerfLvlNameMap.at(orig_pfl) << std::endl; - } - - uint32_t pfl_i = static_cast(RSMI_DEV_PERF_LEVEL_FIRST); - for (; pfl_i <= static_cast(RSMI_DEV_PERF_LEVEL_LAST); pfl_i++) { - if (pfl_i == static_cast(orig_pfl)) { - continue; - } - - IF_VERB(STANDARD) { - std::cout << "Set Performance Level to " << - kDevPerfLvlNameMap.at(static_cast(pfl_i)) << - " ..." << std::endl; - } - ret = rsmi_dev_perf_level_set(dv_ind, - static_cast(pfl_i)); - CHK_ERR_RET(ret) - ret = rsmi_dev_perf_level_get(dv_ind, &pfl); - CHK_ERR_RET(ret) - IF_VERB(STANDARD) { - std::cout << "\t**New Perf Level:" << kDevPerfLvlNameMap.at(pfl) << - std::endl; - } - } - std::cout << "Reset Perf level to " << kDevPerfLvlNameMap.at(orig_pfl) << - " ..." << std::endl; - ret = rsmi_dev_perf_level_set(dv_ind, orig_pfl); - CHK_ERR_RET(ret) - ret = rsmi_dev_perf_level_get(dv_ind, &pfl); - CHK_ERR_RET(ret) - - IF_VERB(STANDARD) { - std::cout << "\t**New Perf Level:" << kDevPerfLvlNameMap.at(pfl) << - std::endl; - } - return ret; -} - -static rsmi_status_t test_set_freq(uint32_t dv_ind) { - rsmi_status_t ret; - rsmi_frequencies f; - uint32_t freq_bitmask; - rsmi_clk_type rsmi_clk; - - print_test_header("Clock Frequency Control", dv_ind); - for (uint32_t clk = (uint32_t)RSMI_CLK_TYPE_FIRST; - clk <= RSMI_CLK_TYPE_LAST; ++clk) { - rsmi_clk = (rsmi_clk_type)clk; - - ret = rsmi_dev_gpu_clk_freq_get(dv_ind, rsmi_clk, &f); - CHK_ERR_RET(ret) - - IF_VERB(STANDARD) { - std::cout << "Initial frequency for clock" << rsmi_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(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 " << rsmi_clk << - " to 0b" << freq_bm_str << " ..." << std::endl; - } - ret = rsmi_dev_gpu_clk_freq_set(dv_ind, rsmi_clk, freq_bitmask); - CHK_ERR_RET(ret) - - ret = rsmi_dev_gpu_clk_freq_get(dv_ind, rsmi_clk, &f); - CHK_ERR_RET(ret) - - IF_VERB(STANDARD) { - std::cout << "Frequency is now index " << f.current << std::endl; - std::cout << "Resetting mask to all frequencies." << std::endl; - } - ret = rsmi_dev_gpu_clk_freq_set(dv_ind, rsmi_clk, 0xFFFFFFFF); - CHK_ERR_RET(ret) - - ret = rsmi_dev_perf_level_set(dv_ind, RSMI_DEV_PERF_LEVEL_AUTO); - CHK_ERR_RET(ret) - } - return RSMI_STATUS_SUCCESS; -} - -static rsmi_status_t test_set_pci_bw(uint32_t dv_ind) { - rsmi_status_t ret; - rsmi_pcie_bandwidth bw; - uint32_t freq_bitmask; - - print_test_header("PCIe Bandwidth Control", dv_ind); - - ret = rsmi_dev_pci_bandwidth_get(dv_ind, &bw); - CHK_ERR_RET(ret) - - IF_VERB(STANDARD) { - std::cout << "Initial PCIe is " << bw.transfer_rate.current << std::endl; - } - - // First set the bitmask to all supported bandwidths - freq_bitmask = ~(~0 << bw.transfer_rate.num_supported); - - // Then, set the bitmask to all bandwidths besides the initial BW - freq_bitmask ^= (1 << bw.transfer_rate.current); - - std::string freq_bm_str = - std::bitset(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 bandwidth mask to " << "0b" << freq_bm_str << - " ..." << std::endl; - } - ret = rsmi_dev_pci_bandwidth_set(dv_ind, freq_bitmask); - CHK_ERR_RET(ret) - - ret = rsmi_dev_pci_bandwidth_get(dv_ind, &bw); - CHK_ERR_RET(ret) - - IF_VERB(STANDARD) { - std::cout << "Bandwidth is now index " << bw.transfer_rate.current << - std::endl; - std::cout << "Resetting mask to all bandwidths." << std::endl; - } - ret = rsmi_dev_pci_bandwidth_set(dv_ind, 0xFFFFFFFF); - CHK_ERR_RET(ret) - - ret = rsmi_dev_perf_level_set(dv_ind, RSMI_DEV_PERF_LEVEL_AUTO); - CHK_ERR_RET(ret) - - return RSMI_STATUS_SUCCESS; -} static void print_frequencies(rsmi_frequencies *f, uint32_t *l = nullptr) { assert(f != nullptr); @@ -534,64 +156,11 @@ static void print_frequencies(rsmi_frequencies *f, uint32_t *l = nullptr) { } } -static void pt_rng_mhz(std::string title, rsmi_range *r) { - assert(r != nullptr); - std::cout << title << std::endl; - std::cout << "\t\t** " << r->lower_bound/1000000 << " to " << - r->upper_bound/1000000 << " MHz" << std::endl; -} - -static void print_pnt(rsmi_od_vddc_point *pt) { - std::cout << "\t\t** Frequency: " << pt->frequency/1000000 << "MHz" << - std::endl; - std::cout << "\t\t** Voltage: " << pt->voltage << "mV" << std::endl; -} -static void pt_vddc_curve(rsmi_od_vddc_point *c) { - assert(c != nullptr); - - for (uint32_t i = 0; i < RSMI_NUM_VOLTAGE_CURVE_POINTS; ++i) { - print_pnt(&c[i]); - } -} - -static void print_rsmi_od_volt_freq_data(rsmi_od_volt_freq_data *odv) { - assert(odv != nullptr); - - std::cout.setf(std::ios::dec, std::ios::basefield); - pt_rng_mhz("\t\tCurrent SCLK frequency range:", &odv->curr_sclk_range); - pt_rng_mhz("\t\tCurrent MCLK frequency range:", &odv->curr_mclk_range); - pt_rng_mhz("\t\tMin/Max Possible SCLK frequency range:", - &odv->sclk_freq_limits); - pt_rng_mhz("\t\tMin/Max Possible MCLK frequency range:", - &odv->mclk_freq_limits); - - std::cout << "\t\tCurrent Freq/Volt. curve:" << std::endl; - pt_vddc_curve(odv->curve); - - std::cout << "\tNumber of Freq./Volt. regions: " << - odv->num_regions << std::endl; -} - -static void print_odv_region(rsmi_freq_volt_region *region) { - std::cout << "\t\t\"lower-left\" corner:" << std::endl; - print_pnt(®ion->min_corner); - std::cout << "\t\t\"upper-right\" corner:" << std::endl; - print_pnt(®ion->max_corner); -} -static void print_rsmi_od_volt_freq_regions(uint32_t num_regions, - rsmi_freq_volt_region *regions) { - for (uint32_t i = 0; i < num_regions; ++i) { - std::cout << "\tRegion " << i << ":" << std::endl; - print_odv_region(®ions[i]); - } -} +#endif // reorg test 1 TestSanity::TestSanity(void) : TestBase() { - set_num_iteration(10); // Number of iterations to execute of the main test; - // This is a default value which can be overridden - // on the command line. set_title("rocm_smi_lib Sanity Test"); set_description("This test runs through most of the rocm_smi_lib calls and " "verifies that they execute as expected"); @@ -603,28 +172,23 @@ TestSanity::~TestSanity(void) { // Any 1-time setup involving member variables used in the rest of the test // should be done here. void TestSanity::SetUp(void) { - rsmi_status_t err; +// rsmi_status_t err; TestBase::SetUp(); - gVerbosity = verbosity(); - gDontFail = dont_fail(); - err = rsmi_init(0); - ASSERT_EQ(err, RSMI_STATUS_SUCCESS); - return; } void TestSanity::Run(void) { TestBase::Run(); +#if 0 // reorg test 2 rsmi_status_t err; std::string val_str; std::vector val_vec; uint64_t val_ui64, val2_ui64; int64_t val_i64; uint32_t val_ui32; - rsmi_dev_perf_level pfl; rsmi_frequencies f; rsmi_pcie_bandwidth b; rsmi_version ver = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, nullptr}; @@ -643,11 +207,6 @@ void TestSanity::Run(void) { } for (uint32_t i = 0; i < num_iteration(); i++) { - IF_VERB(PROGRESS) { - std::cout << "Iteration: " << i << std::endl; - fflush(stdout); - } - err = rsmi_num_monitor_devices(&num_monitor_devs); ASSERT_EQ(err, RSMI_STATUS_SUCCESS); @@ -658,221 +217,12 @@ void TestSanity::Run(void) { } for (uint32_t i = 0; i < num_monitor_devs; ++i) { - err = rsmi_dev_id_get(i, &val_ui64); - CHK_ERR_ASRT(err) - IF_VERB(STANDARD) { - std::cout << "\t**Device ID: 0x" << std::hex << val_ui64 << std::endl; - } - - err = rsmi_dev_od_volt_info_get(i, &odv); - if (err == RSMI_STATUS_FILE_ERROR || - err == RSMI_STATUS_NOT_YET_IMPLEMENTED) { - IF_VERB(STANDARD) { - std::cout << - "\t**rsmi_dev_od_volt_info_get: Not supported on this machine" - << std::endl; - } - } else { - CHK_ERR_ASRT(err) - } - - if (err == RSMI_STATUS_SUCCESS) { - std::cout << "\t**Frequency-voltage curve data:" << std::endl; - print_rsmi_od_volt_freq_data(&odv); - - rsmi_freq_volt_region *regions; - uint32_t num_regions; - regions = new rsmi_freq_volt_region[odv.num_regions]; - ASSERT_TRUE(regions != nullptr); - - num_regions = odv.num_regions; - err = rsmi_dev_od_volt_curve_regions_get(i, &num_regions, regions); - CHK_ERR_ASRT(err) - ASSERT_TRUE(num_regions == odv.num_regions); - - std::cout << "\t**Frequency-voltage curve regions:" << std::endl; - print_rsmi_od_volt_freq_regions(num_regions, regions); - - delete []regions; - } - - err = rsmi_dev_perf_level_get(i, &pfl); - CHK_ERR_ASRT(err) - IF_VERB(STANDARD) { - std::cout << "\t**Performance Level:" << std::dec << (uint32_t)pfl << - std::endl; - } - err = rsmi_dev_overdrive_level_get(i, &val_ui32); - CHK_ERR_ASRT(err) - IF_VERB(STANDARD) { - std::cout << "\t**OverDrive Level:" << val_ui32 << std::endl; - } - err = rsmi_dev_gpu_clk_freq_get(i, RSMI_CLK_TYPE_MEM, &f); - CHK_ERR_ASRT(err) - IF_VERB(STANDARD) { - std::cout << "\t**Supported GPU Memory clock frequencies: "; - std::cout << f.num_supported << std::endl; - print_frequencies(&f); - } - err = rsmi_dev_pci_bandwidth_get(i, &b); - if (err == RSMI_STATUS_NOT_YET_IMPLEMENTED) { - std::cout << "\t**Get PCIE Bandwidth: Not supported on this machine" - << std::endl; - } else { - CHK_ERR_ASRT(err) - IF_VERB(STANDARD) { - std::cout << "\t**Supported PCIe bandwidths: "; - std::cout << b.transfer_rate.num_supported << std::endl; - print_frequencies(&b.transfer_rate, b.lanes); - } - } - err = rsmi_dev_gpu_clk_freq_get(i, RSMI_CLK_TYPE_SYS, &f); - CHK_ERR_ASRT(err) - IF_VERB(STANDARD) { - std::cout << "\t**Supported GPU clock frequencies: "; - std::cout << f.num_supported << std::endl; - print_frequencies(&f); - } - err = rsmi_dev_busy_percent_get(i, &val_ui32); - if (err != RSMI_STATUS_SUCCESS) { - if (err == RSMI_STATUS_FILE_ERROR) { - IF_VERB(STANDARD) { - std::cout << "\t**GPU Busy Percent: Not supported on this machine" - << std::endl; - } - } else { - CHK_ERR_ASRT(err) - } - } else { - IF_VERB(STANDARD) { - std::cout << "\t**GPU Busy Percent (Percent Idle):" << std::dec << - val_ui32 << " (" << 100 - val_ui32 << ")" << std::endl; - } - } - - char name[20]; - err = rsmi_dev_name_get(i, name, 20); - CHK_ERR_ASRT(err) - IF_VERB(STANDARD) { - std::cout << "\t**Monitor name: " << name << std::endl; - } - - err = rsmi_dev_pci_id_get(i, &val_ui64); - CHK_ERR_ASRT(err) - IF_VERB(STANDARD) { - std::cout << "\t**PCI ID (BDFID): 0x" << std::hex << val_ui64; - std::cout << " (" << std::dec << val_ui64 << ")" << std::endl; - } - - auto print_temp_metric = [&](rsmi_temperature_metric met, - std::string label) { - err = rsmi_dev_temp_metric_get(i, 0, met, &val_i64); - - if (err != RSMI_STATUS_SUCCESS) { - if (err == RSMI_STATUS_FILE_ERROR) { - IF_VERB(STANDARD) { - std::cout << "\t**" << label << ": " << - "Not supported on this machine" << std::endl; - return; - } - } else { - CHK_ERR_ASRT(err) - } - } - - IF_VERB(STANDARD) { - std::cout << "\t**" << label << ": " << val_i64/1000 << - "C" << std::endl; - } - }; - print_temp_metric(RSMI_TEMP_CURRENT, "Current Temp."); - print_temp_metric(RSMI_TEMP_MAX, "Temperature max value"); - print_temp_metric(RSMI_TEMP_MIN, "Temperature min value"); - print_temp_metric(RSMI_TEMP_MAX_HYST, - "Temperature hysteresis value for max limit"); - print_temp_metric(RSMI_TEMP_MIN_HYST, - "Temperature hysteresis value for min limit"); - print_temp_metric(RSMI_TEMP_CRITICAL, "Temperature critical max value"); - print_temp_metric(RSMI_TEMP_CRITICAL_HYST, - "Temperature hysteresis value for critical limit"); - print_temp_metric(RSMI_TEMP_EMERGENCY, - "Temperature emergency max value"); - print_temp_metric(RSMI_TEMP_EMERGENCY_HYST, - "Temperature hysteresis value for emergency limit"); - print_temp_metric(RSMI_TEMP_CRIT_MIN, "Temperature critical min value"); - print_temp_metric(RSMI_TEMP_CRIT_MIN_HYST, - "Temperature hysteresis value for critical min value"); - print_temp_metric(RSMI_TEMP_OFFSET, "Temperature offset"); - print_temp_metric(RSMI_TEMP_LOWEST, "Historical minimum temperature"); - print_temp_metric(RSMI_TEMP_HIGHEST, "Historical maximum temperature"); - - err = rsmi_dev_fan_speed_get(i, 0, &val_i64); - CHK_ERR_ASRT(err) - err = rsmi_dev_fan_speed_max_get(i, 0, &val_ui64); - CHK_ERR_ASRT(err) - IF_VERB(STANDARD) { - std::cout << "\t**Current Fan Speed: "; - std::cout << val_i64/static_cast(val_ui64)*100; - std::cout << "% ("<< val_i64 << "/" << val_ui64 << ")" << std::endl; - } - err = rsmi_dev_fan_rpms_get(i, 0, &val_i64); - CHK_ERR_ASRT(err) - IF_VERB(STANDARD) { - std::cout << "\t**Current fan RPMs: " << val_i64 << std::endl; - } - err = rsmi_dev_power_cap_get(i, 0, &val_ui64); - CHK_ERR_ASRT(err) - IF_VERB(STANDARD) { - std::cout << "\t**Current Power Cap: " << val_ui64 << "uW" <(val_ui64)/1000 << " W" << std::endl; - } - std::cout << "\t=======" << std::endl; - } - } - - IF_VERB(STANDARD) { - std::cout << "***** Testing write api's" << std::endl; - } - for (uint32_t i = 0; i < num_monitor_devs; ++i) { - err = test_set_overdrive(i); - CHK_RSMI_PERM_ERR(err) - - err = test_set_perf_level(i); - CHK_RSMI_PERM_ERR(err) - - err = test_set_freq(i); - CHK_RSMI_PERM_ERR(err) - - err = test_set_pci_bw(i); - if (err == RSMI_STATUS_NOT_YET_IMPLEMENTED) { - std::cout << "\t**Set PCIE Bandwidth: Not supported on this machine" - << std::endl; - } else { - CHK_RSMI_PERM_ERR(err) - } - err = test_set_fan_speed(i); - CHK_RSMI_PERM_ERR(err) - err = test_power_cap(i); CHK_RSMI_PERM_ERR(err) - err = test_power_profile(i); - CHK_RSMI_PERM_ERR(err) } } +#endif // reorg test 2 } void TestSanity::DisplayTestInfo(void) { diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/temp_read.cc b/projects/amdsmi/tests/rocm_smi_test/functional/temp_read.cc new file mode 100755 index 0000000000..f85baa101b --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/temp_read.cc @@ -0,0 +1,139 @@ +/* + * ============================================================================= + * 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 , + * 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 +#include + +#include +#include + +#include "gtest/gtest.h" +#include "rocm_smi/rocm_smi.h" +#include "rocm_smi_test/functional/temp_read.h" +#include "rocm_smi_test/test_common.h" + +TestTempRead::TestTempRead() : TestBase() { + set_title("RSMI Temp Read Test"); + set_description("The Temperature Read tests verifies that the temperature " + "monitors can be read properly."); +} + +TestTempRead::~TestTempRead(void) { +} + +void TestTempRead::SetUp(void) { + TestBase::SetUp(); + + return; +} + +void TestTempRead::DisplayTestInfo(void) { + TestBase::DisplayTestInfo(); +} + +void TestTempRead::DisplayResults(void) const { + TestBase::DisplayResults(); + return; +} + +void TestTempRead::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 TestTempRead::Run(void) { + rsmi_status_t err; + int64_t val_i64; + + TestBase::Run(); + + for (uint32_t i = 0; i < num_monitor_devs(); ++i) { + PrintDeviceHeader(i); + + auto print_temp_metric = [&](rsmi_temperature_metric met, + std::string label) { + err = rsmi_dev_temp_metric_get(i, 0, met, &val_i64); + + if (err != RSMI_STATUS_SUCCESS) { + if (err == RSMI_STATUS_FILE_ERROR) { + IF_VERB(STANDARD) { + std::cout << "\t**" << label << ": " << + "Not supported on this machine" << std::endl; + return; + } + } else { + CHK_ERR_ASRT(err) + } + } + + IF_VERB(STANDARD) { + std::cout << "\t**" << label << ": " << val_i64/1000 << + "C" << std::endl; + } + }; + print_temp_metric(RSMI_TEMP_CURRENT, "Current Temp."); + print_temp_metric(RSMI_TEMP_MAX, "Temperature max value"); + print_temp_metric(RSMI_TEMP_MIN, "Temperature min value"); + print_temp_metric(RSMI_TEMP_MAX_HYST, + "Temperature hysteresis value for max limit"); + print_temp_metric(RSMI_TEMP_MIN_HYST, + "Temperature hysteresis value for min limit"); + print_temp_metric(RSMI_TEMP_CRITICAL, "Temperature critical max value"); + print_temp_metric(RSMI_TEMP_CRITICAL_HYST, + "Temperature hysteresis value for critical limit"); + print_temp_metric(RSMI_TEMP_EMERGENCY, + "Temperature emergency max value"); + print_temp_metric(RSMI_TEMP_EMERGENCY_HYST, + "Temperature hysteresis value for emergency limit"); + print_temp_metric(RSMI_TEMP_CRIT_MIN, "Temperature critical min value"); + print_temp_metric(RSMI_TEMP_CRIT_MIN_HYST, + "Temperature hysteresis value for critical min value"); + print_temp_metric(RSMI_TEMP_OFFSET, "Temperature offset"); + print_temp_metric(RSMI_TEMP_LOWEST, "Historical minimum temperature"); + print_temp_metric(RSMI_TEMP_HIGHEST, "Historical maximum temperature"); + } +} diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/temp_read.h b/projects/amdsmi/tests/rocm_smi_test/functional/temp_read.h new file mode 100755 index 0000000000..c97a8246d4 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/temp_read.h @@ -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 , + * 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_TEMP_READ_H_ +#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_TEMP_READ_H_ + +#include "rocm_smi_test/test_base.h" + +class TestTempRead : public TestBase { + public: + TestTempRead(); + + // @Brief: Destructor for test case of TestTempRead + virtual ~TestTempRead(); + + // @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_TEMP_READ_H_ diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/volt_freq_curv_read.cc b/projects/amdsmi/tests/rocm_smi_test/functional/volt_freq_curv_read.cc new file mode 100755 index 0000000000..c1d7a7d1db --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/volt_freq_curv_read.cc @@ -0,0 +1,181 @@ +/* + * ============================================================================= + * 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 , + * 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 +#include + +#include +#include + +#include "gtest/gtest.h" +#include "rocm_smi/rocm_smi.h" +#include "rocm_smi_test/functional/volt_freq_curv_read.h" +#include "rocm_smi_test/test_common.h" + +TestVoltCurvRead::TestVoltCurvRead() : TestBase() { + set_title("RSMI Voltage-Frequency Curve Read Test"); + set_description("The Voltage-Frequency Read tests verifies that the voltage" + " frequency curve information can be read properly."); +} + +TestVoltCurvRead::~TestVoltCurvRead(void) { +} + +void TestVoltCurvRead::SetUp(void) { + TestBase::SetUp(); + + return; +} + +void TestVoltCurvRead::DisplayTestInfo(void) { + TestBase::DisplayTestInfo(); +} + +void TestVoltCurvRead::DisplayResults(void) const { + TestBase::DisplayResults(); + return; +} + +void TestVoltCurvRead::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(); +} + +static void pt_rng_mhz(std::string title, rsmi_range *r) { + assert(r != nullptr); + + std::cout << title << std::endl; + std::cout << "\t\t** " << r->lower_bound/1000000 << " to " << + r->upper_bound/1000000 << " MHz" << std::endl; +} + +static void print_pnt(rsmi_od_vddc_point *pt) { + std::cout << "\t\t** Frequency: " << pt->frequency/1000000 << "MHz" << + std::endl; + std::cout << "\t\t** Voltage: " << pt->voltage << "mV" << std::endl; +} +static void pt_vddc_curve(rsmi_od_vddc_point *c) { + assert(c != nullptr); + + for (uint32_t i = 0; i < RSMI_NUM_VOLTAGE_CURVE_POINTS; ++i) { + print_pnt(&c[i]); + } +} + +static void print_rsmi_od_volt_freq_data(rsmi_od_volt_freq_data *odv) { + assert(odv != nullptr); + + std::cout.setf(std::ios::dec, std::ios::basefield); + pt_rng_mhz("\t\tCurrent SCLK frequency range:", &odv->curr_sclk_range); + pt_rng_mhz("\t\tCurrent MCLK frequency range:", &odv->curr_mclk_range); + pt_rng_mhz("\t\tMin/Max Possible SCLK frequency range:", + &odv->sclk_freq_limits); + pt_rng_mhz("\t\tMin/Max Possible MCLK frequency range:", + &odv->mclk_freq_limits); + + std::cout << "\t\tCurrent Freq/Volt. curve:" << std::endl; + pt_vddc_curve(odv->curve); + + std::cout << "\tNumber of Freq./Volt. regions: " << + odv->num_regions << std::endl; +} + +static void print_odv_region(rsmi_freq_volt_region *region) { + std::cout << "\t\t\"lower-left\" corner:" << std::endl; + print_pnt(®ion->min_corner); + std::cout << "\t\t\"upper-right\" corner:" << std::endl; + print_pnt(®ion->max_corner); +} +static void print_rsmi_od_volt_freq_regions(uint32_t num_regions, + rsmi_freq_volt_region *regions) { + for (uint32_t i = 0; i < num_regions; ++i) { + std::cout << "\tRegion " << i << ":" << std::endl; + print_odv_region(®ions[i]); + } +} + +void TestVoltCurvRead::Run(void) { + rsmi_status_t err; + rsmi_od_volt_freq_data odv; + + TestBase::Run(); + + for (uint32_t i = 0; i < num_monitor_devs(); ++i) { + PrintDeviceHeader(i); + + err = rsmi_dev_od_volt_info_get(i, &odv); + if (err == RSMI_STATUS_FILE_ERROR || + err == RSMI_STATUS_NOT_YET_IMPLEMENTED) { + IF_VERB(STANDARD) { + std::cout << + "\t**rsmi_dev_od_volt_info_get: Not supported on this machine" + << std::endl; + } + } else { + CHK_ERR_ASRT(err) + } + + if (err == RSMI_STATUS_SUCCESS) { + std::cout << "\t**Frequency-voltage curve data:" << std::endl; + print_rsmi_od_volt_freq_data(&odv); + + rsmi_freq_volt_region *regions; + uint32_t num_regions; + regions = new rsmi_freq_volt_region[odv.num_regions]; + ASSERT_TRUE(regions != nullptr); + + num_regions = odv.num_regions; + err = rsmi_dev_od_volt_curve_regions_get(i, &num_regions, regions); + CHK_ERR_ASRT(err) + ASSERT_TRUE(num_regions == odv.num_regions); + + std::cout << "\t**Frequency-voltage curve regions:" << std::endl; + print_rsmi_od_volt_freq_regions(num_regions, regions); + + delete []regions; + } + } +} diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/volt_freq_curv_read.h b/projects/amdsmi/tests/rocm_smi_test/functional/volt_freq_curv_read.h new file mode 100755 index 0000000000..5227ae70b9 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/volt_freq_curv_read.h @@ -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 , + * 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_FREQ_CURV_READ_H_ +#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_VOLT_FREQ_CURV_READ_H_ + +#include "rocm_smi_test/test_base.h" + +class TestVoltCurvRead : public TestBase { + public: + TestVoltCurvRead(); + + // @Brief: Destructor for test case of TestVoltCurvRead + virtual ~TestVoltCurvRead(); + + // @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_FREQ_CURV_READ_H_ diff --git a/projects/amdsmi/tests/rocm_smi_test/main.cc b/projects/amdsmi/tests/rocm_smi_test/main.cc index 6c30ccb94e..b50cc0d275 100755 --- a/projects/amdsmi/tests/rocm_smi_test/main.cc +++ b/projects/amdsmi/tests/rocm_smi_test/main.cc @@ -52,13 +52,28 @@ #include "rocm_smi_test/test_common.h" #include "rocm_smi_test/test_base.h" #include "functional/rsmi_sanity.h" +#include "functional/fan_read.h" +#include "functional/fan_read_write.h" +#include "functional/temp_read.h" +#include "functional/volt_freq_curv_read.h" +#include "functional/perf_level_read.h" +#include "functional/overdrive_read.h" +#include "functional/frequencies_read.h" +#include "functional/bdfid_read.h" +#include "functional/gpu_busy_read.h" +#include "functional/power_read.h" +#include "functional/overdrive_read_write.h" +#include "functional/perf_level_read_write.h" +#include "functional/frequencies_read_write.h" +#include "functional/pci_bw_read_write.h" +#include "functional/power_read_write.h" +#include "functional/power_cap_read_write.h" static RSMITstGlobals *sRSMIGlvalues = nullptr; static void SetFlags(TestBase *test) { assert(sRSMIGlvalues != nullptr); - test->set_num_iteration(sRSMIGlvalues->num_iterations); test->set_verbosity(sRSMIGlvalues->verbosity); test->set_dont_fail(sRSMIGlvalues->dont_fail); } @@ -104,6 +119,71 @@ TEST(rsmitst, RSMISanityTest) { RunGenericTest(&tst); } +TEST(rsmitstReadOnly, FanRead) { + TestFanRead tst; + RunGenericTest(&tst); +} +TEST(rsmitstReadWrite, FanReadWrite) { + TestFanReadWrite tst; + RunGenericTest(&tst); +} +TEST(rsmitstReadOnly, TempRead) { + TestTempRead tst; + RunGenericTest(&tst); +} +TEST(rsmitstReadOnly, TestVoltCurvRead) { + TestVoltCurvRead tst; + RunGenericTest(&tst); +} +TEST(rsmitstReadOnly, TestPerfLevelRead) { + TestPerfLevelRead tst; + RunGenericTest(&tst); +} +TEST(rsmitstReadWrite, TestPerfLevelReadWrite) { + TestPerfLevelReadWrite tst; + RunGenericTest(&tst); +} +TEST(rsmitstReadOnly, TestOverdriveRead) { + TestOverdriveRead tst; + RunGenericTest(&tst); +} +TEST(rsmitstReadWrite, TestOverdriveReadWrite) { + TestOverdriveReadWrite tst; + RunGenericTest(&tst); +} +TEST(rsmitstReadOnly, TestFrequenciesRead) { + TestFrequenciesRead tst; + RunGenericTest(&tst); +} +TEST(rsmitstReadWrite, TestFrequenciesReadWrite) { + TestFrequenciesReadWrite tst; + RunGenericTest(&tst); +} +TEST(rsmitstReadWrite, TestPciBWReadWrite) { + TestPciBWReadWrite tst; + RunGenericTest(&tst); +} +TEST(rsmitstReadOnly, TestBDFIDRead) { + TestBDFIDRead tst; + RunGenericTest(&tst); +} +TEST(rsmitstReadOnly, TestGPUBusyRead) { + TestGPUBusyRead tst; + RunGenericTest(&tst); +} +TEST(rsmitstReadOnly, TestPowerRead) { + TestPowerRead tst; + RunGenericTest(&tst); +} +TEST(rsmitstReadWrite, TestPowerReadWrite) { + TestPowerReadWrite tst; + RunGenericTest(&tst); +} +TEST(rsmitstReadWrite, TestPowerCapReadWrite) { + TestPowerCapReadWrite tst; + RunGenericTest(&tst); +} + int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/projects/amdsmi/tests/rocm_smi_test/test_base.cc b/projects/amdsmi/tests/rocm_smi_test/test_base.cc index 903e5e4284..98aa7f7f13 100755 --- a/projects/amdsmi/tests/rocm_smi_test/test_base.cc +++ b/projects/amdsmi/tests/rocm_smi_test/test_base.cc @@ -45,6 +45,7 @@ #include +#include "rocm_smi/rocm_smi.h" #include "rocm_smi_test/test_base.h" #include "rocm_smi_test/test_common.h" #include "gtest/gtest.h" @@ -78,12 +79,46 @@ static void MakeHeaderStr(const char *inStr, std::string *outStr) { void TestBase::SetUp(void) { std::string label; + rsmi_status_t err; + MakeHeaderStr(kSetupLabel, &label); printf("\n\t%s\n", label.c_str()); + err = rsmi_init(0); + ASSERT_EQ(err, RSMI_STATUS_SUCCESS); + + err = rsmi_num_monitor_devices(&num_monitor_devs_); + ASSERT_EQ(err, RSMI_STATUS_SUCCESS); + + if (num_monitor_devs_ == 0) { + std::cout << "No monitor devices found on this machine." << std::endl; + std::cout << "No ROCm SMI tests can be run." << std::endl; + } + return; } +void TestBase::PrintDeviceHeader(uint32_t dv_ind) { + rsmi_status_t err; + uint64_t val_ui64; + + IF_VERB(STANDARD) { + std::cout << "\t**Device index: " << dv_ind << std::endl; + } + err = rsmi_dev_id_get(dv_ind, &val_ui64); + CHK_ERR_ASRT(err) + IF_VERB(STANDARD) { + std::cout << "\t**Device ID: 0x" << std::hex << val_ui64 << std::endl; + } + std::cout << std::setbase(10); + + char name[20]; + err = rsmi_dev_name_get(dv_ind, name, 20); + CHK_ERR_ASRT(err) + IF_VERB(STANDARD) { + std::cout << "\t**Monitor name: " << name << std::endl; + } +} void TestBase::Run(void) { std::string label; MakeHeaderStr(kRunLabel, &label); @@ -94,6 +129,9 @@ void TestBase::Close(void) { std::string label; MakeHeaderStr(kCloseLabel, &label); printf("\n\t%s\n", label.c_str()); + + rsmi_status_t err = rsmi_shut_down(); + ASSERT_EQ(err, RSMI_STATUS_SUCCESS); } void TestBase::DisplayResults(void) const { diff --git a/projects/amdsmi/tests/rocm_smi_test/test_base.h b/projects/amdsmi/tests/rocm_smi_test/test_base.h index 497686f3f2..22c948c7be 100755 --- a/projects/amdsmi/tests/rocm_smi_test/test_base.h +++ b/projects/amdsmi/tests/rocm_smi_test/test_base.h @@ -75,12 +75,6 @@ class TestBase { void set_description(std::string d); - void set_num_iteration(int num) { - num_iteration_ = num; - } - uint32_t num_iteration(void) const { - return num_iteration_; - } void set_title(std::string name) { title_ = name; } @@ -99,13 +93,38 @@ class TestBase { bool dont_fail(void) const { return dont_fail_; } + void set_num_monitor_devs(uint32_t i) { + num_monitor_devs_ = i; + } + uint32_t num_monitor_devs(void) const { + return num_monitor_devs_; + } + + protected: + void PrintDeviceHeader(uint32_t dv_ind); private: - uint64_t num_iteration_; ///< Number of times to execute test + uint32_t num_monitor_devs_; ///< Number of monitor devices found std::string description_; std::string title_; ///< Displayed title of test uint32_t verbosity_; ///< How much additional output to produce bool dont_fail_; ///< Don't quit test on individual failure if true }; +#define IF_VERB(VB) if (verbosity() && verbosity() >= (TestBase::VERBOSE_##VB)) + +// Macros to be used within TestBase classes +#define CHK_ERR_ASRT(RET) { \ + if (dont_fail() && ((RET) != RSMI_STATUS_SUCCESS)) { \ + std::cout << std::endl << "\t===> TEST FAILURE." << std::endl; \ + DISPLAY_RSMI_ERR(RET); \ + std::cout << \ + "\t===> Abort is over-ridden due to dont_fail command line option." \ + << std::endl; \ + return; \ + } else { \ + ASSERT_EQ(RSMI_STATUS_SUCCESS, (RET)); \ + } \ +} + #endif // TESTS_ROCM_SMI_TEST_TEST_BASE_H_ diff --git a/projects/amdsmi/tests/rocm_smi_test/test_common.cc b/projects/amdsmi/tests/rocm_smi_test/test_common.cc index 950566f2af..4869cbf158 100755 --- a/projects/amdsmi/tests/rocm_smi_test/test_common.cc +++ b/projects/amdsmi/tests/rocm_smi_test/test_common.cc @@ -69,8 +69,6 @@ static void PrintHelp(void) { "Optional rsmitst Arguments:\n" "--dont_fail, -f if set, don't fail test when individual test fails; " "default is to fail when an individual test fails\n" - "--iterations, -i ; override default, " - "which varies for each test\n" "--rsmitst_help, -r print this help message\n" "--verbosity, -v \n" " Verbosity levels:\n" @@ -78,13 +76,7 @@ static void PrintHelp(void) { " 1 -- intermediate; show intermediate values such as intermediate " "perf. data\n" " 2 -- progress; show progress displays\n" - " >= 3 -- more debug output\n" - "--monitor_verbosity, -m \n" - " Monitor Verbosity levels:\n" - " 0 -- don't read or print out any GPU monitor information;\n" - " 1 -- print out all available monitor information before the first " - "test and after each test\n" - " >= 2 -- print out even more monitor information (test specific)\n"; + " >= 3 -- more debug output\n"; } uint32_t ProcessCmdline(RSMITstGlobals* test, int arg_cnt, char** arg_list) { @@ -122,12 +114,15 @@ uint32_t ProcessCmdline(RSMITstGlobals* test, int arg_cnt, char** arg_list) { break; default: + std::cout << "Unknown command line option: \"" << a << + "\". Ignoring..." << std::endl; PrintHelp(); - return 1; + return 0; } } return 0; } + #if ENABLE_SMI void DumpMonitorInfo(const TestBase *test) { int ret = 0; diff --git a/projects/amdsmi/tests/rocm_smi_test/test_common.h b/projects/amdsmi/tests/rocm_smi_test/test_common.h index fc0dce8a53..5769153f05 100755 --- a/projects/amdsmi/tests/rocm_smi_test/test_common.h +++ b/projects/amdsmi/tests/rocm_smi_test/test_common.h @@ -51,6 +51,7 @@ #if ENABLE_SMI #include "rocm_smi/rocm_smi.h" #endif + struct RSMITstGlobals { uint32_t verbosity; uint32_t monitor_verbosity; @@ -60,8 +61,35 @@ struct RSMITstGlobals { uint32_t ProcessCmdline(RSMITstGlobals* test, int arg_cnt, char** arg_list); +void PrintTestHeader(uint32_t dv_ind); + #if ENABLE_SMI void DumpMonitorInfo(const TestBase *test); #endif +#define DISPLAY_RSMI_ERR(RET) { \ + if (RET != RSMI_STATUS_SUCCESS) { \ + const char *err_str; \ + std::cout << "\t===> ERROR: RSMI call returned " << (RET) << std::endl; \ + rsmi_status_string((RET), &err_str); \ + std::cout << "\t===> (" << err_str << ")" << std::endl; \ + std::cout << "\t===> at " << __FILE__ << ":" << std::dec << __LINE__ << \ + std::endl; \ + } \ +} + +#define CHK_ERR_RET(RET) { \ + DISPLAY_RSMI_ERR(RET) \ + if ((RET) != RSMI_STATUS_SUCCESS) { \ + return (RET); \ + } \ +} +#define CHK_RSMI_PERM_ERR(RET) { \ + if (RET == RSMI_STATUS_PERMISSION) { \ + std::cout << "This command requires root access." << std::endl; \ + } else { \ + DISPLAY_RSMI_ERR(RET) \ + } \ +} + #endif // TESTS_ROCM_SMI_TEST_TEST_COMMON_H_