Skip to content

Commit

Permalink
Adding ROCm SMI reader
Browse files Browse the repository at this point in the history
  • Loading branch information
khuck committed Aug 18, 2021
1 parent 41cf98a commit 406281a
Show file tree
Hide file tree
Showing 8 changed files with 471 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -658,14 +658,17 @@ endif (APEX_WITH_CUDA)
if (APEX_WITH_HIP)
find_package(ROCTRACER REQUIRED)
find_package(ROCTX REQUIRED)
set(LIBS ${LIBS} ${ROCTRACER_LIBRARIES} ${ROCTX_LIBRARIES})
find_package(RSMI REQUIRED)
set(LIBS ${LIBS} ${ROCTRACER_LIBRARIES} ${ROCTX_LIBRARIES} ${RSMI_LIBRARIES})
add_definitions(-DAPEX_WITH_HIP)
add_definitions(-DAMD_INTERNAL_BUILD)
add_definitions(-D__HIP_PLATFORM_HCC__)
message(INFO " Using ROCTRACER include: ${ROCTRACER_INCLUDE_DIRS}")
include_directories(${ROCTRACER_INCLUDE_DIRS})
message(INFO " Using ROCTX include: ${ROCTX_INCLUDE_DIRS}")
include_directories(${ROCTX_INCLUDE_DIRS})
message(INFO " Using ROCm SMI include: ${RSMI_INCLUDE_DIRS}")
include_directories(${RSMI_INCLUDE_DIRS})
endif (APEX_WITH_HIP)

################################################################################
Expand Down
3 changes: 3 additions & 0 deletions cmake/Modules/FindBFD.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ find_path(BFD_INCLUDE_DIR bfd.h
HINTS ${BFD_ROOT}/include
${PC_BFD_INCLUDEDIR}
${PC_BFD_INCLUDE_DIRS}
${CMAKE_INSTALL_PREFIX}/binutils/include
PATH_SUFFIXES BFD )

set(TMP_PATH $ENV{LD_LIBRARY_PATH})
Expand All @@ -31,6 +32,8 @@ find_library(BFD_LIBRARY NAMES bfd
HINTS ${BFD_ROOT}/lib ${BFD_ROOT}/lib64
${PC_BFD_LIBDIR}
${PC_BFD_LIBRARY_DIRS}
${CMAKE_INSTALL_PREFIX}/binutils/lib
${CMAKE_INSTALL_PREFIX}/binutils/lib64
${LD_LIBRARY_PATH_STR})

include(FindPackageHandleStandardArgs)
Expand Down
8 changes: 7 additions & 1 deletion cmake/Modules/FindDEMANGLE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ set(DEMANGLE_DEFINITIONS ${PC_DEMANGLE_CFLAGS_OTHER})

