Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix omnitrace print-* with libraries #94

Merged
merged 17 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cmake-format.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ parse:
omnitrace_add_bin_test:
flags:
- WILL_FAIL
- ADD_INVERSE
kwargs:
NAME: '*'
ARGS: '*'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/opensuse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ jobs:
timeout-minutes: 45
run:
cd build &&
ldd ./omnitrace &&
./omnitrace --help &&
ldd ./bin/omnitrace &&
./bin/omnitrace --help &&
ctest -V -N -O omnitrace-ctest-${{ github.job }}-commands.log &&
ctest -V --output-log omnitrace-ctest-${{ github.job }}.log --stop-on-failure

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ubuntu-bionic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ jobs:
timeout-minutes: 45
run:
cd build &&
ldd ./omnitrace &&
./omnitrace --help &&
ldd ./bin/omnitrace &&
./bin/omnitrace --help &&
ctest -V -N -O omnitrace-ctest-${{ github.job }}-commands.log &&
ctest -V --output-log omnitrace-ctest-${{ github.job }}.log --stop-on-failure

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ubuntu-focal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ jobs:
timeout-minutes: 45
run:
cd build &&
ldd ./omnitrace &&
./omnitrace --help &&
ldd ./bin/omnitrace &&
./bin/omnitrace --help &&
ctest -V -N -O omnitrace-ctest-${{ github.job }}-commands.log &&
ctest -V --output-log omnitrace-ctest-${{ github.job }}.log --stop-on-failure

Expand Down Expand Up @@ -241,8 +241,8 @@ jobs:
timeout-minutes: 45
run:
cd build &&
ldd ./omnitrace &&
./omnitrace --help &&
ldd ./bin/omnitrace &&
./bin/omnitrace --help &&
ctest -V -N -O omnitrace-ctest-${{ github.job }}-commands.log &&
ctest -V --output-log omnitrace-ctest-${{ github.job }}.log --stop-on-failure

Expand Down
37 changes: 23 additions & 14 deletions cmake/MacroUtilities.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ function(OMNITRACE_FIND_SHARED_LIBRARY)
find_library(${ARGN})
endfunction()

function(OMNITRACE_INSTALL_TPL _TPL_TARGET _NEW_NAME _BUILD_TREE_DIR)
function(OMNITRACE_BUILDTREE_TPL _TPL_TARGET _NEW_NAME _BUILD_TREE_DIR)
get_target_property(_TPL_VERSION ${_TPL_TARGET} VERSION)
get_target_property(_TPL_SOVERSION ${_TPL_TARGET} SOVERSION)
get_target_property(_TPL_NAME ${_TPL_TARGET} OUTPUT_NAME)
Expand All @@ -794,9 +794,11 @@ function(OMNITRACE_INSTALL_TPL _TPL_TARGET _NEW_NAME _BUILD_TREE_DIR)
set(_OUT ${_TPL_PREFIX}${_NEW_NAME}${_TAIL})
endforeach()

string(REPLACE " " "-" _TAIL "${ARGN}")

# build tree symbolic links
add_custom_target(
${_NEW_NAME}-library ALL
${_NEW_NAME}-build-tree-library${_TAIL} ALL
${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${_TPL_TARGET}>
${_TPL_PREFIX}${_NEW_NAME}${_TPL_SUFFIX}.${_TPL_VERSION}
COMMAND
Expand All @@ -810,26 +812,33 @@ function(OMNITRACE_INSTALL_TPL _TPL_TARGET _NEW_NAME _BUILD_TREE_DIR)
WORKING_DIRECTORY ${_BUILD_TREE_DIR}
DEPENDS ${_TPL_TARGET}
COMMENT "Creating ${_NEW_NAME} from ${_TPL_TARGET}...")
endfunction()

function(OMNITRACE_INSTALL_TPL _TPL_TARGET _NEW_NAME _BUILD_TREE_DIR)
get_target_property(_TPL_VERSION ${_TPL_TARGET} VERSION)
get_target_property(_TPL_SOVERSION ${_TPL_TARGET} SOVERSION)
get_target_property(_TPL_NAME ${_TPL_TARGET} OUTPUT_NAME)
set(_TPL_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX})
set(_TPL_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})

