Skip to content

Commit

Permalink
Merge amd-staging into amd-master 20230323
Browse files Browse the repository at this point in the history
Signed-off-by: Hao Zhou <[email protected]>
Change-Id: I2155fa727d4a2a46cbeca3e65f6ae2d9c31c91a5
  • Loading branch information
Hao Zhou authored and Hao Zhou committed Mar 23, 2023
2 parents 74c96db + 778f3b7 commit 230b5bc
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 35 deletions.
79 changes: 70 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,42 @@ set(CMN_INC_LIST ${CMN_INC_LIST} "${COMMON_INC_DIR}/rocm_smi_io_link.h")
set(CMN_INC_LIST ${CMN_INC_LIST} "${COMMON_INC_DIR}/rocm_smi.h")
set(CMN_INC_LIST ${CMN_INC_LIST} "${SHR_MUTEX_DIR}/shared_mutex.h")

## set components
if(ENABLE_ASAN_PACKAGING)
# ASAN Package requires only asan component with libraries and license file
set(CPACK_COMPONENTS_ALL asan)
else()
set(CPACK_COMPONENTS_ALL dev)
endif()

# Enable Component Mode & Install Settings
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_RPM_COMPONENT_INSTALL ON)

#Component Specific Configuration/Flags
set(CPACK_DEBIAN_ASAN_PACKAGE_NAME ${ROCM_SMI_PACKAGE}-asan)
set(CPACK_DEBIAN_DEV_PACKAGE_NAME ${ROCM_SMI_PACKAGE})
set(CPACK_RPM_ASAN_PACKAGE_NAME ${ROCM_SMI_PACKAGE}-asan)
set(CPACK_RPM_DEV_PACKAGE_NAME ${ROCM_SMI_PACKAGE})

set (CPACK_DEBIAN_ASAN_PACKAGE_PROVIDES "${ROCM_SMI_PACKAGE}-asan")
set (CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS "python3, rocm-core-asan")
set (CPACK_DEBIAN_DEV_PACKAGE_PROVIDES "rocm-smi")
set (CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "python3, rocm-core")
set (CPACK_RPM_ASAN_PACKAGE_PROVIDES "${ROCM_SMI_PACKAGE}-asan")
set (CPACK_RPM_ASAN_PACKAGE_REQUIRES "python3, rocm-core-asan")
set (CPACK_RPM_DEV_PACKAGE_PROVIDES "rocm-smi")
set (CPACK_RPM_DEV_PACKAGE_REQUIRES "python3, rocm-core")


add_subdirectory("rocm_smi")
add_subdirectory("oam")

option(FILE_REORG_BACKWARD_COMPATIBILITY "Enable File Reorg with backward compatibility" ON)
# Disable file reorg backward compatibility for ASAN packaging
if(NOT ENABLE_ASAN_PACKAGING)
option(FILE_REORG_BACKWARD_COMPATIBILITY "Enable File Reorg with backward compatibility" ON)
endif()

if(FILE_REORG_BACKWARD_COMPATIBILITY)
# To enable/disable #error in wrapper header files
if(NOT DEFINED ROCM_HEADER_WRAPPER_WERROR)
Expand All @@ -166,11 +198,12 @@ if(FILE_REORG_BACKWARD_COMPATIBILITY)
include(rocm_smi-backward-compat.cmake)
endif()

include(CMakePackageConfigHelpers)

