Update tests to use rocm-smi

Change-Id: Ia4692019460f4ba42a12ecba1f9e59576561c73e
This commit is contained in:
Chris Freehill
2017-07-24 23:46:56 -05:00
rodzic 8424fd6f23
commit a055531eb4
8 zmienionych plików z 242 dodań i 35 usunięć
+1
Wyświetl plik
@@ -64,6 +64,7 @@ BaseRocR::BaseRocR(void) {
orig_hsa_enable_interrupt_ = GetEnv("HSA_ENABLE_INTERRUPT");
set_kernel_file_name("");
set_verbosity(0);
set_monitor_verbosity(0);
set_title("unset_title");
}
+9
Wyświetl plik
@@ -214,6 +214,13 @@ class BaseRocR {
return verbosity_;
}
void set_monitor_verbosity(uint32_t m) {
monitor_verbosity_ = m;
}
uint32_t monitor_verbosity(void) const {
return monitor_verbosity_;
}
protected:
void set_requires_profile(int32_t reqd_prof) {
requires_profile_ = reqd_prof;
@@ -270,6 +277,8 @@ class BaseRocR {
uint32_t verbosity_; ///< How much additional output to produce
uint32_t monitor_verbosity_; ///< How much additional output to produce
PerfTimer hsa_timer_; ///< Timer to be used for timing parts of test
};
+47 -8
Wyświetl plik
@@ -43,6 +43,10 @@
*
*/
#include <string>
#include <vector>
#include <memory>
#include "gtest/gtest.h"
#include "suites/performance/dispatch_time.h"
#include "suites/performance/memory_async_copy.h"
@@ -50,15 +54,35 @@
#include "suites/performance/main.h"
#include "suites/test_common/test_common.h"
static uint32_t sRocrTstOptVerbosity = 1;
static uint32_t sRocrTestOptIterations = 0;
#include "common/rocm_smi/rocm_smi.h"
static RocrTstGlobals *sRocrtstGlvalues = nullptr;
static bool GetMonitorDevices(const std::shared_ptr<rocrtst::smi::Device> &d,
void *p) {
std::string val_str;
assert(p != nullptr);
std::vector<std::shared_ptr<rocrtst::smi::Device>> *device_list =
reinterpret_cast<std::vector<std::shared_ptr<rocrtst::smi::Device>> *>(p);
if (d->monitor() != nullptr) {
device_list->push_back(d);
}
return false;
}
static void RunTest(TestBase *test) {
test->set_verbosity(sRocrTstOptVerbosity);
assert(sRocrtstGlvalues != nullptr);
test->set_verbosity(sRocrtstGlvalues->verbosity);
test->set_monitor_verbosity(sRocrtstGlvalues->monitor_verbosity);
test->set_num_iteration(sRocrtstGlvalues->num_iterations);
test->set_monitor_devices(&sRocrtstGlvalues->monitor_devices);
if (sRocrTestOptIterations) {
test->set_num_iteration(sRocrTestOptIterations);
}
test->DisplayTestInfo();
test->SetUp();
test->Run();
@@ -79,6 +103,10 @@ static void RunTest(TestBase *test) {
TEST(rocrtst, Test_Example) {
TestExample tst;
rocrtst::smi::RocmSMI hw;
hw.DiscoverDevices();
RunTest(&tst);
}
@@ -117,11 +145,22 @@ TEST(rocrtst, Perf_Dispatch_Time_Multi_Interrupt) {
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
RocrtstOptions opts(&sRocrTstOptVerbosity, &sRocrTestOptIterations);
RocrTstGlobals settings;
if (ProcessCmdline(&opts, argc, argv)) {
settings.verbosity = 1;
settings.monitor_verbosity = 1;
settings.num_iterations = 0;
if (ProcessCmdline(&settings, argc, argv)) {
return 1;
}
rocrtst::smi::RocmSMI hw;
hw.DiscoverDevices();
hw.IterateSMIDevices(
GetMonitorDevices, reinterpret_cast<void *>(&settings.monitor_devices));
sRocrtstGlvalues = &settings;
return RUN_ALL_TESTS();
}
+49
Wyświetl plik
@@ -0,0 +1,49 @@
/*
* =============================================================================
* ROC Runtime Conformance Release License
* =============================================================================
* The University of Illinois/NCSA
* Open Source License (NCSA)
*
* Copyright (c) 2017, Advanced Micro Devices, Inc.
* All rights reserved.
*
* Developed by:
*
* AMD Research and AMD ROC Software Development
*
* Advanced Micro Devices, Inc.
*
* www.amd.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal with the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimers.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimers in
* the documentation and/or other materials provided with the distribution.
* - Neither the names of <Name of Development Group, Name of Institution>,
* nor the names of its contributors may be used to endorse or promote
* products derived from this Software without specific prior written
* permission.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS WITH THE SOFTWARE.
*
*/
#ifndef ROCRTST_SUITES_PERFORMANCE_MAIN_H_
#define ROCRTST_SUITES_PERFORMANCE_MAIN_H_
#endif // ROCRTST_SUITES_PERFORMANCE_MAIN_H_
@@ -46,6 +46,7 @@
#include <assert.h>
#include "suites/test_common/test_base.h"
#include "suites/test_common/test_common.h"
#include "common/base_rocr_utils.h"
#include "gtest/gtest.h"
@@ -101,6 +102,11 @@ void TestBase::Close(void) {
MakeHeaderStr(kCloseLabel, &label);
printf("\n\t%s\n", label.c_str());
if (monitor_verbosity() > 0) {
DumpMonitorInfo(this);
}
err = rocrtst::CommonCleanUp(this);
ASSERT_EQ(err, HSA_STATUS_SUCCESS);
}
+14 -1
Wyświetl plik
@@ -46,11 +46,14 @@
#define ROCRTST_SUITES_TEST_COMMON_TEST_BASE_H_
#include <string>
#include <memory>
#include <vector>
#include "common/base_rocr.h"
#include "common/rocm_smi/rocm_smi.h"
class TestBase : public rocrtst::BaseRocR {
public:
TestBase(void);
virtual ~TestBase(void);
@@ -77,8 +80,18 @@ class TestBase : public rocrtst::BaseRocR {
void set_description(std::string d);
void set_monitor_devices(
std::vector<std::shared_ptr<rocrtst::smi::Device>> *m) {
monitor_devices_ = m;
}
std::vector<std::shared_ptr<rocrtst::smi::Device>> *
monitor_devices(void) const {
return monitor_devices_;
}
private:
std::string description_;
std::vector<std::shared_ptr<rocrtst::smi::Device>> *monitor_devices_;
};
#endif // ROCRTST_SUITES_TEST_COMMON_TEST_BASE_H_
+105 -19
Wyświetl plik
@@ -45,34 +45,26 @@
#include <assert.h>
#include <stdint.h>
#include <iostream>
#include <getopt.h>
#include <iostream>
#include <string>
#include "suites/test_common/test_base.h"
#include "suites/test_common/test_common.h"
RocrtstOptions::RocrtstOptions(uint32_t *verb, uint32_t *iter) {
assert(verb != nullptr);
assert(iter != nullptr);
verbosity_ = verb;
iterations_ = iter;
}
RocrtstOptions::~RocrtstOptions() {
}
static const struct option long_options[] = {
{"iterations", required_argument, nullptr, 'i'},
{"verbose", no_argument, nullptr, 'v'},
{"verbose", required_argument, nullptr, 'v'},
{"monitor_verbose", required_argument, nullptr, 'm'},
{nullptr, 0, nullptr, 0}
};
static const char* short_options = "i:v:r";
static const char* short_options = "i:v:m:r";
static void PrintHelp(void) {
std::cout <<
// "Required Arguments:\n"
// "--kernel, -k <path to kernel obj. file>\n"
"Optional RocRTst Arguments:\n"
"--iterations, -i <number of iterations to execute>; override default, "
"which varies for each test\n"
@@ -83,10 +75,16 @@ 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";
" >= 3 -- more debug output\n"
"--monitor_verbosity, -m <monitor verbosity level>\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";
}
uint32_t ProcessCmdline(RocrtstOptions* test, int arg_cnt, char** arg_list) {
uint32_t ProcessCmdline(RocrTstGlobals* test, int arg_cnt, char** arg_list) {
int a;
int ind = -1;
@@ -101,11 +99,15 @@ uint32_t ProcessCmdline(RocrtstOptions* test, int arg_cnt, char** arg_list) {
switch (a) {
case 'i':
*test->iterations_ = std::stoi(optarg);
test->num_iterations = std::stoi(optarg);
break;
case 'v':
*test->verbosity_ = std::stoi(optarg);
test->verbosity = std::stoi(optarg);
break;
case 'm':
test->monitor_verbosity = std::stoi(optarg);
break;
case 'r':
@@ -119,3 +121,87 @@ uint32_t ProcessCmdline(RocrtstOptions* test, int arg_cnt, char** arg_list) {
}
return 0;
}
void DumpMonitorInfo(const TestBase *test) {
int ret = 0;
uint32_t value;
uint32_t value2;
std::string val_str;
std::vector<std::string> val_vec;
assert(test != nullptr);
assert(test->monitor_devices() != nullptr &&
"Make sure to call test->set_monitor_devices()");
auto print_attr_label =
[&](std::string attrib) -> bool {
std::cout << "\t** " << attrib;
if (ret == -1) {
std::cout << "not available" << std::endl;
return false;
}
return true;
};
auto delim = "\t***********************************";
std::cout << "\t***** Hardware monitor values *****" << std::endl;
std::cout << delim << std::endl;
std::cout.setf(std::ios::dec, std::ios::basefield);
for (auto dev : *test->monitor_devices()) {
auto print_vector =
[&](rocrtst::smi::DevInfoTypes type, std::string label) {
ret = dev->readDevInfo(type, &val_vec);
if (print_attr_label(label)) {
for (auto vs : val_vec) {
std::cout << "\t** " << vs << std::endl;
}
val_vec.clear();
}
};
auto print_val_str =
[&](rocrtst::smi::DevInfoTypes type, std::string label) {
ret = dev->readDevInfo(type, &val_str);
std::cout << "\t** " << label;
if (ret == -1) {
std::cout << "not available";
} else {
std::cout << val_str;
}
std::cout << std:: endl;
};
print_val_str(rocrtst::smi::kDevDevID, "Device ID: ");
print_val_str(rocrtst::smi::kDevPerfLevel, "Performance Level: ");
print_val_str(rocrtst::smi::kDevOverDriveLevel, "OverDrive Level: ");
print_vector(rocrtst::smi::kDevGPUMClk,
"Supported GPU Memory clock frequencies:\n");
print_vector(rocrtst::smi::kDevGPUSClk,
"Supported GPU clock frequencies:\n");
if (dev->monitor() != nullptr) {
ret = dev->monitor()->readMonitor(rocrtst::smi::kMonName, &val_str);
if (print_attr_label("Monitor name: ")) {
std::cout << val_str << std::endl;
}
ret = dev->monitor()->readMonitor(rocrtst::smi::kMonTemp, &value);
if (print_attr_label("Temperature: ")) {
std::cout << static_cast<float>(value)/1000.0 << "C" << std::endl;
}
std::cout.setf(std::ios::dec, std::ios::basefield);
ret = dev->monitor()->readMonitor(rocrtst::smi::kMonMaxFanSpeed, &value);
if (ret == 0) {
ret = dev->monitor()->readMonitor(rocrtst::smi::kMonFanSpeed, &value2);
}
if (print_attr_label("Current Fan Speed: ")) {
std::cout << value2/static_cast<float>(value) * 100 << "% (" <<
value2 << "/" << value << ")" << std::endl;
}
}
std::cout << "\t=======" << std::endl;
}
std::cout << delim << std::endl;
}
+11 -7
Wyświetl plik
@@ -46,16 +46,20 @@
#ifndef ROCRTST_SUITES_TEST_COMMON_TEST_COMMON_H_
#define ROCRTST_SUITES_TEST_COMMON_TEST_COMMON_H_
class RocrtstOptions {
public:
RocrtstOptions(uint32_t *verb, uint32_t *iter);
#include <memory>
#include <vector>
~RocrtstOptions(void);
#include "common/rocm_smi/rocm_smi.h"
uint32_t *verbosity_;
uint32_t *iterations_;
struct RocrTstGlobals {
uint32_t verbosity;
uint32_t monitor_verbosity;
uint32_t num_iterations;
std::vector<std::shared_ptr<rocrtst::smi::Device>> monitor_devices;
};
uint32_t ProcessCmdline(RocrtstOptions* test, int arg_cnt, char** arg_list);
uint32_t ProcessCmdline(RocrTstGlobals* test, int arg_cnt, char** arg_list);
void DumpMonitorInfo(const TestBase *test);
#endif // ROCRTST_SUITES_TEST_COMMON_TEST_COMMON_H_