find_path(DEMANGLE_INCLUDE_DIR demangle.h
HINTS ${PC_DEMANGLE_INCLUDEDIR} ${PC_DEMANGLE_INCLUDE_DIRS}
${DEMANGLE_ROOT}/include ${BFD_ROOT}/include ${BFD_ROOT}/include/extra /usr/include
${DEMANGLE_ROOT}/include ${BFD_ROOT}/include ${BFD_ROOT}/include/extra
${CMAKE_INSTALL_PREFIX}/binutils/include
${CMAKE_INSTALL_PREFIX}/binutils/include/extra /usr/include
${PC_DEMANGLE_INCLUDEDIR}/* ${PC_DEMANGLE_INCLUDE_DIRS}/*
${DEMANGLE_ROOT}/* ${BFD_ROOT}/* /usr/include/*
PATH_SUFFIXES DEMANGLE )
Expand All @@ -32,13 +34,17 @@ find_path(LIBIBERTY_INCLUDE_DIR libiberty.h
HINTS ${PC_DEMANGLE_INCLUDEDIR} ${PC_DEMANGLE_INCLUDE_DIRS}
${DEMANGLE_ROOT}/include ${DEMANGLE_ROOT}/include/libiberty
${BFD_ROOT}/include ${BFD_ROOT}/include/extra ${BFD_ROOT}/include/libiberty
${CMAKE_INSTALL_PREFIX}/binutils/include
${CMAKE_INSTALL_PREFIX}/binutils/include/extra
${PC_DEMANGLE_INCLUDEDIR}/* ${PC_DEMANGLE_INCLUDE_DIRS}/*
${DEMANGLE_ROOT}/* ${BFD_ROOT}/* /usr/include /usr/include/*
PATH_SUFFIXES LIBIBERTY)

find_library(DEMANGLE_LIBRARY NAMES iberty HINTS
${DEMANGLE_ROOT}/lib ${BFD_ROOT}/lib
${DEMANGLE_ROOT}/lib64 ${BFD_ROOT}/lib64
${CMAKE_INSTALL_PREFIX}/binutils/lib
${CMAKE_INSTALL_PREFIX}/binutils/lib64
${PC_DEMANGLE_LIBDIR} ${PC_DEMANGLE_LIBRARY_DIRS})

include(FindPackageHandleStandardArgs)
Expand Down
40 changes: 40 additions & 0 deletions cmake/Modules/FindRSMI.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# - Try to find LibRSMI
# Once done this will define
# RSMI_FOUND - System has RSMI
# RSMI_INCLUDE_DIRS - The RSMI include directories
# RSMI_LIBRARIES - The libraries needed to use RSMI
# RSMI_DEFINITIONS - Compiler switches required for using RSMI

if(NOT DEFINED $RSMI_ROOT)
if(DEFINED ENV{RSMI_ROOT})
# message(" env RSMI_ROOT is defined as $ENV{RSMI_ROOT}")
set(RSMI_ROOT $ENV{RSMI_ROOT})
endif()
endif()

if(NOT DEFINED $RSMI_ROOT AND ROCM_PATH)
message(INFO " env RSMI_ROOT is assuming ${ROCM_PATH}/rocm_smi")
set(RSMI_ROOT "${ROCM_PATH}/rocm_smi")
endif()

find_path(RSMI_INCLUDE_DIR NAMES rocm_smi/rocm_smi.h
HINTS ${CUDAToolkit_INCLUDE_DIRS} ${RSMI_ROOT}/include)

find_library(RSMI_LIBRARY NAMES rocm_smi64
HINTS ${CUDAToolkit_LIBRARY_DIR} ${RSMI_ROOT} ${RSMI_ROOT}/lib64 ${RSMI_ROOT}/lib)

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set RSMI_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(RSMI DEFAULT_MSG
RSMI_LIBRARY RSMI_INCLUDE_DIR)

mark_as_advanced(RSMI_INCLUDE_DIR RSMI_LIBRARY)

if(RSMI_FOUND)
set(RSMI_LIBRARIES ${RSMI_LIBRARY} )
set(RSMI_INCLUDE_DIRS ${RSMI_INCLUDE_DIR})
set(RSMI_DIR ${RSMI_ROOT})
add_definitions(-DAPEX_HAVE_RSMI)
endif()

5 changes: 5 additions & 0 deletions src/apex/CMakeLists.standalone
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ if (NVML_FOUND)
SET(NVML_SOURCE apex_nvml.cpp)
endif(NVML_FOUND)

if (RSMI_FOUND)
SET(RSMI_SOURCE apex_rocm_smi.cpp)
endif(RSMI_FOUND)

if (OpenACC_CXX_FOUND AND OpenACCProfiling_FOUND)
set(OpenACC_SOURCE apex_openacc.cpp)
endif (OpenACC_CXX_FOUND AND OpenACCProfiling_FOUND)
Expand All @@ -58,6 +62,7 @@ SET(all_SOURCE
${CUPTI_SOURCE}
${ROCTRACER_SOURCE}
${NVML_SOURCE}
${RSMI_SOURCE}
apex.cpp
apex_kokkos.cpp
apex_kokkos_tuning.cpp
Expand Down
Loading

0 comments on commit 406281a

Please sign in to comment.