set(LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
set(BIN_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}")

include(CMakePackageConfigHelpers)

configure_package_config_file(
rocm_smi-config.cmake.in
Expand Down Expand Up @@ -201,22 +234,34 @@ export(TARGETS ${ROCM_SMI_TARGET} ${OAM_TARGET}
# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
export(PACKAGE rocm_smi)

# Create the rocm_smiConfig.cmake and rocm_smiConfigVersion files
# ... for the build tree
install(EXPORT rocm_smiTargets DESTINATION
"${CMAKE_INSTALL_LIBDIR}/cmake/${ROCM_SMI}" COMPONENT dev)
install(EXPORT rocm_smiTargets
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${ROCM_SMI}"
COMPONENT dev)

#License file
set(CPACK_RPM_PACKAGE_LICENSE "NCSA")
install( FILES ${CPACK_RESOURCE_FILE_LICENSE} DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/${ROCM_SMI} RENAME LICENSE.txt)
# install license file in share/doc/rocm_smi-asan folder
install(FILES ${CPACK_RESOURCE_FILE_LICENSE}
DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/${ROCM_SMI}-asan RENAME LICENSE.txt
COMPONENT asan)
install( FILES ${CPACK_RESOURCE_FILE_LICENSE}
DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/${ROCM_SMI} RENAME LICENSE.txt
COMPONENT dev)

###########################
# Packaging directives
###########################
set(CPACK_GENERATOR "DEB;RPM" CACHE STRING "Default packaging generators.")
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/rocm" CACHE STRING "Default packaging prefix.")
set ( ENABLE_LDCONFIG ON CACHE BOOL "Set library links and caches using ldconfig.")
set(CPACK_PACKAGE_NAME ${ROCM_SMI_PACKAGE})
if( ENABLE_ASAN_PACKAGING )
set(CPACK_PACKAGE_NAME ${ROCM_SMI_PACKAGE}-asan)
else()
set(CPACK_PACKAGE_NAME ${ROCM_SMI_PACKAGE})
endif()
set(CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc.")
set(CPACK_PACKAGE_CONTACT "RocmSMILib Support <[email protected]>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "AMD System Management libraries")
Expand All @@ -236,8 +281,8 @@ else()
set(CPACK_DEBIAN_PACKAGE_RELEASE "local")
endif()
set (CPACK_DEBIAN_PACKAGE_PROVIDES "rocm-smi")
set (CPACK_DEBIAN_PACKAGE_SUGGESTS "sudo")
set (CPACK_DEBIAN_PACKAGE_DEPENDS "python3, rocm-core")
set (CPACK_DEBIAN_PACKAGE_SUGGESTS "sudo")

## Process the Debian install/remove scripts to update the CPACK variables
configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/postinst.in DEBIAN/postinst @ONLY )
Expand Down Expand Up @@ -279,8 +324,24 @@ set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
# Remove dependency on rocm-core if -DROCM_DEP_ROCMCORE=ON not given to cmake
if(NOT ROCM_DEP_ROCMCORE)
string(REGEX REPLACE ",? ?rocm-core" "" CPACK_RPM_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES})
string(REGEX REPLACE ",? ?rocm-core" "" CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS})
string(REGEX REPLACE ",? ?rocm-core-asan" "" CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CPACK_RPM_ASAN_PACKAGE_REQUIRES})
string(REGEX REPLACE ",? ?rocm-core-asan" "" CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS})
string(REGEX REPLACE ",? ?rocm-core" "" CPACK_RPM_DEV_PACKAGE_REQUIRES ${CPACK_RPM_DEV_PACKAGE_REQUIRES})
string(REGEX REPLACE ",? ?rocm-core" "" CPACK_DEBIAN_DEV_PACKAGE_DEPENDS ${CPACK_DEBIAN_DEV_PACKAGE_DEPENDS})
string(REGEX REPLACE ",? ?rocm-core" "" CPACK_RPM_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES})
string(REGEX REPLACE ",? ?rocm-core" "" CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS})
endif()

include (CPack)

cpack_add_component(
dev
DISPLAY_NAME "Development"
DESCRIPTION "Development needed header files for ROCM-SMI"
DEPENDS dev)

cpack_add_component(
asan
DISPLAY_NAME "ASAN"
DESCRIPTION "ASAN libraries for the ROCM-SMI"
DEPENDS asan)
2 changes: 1 addition & 1 deletion include/rocm_smi/rocm_smi_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class Monitor {
std::string path_;
const RocmSMI_env_vars *env_;
std::map<rsmi_temperature_type_t, uint32_t> temp_type_index_map_;
std::map<rsmi_voltage_type_t, uint32_t> volt_type_index_map_;

// This map uses a 64b index instead of 32b (unlike temp_type_index_map_)
// for flexibility and simplicity. Currently, some parts of the
Expand All @@ -124,7 +125,6 @@ class Monitor {
// a 64b value. Also, if we need to encode anything else, 64b will give
// us more room to do so, without excessive changes.
std::map<uint64_t, rsmi_temperature_type_t> index_temp_type_map_;
std::map<rsmi_voltage_type_t, uint32_t> volt_type_index_map_;
std::map<uint64_t, rsmi_voltage_type_t> index_volt_type_map_;
};

Expand Down
11 changes: 7 additions & 4 deletions oam/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,19 @@ target_include_directories(${OAM_TARGET}
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:{OAM_NAME}/include>")


## Add the install directives for the runtime library.
install(TARGETS ${OAM_TARGET}
EXPORT rocm_smiTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT ${OAM_COMPONENT})
COMPONENT dev)
install(TARGETS ${OAM_TARGET}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT asan)

install(FILES ${COMMON_SRC_ROOT}/oam/include/oam/oam_mapi.h
${COMMON_SRC_ROOT}/oam/include/oam/amd_oam.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/oam)
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/oam
COMPONENT dev)

# Generate Doxygen documentation
if (DOXYGEN_FOUND)
Expand Down
16 changes: 12 additions & 4 deletions rocm_smi-backward-compat.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,17 @@ endfunction()
create_header_template()
#Use template header file and generater wrapper header files
generate_wrapper_header()
install(DIRECTORY ${RSMI_WRAPPER_INC_DIR} DESTINATION ${ROCM_SMI}/include)
install(DIRECTORY ${OAM_WRAPPER_INC_DIR} DESTINATION ${OAM_TARGET_NAME}/include)
install(DIRECTORY ${RSMI_WRAPPER_INC_DIR}
DESTINATION ${ROCM_SMI}/include
COMPONENT dev)
install(DIRECTORY ${OAM_WRAPPER_INC_DIR}
DESTINATION ${OAM_TARGET_NAME}/include
COMPONENT dev)
# Create symlink to library files
create_library_symlink()
install(DIRECTORY ${RSMI_WRAPPER_LIB_DIR} DESTINATION ${ROCM_SMI} COMPONENT lib${ROCM_SMI})
install(DIRECTORY ${OAM_WRAPPER_LIB_DIR} DESTINATION ${OAM_TARGET_NAME} COMPONENT lib${OAM_TARGET_NAME} )
install(DIRECTORY ${RSMI_WRAPPER_LIB_DIR}
DESTINATION ${ROCM_SMI}
COMPONENT dev)
install(DIRECTORY ${OAM_WRAPPER_LIB_DIR}
DESTINATION ${OAM_TARGET_NAME}
COMPONENT dev )
35 changes: 23 additions & 12 deletions rocm_smi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL Release)
POST_BUILD COMMAND ${CMAKE_STRIP} lib${ROCM_SMI_TARGET}.so.${SO_VERSION_STRING})
endif()
endif ()