foreach(_TAIL ${_TPL_SUFFIX} ${_TPL_SUFFIX}.${_TPL_SOVERSION}
${_TPL_SUFFIX}.${_TPL_VERSION})
set(_INP ${_TPL_PREFIX}${_TPL_NAME}${_TAIL})
set(_OUT ${_TPL_PREFIX}${_NEW_NAME}${_TAIL})
endforeach()

# build tree symbolic links
omnitrace_buildtree_tpl("${_TPL_TARGET}" "${_NEW_NAME}" "${_BUILD_TREE_DIR}" ${ARGN})

install(
FILES $<TARGET_FILE:${_TPL_TARGET}>
DESTINATION ${CMAKE_INSTALL_LIBDIR}
RENAME ${_TPL_PREFIX}${_NEW_NAME}${_TPL_SUFFIX}.${_TPL_VERSION})

execute_process(
COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/install-tree
COMMAND
${CMAKE_COMMAND} -E create_symlink
${_TPL_PREFIX}${_NEW_NAME}${_TPL_SUFFIX}.${_TPL_VERSION}
${PROJECT_BINARY_DIR}/install-tree/${_TPL_PREFIX}${_NEW_NAME}${_TPL_SUFFIX}.${_TPL_SOVERSION}
COMMAND
${CMAKE_COMMAND} -E create_symlink
${_TPL_PREFIX}${_NEW_NAME}${_TPL_SUFFIX}.${_TPL_SOVERSION}
${PROJECT_BINARY_DIR}/install-tree/${_TPL_PREFIX}${_NEW_NAME}${_TPL_SUFFIX})
install(
FILES
${PROJECT_BINARY_DIR}/install-tree/${_TPL_PREFIX}${_NEW_NAME}${_TPL_SUFFIX}.${_TPL_SOVERSION}
${PROJECT_BINARY_DIR}/install-tree/${_TPL_PREFIX}${_NEW_NAME}${_TPL_SUFFIX}
${_BUILD_TREE_DIR}/${_TPL_PREFIX}${_NEW_NAME}${_TPL_SUFFIX}.${_TPL_SOVERSION}
${_BUILD_TREE_DIR}/${_TPL_PREFIX}${_NEW_NAME}${_TPL_SUFFIX}
DESTINATION ${CMAKE_INSTALL_LIBDIR})

endfunction()
Expand Down
14 changes: 10 additions & 4 deletions cmake/Modules/FindROCmVersion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,13 @@ function(ROCM_VERSION_PARSE_VERSION_FILES)
endif()

# convert env to cache if not defined
foreach(_PATH ROCmVersion_DIR ROCmVersion_ROOT ROCmVersion_ROOT_DIR ROCM_PATH)
foreach(_PATH ROCmVersion_DIR ROCmVersion_ROOT ROCmVersion_ROOT_DIR
OMNITRACE_DEFAULT_ROCM_PATH ROCM_PATH)
if(NOT DEFINED ${_PATH} AND DEFINED ENV{${_PATH}})
set(_VAL "$ENV{${_PATH}}")
get_filename_component(_VAL "${_VAL}" REALPATH)
set(${_PATH}
"$ENV{${_PATH}}"
"${_VAL}"
CACHE PATH "Search path for ROCm version for ROCmVersion")
endif()
endforeach()
Expand All @@ -229,8 +232,11 @@ function(ROCM_VERSION_PARSE_VERSION_FILES)
set(_PATHS ${ROCmVersion_DIR})
else()
set(_PATHS)
foreach(_DIR ${ROCmVersion_DIR} ${ROCmVersion_ROOT} ${ROCmVersion_ROOT_DIR}
$ENV{CMAKE_PREFIX_PATH} ${CMAKE_PREFIX_PATH} ${ROCM_PATH} /opt/rocm)
foreach(
_DIR
${ROCmVersion_DIR} ${ROCmVersion_ROOT} ${ROCmVersion_ROOT_DIR}
$ENV{CMAKE_PREFIX_PATH} ${CMAKE_PREFIX_PATH} ${OMNITRACE_DEFAULT_ROCM_PATH}
${ROCM_PATH} /opt/rocm)
if(EXISTS ${_DIR})
get_filename_component(_ABS_DIR "${_DIR}" REALPATH)
list(APPEND _PATHS ${_ABS_DIR})
Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/Findrocm-smi.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if(NOT ROCM_PATH AND NOT "$ENV{ROCM_PATH}" STREQUAL "")
set(ROCM_PATH "$ENV{ROCM_PATH}")
endif()

