From 1a86dd75bbb2561335a8e900ad9711dd5ed9b8db Mon Sep 17 00:00:00 2001 From: Jeremy Newton Date: Fri, 23 Jun 2023 13:54:01 -0400 Subject: [PATCH 1/6] Fix version file generation This looks like a typo, as the following variables are not defined: - AMD_SMI_LIBS_TARGET_VERSION_MAJOR - AMD_SMI_LIBS_TARGET_VERSION_MINOR - AMD_SMI_LIBS_TARGET_VERSION_PATCH Change-Id: I43449e7bd2a2de643d33e79fad063a7859679c8d Signed-off-by: Jeremy Newton --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 967033d294..b0b1dce1d8 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,7 +232,7 @@ configure_package_config_file( write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/rocm_smi-config-version.cmake - VERSION "${AMD_SMI_LIBS_TARGET_VERSION_MAJOR}.${AMD_SMI_LIBS_TARGET_VERSION_MINOR}.${AMD_SMI_LIBS_TARGET_VERSION_PATCH}" + VERSION "${${AMD_SMI_LIBS_TARGET}_VERSION_MAJOR}.${${AMD_SMI_LIBS_TARGET}_VERSION_MINOR}.${${AMD_SMI_LIBS_TARGET}_VERSION_PATCH}" COMPATIBILITY SameMajorVersion ) @@ -247,7 +247,7 @@ install( # Create cmake target # Add all targets to the build-tree export set export(TARGETS ${ROCM_SMI_TARGET} ${OAM_TARGET} - FILE "${PROJECT_BINARY_DIR}/rcom_smi_target.cmake") + FILE "${PROJECT_BINARY_DIR}/rocm_smi_target.cmake") # Export the package for use from the build-tree # (this registers the build-tree with a global CMake-registry) From 74dc98114ff563a5bd5118b7d301e0262972a4ac Mon Sep 17 00:00:00 2001 From: Jeremy Newton Date: Thu, 29 Jun 2023 13:19:58 -0400 Subject: [PATCH 2/6] Update default version to match tags When building from github, these tags don't exist, so the defaults should try to match the internal tags Change-Id: Id570341f27e21916b1a7f3605ee2b5b9716cad9b Signed-off-by: Jeremy Newton --- CMakeLists.txt | 2 +- rocm_smi/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0b1dce1d8..e97bdbae08 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ find_program (GIT NAMES git) ## Setup the package version based on git tags. set(PKG_VERSION_GIT_TAG_PREFIX "rsmi_pkg_ver") -get_package_version_number("1.0.0" ${PKG_VERSION_GIT_TAG_PREFIX} GIT) +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}") diff --git a/rocm_smi/CMakeLists.txt b/rocm_smi/CMakeLists.txt index f9b7c4181a..30e2249332 100755 --- a/rocm_smi/CMakeLists.txt +++ b/rocm_smi/CMakeLists.txt @@ -39,7 +39,7 @@ message("Package version: ${PKG_VERSION_STR}") # Debian package specific variables # Set a default value for the package version -get_version_from_tag("1.0.0.0" ${SO_VERSION_GIT_TAG_PREFIX} GIT) +get_version_from_tag("5.0.0.0" ${SO_VERSION_GIT_TAG_PREFIX} GIT) # VERSION_* variables should be set by get_version_from_tag if ( ${ROCM_PATCH_VERSION} ) From 19c3e2aff93dfb23e91e10de9620254767862af3 Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Sat, 24 Jun 2023 06:27:18 -0700 Subject: [PATCH 3/6] Improve handling of ContructBDFID errors Building on this package on Fedora reports this warning In file included from rpmbuild/BUILD/rocm_smi_lib-rocm-5.5.1/src/rocm_smi_main.cc:62: In member function 'amd::smi::Device::set_bdfid(unsigned long)', inlined from 'amd::smi::RocmSMI::Initialize(unsigned long)' at rpmbuild/BUILD/rocm_smi_lib-rocm-5.5.1/src/rocm_smi_main.cc:330:27: rpmbuild/BUILD/rocm_smi_lib-rocm-5.5.1/include/rocm_smi/rocm_smi_device.h:199:42: warning: 'bdfid' may be used uninitialized [-Wmaybe-uninitialized] 199 | void set_bdfid(uint64_t val) {bdfid_ = val;} | ~~~~~~~^~~~~ rpmbuild/BUILD/rocm_smi_lib-rocm-5.5.1/src/rocm_smi_main.cc: In member function 'amd::smi::RocmSMI::Initialize(unsigned long)': rpmbuild/BUILD/rocm_smi_lib-rocm-5.5.1/src/rocm_smi_main.cc:324:12: note: 'bdfid' was declared here 324 | uint64_t bdfid; | ^~~~~ Only set the bdfid when it is know to be valid. Signed-off-by: Tom Rix Change-Id: I839b4d2d2d4e3b25469cf5972245b9630da00c87 --- src/rocm_smi_main.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rocm_smi_main.cc b/src/rocm_smi_main.cc index 72b0d5d5f6..3a5565dbe9 100755 --- a/src/rocm_smi_main.cc +++ b/src/rocm_smi_main.cc @@ -345,8 +345,9 @@ RocmSMI::Initialize(uint64_t flags) { if (ConstructBDFID(devices_[i]->path(), &bdfid) != 0) { std::cerr << "Failed to construct BDFID." << std::endl; ret = 1; + } else { + devices_[i]->set_bdfid(bdfid); } - devices_[i]->set_bdfid(bdfid); } if (ret != 0) { throw amd::smi::rsmi_exception(RSMI_INITIALIZATION_ERROR, From 4f481dd7f35c433258c312dc922f1d4c95bb3911 Mon Sep 17 00:00:00 2001 From: Jeremy Newton Date: Fri, 30 Jun 2023 12:18:05 -0400 Subject: [PATCH 4/6] Actually fix version string There seems to be a scope issue with the existing variables, but just putting in the pkg version string seems sufficient. Change-Id: I4ccef872ff848a70cb2abc07bf605c5f29a608e8 Signed-off-by: Jeremy Newton --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e97bdbae08..a535f72510 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,7 +232,7 @@ configure_package_config_file( write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/rocm_smi-config-version.cmake - VERSION "${${AMD_SMI_LIBS_TARGET}_VERSION_MAJOR}.${${AMD_SMI_LIBS_TARGET}_VERSION_MINOR}.${${AMD_SMI_LIBS_TARGET}_VERSION_PATCH}" + VERSION "${PKG_VERSION_STR}" COMPATIBILITY SameMajorVersion ) From 828f46b44583bea791df2ce580141d9a0259e5b6 Mon Sep 17 00:00:00 2001 From: Jeremy Newton Date: Fri, 30 Jun 2023 11:24:54 -0400 Subject: [PATCH 5/6] Only install asan license if enabled Change-Id: I79c6fce84c23ed12e65db8e234a29dbfedd11f68 Signed-off-by: Jeremy Newton --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a535f72510..4199ef556f 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -262,9 +262,11 @@ install(EXPORT rocm_smiTargets #License file set(CPACK_RPM_PACKAGE_LICENSE "NCSA") # install license file in share/doc/rocm_smi-asan folder -install(FILES ${CPACK_RESOURCE_FILE_LICENSE} +if( ENABLE_ASAN_PACKAGING ) + install(FILES ${CPACK_RESOURCE_FILE_LICENSE} DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/${ROCM_SMI}-asan RENAME LICENSE.txt COMPONENT asan) +endif() install( FILES ${CPACK_RESOURCE_FILE_LICENSE} DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/${ROCM_SMI} RENAME LICENSE.txt COMPONENT dev) From 2d2c73a5e68cacf9b14e92cf863e78d1e848e0f4 Mon Sep 17 00:00:00 2001 From: Jeremy Newton Date: Wed, 5 Jul 2023 12:54:24 -0500 Subject: [PATCH 6/6] Fix python loading of librocm_smi64 The librocm_smi64.so is used for development, while librocm_smi64.so.MAJOR is used for runtime, thus the python front end should not be loading the .so binary, but rather the .so.MAJOR binary. As well, it's good not to hardcode "lib" as some distros will change this. rsmiBindings.py is now generated with CMake Signed-off-by: Jeremy Newton Change-Id: I7cb745f8936fdf10d3ebd6c1e606031f713184ca --- .gitignore | 6 +++--- .../{rsmiBindings.py => rsmiBindings.py.in} | 12 ++++++------ rocm_smi/CMakeLists.txt | 4 ++++ 3 files changed, 13 insertions(+), 9 deletions(-) rename python_smi_tools/{rsmiBindings.py => rsmiBindings.py.in} (98%) diff --git a/.gitignore b/.gitignore index 632b6ea6c9..3729043d02 100644 --- a/.gitignore +++ b/.gitignore @@ -117,12 +117,12 @@ CTestTestfile.cmake _deps # -# ROCm files -# Removes generated config headers like rocmsmi64Config.h & oamConfig.h +# below files are generated via CMake # *Config.h +python_smi_tools/rsmiBindings.py # # Fake SYSFS files # -/device/* \ No newline at end of file +/device/* diff --git a/python_smi_tools/rsmiBindings.py b/python_smi_tools/rsmiBindings.py.in similarity index 98% rename from python_smi_tools/rsmiBindings.py rename to python_smi_tools/rsmiBindings.py.in index d3a81ee411..b6e7f2474d 100644 --- a/python_smi_tools/rsmiBindings.py +++ b/python_smi_tools/rsmiBindings.py.in @@ -12,16 +12,16 @@ import os # Use ROCm installation path if running from standard installation # With File Reorg rsmiBindings.py will be installed in /opt/rocm/libexec/rocm_smi. # relative path changed accordingly -path_librocm = os.path.dirname(os.path.realpath(__file__)) + '/../../lib/librocm_smi64.so' +path_librocm = os.path.dirname(os.path.realpath(__file__)) + '/../../@CMAKE_INSTALL_LIBDIR@/librocm_smi64.so.@VERSION_MAJOR@' if not os.path.isfile(path_librocm): print('Unable to find %s . Trying /opt/rocm*' % path_librocm) for root, dirs, files in os.walk('/opt', followlinks=True): - if 'librocm_smi64.so' in files: - path_librocm = os.path.join(os.path.realpath(root), 'librocm_smi64.so') + if 'librocm_smi64.so.@VERSION_MAJOR@' in files: + path_librocm = os.path.join(os.path.realpath(root), 'librocm_smi64.so.@VERSION_MAJOR@') if os.path.isfile(path_librocm): print('Using lib from %s' % path_librocm) else: - print('Unable to find librocm_smi64.so') + print('Unable to find librocm_smi64.so.@VERSION_MAJOR@') # ----------> TODO: Support static libs as well as SO @@ -30,7 +30,7 @@ try: rocmsmi = CDLL(path_librocm) except OSError: print('Unable to load the rocm_smi library.\n'\ - 'Set LD_LIBRARY_PATH to the folder containing librocm_smi64.\n'\ + 'Set LD_LIBRARY_PATH to the folder containing librocm_smi64.so.@VERSION_MAJOR@\n'\ '{0}Please refer to https://github.com/'\ 'RadeonOpenCompute/rocm_smi_lib for the installation guide.{1}'\ .format('\33[33m', '\033[0m')) @@ -638,4 +638,4 @@ rsmi_nps_mode_type = rsmi_nps_mode_type_t # Usage example to get corresponding names: # nps_mode_type_l[rsmi_nps_mode_type_t.RSMI_MEMORY_PARTITION_NPS2] # will return string 'NPS2' -nps_mode_type_l = ['NPS1', 'NPS2', 'NPS4', 'NPS8'] \ No newline at end of file +nps_mode_type_l = ['NPS1', 'NPS2', 'NPS4', 'NPS8'] diff --git a/rocm_smi/CMakeLists.txt b/rocm_smi/CMakeLists.txt index 30e2249332..ae8c017933 100755 --- a/rocm_smi/CMakeLists.txt +++ b/rocm_smi/CMakeLists.txt @@ -54,6 +54,10 @@ set(${ROCM_SMI}_VERSION_PATCH "0") set(${ROCM_SMI}_VERSION_BUILD "0") message("SOVERSION: ${SO_VERSION_STRING}") +# Configure rsmiBindings.py.in with SO major version: +configure_file( + "${COMMON_SRC_ROOT}/python_smi_tools/rsmiBindings.py.in" + "${COMMON_SRC_ROOT}/python_smi_tools/rsmiBindings.py") # Create a configure file to get version info from within library configure_file(