#file reorganization changes
#rocm_smi.py moved to libexec/rocm_smi. so creating rocm-smi symlink
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
Expand All @@ -119,23 +120,31 @@ add_custom_target(link-rocm-smi ALL
install(TARGETS ${ROCM_SMI_TARGET}
EXPORT rocm_smiTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT ${ROCM_SMI_COMPONENT})
COMPONENT dev)
install(TARGETS ${ROCM_SMI_TARGET}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT asan)

install(FILES ${COMMON_SRC_ROOT}/include/rocm_smi/rocm_smi.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm_smi)
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm_smi
COMPONENT dev)
install(FILES ${COMMON_SRC_ROOT}/include/rocm_smi/${ROCM_SMI_TARGET}Config.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm_smi)
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm_smi
COMPONENT dev)
install(FILES ${COMMON_SRC_ROOT}/include/rocm_smi/kfd_ioctl.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm_smi)
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm_smi
COMPONENT dev)
install(FILES ${COMMON_SRC_ROOT}/python_smi_tools/rsmiBindings.py
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/${ROCM_SMI})
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/${ROCM_SMI}
COMPONENT dev)
install(FILES ${COMMON_SRC_ROOT}/python_smi_tools/rocm_smi.py
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/${ROCM_SMI})
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/${ROCM_SMI}
COMPONENT dev)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bin/rocm-smi
DESTINATION ${CMAKE_INSTALL_BINDIR})
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT dev)

# Generate Doxygen documentation
find_package(Doxygen)
Expand All @@ -162,9 +171,11 @@ if (DOXYGEN_FOUND AND LATEX_FOUND)

add_dependencies(${ROCM_SMI_TARGET} docs)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/latex/refman.pdf
DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/${ROCM_SMI} RENAME ${RSMI_MANUAL_NAME}.pdf)
DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/${ROCM_SMI} RENAME ${RSMI_MANUAL_NAME}.pdf
COMPONENT dev)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../README.md
DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/${ROCM_SMI}/)
DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/${ROCM_SMI}/
COMPONENT dev)
else()
message("Doxygen or Latex is not found. Will not generate documents.")
endif(DOXYGEN_FOUND AND LATEX_FOUND)
Expand Down
7 changes: 4 additions & 3 deletions src/rocm_smi_monitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -367,15 +367,16 @@ Monitor::setVoltSensorLabelMap(void) {
}
auto add_volt_sensor_entry = [&](uint32_t file_index) {
ret = readMonitor(kMonVoltLabel, file_index, &type_str);
rsmi_voltage_type_t t_type = kVoltSensorNameMap.at(type_str);
rsmi_voltage_type_t t_type;

// If readMonitor fails, there is no label file for the file_index.
// In that case, map the type to file index 0, which is not supported
// and will fail appropriately later when we check for support.
if (ret) {
volt_type_index_map_.insert({t_type, 0});
index_volt_type_map_.insert({file_index, RSMI_VOLT_TYPE_INVALID});
} else {
volt_type_index_map_.insert({t_type, file_index});
t_type = kVoltSensorNameMap.at(type_str);
volt_type_index_map_[t_type] = file_index;
index_volt_type_map_.insert({file_index, t_type});
}
return 0;
Expand Down
6 changes: 4 additions & 2 deletions tests/rocm_smi_test/gtest/googletest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,14 @@ if (INSTALL_GTEST)
write_basic_package_version_file(${version_file} VERSION ${GOOGLETEST_VERSION} COMPATIBILITY AnyNewerVersion)
install(EXPORT ${targets_export_name}
NAMESPACE ${cmake_package_name}::
DESTINATION ${cmake_files_install_dir})
DESTINATION ${cmake_files_install_dir}
COMPONENT dev)
set(config_file "${generated_dir}/${cmake_package_name}Config.cmake")
configure_package_config_file("${gtest_SOURCE_DIR}/cmake/Config.cmake.in"
"${config_file}" INSTALL_DESTINATION ${cmake_files_install_dir})
install(FILES ${version_file} ${config_file}
DESTINATION ${cmake_files_install_dir})
DESTINATION ${cmake_files_install_dir}
COMPONENT dev)
endif()

# Where Google Test's .h files can be found.
Expand Down

0 comments on commit 230b5bc

Please sign in to comment.