foreach(_DIR ${ROCM_PATH} /opt/rocm /opt/rocm/rocm_smi)
foreach(_DIR ${ROCmVersion_DIR} ${ROCM_PATH} /opt/rocm /opt/rocm/rocm_smi)
if(EXISTS ${_DIR})
get_filename_component(_ABS_DIR "${_DIR}" REALPATH)
list(APPEND _ROCM_SMI_PATHS ${_ABS_DIR})
Expand Down
3 changes: 1 addition & 2 deletions cmake/Modules/Findrocprofiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if(NOT ROCM_PATH AND NOT "$ENV{ROCM_PATH}" STREQUAL "")
set(ROCM_PATH "$ENV{ROCM_PATH}")
endif()

foreach(_DIR ${ROCM_PATH} /opt/rocm /opt/rocm/rocprofiler)
foreach(_DIR ${ROCmVersion_DIR} ${ROCM_PATH} /opt/rocm /opt/rocm/rocprofiler)
if(EXISTS ${_DIR})
get_filename_component(_ABS_DIR "${_DIR}" REALPATH)
list(APPEND _ROCM_ROCPROFILER_PATHS ${_ABS_DIR})
Expand Down Expand Up @@ -48,7 +48,6 @@ find_path(
mark_as_advanced(rocprofiler_hsa_INCLUDE_DIR)

# ----------------------------------------------------------------------------------------#

find_library(
rocprofiler_LIBRARY
NAMES rocprofiler64 rocprofiler
Expand Down
5 changes: 3 additions & 2 deletions cmake/Modules/Findroctracer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if(NOT ROCM_PATH AND NOT "$ENV{ROCM_PATH}" STREQUAL "")
set(ROCM_PATH "$ENV{ROCM_PATH}")
endif()

foreach(_DIR ${ROCM_PATH} /opt/rocm /opt/rocm/roctracer)
foreach(_DIR ${ROCmVersion_DIR} ${ROCM_PATH} /opt/rocm /opt/rocm/roctracer)
if(EXISTS ${_DIR})
get_filename_component(_ABS_DIR "${_DIR}" REALPATH)
list(APPEND _ROCM_ROCTRACER_PATHS ${_ABS_DIR})
Expand Down Expand Up @@ -70,7 +70,8 @@ find_library(
PATHS ${roctracer_ROOT_DIR} ${_ROCM_ROCTRACER_PATHS}
PATH_SUFFIXES lib lib64)

find_package(hsakmt)
find_package(hsakmt HINTS ${_ROCM_ROCTRACER_PATHS} PATHS ${_ROCM_ROCTRACER_PATHS})

if(hsakmt_FOUND)
set(roctracer_hsakmt_LIBRARY
hsakmt::hsakmt
Expand Down
88 changes: 52 additions & 36 deletions cmake/Packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,14 @@ set(OMNITRACE_DEFAULT_ROCM_PATH
/opt/rocm
CACHE PATH "Default search path for ROCM")
if(EXISTS ${OMNITRACE_DEFAULT_ROCM_PATH})
get_filename_component(OMNITRACE_DEFAULT_ROCM_PATH "${OMNITRACE_DEFAULT_ROCM_PATH}"
get_filename_component(_OMNITRACE_DEFAULT_ROCM_PATH "${OMNITRACE_DEFAULT_ROCM_PATH}"
REALPATH)

if(NOT "${_OMNITRACE_DEFAULT_ROCM_PATH}" STREQUAL "${OMNITRACE_DEFAULT_ROCM_PATH}")
set(OMNITRACE_DEFAULT_ROCM_PATH
"${_OMNITRACE_DEFAULT_ROCM_PATH}"
CACHE PATH "Default search path for ROCM" FORCE)
endif()
endif()

# ----------------------------------------------------------------------------------------#
Expand Down Expand Up @@ -93,14 +99,56 @@ foreach(_LIB dl rt)
endif()
endforeach()

# ----------------------------------------------------------------------------------------#
#
# hip version
#
# ----------------------------------------------------------------------------------------#

if(OMNITRACE_USE_HIP
OR OMNITRACE_USE_ROCTRACER
OR OMNITRACE_USE_ROCPROFILER
OR OMNITRACE_USE_ROCM_SMI)
find_package(ROCmVersion)

if(NOT ROCmVersion_FOUND)
find_package(hip ${omnitrace_FIND_QUIETLY} REQUIRED HINTS
${OMNITRACE_DEFAULT_ROCM_PATH} PATHS ${OMNITRACE_DEFAULT_ROCM_PATH})
find_package(ROCmVersion REQUIRED HINTS ${ROCM_PATH} PATHS ${ROCM_PATH})
endif()

list(APPEND CMAKE_PREFIX_PATH ${ROCmVersion_DIR})

set(OMNITRACE_ROCM_VERSION ${ROCmVersion_FULL_VERSION})
set(OMNITRACE_HIP_VERSION_MAJOR ${ROCmVersion_MAJOR_VERSION})
set(OMNITRACE_HIP_VERSION_MINOR ${ROCmVersion_MINOR_VERSION})
set(OMNITRACE_HIP_VERSION_PATCH ${ROCmVersion_PATCH_VERSION})
set(OMNITRACE_HIP_VERSION ${ROCmVersion_TRIPLE_VERSION})

if(OMNITRACE_HIP_VERSION_MAJOR GREATER_EQUAL 4 AND OMNITRACE_HIP_VERSION_MINOR
GREATER 3)
set(roctracer_kfdwrapper_LIBRARY)
endif()

if(NOT roctracer_kfdwrapper_LIBRARY)
set(roctracer_kfdwrapper_LIBRARY)
endif()

omnitrace_add_feature(OMNITRACE_ROCM_VERSION "ROCm version used by omnitrace")
else()
set(OMNITRACE_HIP_VERSION "0.0.0")
set(OMNITRACE_HIP_VERSION_MAJOR 0)
set(OMNITRACE_HIP_VERSION_MINOR 0)
set(OMNITRACE_HIP_VERSION_PATCH 0)
endif()

# ----------------------------------------------------------------------------------------#
#
# HIP
#
# ----------------------------------------------------------------------------------------#

if(OMNITRACE_USE_HIP)
list(APPEND CMAKE_PREFIX_PATH ${OMNITRACE_DEFAULT_ROCM_PATH})
find_package(hip ${omnitrace_FIND_QUIETLY} REQUIRED)
omnitrace_target_compile_definitions(omnitrace-hip INTERFACE OMNITRACE_USE_HIP)
target_link_libraries(omnitrace-hip INTERFACE hip::host)
Expand All @@ -113,7 +161,6 @@ endif()
# ----------------------------------------------------------------------------------------#

if(OMNITRACE_USE_ROCTRACER)
list(APPEND CMAKE_PREFIX_PATH ${OMNITRACE_DEFAULT_ROCM_PATH})
find_package(roctracer ${omnitrace_FIND_QUIETLY} REQUIRED)
omnitrace_target_compile_definitions(omnitrace-roctracer
INTERFACE OMNITRACE_USE_ROCTRACER)
Expand All @@ -128,7 +175,6 @@ endif()
#
# ----------------------------------------------------------------------------------------#
if(OMNITRACE_USE_ROCPROFILER)
list(APPEND CMAKE_PREFIX_PATH ${OMNITRACE_DEFAULT_ROCM_PATH})
find_package(rocprofiler ${omnitrace_FIND_QUIETLY} REQUIRED)
omnitrace_target_compile_definitions(omnitrace-rocprofiler
INTERFACE OMNITRACE_USE_ROCPROFILER)
Expand All @@ -143,44 +189,13 @@ endif()
# ----------------------------------------------------------------------------------------#

if(OMNITRACE_USE_ROCM_SMI)
list(APPEND CMAKE_PREFIX_PATH ${OMNITRACE_DEFAULT_ROCM_PATH})
find_package(rocm-smi ${omnitrace_FIND_QUIETLY} REQUIRED)
omnitrace_target_compile_definitions(omnitrace-rocm-smi
INTERFACE OMNITRACE_USE_ROCM_SMI)
target_link_libraries(omnitrace-rocm-smi INTERFACE rocm-smi::rocm-smi)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${rocm-smi_LIBRARY_DIRS}")
endif()

# ----------------------------------------------------------------------------------------#
#
# hip version
#
# ----------------------------------------------------------------------------------------#

if(OMNITRACE_USE_HIP
OR OMNITRACE_USE_ROCTRACER
OR OMNITRACE_USE_ROCM_SMI)
find_package(ROCmVersion REQUIRED)
set(OMNITRACE_ROCM_VERSION ${ROCmVersion_FULL_VERSION})
set(OMNITRACE_HIP_VERSION_MAJOR ${ROCmVersion_MAJOR_VERSION})
set(OMNITRACE_HIP_VERSION_MINOR ${ROCmVersion_MINOR_VERSION})
set(OMNITRACE_HIP_VERSION_PATCH ${ROCmVersion_PATCH_VERSION})
set(OMNITRACE_HIP_VERSION ${ROCmVersion_TRIPLE_VERSION})
if(OMNITRACE_HIP_VERSION_MAJOR GREATER_EQUAL 4 AND OMNITRACE_HIP_VERSION_MINOR
GREATER 3)
set(roctracer_kfdwrapper_LIBRARY)
endif()
if(NOT roctracer_kfdwrapper_LIBRARY)
set(roctracer_kfdwrapper_LIBRARY)
endif()
omnitrace_add_feature(OMNITRACE_ROCM_VERSION "ROCm version used by omnitrace")
else()
set(OMNITRACE_HIP_VERSION "0.0.0")
set(OMNITRACE_HIP_VERSION_MAJOR 0)
set(OMNITRACE_HIP_VERSION_MINOR 0)
set(OMNITRACE_HIP_VERSION_PATCH 0)
endif()

# ----------------------------------------------------------------------------------------#
#
# MPI
Expand Down Expand Up @@ -276,7 +291,8 @@ if(OMNITRACE_BUILD_DYNINST)
endif()
endforeach()

omnitrace_install_tpl(dyninstAPI_RT omnitrace-rt "${PROJECT_BINARY_DIR}")
omnitrace_install_tpl(dyninstAPI_RT omnitrace-rt
"${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")

# for packaging
install(
Expand Down
4 changes: 2 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ option(BUILD_SHARED_LIBS "Build dynamic libraries" ON)

if(CMAKE_PROJECT_NAME STREQUAL "omnitrace")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
omnitrace_add_option(OMNITRACE_INSTALL_EXAMPLES "Install omnitrace examples" OFF)
else()
option(OMNITRACE_INSTALL_EXAMPLES "Install omnitrace examples" ON)
Expand Down
6 changes: 3 additions & 3 deletions examples/lulesh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ if(LULESH_BUILD_KOKKOS)
kokkos_compilation(PROJECT)
elseif(LULESH_USE_HIP AND NOT "${CMAKE_CXX_COMPILER}" MATCHES "hipcc")
if(NOT HIPCC_EXECUTABLE)
find_package(hip QUIET)
find_package(hip QUIET HINTS ${ROCmVersion_DIR} PATHS ${ROCmVersion_DIR})

find_program(
HIPCC_EXECUTABLE
NAMES hipcc
HINTS ${ROCM_PATH} ENV ROCM_PATH /opt/rocm
PATHS ${ROCM_PATH} ENV ROCM_PATH /opt/rocm)
HINTS ${ROCmVersion_DIR} ${ROCM_PATH} ENV ROCM_PATH /opt/rocm
PATHS ${ROCmVersion_DIR} ${ROCM_PATH} ENV ROCM_PATH /opt/rocm)
mark_as_advanced(HIPCC_EXECUTABLE)
endif()
kokkos_compilation(PROJECT COMPILER ${HIPCC_EXECUTABLE})
Expand Down
6 changes: 3 additions & 3 deletions examples/transpose/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR)

project(omnitrace-transpose LANGUAGES CXX)

find_package(hip QUIET)
find_package(hip QUIET HINTS ${ROCmVersion_DIR} PATHS ${ROCmVersion_DIR})

find_program(
HIPCC_EXECUTABLE
NAMES hipcc
HINTS ${ROCM_PATH} ENV ROCM_PATH /opt/rocm
PATHS ${ROCM_PATH} ENV ROCM_PATH /opt/rocm)
HINTS ${ROCmVersion_DIR} ${ROCM_PATH} ENV ROCM_PATH /opt/rocm
PATHS ${ROCmVersion_DIR} ${ROCM_PATH} ENV ROCM_PATH /opt/rocm NO_CACHE)
mark_as_advanced(HIPCC_EXECUTABLE)

if(NOT HIPCC_EXECUTABLE)
Expand Down
Loading