Add unit test support
Add gtest based unit test framework. Implement fan read/write function. Change-Id: I83375c24b99d24d01d12bccda863a38f75f5987f
This commit is contained in:
@@ -73,6 +73,7 @@ extern "C" {
|
||||
#define AMDSMI_MAX_DEVICES 32
|
||||
#define AMDSMI_MAX_NAME 32
|
||||
#define AMDSMI_MAX_DRIVER_VERSION_LENGTH 80
|
||||
#define AMDSMI_PRODUCT_NAME_LENGTH 128
|
||||
#define AMDSMI_MAX_CONTAINER_TYPE 2
|
||||
|
||||
#define AMDSMI_GPU_UUID_SIZE 38
|
||||
@@ -140,17 +141,19 @@ typedef enum amdsmi_status {
|
||||
* Clock types
|
||||
*/
|
||||
typedef enum amdsmi_clk_type {
|
||||
CLOCK_TYPE_GFX,
|
||||
CLOCK_TYPE_SYS, //!< System clock
|
||||
CLOCK_TYPE_DF, //!< Data Fabric clock (for ASICs
|
||||
//!< running on a separate clock)
|
||||
CLOCK_TYPE_DCEF, //!< Display Controller Engine clock
|
||||
CLOCK_TYPE_SOC,
|
||||
CLOCK_TYPE_MEM,
|
||||
CLOCK_TYPE_PCIE,
|
||||
CLOCK_TYPE_GFX,
|
||||
CLOCK_TYPE_VCLK0,
|
||||
CLOCK_TYPE_VCLK1,
|
||||
CLOCK_TYPE_DCLK0,
|
||||
CLOCK_TYPE_DCLK1,
|
||||
CLOCK_TYPE_SYS,
|
||||
CLOCK_TYPE_DF,
|
||||
CLOCK_TYPE_SOC,
|
||||
CLOCK_TYPE_PCIE,
|
||||
CLOCK_TYPE__MAX
|
||||
CLOCK_TYPE__MAX = CLOCK_TYPE_DCLK1
|
||||
} amdsmi_clk_type_t;
|
||||
/// \cond Ignore in docs.
|
||||
typedef amdsmi_clk_type_t amdsmi_clk_type;
|
||||
@@ -218,6 +221,9 @@ typedef enum amdsmi_fw_block {
|
||||
FW_ID_ASD,
|
||||
FW_ID_TA_RAS,
|
||||
FW_ID_XGMI,
|
||||
FW_ID_RLC_SRLG,
|
||||
FW_ID_RLC_SRLS,
|
||||
FW_ID_SMC,
|
||||
FW_ID__MAX
|
||||
} amdsmi_fw_block_t;
|
||||
|
||||
@@ -305,7 +311,7 @@ typedef struct amdsmi_fw_info {
|
||||
typedef struct amdsmi_asic_info {
|
||||
char market_name[AMDSMI_MAX_STRING_LENGTH];
|
||||
uint32_t family; /**< Has zero value */
|
||||
uint32_t vendor_id;
|
||||
uint32_t vendor_id; //< Use 32 bit to be compatible with other platform.
|
||||
uint32_t subvendor_id;
|
||||
uint32_t device_id;
|
||||
uint32_t rev_id;
|
||||
@@ -314,11 +320,11 @@ typedef struct amdsmi_asic_info {
|
||||
|
||||
typedef struct amdsmi_board_info {
|
||||
uint64_t serial_number;
|
||||
bool is_master;
|
||||
bool is_master;
|
||||
char model_number[AMDSMI_NORMAL_STRING_LENGTH];
|
||||
char product_serial[AMDSMI_NORMAL_STRING_LENGTH];
|
||||
char fru_id[AMDSMI_NORMAL_STRING_LENGTH];
|
||||
char product_name[AMDSMI_NORMAL_STRING_LENGTH];
|
||||
char product_name[AMDSMI_PRODUCT_NAME_LENGTH];
|
||||
char manufacturer_name[AMDSMI_NORMAL_STRING_LENGTH];
|
||||
} amdsmi_board_info_t;
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ amdsmi_status_string(amdsmi_status_t status, const char **status_string) {
|
||||
*status_string = "FAIL_LOAD_MODULE: Fail to load module.";
|
||||
break;
|
||||
case AMDSMI_STATUS_FAIL_LOAD_SYMBOL:
|
||||
*status_string = "FAIL_LOAD_SYMOBL: Fail to load symobl.";
|
||||
*status_string = "FAIL_LOAD_SYMOBL: Fail to load symbol.";
|
||||
break;
|
||||
case AMDSMI_STATUS_DRM_ERROR:
|
||||
*status_string = "DRM_ERROR: Fail to run function in libdrm.";
|
||||
@@ -187,7 +187,7 @@ amdsmi_status_t amdsmi_get_board_info(amdsmi_device_handle device_handle, amdsmi
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
}
|
||||
|
||||
return rsmi_wrapper(rsmi_dev_name_get, device_handle, board_info->product_name, AMDSMI_NORMAL_STRING_LENGTH);
|
||||
return rsmi_wrapper(rsmi_dev_name_get, device_handle, board_info->product_name, AMDSMI_PRODUCT_NAME_LENGTH);
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_dev_temp_metric_get(amdsmi_device_handle device_handle,
|
||||
@@ -320,3 +320,61 @@ amdsmi_status_t amdsmi_get_caps_info(amdsmi_device_handle device_handle,
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
amdsmi_status_t amdsmi_dev_fan_rpms_get(amdsmi_device_handle device_handle,
|
||||
uint32_t sensor_ind, int64_t *speed) {
|
||||
return rsmi_wrapper(rsmi_dev_fan_rpms_get, device_handle, sensor_ind,
|
||||
speed);
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_dev_fan_speed_get(amdsmi_device_handle device_handle,
|
||||
uint32_t sensor_ind, int64_t *speed) {
|
||||
return rsmi_wrapper(rsmi_dev_fan_speed_get, device_handle,
|
||||
sensor_ind, speed);
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_dev_fan_speed_max_get(amdsmi_device_handle device_handle,
|
||||
uint32_t sensor_ind, uint64_t *max_speed) {
|
||||
return rsmi_wrapper(rsmi_dev_fan_speed_max_get, device_handle,
|
||||
sensor_ind, max_speed);
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_dev_fan_reset(amdsmi_device_handle device_handle,
|
||||
uint32_t sensor_ind) {
|
||||
return rsmi_wrapper(rsmi_dev_fan_reset, device_handle, sensor_ind);
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_dev_fan_speed_set(amdsmi_device_handle device_handle,
|
||||
uint32_t sensor_ind, uint64_t speed) {
|
||||
return rsmi_wrapper(rsmi_dev_fan_speed_set, device_handle,
|
||||
sensor_ind, speed);
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_dev_id_get(amdsmi_device_handle device_handle,
|
||||
uint16_t *id) {
|
||||
return rsmi_wrapper(rsmi_dev_id_get, device_handle, id);
|
||||
}
|
||||
|
||||
// TODO(bliu) : add other asic info
|
||||
amdsmi_status
|
||||
amdsmi_get_asic_info(amdsmi_device_handle dev, amdsmi_asic_info_t *info) {
|
||||
if (info == nullptr) return AMDSMI_STATUS_INVAL;
|
||||
uint16_t vendor_id = 0;
|
||||
amdsmi_status status = rsmi_wrapper(rsmi_dev_vendor_id_get, dev,
|
||||
&vendor_id);
|
||||
if (status == AMDSMI_STATUS_SUCCESS) info->vendor_id = vendor_id;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
amdsmi_status_t amdsmi_dev_subsystem_id_get(amdsmi_device_handle device_handle,
|
||||
uint16_t *id) {
|
||||
return rsmi_wrapper(rsmi_dev_subsystem_id_get, device_handle, id);
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_dev_subsystem_vendor_id_get(
|
||||
amdsmi_device_handle device_handle, uint16_t *id) {
|
||||
return rsmi_wrapper(rsmi_dev_subsystem_vendor_id_get, device_handle, id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,236 @@
|
||||
#
|
||||
# Minimum version of cmake required
|
||||
#
|
||||
cmake_minimum_required(VERSION 2.8.0)
|
||||
|
||||
#
|
||||
# Required Defines on cmake command line
|
||||
#
|
||||
# 1) Set location of AMDSMI header files
|
||||
#
|
||||
# ROCM_DIR="Root for ROCM install"
|
||||
#
|
||||
# 2) Set AMDSMITST_BLD_TYPE to either "Debug" or "Release".
|
||||
# If not set, the default value is "Debug" is bound.
|
||||
#
|
||||
# AMDSMITST_BLD_TYPE=Debug or AMDSMITST_BLD_TYPE=Release
|
||||
#
|
||||
# 3) Set AMDSMITST_BLD_BITS to either "32" or "64"
|
||||
# If not set, the default value of "64" is bound.
|
||||
#
|
||||
# AMDSMITST_BLD_BITS=32 or AMDSMITST_BLD_BITS=64
|
||||
#
|
||||
# Building rocrtst Suite
|
||||
#
|
||||
#
|
||||
# 1) Create build folder e.g. "rocrtst/build" - any name will do
|
||||
# 2) Cd into build folder
|
||||
# 3) Run "cmake .."
|
||||
# 4) Run "make"
|
||||
#
|
||||
|
||||
#
|
||||
# Currently support for Windows platform is not present
|
||||
#
|
||||
|
||||
#############################
|
||||
# COMMON AREA
|
||||
#############################
|
||||
if(WIN32)
|
||||
message("amdsmi library test suite is not supported on Windows platform")
|
||||
return()
|
||||
endif()
|
||||
|
||||
#
|
||||
# Process input variables
|
||||
#
|
||||
|
||||
# Required Defines first:
|
||||
|
||||
if(NOT DEFINED AMDSMI_INC_DIR)
|
||||
set(AMDSMI_INC_DIR ${ROCM_DIR}/include)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED AMDSMI_LIB_DIR)
|
||||
set(AMDSMI_LIB_DIR ${ROCM_DIR}/lib)
|
||||
endif()
|
||||
#
|
||||
# Determine AMDSMI Header files are present
|
||||
# (no external source dependencies)
|
||||
|
||||
# Determine AMDSMI Library file is present
|
||||
#
|
||||
if("${AMDSMITST_BLD_BITS}" STREQUAL 32)
|
||||
set (ONLY64STR "")
|
||||
set (IS64BIT 0)
|
||||
else()
|
||||
set (ONLY64STR "64")
|
||||
set (IS64BIT 1)
|
||||
endif()
|
||||
#
|
||||
if (${IS64BIT} EQUAL 0)
|
||||
if(NOT EXISTS ${AMDSMI_LIB_DIR}/librocm_smi32.so)
|
||||
message("ERROR: ${AMDSMI_LIB_DIR}/librocm_smi32.so doesn't exist. Check value of ROCM_DIR define")
|
||||
return()
|
||||
endif()
|
||||
else()
|
||||
if(NOT EXISTS ${AMDSMI_LIB_DIR}/librocm_smi64.so)
|
||||
message("ERROR: Define AMDSMI_LIB_DIR pointing to AMDSMI library is not set")
|
||||
message(" missing: ${AMDSMI_LIB_DIR}/librocm_smi64.so")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
string(TOLOWER "${AMDSMITST_BLD_TYPE}" tmp)
|
||||
if("${tmp}" STREQUAL release)
|
||||
set(BUILD_TYPE "Release")
|
||||
set(ISDEBUG 0)
|
||||
else()
|
||||
set(BUILD_TYPE "Debug")
|
||||
set(ISDEBUG 1)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Print out the build configuration being used:
|
||||
#
|
||||
# Build Src directory
|
||||
# Build Binary directory
|
||||
# Build Type: Debug Vs Release, 32 Vs 64
|
||||
# Compiler Version, etc
|
||||
#
|
||||
message("")
|
||||
message("Build Configuration:")
|
||||
message("-------------IS64BIT: " ${IS64BIT})
|
||||
message("-----------BuildType: " ${BUILD_TYPE})
|
||||
message("------------Compiler: " ${CMAKE_CXX_COMPILER})
|
||||
message("-------------Version: " ${CMAKE_CXX_COMPILER_VERSION})
|
||||
message("--------Proj Src Dir: " ${PROJECT_SOURCE_DIR})
|
||||
message("--------Proj Bld Dir: " ${PROJECT_BINARY_DIR})
|
||||
message("--------Proj Lib Dir: " ${PROJECT_BINARY_DIR}/lib)
|
||||
message("--------Proj Exe Dir: " ${PROJECT_BINARY_DIR}/bin)
|
||||
message("--------AMDSMI Lib Dir: " ${AMDSMI_LIB_DIR})
|
||||
message("")
|
||||
|
||||
#
|
||||
# Set the build type based on user input
|
||||
#
|
||||
set(CMAKE_BUILD_TYPE ${BUILD_TYPE})
|
||||
#
|
||||
# Flag to enable / disable verbose output.
|
||||
#
|
||||
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||
#
|
||||
# Compiler pre-processor definitions.
|
||||
#
|
||||
# Define MACRO "DEBUG" if build type is "Debug"
|
||||
if(${BUILD_TYPE} STREQUAL "Debug")
|
||||
add_definitions(-DDEBUG)
|
||||
endif()
|
||||
|
||||
add_definitions(-D__linux__)
|
||||
add_definitions(-DLITTLEENDIAN_CPU=1)
|
||||
|
||||
#
|
||||
# Linux Compiler options
|
||||
#
|
||||
set(CMAKE_CXX_FLAGS "-std=c++11 ")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-math-errno")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-threadsafe-statics")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmerge-all-constants")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fms-extensions")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
|
||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
|
||||
|
||||
## Address Sanitize Flag
|
||||
if (${ADDRESS_SANITIZER})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -g")
|
||||
set(CMAKE_EXE_LINKER_FLAGS -fsanitize=address)
|
||||
|
||||
if (BUILD_SHARED_LIBS})
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -shared-libsan" )
|
||||
else ()
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libsan" )
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Extend the compiler flags for 64-bit builds
|
||||
#
|
||||
if (IS64BIT)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -msse -msse2")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
|
||||
endif()
|
||||
|
||||
#
|
||||
# Add compiler flags to include symbol information for debug builds
|
||||
#
|
||||
if(ISDEBUG)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb -O0")
|
||||
endif()
|
||||
MESSAGE("ISDEBUG STEP:Done")
|
||||
|
||||
|
||||
set(AMDSMITST_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# Set Name for Google Test Framework and build it as a
|
||||
# static library to be linked with user test programs
|
||||
#
|
||||
set(GOOGLE_TEST_FRWK_NAME "gtest")
|
||||
add_subdirectory(${AMDSMITST_ROOT}/../rocm_smi_test/gtest "${PROJECT_BINARY_DIR}/gtest")
|
||||
set (AMDSMITST_LIBS ${AMDSMITST_LIBS} ${GOOGLE_TEST_FRWK_NAME})
|
||||
|
||||
#
|
||||
#
|
||||
# Other source directories
|
||||
aux_source_directory(${AMDSMITST_ROOT}/functional functionalSources)
|
||||
|
||||
#
|
||||
# Specify the directory containing various libraries of ROCR
|
||||
# to be linked against for building ROC Perf applications
|
||||
#
|
||||
LINK_DIRECTORIES(${AMDSMI_LIB_DIR} ${GTEST_LIB_DIR})
|
||||
|
||||
#
|
||||
# Extend the list of libraries to be used for linking amdsmi apps
|
||||
#
|
||||
if (IS64BIT)
|
||||
set(AMDSMITST_LIBS ${AMDSMITST_LIBS} rocm_smi64)
|
||||
set(AMDSMITST "amdsmitst64")
|
||||
else()
|
||||
set(AMDSMITST_LIBS ${AMDSMITST_LIBS} rocm_smi32)
|
||||
set(AMDSMITST "amdsmitst")
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Source files for building rocrtst
|
||||
#
|
||||
aux_source_directory(${AMDSMITST_ROOT} amdsmitstSources)
|
||||
|
||||
# Header file include path
|
||||
|
||||
include_directories(${AMDSMI_INC_DIR})
|
||||
include_directories(${AMDSMITST_ROOT}/..)
|
||||
include_directories(${AMDSMITST_ROOT}/../../amd_smi/include)
|
||||
include_directories(${AMDSMITST_ROOT}/../../include)
|
||||
include_directories(${AMDSMITST_ROOT}/gtest/include)
|
||||
|
||||
# Build rules
|
||||
message("--------AMDSMITST: " ${AMDSMITST} )
|
||||
message("--------amdsmitstSources: " ${amdsmitstSources} )
|
||||
message("--------functionalSources: " ${functionalSources} )
|
||||
add_executable(${AMDSMITST} ${amdsmitstSources} ${functionalSources})
|
||||
|
||||
target_link_libraries(${AMDSMITST} ${AMDSMITST_LIBS} c stdc++ pthread)
|
||||
|
||||
install(TARGETS ${AMDSMITST}
|
||||
ARCHIVE DESTINATION ${PROJECT_BINARY_DIR}/lib
|
||||
LIBRARY DESTINATION ${PROJECT_BINARY_DIR}/lib
|
||||
RUNTIME DESTINATION ${PROJECT_BINARY_DIR}/bin)
|
||||
|
||||
Executable
+144
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* =============================================================================
|
||||
* ROC Runtime Conformance Release License
|
||||
* =============================================================================
|
||||
* The University of Illinois/NCSA
|
||||
* Open Source License (NCSA)
|
||||
*
|
||||
* Copyright (c) 2019, Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Developed by:
|
||||
*
|
||||
* AMD Research and AMD ROC Software Development
|
||||
*
|
||||
* Advanced Micro Devices, Inc.
|
||||
*
|
||||
* www.amd.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal with the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimers.
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimers in
|
||||
* the documentation and/or other materials provided with the distribution.
|
||||
* - Neither the names of <Name of Development Group, Name of Institution>,
|
||||
* nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this Software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS WITH THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "amd_smi.h"
|
||||
#include "amd_smi_test/functional/fan_read.h"
|
||||
#include "amd_smi_test/test_common.h"
|
||||
|
||||
TestFanRead::TestFanRead() : TestBase() {
|
||||
set_title("AMDSMI 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
|
||||
// amdsmi_shut_down(), so it should be done after other hsa cleanup
|
||||
TestBase::Close();
|
||||
}
|
||||
|
||||
|
||||
void TestFanRead::Run(void) {
|
||||
uint64_t val_ui64;
|
||||
amdsmi_status_t err;
|
||||
int64_t val_i64;
|
||||
|
||||
TestBase::Run();
|
||||
if (setup_failed_) {
|
||||
std::cout << "** SetUp Failed for this test. Skipping.**" << std::endl;
|
||||
return;
|
||||
}
|
||||
for (uint32_t x = 0; x < num_iterations(); ++x) {
|
||||
for (uint32_t i = 0; i < num_monitor_devs(); ++i) {
|
||||
PrintDeviceHeader(device_handles_[i]);
|
||||
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Current Fan Speed: ";
|
||||
}
|
||||
err = amdsmi_dev_fan_speed_get(device_handles_[i], 0, &val_i64);
|
||||
if (err == AMDSMI_STATUS_NOT_SUPPORTED) {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**" << ": " <<
|
||||
"Not supported on this machine" << std::endl;
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
CHK_ERR_ASRT(err)
|
||||
}
|
||||
|
||||
|
||||
// Verify api support checking functionality is working
|
||||
err = amdsmi_dev_fan_speed_get(device_handles_[i], 0, nullptr);
|
||||
ASSERT_EQ(err, AMDSMI_STATUS_INVAL);
|
||||
|
||||
err = amdsmi_dev_fan_speed_max_get(device_handles_[i], 0, &val_ui64);
|
||||
CHK_ERR_ASRT(err)
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << val_i64/static_cast<float>(val_ui64)*100;
|
||||
std::cout << "% ("<< val_i64 << "/" << val_ui64 << ")" << std::endl;
|
||||
}
|
||||
// Verify api support checking functionality is working
|
||||
err = amdsmi_dev_fan_speed_max_get(device_handles_[i], 0, nullptr);
|
||||
ASSERT_EQ(err, AMDSMI_STATUS_INVAL);
|
||||
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Current fan RPMs: ";
|
||||
}
|
||||
err = amdsmi_dev_fan_rpms_get(device_handles_[i], 0, &val_i64);
|
||||
CHK_ERR_ASRT(err)
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << val_i64 << std::endl;
|
||||
}
|
||||
|
||||
// Verify api support checking functionality is working
|
||||
err = amdsmi_dev_fan_rpms_get(device_handles_[i], 0, nullptr);
|
||||
ASSERT_EQ(err, AMDSMI_STATUS_INVAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+73
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* =============================================================================
|
||||
* ROC Runtime Conformance Release License
|
||||
* =============================================================================
|
||||
* The University of Illinois/NCSA
|
||||
* Open Source License (NCSA)
|
||||
*
|
||||
* Copyright (c) 2019, Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Developed by:
|
||||
*
|
||||
* AMD Research and AMD ROC Software Development
|
||||
*
|
||||
* Advanced Micro Devices, Inc.
|
||||
*
|
||||
* www.amd.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal with the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimers.
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimers in
|
||||
* the documentation and/or other materials provided with the distribution.
|
||||
* - Neither the names of <Name of Development Group, Name of Institution>,
|
||||
* nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this Software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS WITH THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#ifndef TESTS_AMDSMI_TEST_FUNCTIONAL_FAN_READ_H_
|
||||
#define TESTS_AMDSMI_TEST_FUNCTIONAL_FAN_READ_H_
|
||||
|
||||
#include "amd_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_AMDSMI_TEST_FUNCTIONAL_FAN_READ_H_
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* =============================================================================
|
||||
* ROC Runtime Conformance Release License
|
||||
* =============================================================================
|
||||
* The University of Illinois/NCSA
|
||||
* Open Source License (NCSA)
|
||||
*
|
||||
* Copyright (c) 2019, Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Developed by:
|
||||
*
|
||||
* AMD Research and AMD ROC Software Development
|
||||
*
|
||||
* Advanced Micro Devices, Inc.
|
||||
*
|
||||
* www.amd.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal with the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimers.
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimers in
|
||||
* the documentation and/or other materials provided with the distribution.
|
||||
* - Neither the names of <Name of Development Group, Name of Institution>,
|
||||
* nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this Software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS WITH THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "amd_smi.h"
|
||||
#include "amd_smi_test/functional/fan_read_write.h"
|
||||
#include "amd_smi_test/test_common.h"
|
||||
|
||||
TestFanReadWrite::TestFanReadWrite() : TestBase() {
|
||||
set_title("AMDSMI 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
|
||||
// amdsmi_shut_down(), so it should be done after other hsa cleanup
|
||||
TestBase::Close();
|
||||
}
|
||||
|
||||
|
||||
void TestFanReadWrite::Run(void) {
|
||||
amdsmi_status_t ret;
|
||||
int64_t orig_speed;
|
||||
int64_t new_speed;
|
||||
int64_t cur_speed;
|
||||
uint64_t max_speed;
|
||||
|
||||
TestBase::Run();
|
||||
if (setup_failed_) {
|
||||
std::cout << "** SetUp Failed for this test. Skipping.**" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
for (uint32_t dv_ind = 0; dv_ind < num_monitor_devs(); ++dv_ind) {
|
||||
PrintDeviceHeader(device_handles_[dv_ind]);
|
||||
|
||||
ret = amdsmi_dev_fan_speed_get(device_handles_[dv_ind], 0, &orig_speed);
|
||||
if (ret == AMDSMI_STATUS_NOT_SUPPORTED) {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**" << ": " <<
|
||||
"Not supported on this machine" << std::endl;
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
ret = amdsmi_dev_fan_speed_max_get(device_handles_[dv_ind], 0, &max_speed);
|
||||
CHK_ERR_ASRT(ret)
|
||||
|
||||
new_speed = 1.1 * orig_speed;
|
||||
|
||||
if (new_speed > static_cast<int64_t>(max_speed)) {
|
||||
std::cout <<
|
||||
"***System fan speed value is close to max. Will not adjust upward." <<
|
||||
std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "Setting fan speed to " << new_speed << std::endl;
|
||||
}
|
||||
|
||||
ret = amdsmi_dev_fan_speed_set(device_handles_[dv_ind], 0, new_speed);
|
||||
CHK_ERR_ASRT(ret)
|
||||
|
||||
sleep(4);
|
||||
|
||||
ret = amdsmi_dev_fan_speed_get(device_handles_[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 * AMDSMI_MAX_FAN_SPEED);
|
||||
IF_VERB(STANDARD) {
|
||||
if (!((cur_speed > 0.95 * new_speed && cur_speed < 1.1 * new_speed) ||
|
||||
(cur_speed > 0.95 * AMDSMI_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 = amdsmi_dev_fan_reset(device_handles_[dv_ind], 0);
|
||||
CHK_ERR_ASRT(ret)
|
||||
|
||||
sleep(3);
|
||||
|
||||
ret = amdsmi_dev_fan_speed_get(device_handles_[dv_ind], 0, &cur_speed);
|
||||
CHK_ERR_ASRT(ret)
|
||||
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "End fan speed: " << cur_speed << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* =============================================================================
|
||||
* ROC Runtime Conformance Release License
|
||||
* =============================================================================
|
||||
* The University of Illinois/NCSA
|
||||
* Open Source License (NCSA)
|
||||
*
|
||||
* Copyright (c) 2019, Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Developed by:
|
||||
*
|
||||
* AMD Research and AMD ROC Software Development
|
||||
*
|
||||
* Advanced Micro Devices, Inc.
|
||||
*
|
||||
* www.amd.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal with the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimers.
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimers in
|
||||
* the documentation and/or other materials provided with the distribution.
|
||||
* - Neither the names of <Name of Development Group, Name of Institution>,
|
||||
* nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this Software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS WITH THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#ifndef TESTS_AMDSMI_TEST_FUNCTIONAL_FAN_READ_WRITE_H_
|
||||
#define TESTS_AMDSMI_TEST_FUNCTIONAL_FAN_READ_WRITE_H_
|
||||
|
||||
#include "amd_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_AMDSMI_TEST_FUNCTIONAL_FAN_READ_WRITE_H_
|
||||
@@ -0,0 +1,305 @@
|
||||
/*
|
||||
* =============================================================================
|
||||
* ROC Runtime Conformance Release License
|
||||
* =============================================================================
|
||||
* The University of Illinois/NCSA
|
||||
* Open Source License (NCSA)
|
||||
*
|
||||
* Copyright (c) 2018, Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Developed by:
|
||||
*
|
||||
* AMD Research and AMD ROC Software Development
|
||||
*
|
||||
* Advanced Micro Devices, Inc.
|
||||
*
|
||||
* www.amd.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal with the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimers.
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimers in
|
||||
* the documentation and/or other materials provided with the distribution.
|
||||
* - Neither the names of <Name of Development Group, Name of Institution>,
|
||||
* nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this Software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS WITH THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <iostream>
|
||||
|
||||
#include "amd_smi.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "amd_smi_test/test_common.h"
|
||||
#include "amd_smi_test/test_base.h"
|
||||
|
||||
#include "functional/fan_read.h"
|
||||
#include "functional/fan_read_write.h"
|
||||
/*
|
||||
#include "functional/temp_read.h"
|
||||
#include "functional/volt_read.h"
|
||||
#include "functional/volt_freq_curv_read.h"
|
||||
#include "functional/perf_level_read.h"
|
||||
#include "functional/overdrive_read.h"
|
||||
#include "functional/frequencies_read.h"
|
||||
#include "functional/sys_info_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_read_write.h"
|
||||
#include "functional/power_read_write.h"
|
||||
#include "functional/power_cap_read_write.h"
|
||||
#include "functional/version_read.h"
|
||||
#include "functional/err_cnt_read.h"
|
||||
#include "functional/mem_util_read.h"
|
||||
#include "functional/id_info_read.h"
|
||||
#include "functional/perf_cntr_read_write.h"
|
||||
#include "functional/process_info_read.h"
|
||||
#include "functional/xgmi_read_write.h"
|
||||
#include "functional/mem_page_info_read.h"
|
||||
#include "functional/api_support_read.h"
|
||||
#include "functional/mutual_exclusion.h"
|
||||
#include "functional/evt_notif_read_write.h"
|
||||
#include "functional/init_shutdown_refcount.h"
|
||||
#include "amd_smi_test/functional/hw_topology_read.h"
|
||||
#include "amd_smi_test/functional/gpu_metrics_read.h"
|
||||
#include "amd_smi_test/functional/metrics_counter_read.h"
|
||||
#include "amd_smi_test/functional/perf_determinism.h"
|
||||
*/
|
||||
|
||||
static AMDSMITstGlobals *sRSMIGlvalues = nullptr;
|
||||
|
||||
static void SetFlags(TestBase *test) {
|
||||
assert(sRSMIGlvalues != nullptr);
|
||||
|
||||
test->set_verbosity(sRSMIGlvalues->verbosity);
|
||||
test->set_dont_fail(sRSMIGlvalues->dont_fail);
|
||||
test->set_init_options(sRSMIGlvalues->init_options);
|
||||
test->set_num_iterations(sRSMIGlvalues->num_iterations);
|
||||
}
|
||||
|
||||
static void RunCustomTestProlog(TestBase *test) {
|
||||
SetFlags(test);
|
||||
|
||||
if (sRSMIGlvalues->verbosity >= TestBase::VERBOSE_STANDARD) {
|
||||
test->DisplayTestInfo();
|
||||
}
|
||||
test->SetUp();
|
||||
test->Run();
|
||||
return;
|
||||
}
|
||||
static void RunCustomTestEpilog(TestBase *tst) {
|
||||
if (sRSMIGlvalues->verbosity >= TestBase::VERBOSE_STANDARD) {
|
||||
tst->DisplayResults();
|
||||
}
|
||||
tst->Close();
|
||||
return;
|
||||
}
|
||||
|
||||
// If the test case one big test, you should use RunGenericTest()
|
||||
// to run the test case. OTOH, if the test case consists of multiple
|
||||
// functions to be run as separate tests, follow this pattern:
|
||||
// * RunCustomTestProlog(test) // Run() should contain minimal code
|
||||
// * <insert call to actual test function within test case>
|
||||
// * RunCustomTestEpilog(test)
|
||||
static void RunGenericTest(TestBase *test) {
|
||||
RunCustomTestProlog(test);
|
||||
RunCustomTestEpilog(test);
|
||||
return;
|
||||
}
|
||||
|
||||
// TEST ENTRY TEMPLATE:
|
||||
// TEST(rocrtst, Perf_<test name>) {
|
||||
// <Test Implementation class> <test_obj>;
|
||||
//
|
||||
// // Copy and modify implementation of RunGenericTest() if you need to deviate
|
||||
// // from the standard pattern implemented there.
|
||||
// RunGenericTest(&<test_obj>);
|
||||
// }
|
||||
|
||||
/*
|
||||
TEST(amdsmitstReadOnly, TestVersionRead) {
|
||||
TestVersionRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
*/
|
||||
TEST(amdsmitstReadOnly, FanRead) {
|
||||
TestFanRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadWrite, FanReadWrite) {
|
||||
TestFanReadWrite tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
/*
|
||||
TEST(amdsmitstReadOnly, TempRead) {
|
||||
TestTempRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadOnly, VoltRead) {
|
||||
TestVoltRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadOnly, TestVoltCurvRead) {
|
||||
TestVoltCurvRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadOnly, TestPerfLevelRead) {
|
||||
TestPerfLevelRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadWrite, TestPerfLevelReadWrite) {
|
||||
TestPerfLevelReadWrite tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadOnly, TestOverdriveRead) {
|
||||
TestOverdriveRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadWrite, TestOverdriveReadWrite) {
|
||||
TestOverdriveReadWrite tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadOnly, TestFrequenciesRead) {
|
||||
TestFrequenciesRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadWrite, TestFrequenciesReadWrite) {
|
||||
TestFrequenciesReadWrite tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadWrite, TestPciReadWrite) {
|
||||
TestPciReadWrite tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadOnly, TestSysInfoRead) {
|
||||
TestSysInfoRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadOnly, TestGPUBusyRead) {
|
||||
TestGPUBusyRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadOnly, TestPowerRead) {
|
||||
TestPowerRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadWrite, TestPowerReadWrite) {
|
||||
TestPowerReadWrite tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadWrite, TestPowerCapReadWrite) {
|
||||
TestPowerCapReadWrite tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadOnly, TestErrCntRead) {
|
||||
TestErrCntRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadOnly, TestMemUtilRead) {
|
||||
TestMemUtilRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadOnly, TestIdInfoRead) {
|
||||
TestIdInfoRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadWrite, TestPerfCntrReadWrite) {
|
||||
TestPerfCntrReadWrite tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadOnly, TestProcInfoRead) {
|
||||
TestProcInfoRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadOnly, TestHWTopologyRead) {
|
||||
TestHWTopologyRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadOnly, TestGpuMetricsRead) {
|
||||
TestGpuMetricsRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadOnly, TestMetricsCounterRead) {
|
||||
TestMetricsCounterRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadWrite, TestPerfDeterminism) {
|
||||
TestPerfDeterminism tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadWrite, TestXGMIReadWrite) {
|
||||
TestXGMIReadWrite tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadOnly, TestMemPageInfoRead) {
|
||||
TestMemPageInfoRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadOnly, TestAPISupportRead) {
|
||||
TestAPISupportRead tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadOnly, TestMutualExclusion) {
|
||||
TestMutualExclusion tst;
|
||||
SetFlags(&tst);
|
||||
tst.DisplayTestInfo();
|
||||
tst.SetUp();
|
||||
tst.Run();
|
||||
RunCustomTestEpilog(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadWrite, TestEvtNotifReadWrite) {
|
||||
TestEvtNotifReadWrite tst;
|
||||
RunGenericTest(&tst);
|
||||
}
|
||||
TEST(amdsmitstReadOnly, TestConcurrentInit) {
|
||||
TestConcurrentInit tst;
|
||||
SetFlags(&tst);
|
||||
tst.DisplayTestInfo();
|
||||
// tst.SetUp(); // Avoid extra amdsmi_init
|
||||
tst.Run();
|
||||
// RunCustomTestEpilog(&tst); // Avoid extra amdsmi_shut_down
|
||||
tst.DisplayResults();
|
||||
}
|
||||
*/
|
||||
int main(int argc, char** argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
AMDSMITstGlobals settings;
|
||||
|
||||
// Set some default values
|
||||
settings.verbosity = 1;
|
||||
settings.monitor_verbosity = 1;
|
||||
settings.num_iterations = 1;
|
||||
settings.dont_fail = false;
|
||||
settings.init_options = 0;
|
||||
|
||||
if (ProcessCmdline(&settings, argc, argv)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
sRSMIGlvalues = &settings;
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
declare -A FILTER
|
||||
|
||||
# FILTER is meant to be used with a negative gtest filter
|
||||
|
||||
# Designate the tests to be excluded from all test runs first,
|
||||
# followed by tests that should be excluded by device.
|
||||
|
||||
# Permanent exclusions
|
||||
# These tests are included for debugging, but are not executed in normal
|
||||
# execution on any ASIC:
|
||||
PERMANENT_BLACKLIST_ALL_ASICS=
|
||||
|
||||
# This is the temporary blacklist for all ASICs. This is to be used when a test
|
||||
# is failing consistently
|
||||
TEMPORARY_BLACKLIST_ALL_ASICS=
|
||||
|
||||
if [ -z $PERMANENT_BLACKLIST_ALL_ASICS -a -z $TEMPORARY_BLACKLIST_ALL_ASICS ]; then
|
||||
BLACKLIST_ALL_ASICS=
|
||||
else
|
||||
BLACKLIST_ALL_ASICS=\
|
||||
"$PERMANENT_BLACKLIST_ALL_ASICS:"\
|
||||
"$TEMPORARY_BLACKLIST_ALL_ASICS"
|
||||
fi
|
||||
|
||||
# Device specific blacklists
|
||||
FILTER[vega10]=\
|
||||
$BLACKLIST_ALL_ASICS
|
||||
|
||||
# SWDEV-207510
|
||||
FILTER[vega20]=\
|
||||
$BLACKLIST_ALL_ASICS\
|
||||
"rsmitstReadOnly.TestFrequenciesRead:"\
|
||||
"rsmitstReadOnly.TestProcInfoRead"
|
||||
|
||||
# SWDEV-207510
|
||||
FILTER[arcturus]=\
|
||||
$BLACKLIST_ALL_ASICS\
|
||||
"rsmitstReadOnly.TestFrequenciesRead:"\
|
||||
"rsmitstReadWrite.TestFrequenciesReadWrite:"\
|
||||
"rsmitstReadOnly.TestProcInfoRead"
|
||||
|
||||
# SWDEV-306889
|
||||
FILTER[aldebaran]=\
|
||||
$BLACKLIST_ALL_ASICS\
|
||||
"rsmitstReadOnly.FanRead:"\
|
||||
"rsmitstReadOnly.TestVoltCurvRead:"\
|
||||
"rsmitstReadOnly.TestFrequenciesRead:"\
|
||||
"rsmitstReadWrite.FanReadWrite:"\
|
||||
"rsmitstReadWrite.TestFrequenciesReadWrite:"\
|
||||
"rsmitstReadWrite.TestPciReadWrite:"\
|
||||
"rsmitstReadWrite.TestPowerReadWrite"
|
||||
|
||||
# SWDEV-319795
|
||||
FILTER[sienna_cichlid]=\
|
||||
$BLACKLIST_ALL_ASICS\
|
||||
"rsmitstReadWrite.TestPerfLevelReadWrite"
|
||||
|
||||
# SWDEV-321166
|
||||
FILTER[virtualization]=\
|
||||
$BLACKLIST_ALL_ASICS\
|
||||
"rsmitstReadOnly.TestOverdriveRead:"\
|
||||
"rsmitstReadOnly.TestGPUBusyRead:"\
|
||||
"rsmitstReadWrite.FanReadWrite:"\
|
||||
"rsmitstReadWrite.TestOverdriveReadWrite:"\
|
||||
"rsmitstReadWrite.TestPowerReadWrite:"\
|
||||
"rsmitstReadWrite.TestPowerCapReadWrite"
|
||||
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
* =============================================================================
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "amd_smi.h"
|
||||
#include "amd_smi_test/test_base.h"
|
||||
#include "amd_smi_test/test_common.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
static const int kOutputLineLength = 80;
|
||||
static const char kLabelDelimiter[] = "####";
|
||||
static const char kDescriptionLabel[] = "TEST DESCRIPTION";
|
||||
static const char kTitleLabel[] = "TEST NAME";
|
||||
static const char kRunLabel[] = "TEST EXECUTION";
|
||||
static const char kCloseLabel[] = "TEST CLEAN UP";
|
||||
static const char kResultsLabel[] = "TEST RESULTS";
|
||||
|
||||
// This one is used outside this file
|
||||
const char kSetupLabel[] = "TEST SETUP";
|
||||
|
||||
TestBase::TestBase() : setup_failed_(false), description_("") {
|
||||
}
|
||||
TestBase::~TestBase() {
|
||||
}
|
||||
|
||||
void TestBase::MakeHeaderStr(const char *inStr,
|
||||
std::string *outStr) const {
|
||||
assert(outStr != nullptr);
|
||||
assert(inStr != nullptr);
|
||||
outStr->clear();
|
||||
IF_VERB(STANDARD) {
|
||||
*outStr = kLabelDelimiter;
|
||||
*outStr += " ";
|
||||
*outStr += inStr;
|
||||
*outStr += " ";
|
||||
*outStr += kLabelDelimiter;
|
||||
}
|
||||
}
|
||||
|
||||
void TestBase::SetUp(void) {
|
||||
SetUp(AMD_SMI_INIT_AMD_GPUS);
|
||||
}
|
||||
|
||||
void TestBase::SetUp(uint64_t init_flags) {
|
||||
std::string label;
|
||||
amdsmi_status_t err;
|
||||
|
||||
IF_VERB(STANDARD) {
|
||||
MakeHeaderStr(kSetupLabel, &label);
|
||||
printf("\n\t%s\n", label.c_str());
|
||||
}
|
||||
|
||||
if (init_flags) {
|
||||
err = amdsmi_init(init_flags);
|
||||
} else {
|
||||
err = amdsmi_init(init_options());
|
||||
}
|
||||
|
||||
if (err != AMDSMI_STATUS_SUCCESS) {
|
||||
setup_failed_ = true;
|
||||
}
|
||||
ASSERT_EQ(err, AMDSMI_STATUS_SUCCESS);
|
||||
|
||||
socket_count_ = 0;
|
||||
err = amdsmi_get_socket_handles(&socket_count_, &sockets_);
|
||||
if (err != AMDSMI_STATUS_SUCCESS) {
|
||||
setup_failed_ = true;
|
||||
}
|
||||
ASSERT_EQ(err, AMDSMI_STATUS_SUCCESS);
|
||||
|
||||
// collect devices from sockets
|
||||
num_monitor_devs_ = 0;
|
||||
for (uint32_t i=0; i < socket_count_; i++) {
|
||||
// Get all devices of the socket
|
||||
uint32_t device_count = 0;
|
||||
amdsmi_device_handle* device_handles = nullptr;
|
||||
err = amdsmi_get_device_handles(sockets_[i],
|
||||
&device_count, &device_handles);
|
||||
if (err != AMDSMI_STATUS_SUCCESS) {
|
||||
setup_failed_ = true;
|
||||
}
|
||||
ASSERT_EQ(err, AMDSMI_STATUS_SUCCESS);
|
||||
// store the device handles for following tests
|
||||
for (uint32_t j=0; j < device_count; j++) {
|
||||
if (num_monitor_devs_ >= MAX_MONITOR_DEVICES) {
|
||||
setup_failed_ = true;
|
||||
ASSERT_EQ(AMDSMI_STATUS_INPUT_OUT_OF_BOUNDS, AMDSMI_STATUS_SUCCESS);
|
||||
}
|
||||
device_handles_[num_monitor_devs_] = device_handles[j];
|
||||
num_monitor_devs_++;
|
||||
}
|
||||
}
|
||||
|
||||
if (num_monitor_devs_ == 0) {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "No monitor devices found on this machine." << std::endl;
|
||||
std::cout << "No AMD SMI tests can be run." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void TestBase::PrintDeviceHeader(amdsmi_device_handle dv_ind) {
|
||||
amdsmi_status_t err;
|
||||
uint16_t val_ui16;
|
||||
amdsmi_asic_info_t info;
|
||||
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Device handle: " << dv_ind << std::endl;
|
||||
}
|
||||
err = amdsmi_dev_id_get(dv_ind, &val_ui16);
|
||||
CHK_ERR_ASRT(err)
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Device ID: 0x" << std::hex << val_ui16 << std::endl;
|
||||
}
|
||||
|
||||
amdsmi_board_info board_info;
|
||||
err = amdsmi_get_board_info(dv_ind, &board_info);
|
||||
CHK_ERR_ASRT(err)
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Device name: " << board_info.product_name << std::endl;
|
||||
}
|
||||
|
||||
err = amdsmi_get_asic_info(dv_ind, &info);
|
||||
CHK_ERR_ASRT(err)
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Device Vendor ID: 0x" << std::hex << info.vendor_id <<
|
||||
std::endl;
|
||||
}
|
||||
err = amdsmi_dev_subsystem_id_get(dv_ind, &val_ui16);
|
||||
CHK_ERR_ASRT(err)
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Subsystem ID: 0x" << std::hex << val_ui16 << std::endl;
|
||||
}
|
||||
err = amdsmi_dev_subsystem_vendor_id_get(dv_ind, &val_ui16);
|
||||
CHK_ERR_ASRT(err)
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Subsystem Vendor ID: 0x" << std::hex << val_ui16 <<
|
||||
std::endl;
|
||||
}
|
||||
std::cout << std::setbase(10);
|
||||
}
|
||||
void TestBase::Run(void) {
|
||||
std::string label;
|
||||
IF_VERB(STANDARD) {
|
||||
MakeHeaderStr(kRunLabel, &label);
|
||||
printf("\n\t%s\n", label.c_str());
|
||||
}
|
||||
ASSERT_TRUE(!setup_failed_);
|
||||
}
|
||||
|
||||
void TestBase::Close(void) {
|
||||
std::string label;
|
||||
IF_VERB(STANDARD) {
|
||||
MakeHeaderStr(kCloseLabel, &label);
|
||||
printf("\n\t%s\n", label.c_str());
|
||||
}
|
||||
amdsmi_status_t err = amdsmi_shut_down();
|
||||
ASSERT_EQ(err, AMDSMI_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
void TestBase::DisplayResults(void) const {
|
||||
std::string label;
|
||||
IF_VERB(STANDARD) {
|
||||
MakeHeaderStr(kResultsLabel, &label);
|
||||
printf("\n\t%s\n", label.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void TestBase::DisplayTestInfo(void) {
|
||||
IF_VERB(STANDARD) {
|
||||
printf("#########################################"
|
||||
"######################################\n");
|
||||
|
||||
std::string label;
|
||||
MakeHeaderStr(kTitleLabel, &label);
|
||||
printf("\n\t%s\n%s\n", label.c_str(), title().c_str());
|
||||
|
||||
if (verbosity() >= VERBOSE_STANDARD) {
|
||||
MakeHeaderStr(kDescriptionLabel, &label);
|
||||
printf("\n\t%s\n%s\n", label.c_str(), description().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TestBase::set_description(std::string d) {
|
||||
int le = kOutputLineLength - 4;
|
||||
|
||||
description_ = d;
|
||||
size_t endlptr;
|
||||
|
||||
for (size_t i = le; i < description_.size(); i += le) {
|
||||
endlptr = description_.find_last_of(" ", i);
|
||||
description_.replace(endlptr, 1, "\n");
|
||||
i = endlptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* =============================================================================
|
||||
* ROC Runtime Conformance Release License
|
||||
* =============================================================================
|
||||
* The University of Illinois/NCSA
|
||||
* Open Source License (NCSA)
|
||||
*
|
||||
* Copyright (c) 2018, Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Developed by:
|
||||
*
|
||||
* AMD Research and AMD ROC Software Development
|
||||
*
|
||||
* Advanced Micro Devices, Inc.
|
||||
*
|
||||
* www.amd.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal with the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimers.
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimers in
|
||||
* the documentation and/or other materials provided with the distribution.
|
||||
* - Neither the names of <Name of Development Group, Name of Institution>,
|
||||
* nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this Software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS WITH THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#ifndef TESTS_AMD_SMI_TEST_TEST_BASE_H_
|
||||
#define TESTS_AMD_SMI_TEST_TEST_BASE_H_
|
||||
|
||||
#include <string>
|
||||
#include "amd_smi.h"
|
||||
|
||||
// The max devices can be monitored
|
||||
#define MAX_MONITOR_DEVICES 128
|
||||
class TestBase {
|
||||
public:
|
||||
TestBase(void);
|
||||
|
||||
virtual ~TestBase(void);
|
||||
|
||||
enum VerboseLevel {VERBOSE_MIN = 0, VERBOSE_STANDARD, VERBOSE_PROGRESS};
|
||||
|
||||
// @Brief: Before run the core measure codes, do something to set up
|
||||
// i.e. init runtime, prepare packet...
|
||||
// The init_flags option will override any flags set for the whole test
|
||||
// suite
|
||||
void SetUp(uint64_t init_flags);
|
||||
virtual void SetUp(void);
|
||||
|
||||
// @Brief: Core measurement codes executing here
|
||||
virtual void Run(void);
|
||||
|
||||
// @Brief: Do something clean up
|
||||
virtual void Close(void);
|
||||
|
||||
// @Brief: Display the results
|
||||
virtual void DisplayResults(void) const;
|
||||
|
||||
// @Brief: Display information about the test
|
||||
virtual void DisplayTestInfo(void);
|
||||
|
||||
const std::string & description(void) const {return description_;}
|
||||
|
||||
void set_description(std::string d);
|
||||
|
||||
void set_title(std::string name) {
|
||||
title_ = name;
|
||||
}
|
||||
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_;
|
||||
}
|
||||
void set_num_monitor_devs(uint32_t i) {
|
||||
num_monitor_devs_ = i;
|
||||
}
|
||||
uint32_t num_monitor_devs(void) const {
|
||||
return num_monitor_devs_;
|
||||
}
|
||||
void set_init_options(uint64_t x) {
|
||||
init_options_ = x;
|
||||
}
|
||||
uint64_t init_options(void) const {
|
||||
return init_options_;
|
||||
}
|
||||
void set_num_iterations(uint32_t x) {
|
||||
num_iterations_ = x;
|
||||
}
|
||||
uint32_t num_iterations(void) const {
|
||||
return num_iterations_;
|
||||
}
|
||||
|
||||
protected:
|
||||
void MakeHeaderStr(const char *inStr, std::string *outStr) const;
|
||||
void PrintDeviceHeader(amdsmi_device_handle dv_ind);
|
||||
bool setup_failed_; ///< Record that setup failed to return ierr in Run
|
||||
uint32_t num_monitor_devs_; ///< Number of monitor devices found
|
||||
///< device handles
|
||||
amdsmi_device_handle device_handles_[MAX_MONITOR_DEVICES];
|
||||
uint32_t socket_count_; ///< socket count
|
||||
amdsmi_socket_handle* sockets_; ///< sockets
|
||||
|
||||
private:
|
||||
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
|
||||
uint64_t init_options_; ///< rsmi initialization options
|
||||
uint32_t num_iterations_;
|
||||
};
|
||||
|
||||
#define IF_VERB(VB) if (verbosity() && verbosity() >= (TestBase::VERBOSE_##VB))
|
||||
#define IF_NVERB(VB) if (verbosity() < (TestBase::VERBOSE_##VB))
|
||||
|
||||
// Macros to be used within TestBase classes
|
||||
#define CHK_ERR_ASRT(RET) { \
|
||||
if (dont_fail() && ((RET) != AMDSMI_STATUS_SUCCESS)) { \
|
||||
std::cout << std::endl << "\t===> TEST FAILURE." << std::endl; \
|
||||
DISPLAY_AMDSMI_ERR(RET); \
|
||||
std::cout << \
|
||||
"\t===> Abort is over-ridden due to dont_fail command line option." \
|
||||
<< std::endl; \
|
||||
return; \
|
||||
} else { \
|
||||
ASSERT_EQ(AMDSMI_STATUS_SUCCESS, (RET)); \
|
||||
} \
|
||||
}
|
||||
|
||||
void MakeHeaderStr(const char *inStr, std::string *outStr);
|
||||
extern const char kSetupLabel[];
|
||||
|
||||
#endif // TESTS_AMD_SMI_TEST_TEST_BASE_H_
|
||||
@@ -0,0 +1,314 @@
|
||||
/*
|
||||
* =============================================================================
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include "amd_smi_test/test_base.h"
|
||||
#include "amd_smi_test/test_common.h"
|
||||
#include "amd_smi.h"
|
||||
|
||||
static const std::map<amdsmi_dev_perf_level_t, const char *>
|
||||
kDevPerfLvlNameMap = {
|
||||
{AMDSMI_DEV_PERF_LEVEL_AUTO, "AMDSMI_DEV_PERF_LEVEL_AUTO"},
|
||||
{AMDSMI_DEV_PERF_LEVEL_LOW, "AMDSMI_DEV_PERF_LEVEL_LOW"},
|
||||
{AMDSMI_DEV_PERF_LEVEL_HIGH, "AMDSMI_DEV_PERF_LEVEL_HIGH"},
|
||||
{AMDSMI_DEV_PERF_LEVEL_MANUAL, "AMDSMI_DEV_PERF_LEVEL_MANUAL"},
|
||||
{AMDSMI_DEV_PERF_LEVEL_STABLE_STD, "AMDSMI_DEV_PERF_LEVEL_STABLE_STD"},
|
||||
{AMDSMI_DEV_PERF_LEVEL_STABLE_PEAK, "AMDSMI_DEV_PERF_LEVEL_STABLE_PEAK"},
|
||||
{AMDSMI_DEV_PERF_LEVEL_STABLE_MIN_MCLK,
|
||||
"AMDSMI_DEV_PERF_LEVEL_STABLE_MIN_MCLK"},
|
||||
{AMDSMI_DEV_PERF_LEVEL_STABLE_MIN_SCLK,
|
||||
"AMDSMI_DEV_PERF_LEVEL_STABLE_MIN_SCLK"},
|
||||
{AMDSMI_DEV_PERF_LEVEL_DETERMINISM, "AMDSMI_DEV_PERF_LEVEL_DETERMINISM"},
|
||||
|
||||
{AMDSMI_DEV_PERF_LEVEL_UNKNOWN, "AMDSMI_DEV_PERF_LEVEL_UNKNOWN"},
|
||||
};
|
||||
// If the assert below fails, the map above needs to be updated to match
|
||||
// amdsmi_dev_perf_level_t.
|
||||
static_assert(AMDSMI_DEV_PERF_LEVEL_LAST == AMDSMI_DEV_PERF_LEVEL_DETERMINISM,
|
||||
"kDevPerfLvlNameMap needs to be updated");
|
||||
|
||||
static const std::map<amdsmi_gpu_block_t, const char *> kBlockNameMap = {
|
||||
{AMDSMI_GPU_BLOCK_UMC, "UMC"},
|
||||
{AMDSMI_GPU_BLOCK_SDMA, "SDMA"},
|
||||
{AMDSMI_GPU_BLOCK_GFX, "GFX"},
|
||||
{AMDSMI_GPU_BLOCK_MMHUB, "MMHUB"},
|
||||
{AMDSMI_GPU_BLOCK_ATHUB, "ATHUB"},
|
||||
{AMDSMI_GPU_BLOCK_PCIE_BIF, "PCIE_BIF"},
|
||||
{AMDSMI_GPU_BLOCK_HDP, "HDP"},
|
||||
{AMDSMI_GPU_BLOCK_XGMI_WAFL, "XGMI_WAFL"},
|
||||
{AMDSMI_GPU_BLOCK_DF, "DF"},
|
||||
{AMDSMI_GPU_BLOCK_SMN, "SMN"},
|
||||
{AMDSMI_GPU_BLOCK_SEM, "SEM"},
|
||||
{AMDSMI_GPU_BLOCK_MP0, "MP0"},
|
||||
{AMDSMI_GPU_BLOCK_MP1, "MP1"},
|
||||
{AMDSMI_GPU_BLOCK_FUSE, "FUSE"},
|
||||
};
|
||||
static_assert(AMDSMI_GPU_BLOCK_LAST == AMDSMI_GPU_BLOCK_FUSE,
|
||||
"kBlockNameMap needs to be updated");
|
||||
|
||||
static const char * kRasErrStateStrings[] = {
|
||||
"None", // AMDSMI_RAS_ERR_STATE_NONE
|
||||
"Disabled", // AMDSMI_RAS_ERR_STATE_DISABLED
|
||||
"Error Unknown", // AMDSMI_RAS_ERR_STATE_PARITY
|
||||
"Single, Correctable", // AMDSMI_RAS_ERR_STATE_SING_C
|
||||
"Multiple, Uncorrectable", // AMDSMI_RAS_ERR_STATE_MULT_UC
|
||||
"Poison", // AMDSMI_RAS_ERR_STATE_POISON
|
||||
"Enabled", // AMDSMI_RAS_ERR_STATE_ENABLED
|
||||
};
|
||||
static_assert(
|
||||
sizeof(kRasErrStateStrings)/sizeof(char *) == (AMDSMI_RAS_ERR_STATE_LAST + 1),
|
||||
"kErrStateNameMap needs to be updated");
|
||||
|
||||
|
||||
static const std::map<amdsmi_ras_err_state_t, const char *> kErrStateNameMap = {
|
||||
{AMDSMI_RAS_ERR_STATE_NONE,
|
||||
kRasErrStateStrings[AMDSMI_RAS_ERR_STATE_NONE]},
|
||||
{AMDSMI_RAS_ERR_STATE_DISABLED,
|
||||
kRasErrStateStrings[AMDSMI_RAS_ERR_STATE_DISABLED]},
|
||||
{AMDSMI_RAS_ERR_STATE_PARITY,
|
||||
kRasErrStateStrings[AMDSMI_RAS_ERR_STATE_PARITY]},
|
||||
{AMDSMI_RAS_ERR_STATE_SING_C,
|
||||
kRasErrStateStrings[AMDSMI_RAS_ERR_STATE_SING_C]},
|
||||
{AMDSMI_RAS_ERR_STATE_MULT_UC,
|
||||
kRasErrStateStrings[AMDSMI_RAS_ERR_STATE_MULT_UC]},
|
||||
{AMDSMI_RAS_ERR_STATE_POISON,
|
||||
kRasErrStateStrings[AMDSMI_RAS_ERR_STATE_POISON]},
|
||||
{AMDSMI_RAS_ERR_STATE_ENABLED,
|
||||
kRasErrStateStrings[AMDSMI_RAS_ERR_STATE_ENABLED]},
|
||||
};
|
||||
static_assert(AMDSMI_RAS_ERR_STATE_LAST == AMDSMI_RAS_ERR_STATE_ENABLED,
|
||||
"kErrStateNameMap needs to be updated");
|
||||
|
||||
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'},
|
||||
{"amdsmitst_help", no_argument, nullptr, 'r'},
|
||||
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
static const char* short_options = "i:v:m:fr";
|
||||
|
||||
static const std::map<uint32_t, std::string> kVoltSensorNameMap = {
|
||||
{AMDSMI_VOLT_TYPE_VDDGFX, "Vddgfx"},
|
||||
};
|
||||
|
||||
static void PrintHelp(void) {
|
||||
std::cout <<
|
||||
"Optional amdsmitst 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"
|
||||
"--amdsmitst_help, -r print this help message\n"
|
||||
"--verbosity, -v <verbosity level>\n"
|
||||
" Verbosity levels:\n"
|
||||
" 0 -- minimal; just summary information\n"
|
||||
" 1 -- intermediate; show intermediate values such as intermediate "
|
||||
"perf. data\n"
|
||||
" 2 -- progress; show progress displays\n"
|
||||
" >= 3 -- more debug output\n";
|
||||
}
|
||||
|
||||
uint32_t ProcessCmdline(AMDSMITstGlobals* test, int arg_cnt, char** arg_list) {
|
||||
int a;
|
||||
int ind = -1;
|
||||
|
||||
assert(test != nullptr);
|
||||
|
||||
while (true) {
|
||||
a = getopt_long(arg_cnt, arg_list, short_options, long_options, &ind);
|
||||
|
||||
if (a == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
switch (a) {
|
||||
case 'i':
|
||||
test->num_iterations = std::stoi(optarg);
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
test->verbosity = std::stoi(optarg);
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
test->monitor_verbosity = std::stoi(optarg);
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
PrintHelp();
|
||||
return 1;
|
||||
|
||||
case 'f':
|
||||
test->dont_fail = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
std::cout << "Unknown command line option: \"" << a <<
|
||||
"\". Ignoring..." << std::endl;
|
||||
PrintHelp();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *GetPerfLevelStr(amdsmi_dev_perf_level_t lvl) {
|
||||
return kDevPerfLvlNameMap.at(lvl);
|
||||
}
|
||||
const char *GetBlockNameStr(amdsmi_gpu_block_t id) {
|
||||
return kBlockNameMap.at(id);
|
||||
}
|
||||
const char *GetErrStateNameStr(amdsmi_ras_err_state_t st) {
|
||||
return kErrStateNameMap.at(st);
|
||||
}
|
||||
const std::string GetVoltSensorNameStr(amdsmi_voltage_type_t st) {
|
||||
return kVoltSensorNameMap.at(st);
|
||||
}
|
||||
const char *FreqEnumToStr(amdsmi_clk_type amdsmi_clk) {
|
||||
static_assert(CLOCK_TYPE__MAX == CLOCK_TYPE_DCLK1,
|
||||
"FreqEnumToStr() needs to be updated");
|
||||
switch (amdsmi_clk) {
|
||||
case CLOCK_TYPE_SYS: return "System clock";
|
||||
case CLOCK_TYPE_DF: return "Data Fabric clock";
|
||||
case CLOCK_TYPE_DCEF: return "Display Controller Engine clock";
|
||||
case CLOCK_TYPE_SOC: return "SOC clock";
|
||||
case CLOCK_TYPE_MEM: return "Memory clock";
|
||||
default: return "Invalid Clock ID";
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLE_SMI
|
||||
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 =
|
||||
[&](amd::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 =
|
||||
[&](amd::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(amd::smi::kDevDevID, "Device ID: ");
|
||||
print_val_str(amd::smi::kDevPerfLevel, "Performance Level: ");
|
||||
print_val_str(amd::smi::kDevOverDriveLevel, "OverDrive Level: ");
|
||||
print_vector(amd::smi::kDevGPUMClk,
|
||||
"Supported GPU Memory clock frequencies:\n");
|
||||
print_vector(amd::smi::kDevGPUSClk,
|
||||
"Supported GPU clock frequencies:\n");
|
||||
|
||||
if (dev->monitor() != nullptr) {
|
||||
ret = dev->monitor()->readMonitor(amd::smi::kMonName, &val_str);
|
||||
if (print_attr_label("Monitor name: ")) {
|
||||
std::cout << val_str << std::endl;
|
||||
}
|
||||
|
||||
ret = dev->monitor()->readMonitor(amd::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(amd::smi::kMonMaxFanSpeed, &value);
|
||||
if (ret == 0) {
|
||||
ret = dev->monitor()->readMonitor(amd::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;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* =============================================================================
|
||||
* ROC Runtime Conformance Release License
|
||||
* =============================================================================
|
||||
* The University of Illinois/NCSA
|
||||
* Open Source License (NCSA)
|
||||
*
|
||||
* Copyright (c) 2018, Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Developed by:
|
||||
*
|
||||
* AMD Research and AMD ROC Software Development
|
||||
*
|
||||
* Advanced Micro Devices, Inc.
|
||||
*
|
||||
* www.amd.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal with the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimers.
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimers in
|
||||
* the documentation and/or other materials provided with the distribution.
|
||||
* - Neither the names of <Name of Development Group, Name of Institution>,
|
||||
* nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this Software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS WITH THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TESTS_AMD_SMI_TEST_TEST_COMMON_H_
|
||||
#define TESTS_AMD_SMI_TEST_TEST_COMMON_H_
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "amd_smi.h"
|
||||
|
||||
struct AMDSMITstGlobals {
|
||||
uint32_t verbosity;
|
||||
uint32_t monitor_verbosity;
|
||||
uint32_t num_iterations;
|
||||
uint64_t init_options;
|
||||
bool dont_fail;
|
||||
};
|
||||
|
||||
uint32_t ProcessCmdline(AMDSMITstGlobals* test, int arg_cnt, char** arg_list);
|
||||
|
||||
void PrintTestHeader(uint32_t dv_ind);
|
||||
const char *GetPerfLevelStr(amdsmi_dev_perf_level_t lvl);
|
||||
const char *GetBlockNameStr(amdsmi_gpu_block_t id);
|
||||
const char *GetErrStateNameStr(amdsmi_ras_err_state_t st);
|
||||
const char *FreqEnumToStr(amdsmi_clk_type amdsmi_clk);
|
||||
const std::string GetVoltSensorNameStr(amdsmi_voltage_type_t st);
|
||||
|
||||
#if ENABLE_SMI
|
||||
void DumpMonitorInfo(const TestBase *test);
|
||||
#endif
|
||||
|
||||
#define DISPLAY_AMDSMI_ERR(RET) { \
|
||||
if (RET != AMDSMI_STATUS_SUCCESS) { \
|
||||
const char *err_str; \
|
||||
std::cout << "\t===> ERROR: AMDSMI call returned " << (RET) << std::endl; \
|
||||
amdsmi_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_AMDSMI_ERR(RET) \
|
||||
if ((RET) != AMDSMI_STATUS_SUCCESS) { \
|
||||
return (RET); \
|
||||
} \
|
||||
}
|
||||
#define CHK_AMDSMI_PERM_ERR(RET) { \
|
||||
if (RET == AMDSMI_STATUS_PERMISSION) { \
|
||||
std::cout << "This command requires root access." << std::endl; \
|
||||
} else { \
|
||||
DISPLAY_AMDSMI_ERR(RET) \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif // TESTS_AMD_SMI_TEST_TEST_COMMON_H_
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* =============================================================================
|
||||
* ROC Runtime Conformance Release License
|
||||
* =============================================================================
|
||||
* The University of Illinois/NCSA
|
||||
* Open Source License (NCSA)
|
||||
*
|
||||
* Copyright (c) 2019, Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Developed by:
|
||||
*
|
||||
* AMD Research and AMD ROC Software Development
|
||||
*
|
||||
* Advanced Micro Devices, Inc.
|
||||
*
|
||||
* www.amd.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal with the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimers.
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimers in
|
||||
* the documentation and/or other materials provided with the distribution.
|
||||
* - Neither the names of <Name of Development Group, Name of Institution>,
|
||||
* nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this Software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS WITH THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "amd_smi.h"
|
||||
#include "amd_smi_test/test_utils.h"
|
||||
|
||||
static const std::map<amdsmi_fw_block_t, const char *> kDevFWNameMap = {
|
||||
{FW_ID_ASD, "asd"},
|
||||
{FW_ID_CP_CE, "ce"},
|
||||
{FW_ID_DMCU_ERAM, "dmcu"}, // TODO(bliu): double check
|
||||
{FW_ID_MC, "mc"},
|
||||
{FW_ID_CP_ME, "me"},
|
||||
{FW_ID_CP_MEC1, "mec1"},
|
||||
{FW_ID_CP_MEC2, "mec2"},
|
||||
{FW_ID_CP_PFP, "pfp"},
|
||||
{FW_ID_RLC, "rlc"},
|
||||
{FW_ID_RLC_SRLG, "rlc_srlg"},
|
||||
{FW_ID_RLC_SRLS, "rlc_srls"},
|
||||
{FW_ID_SDMA1, "sdma1"},
|
||||
{FW_ID_SDMA2, "sdma2"},
|
||||
{FW_ID_SMC, "smc"},
|
||||
{FW_ID_PSP_SOSDRV, "sos"},
|
||||
{FW_ID_TA_RAS, "ta_ras"},
|
||||
{FW_ID_XGMI, "ta_xgmi"},
|
||||
{FW_ID_UVD, "uvd"},
|
||||
{FW_ID_VCE, "vce"},
|
||||
{FW_ID_VCN, "vcn"},
|
||||
};
|
||||
|
||||
const char *
|
||||
NameFromFWEnum(amdsmi_fw_block_t blk) {
|
||||
return kDevFWNameMap.at(blk);
|
||||
}
|
||||
|
||||
static const std::map<amdsmi_evt_notification_type_t, const char *>
|
||||
kEvtNotifEvntNameMap = {
|
||||
{AMDSMI_EVT_NOTIF_VMFAULT, "AMDSMI_EVT_NOTIF_VMFAULT"},
|
||||
{AMDSMI_EVT_NOTIF_THERMAL_THROTTLE, "AMDSMI_EVT_NOTIF_THERMAL_THROTTLE"},
|
||||
{AMDSMI_EVT_NOTIF_GPU_PRE_RESET, "AMDSMI_EVT_NOTIF_GPU_PRE_RESET"},
|
||||
{AMDSMI_EVT_NOTIF_GPU_POST_RESET, "AMDSMI_EVT_NOTIF_GPU_POST_RESET"},
|
||||
};
|
||||
const char *
|
||||
NameFromEvtNotifType(amdsmi_evt_notification_type_t evt) {
|
||||
return kEvtNotifEvntNameMap.at(evt);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* =============================================================================
|
||||
* ROC Runtime Conformance Release License
|
||||
* =============================================================================
|
||||
* The University of Illinois/NCSA
|
||||
* Open Source License (NCSA)
|
||||
*
|
||||
* Copyright (c) 2019, Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Developed by:
|
||||
*
|
||||
* AMD Research and AMD ROC Software Development
|
||||
*
|
||||
* Advanced Micro Devices, Inc.
|
||||
*
|
||||
* www.amd.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal with the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimers.
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimers in
|
||||
* the documentation and/or other materials provided with the distribution.
|
||||
* - Neither the names of <Name of Development Group, Name of Institution>,
|
||||
* nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this Software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS WITH THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TESTS_AMD_SMI_TEST_TEST_UTILS_H_
|
||||
#define TESTS_AMD_SMI_TEST_TEST_UTILS_H_
|
||||
|
||||
#include "amd_smi.h"
|
||||
|
||||
const char *
|
||||
NameFromFWEnum(amdsmi_fw_block_t blk);
|
||||
const char *
|
||||
NameFromEvtNotifType(amdsmi_evt_notification_type_t evt);
|
||||
|
||||
#endif // TESTS_AMD_SMI_TEST_TEST_UTILS_H_
|
||||
مرجع در شماره جدید
Block a user