From febbffb50845c2ac0bbb1988ec2c9d40ef1d785d Mon Sep 17 00:00:00 2001 From: "Bill(Shuzhou) Liu" Date: Tue, 26 Sep 2023 10:26:06 -0500 Subject: [PATCH 1/6] Do not print the library name if in default folder The rocm-smi python tool will not print the library name on default folder. Change-Id: I203a872ebe2fc994766a2628049ca50c8bfa7120 [ROCm/amdsmi commit: 016dbf8aa3cc61af4efe55b13cfb674a828d9e04] --- projects/amdsmi/python_smi_tools/rsmiBindings.py.in | 2 -- 1 file changed, 2 deletions(-) diff --git a/projects/amdsmi/python_smi_tools/rsmiBindings.py.in b/projects/amdsmi/python_smi_tools/rsmiBindings.py.in index 36dbb6e5ff..87c32a8fc9 100644 --- a/projects/amdsmi/python_smi_tools/rsmiBindings.py.in +++ b/projects/amdsmi/python_smi_tools/rsmiBindings.py.in @@ -37,8 +37,6 @@ def initRsmiBindings(silent=False): print_silent('Using lib from %s' % path_librocm) else: print('Unable to find librocm_smi64.so.@VERSION_MAJOR@') - else: - print_silent('Library loaded from: %s ' % path_librocm) # ----------> TODO: Support static libs as well as SO try: From 406c11f567ab8119a2fe9a0cb4cf05c2acde6b5e Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Wed, 27 Sep 2023 17:47:59 -0500 Subject: [PATCH 2/6] Upgrade to CXX-17 gtest-1.14 and cmake-3.14 Also change the TARGET from amd_smi_libraries to rocm_smi_libraries This helps reduce confusion between rocm-smi and amd-smi Change-Id: Ie54cedd831ba24bd9afc341ad15b7e8e20732059 Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: cf6bcbbb275f652796228f8213e80b9bd02e9218] --- projects/amdsmi/CMakeLists.txt | 24 +++++++------ .../amdsmi/tests/rocm_smi_test/CMakeLists.txt | 35 ++++++++----------- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/projects/amdsmi/CMakeLists.txt b/projects/amdsmi/CMakeLists.txt index dd4c5d53f2..a16e48ba7f 100755 --- a/projects/amdsmi/CMakeLists.txt +++ b/projects/amdsmi/CMakeLists.txt @@ -1,11 +1,11 @@ # -# Minimum version of cmake required +# Minimum version of cmake and C++ required # -cmake_minimum_required(VERSION 3.6.3) +cmake_minimum_required(VERSION 3.14) -set(AMD_SMI_LIBS_TARGET "amd_smi_libraries") +set(ROCM_SMI_LIBS_TARGET "rocm_smi_libraries") -set ( BUILD_SHARED_LIBS ON CACHE BOOL "Build shared library (.so) or not.") +set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared library (.so) or not.") ## Set default module path if not already set if(NOT DEFINED CMAKE_MODULE_PATH) @@ -37,10 +37,10 @@ find_program (GIT NAMES git) set(PKG_VERSION_GIT_TAG_PREFIX "rsmi_pkg_ver") get_package_version_number("5.0.0" ${PKG_VERSION_GIT_TAG_PREFIX} GIT) message("Package version: ${PKG_VERSION_STR}") -set(${AMD_SMI_LIBS_TARGET}_VERSION_MAJOR "${VERSION_MAJOR}") -set(${AMD_SMI_LIBS_TARGET}_VERSION_MINOR "${VERSION_MINOR}") -set(${AMD_SMI_LIBS_TARGET}_VERSION_PATCH "0") -set(${AMD_SMI_LIBS_TARGET}_VERSION_BUILD "0") +set(${ROCM_SMI_LIBS_TARGET}_VERSION_MAJOR "${VERSION_MAJOR}") +set(${ROCM_SMI_LIBS_TARGET}_VERSION_MINOR "${VERSION_MINOR}") +set(${ROCM_SMI_LIBS_TARGET}_VERSION_PATCH "0") +set(${ROCM_SMI_LIBS_TARGET}_VERSION_BUILD "0") # The following default version values should be updated as appropriate for # ABI breaks (update MAJOR and MINOR), and ABI/API additions (update MINOR). @@ -57,7 +57,9 @@ set(CMAKE_INSTALL_PREFIX "/opt/rocm" CACHE STRING "Default installation director set(COMMON_SRC_ROOT ${CMAKE_CURRENT_SOURCE_DIR} CACHE STRING "Location source code common root.") set(ROCM_SMI_PACKAGE rocm-smi-lib) -project(${AMD_SMI_LIBS_TARGET}) +project(${ROCM_SMI_LIBS_TARGET}) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) include(GNUInstallDirs) set(COMMON_PROJ_ROOT ${PROJECT_SOURCE_DIR}) @@ -70,7 +72,7 @@ endif() ## Compiler flags set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-rtti -m64 -msse -msse2 -std=c++11 ") + "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-rtti -m64 -msse -msse2 ") # Security options set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wconversion -Wcast-align ") @@ -78,7 +80,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat=2 -fno-common -Wstrict-overflow ") # Intentionally leave out -Wsign-promo. It causes spurious warnings. set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -Woverloaded-virtual -Wreorder ") + "${CMAKE_CXX_FLAGS} -Woverloaded-virtual -Wreorder ") # Clang does not set the build-id if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") diff --git a/projects/amdsmi/tests/rocm_smi_test/CMakeLists.txt b/projects/amdsmi/tests/rocm_smi_test/CMakeLists.txt index efdbe96469..2253327813 100755 --- a/projects/amdsmi/tests/rocm_smi_test/CMakeLists.txt +++ b/projects/amdsmi/tests/rocm_smi_test/CMakeLists.txt @@ -36,24 +36,13 @@ set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} ${RSMITST_RPATH}) -# TODO: Try to find googletest -# DISABLED because we want to install gtest with rocm_smi_lib ourselves -#find_package(GTest 1.12.0) - -# GTest_FOUND is set to TRUE if ANY version is found -# GTest_VERSION is set if 1.12.0 or newer version is found -if(NOT GTest_FOUND STREQUAL "TRUE" OR NOT DEFINED GTest_VERSION) - # Google Test wasn't found. Download and compile ourselves - include(FetchContent) - FetchContent_Declare( - googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG release-1.12.0) - FetchContent_MakeAvailable(googletest) - install(TARGETS gtest gtest_main - DESTINATION ${SHARE_INSTALL_PREFIX}/rsmitst_tests - COMPONENT ${TESTS_COMPONENT}) -endif() +# Download and compile googletest +include(FetchContent) +FetchContent_Declare( + googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG v1.14.0) +FetchContent_MakeAvailable(googletest) # Other source directories aux_source_directory(${SRC_DIR}/functional functionalSources) @@ -70,13 +59,13 @@ target_include_directories(${RSMITST} PUBLIC ${SRC_DIR}/..) target_link_libraries( ${RSMITST} PUBLIC ${ROCM_SMI_TARGET} - PUBLIC gtest - PUBLIC gtest_main + PUBLIC GTest::gtest_main PUBLIC c PUBLIC stdc++ PUBLIC pthread PUBLIC dl) +# install tests install(TARGETS ${RSMITST} DESTINATION ${SHARE_INSTALL_PREFIX}/rsmitst_tests COMPONENT ${TESTS_COMPONENT}) @@ -84,3 +73,9 @@ install(TARGETS ${RSMITST} install(FILES rsmitst.exclude DESTINATION ${SHARE_INSTALL_PREFIX}/rsmitst_tests COMPONENT ${TESTS_COMPONENT}) + +# install googletest libraries with tests +install(TARGETS gtest gtest_main + DESTINATION ${SHARE_INSTALL_PREFIX}/rsmitst_tests + COMPONENT ${TESTS_COMPONENT}) + From a57b146e565b79b370d4349c93bd2884093cc111 Mon Sep 17 00:00:00 2001 From: Ori Messinger Date: Wed, 27 Sep 2023 12:38:15 -0400 Subject: [PATCH 3/6] ROCm SMI CLI: Add Missing Firmware Blocks The purpose of this patch is to add the following missing firmware blocks to the SMI CLI: -RSMI_FW_BLOCK_MES -RSMI_FW_BLOCK_MES_KIQ Signed-off-by: Ori Messinger Change-Id: If9cabdc60ffcf08f27c9e6bdc20e8a26b192a738 [ROCm/amdsmi commit: aa89f2e125c80af5cdd35b58fe5f47cfdf120ada] --- projects/amdsmi/python_smi_tools/rocm_smi.py | 2 +- .../python_smi_tools/rsmiBindings.py.in | 32 ++++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/projects/amdsmi/python_smi_tools/rocm_smi.py b/projects/amdsmi/python_smi_tools/rocm_smi.py index 6f7ba1a8e0..ddead08f83 100755 --- a/projects/amdsmi/python_smi_tools/rocm_smi.py +++ b/projects/amdsmi/python_smi_tools/rocm_smi.py @@ -2052,7 +2052,7 @@ def showFwInfo(deviceList, fwType): ret = rocmsmi.rsmi_dev_firmware_version_get(device, fw_block_names_l.index(fw_name), byref(fw_ver)) if rsmi_ret_ok(ret, device, 'get_firmware_version_' + str(fw_name)): # The VCN, VCE, UVD, SOS and ASD firmware's value needs to be in hexadecimal - if fw_name in ['VCN', 'VCE', 'UVD', 'SOS', 'ASD']: + if fw_name in ['VCN', 'VCE', 'UVD', 'SOS', 'ASD', 'MES', 'MES KIQ']: printLog(device, '%s firmware version' % (fw_name), '\t0x%s' % (str(hex(fw_ver.value))[2:].zfill(8))) # The TA XGMI, TA RAS, and SMC firmware's hex value looks like 0x12345678 diff --git a/projects/amdsmi/python_smi_tools/rsmiBindings.py.in b/projects/amdsmi/python_smi_tools/rsmiBindings.py.in index 87c32a8fc9..f913d99936 100644 --- a/projects/amdsmi/python_smi_tools/rsmiBindings.py.in +++ b/projects/amdsmi/python_smi_tools/rsmiBindings.py.in @@ -417,25 +417,27 @@ class rsmi_fw_block_t(c_int): RSMI_FW_BLOCK_ME = 4 RSMI_FW_BLOCK_MEC = 5 RSMI_FW_BLOCK_MEC2 = 6 - RSMI_FW_BLOCK_PFP = 7 - RSMI_FW_BLOCK_RLC = 8 - RSMI_FW_BLOCK_RLC_SRLC = 9 - RSMI_FW_BLOCK_RLC_SRLG = 10 - RSMI_FW_BLOCK_RLC_SRLS = 11 - RSMI_FW_BLOCK_SDMA = 12 - RSMI_FW_BLOCK_SDMA2 = 13 - RSMI_FW_BLOCK_SMC = 14 - RSMI_FW_BLOCK_SOS = 15 - RSMI_FW_BLOCK_TA_RAS = 16 - RSMI_FW_BLOCK_TA_XGMI = 17 - RSMI_FW_BLOCK_UVD = 18 - RSMI_FW_BLOCK_VCE = 19 - RSMI_FW_BLOCK_VCN = 20 + RSMI_FW_BLOCK_MES = 7 + RSMI_FW_BLOCK_MES_KIQ = 8 + RSMI_FW_BLOCK_PFP = 9 + RSMI_FW_BLOCK_RLC = 10 + RSMI_FW_BLOCK_RLC_SRLC = 11 + RSMI_FW_BLOCK_RLC_SRLG = 12 + RSMI_FW_BLOCK_RLC_SRLS = 13 + RSMI_FW_BLOCK_SDMA = 14 + RSMI_FW_BLOCK_SDMA2 = 15 + RSMI_FW_BLOCK_SMC = 16 + RSMI_FW_BLOCK_SOS = 17 + RSMI_FW_BLOCK_TA_RAS = 18 + RSMI_FW_BLOCK_TA_XGMI = 19 + RSMI_FW_BLOCK_UVD = 20 + RSMI_FW_BLOCK_VCE = 21 + RSMI_FW_BLOCK_VCN = 22 RSMI_FW_BLOCK_LAST = RSMI_FW_BLOCK_VCN # The following list correlated to the rsmi_fw_block_t -fw_block_names_l = ['ASD', 'CE', 'DMCU', 'MC', 'ME', 'MEC', 'MEC2', 'PFP',\ +fw_block_names_l = ['ASD', 'CE', 'DMCU', 'MC', 'ME', 'MEC', 'MEC2', 'MES', 'MES KIQ', 'PFP',\ 'RLC', 'RLC SRLC', 'RLC SRLG', 'RLC SRLS', 'SDMA', 'SDMA2',\ 'SMC', 'SOS', 'TA RAS', 'TA XGMI', 'UVD', 'VCE', 'VCN'] From 0d22f058c0b56eb1956bbdec962f704273953a1c Mon Sep 17 00:00:00 2001 From: "Bill(Shuzhou) Liu" Date: Mon, 2 Oct 2023 09:19:12 -0500 Subject: [PATCH 4/6] rocm-smi shows wrong fwinfo Add new fw block into the rocm-smi tool. Change-Id: Id5c7ccc2fc491f7e5d0390aeb4c6f81fd12fa644 [ROCm/amdsmi commit: d665157cd17dcb82a8787dbf179b0c3a5b2ddfbb] From 40bc553d069989c3a130ae998575af0d86a0dff4 Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Mon, 2 Oct 2023 17:57:02 -0500 Subject: [PATCH 5/6] Add --version to CLI Change-Id: Id2a8f10f544ed04e874db773820534eddd73f55d Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: d862bee754ad23d65ac1405ae3a40e5dceef80d2] --- projects/amdsmi/cmake_modules/utils.cmake | 2 +- projects/amdsmi/python_smi_tools/rocm_smi.py | 41 ++++++++++++++++++-- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/projects/amdsmi/cmake_modules/utils.cmake b/projects/amdsmi/cmake_modules/utils.cmake index 76f910a20b..afaa442e59 100755 --- a/projects/amdsmi/cmake_modules/utils.cmake +++ b/projects/amdsmi/cmake_modules/utils.cmake @@ -52,7 +52,7 @@ function( parse_version VERSION_STRING ) string ( SUBSTRING ${VERSION_STRING} ${STRING_INDEX} -1 VERSION_BUILD ) endif () - string ( REGEX MATCHALL "[0123456789]+" VERSIONS ${VERSION_STRING} ) + string ( REGEX MATCHALL "[0-9]+" VERSIONS ${VERSION_STRING} ) list ( LENGTH VERSIONS VERSION_COUNT ) if ( ${VERSION_COUNT} GREATER 0) diff --git a/projects/amdsmi/python_smi_tools/rocm_smi.py b/projects/amdsmi/python_smi_tools/rocm_smi.py index ddead08f83..8db2d7eeea 100755 --- a/projects/amdsmi/python_smi_tools/rocm_smi.py +++ b/projects/amdsmi/python_smi_tools/rocm_smi.py @@ -30,8 +30,8 @@ from rsmiBindings import * # Minor version - Increment when adding a new feature, set to 0 when major is incremented # Patch version - Increment when adding a fix, set to 0 when minor is incremented SMI_MAJ = 1 -SMI_MIN = 4 -SMI_PAT = 1 +SMI_MIN = 5 +SMI_PAT = 0 __version__ = '%s.%s.%s' % (SMI_MAJ, SMI_MIN, SMI_PAT) # Set to 1 if an error occurs @@ -1675,6 +1675,32 @@ def setNPSMode(deviceList, npsMode): printErrLog(device, 'Failed to retrieve NPS mode, even though device supports it.') printLogSpacer() +def showVersion(isCSV=False): + values = { 'ROCM-SMI version': __version__ } + + version = rsmi_version_t() + status = rocmsmi.rsmi_version_get(byref(version)) + if status == 0: + version_string = "%u.%u.%u" % (version.major, version.minor, version.patch) + values['ROCM-SMI-LIB version'] = version_string + + if isCSV: + print('name, value') + for k in values.keys(): + print('%s, %s' % (k, values[k])) + return + if PRINT_JSON: + temp_str = '{\n' + for k in values.keys(): + temp_str += ' "%s": "%s",\n' % (k, values[k]) + if len(values.keys()) > 1: + # replace ',\n' with '\n}' + temp_str = temp_str[:-2] + temp_str += '\n}' + print(temp_str) + return + for k in values.keys(): + print('%s: %s' % (k, values[k])) def showAllConcise(deviceList): """ Display critical info for all devices in a concise format @@ -2955,7 +2981,7 @@ def showTempGraph(deviceList): printLogSpacer() -def showVersion(deviceList, component): +def showDriverVersion(deviceList, component): """ Display the software version for the specified component @param deviceList: List of DRM devices (can be a single-item list) @@ -3614,6 +3640,7 @@ if __name__ == '__main__': parser = argparse.ArgumentParser( description='AMD ROCm System Management Interface | ROCM-SMI version: %s' % __version__, formatter_class=lambda prog: argparse.HelpFormatter(prog, max_help_position=90, width=120)) + groupVersion = parser.add_argument_group() groupDev = parser.add_argument_group() groupDisplayOpt = parser.add_argument_group('Display Options') groupDisplayTop = parser.add_argument_group('Topology') @@ -3627,6 +3654,7 @@ if __name__ == '__main__': groupResponse = parser.add_argument_group('Auto-response options') groupActionOutput = parser.add_argument_group('Output options') + groupVersion.add_argument('-V', '--version', help='Show version information', action='store_true') groupDev.add_argument('-d', '--device', help='Execute command on specified device', type=int, nargs='+') groupDisplayOpt.add_argument('--alldevices', action='store_true') # ------------- function deprecated, no help menu groupDisplayOpt.add_argument('--showhw', help='Show Hardware details', action='store_true') @@ -3775,11 +3803,16 @@ if __name__ == '__main__': # Must set PRINT_JSON early so the prints can be silenced if args.json or args.csv: PRINT_JSON = True + # Initialize rsmiBindings rocmsmi = initRsmiBindings(silent=PRINT_JSON) # Initialize the rocm SMI library initializeRsmi() + if args.version: + showVersion(isCSV=args.csv) + sys.exit() + logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.WARNING) if args.loglevel is not None: numericLogLevel = getattr(logging, args.loglevel.upper(), logging.WARNING) @@ -3878,7 +3911,7 @@ if __name__ == '__main__': if args.showhw: showAllConciseHw(deviceList) if args.showdriverversion: - showVersion(deviceList, rsmi_sw_component_t.RSMI_SW_COMP_DRIVER) + showDriverVersion(deviceList, rsmi_sw_component_t.RSMI_SW_COMP_DRIVER) if args.showtempgraph: showTempGraph(deviceList) if args.showid: From bbe4ff9139a5a7a89f12b7fb27e7c53666ecd62d Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Wed, 4 Oct 2023 13:47:36 -0500 Subject: [PATCH 6/6] TESTS - Don't fail on TestFrequenciesRead - Return from freq_output function early if clock is unsupported - Right-align frequencies Change-Id: I799c9351dac8a5be161bc9243cd3816539728357 Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: e962d3b2815a1d0706cf4fe51e23aa87b8d1b7f6] --- .../functional/frequencies_read.cc | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read.cc b/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read.cc index 37bb9ec0b2..5b956e9951 100755 --- a/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read.cc +++ b/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read.cc @@ -43,9 +43,7 @@ * */ -#include -#include - +#include #include #include @@ -87,15 +85,23 @@ void TestFrequenciesRead::Close() { static void print_frequencies(rsmi_frequencies_t *f, uint32_t *l = nullptr) { assert(f != nullptr); - for (uint32_t j = 0; j < f->num_supported; ++j) { - std::cout << "\t** " << j << ": " << f->frequency[j]; + for (uint32_t clk_i = 0; clk_i < f->num_supported; ++clk_i) { + std::string clk_i_str; + if (f->has_deep_sleep) { + clk_i_str = (clk_i == 0) ? "S" : std::to_string(clk_i-1); + } else { + clk_i_str = std::to_string(clk_i); + } + std::cout << "\t** " << + std::setw(2) << std::right << clk_i_str << ": " << + std::setw(11) << std::right << f->frequency[clk_i]; if (l != nullptr) { - std::cout << "T/s; x" << l[j]; + std::cout << "T/s; x" << l[clk_i]; } else { std::cout << "Hz"; } - if (j == f->current) { + if (clk_i == f->current) { std::cout << " *"; } std::cout << std::endl; @@ -123,12 +129,14 @@ void TestFrequenciesRead::Run(void) { // Verify api support checking functionality is working err = rsmi_dev_gpu_clk_freq_get(i, t, nullptr); ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); + return; } // special driver issue, shouldn't normally occur if (err == RSMI_STATUS_UNEXPECTED_DATA) { std::cerr << "WARN: Clock file [" << FreqEnumToStr(t) << "] exists on device [" << i << "] but empty!" << std::endl; std::cerr << " Likely a driver issue!" << std::endl; + return; } CHK_ERR_ASRT(err) @@ -158,15 +166,15 @@ void TestFrequenciesRead::Run(void) { err = rsmi_dev_pci_bandwidth_get(i, nullptr); ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); } else { - CHK_ERR_ASRT(err) - IF_VERB(STANDARD) { - std::cout << "\t**Supported PCIe bandwidths: "; - std::cout << b.transfer_rate.num_supported << std::endl; - print_frequencies(&b.transfer_rate, b.lanes); - // Verify api support checking functionality is working - err = rsmi_dev_pci_bandwidth_get(i, nullptr); - ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); - } + CHK_ERR_ASRT(err) + IF_VERB(STANDARD) { + std::cout << "\t**Supported PCIe bandwidths: "; + std::cout << b.transfer_rate.num_supported << std::endl; + print_frequencies(&b.transfer_rate, b.lanes); + // Verify api support checking functionality is working + err = rsmi_dev_pci_bandwidth_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); + } } } }