diff --git a/.github/workflows/opensuse.yml b/.github/workflows/opensuse.yml index d2a465ef30..e724fb2942 100644 --- a/.github/workflows/opensuse.yml +++ b/.github/workflows/opensuse.yml @@ -11,6 +11,10 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +env: + OMNITRACE_VERBOSE: 1 + OMNITRACE_CI: ON + jobs: opensuse: runs-on: ubuntu-20.04 @@ -23,10 +27,6 @@ jobs: os-release: [ '15.2', '15.3' ] build-type: ['Release'] - env: - OMNITRACE_VERBOSE: 1 - OMNITRACE_CI: ON - steps: - uses: actions/checkout@v3 @@ -49,7 +49,7 @@ jobs: git config --global --add safe.directory ${PWD} && cmake --version && ./scripts/run-ci.sh -B build - --name opensuse-${{ matrix.os-release }}-${{ matrix.compiler }}-nompi-python + --name ${{ github.repository_owner }}-${{ github.ref_name }}-opensuse-${{ matrix.os-release }}-${{ matrix.compiler }}-nompi-python --build-jobs 2 --site GitHub --cmake-args @@ -62,10 +62,13 @@ jobs: -DOMNITRACE_USE_HIP=OFF -DOMNITRACE_USE_OMPT=OFF -DOMNITRACE_USE_PYTHON=ON + -DOMNITRACE_USE_MPI_HEADERS=ON -DOMNITRACE_PYTHON_PREFIX=/opt/conda/envs -DOMNITRACE_PYTHON_ENVS="py3.6;py3.7;py3.8;py3.9;py3.10" -DOMNITRACE_CI_MPI_RUN_AS_ROOT=ON -DOMNITRACE_MAX_THREADS=32 + -DOMNITRACE_DISABLE_EXAMPLES="transpose;rccl" + -DOMNITRACE_BUILD_NUMBER=${{ github.run_attempt }} - name: Install timeout-minutes: 10 diff --git a/.github/workflows/ubuntu-bionic.yml b/.github/workflows/ubuntu-bionic.yml index 05d1e71713..ae799d0cab 100644 --- a/.github/workflows/ubuntu-bionic.yml +++ b/.github/workflows/ubuntu-bionic.yml @@ -78,11 +78,12 @@ jobs: timeout-minutes: 115 shell: bash run: + git config --global --add safe.directory ${PWD} && cmake --version && if [ "${{ matrix.mpi }}" = "nompi" ]; then USE_MPI=OFF; else USE_MPI=ON; fi && append-tagname() { if [ "${1}" == "ON" ]; then TAG="${TAG}-${2}"; fi; } && ./scripts/run-ci.sh -B build - --name ubuntu-bionic-${{ matrix.compiler }}-${{ matrix.mpi }}-python + --name ${{ github.repository_owner }}-${{ github.ref_name }}-ubuntu-bionic-${{ matrix.compiler }}-${{ matrix.mpi }}-python --build-jobs 2 --site GitHub --cmake-args @@ -99,6 +100,8 @@ jobs: -DOMNITRACE_PYTHON_ENVS="py3.6;py3.7;py3.8;py3.9;py3.10" -DLULESH_BUILD_KOKKOS=OFF -DOMNITRACE_MAX_THREADS=32 + -DOMNITRACE_DISABLE_EXAMPLES="transpose;rccl" + -DOMNITRACE_BUILD_NUMBER=${{ github.run_attempt }} - name: Install run: diff --git a/.github/workflows/ubuntu-focal.yml b/.github/workflows/ubuntu-focal.yml index 9aa62374f2..0b4dfa3bb6 100644 --- a/.github/workflows/ubuntu-focal.yml +++ b/.github/workflows/ubuntu-focal.yml @@ -103,7 +103,7 @@ jobs: append-tagname ${{ matrix.static-libstdcxx }} libstdcxx && cmake --version && ./scripts/run-ci.sh -B build - --name ubuntu-focal-${{ matrix.compiler }}${TAG} + --name ${{ github.repository_owner }}-${{ github.ref_name }}-ubuntu-focal-${{ matrix.compiler }}${TAG} --build-jobs 2 --site GitHub --cmake-args @@ -125,6 +125,8 @@ jobs: -DOMNITRACE_PYTHON_PREFIX=/opt/conda/envs -DOMNITRACE_PYTHON_ENVS="py3.6;py3.7;py3.8;py3.9;py3.10" -DOMNITRACE_MAX_THREADS=32 + -DOMNITRACE_DISABLE_EXAMPLES="transpose;rccl" + -DOMNITRACE_BUILD_NUMBER=${{ github.run_attempt }} - name: Test Build-Tree Module timeout-minutes: 45 @@ -282,7 +284,7 @@ jobs: TAG="-rocm-${{ matrix.rocm-version }}" && TAG="$(echo ${TAG} | sed 's/debian/latest/g')" && ./scripts/run-ci.sh -B build - --name ubuntu-focal-rocm-${{ matrix.compiler }}${TAG} + --name ${{ github.repository_owner }}-${{ github.ref_name }}-ubuntu-focal-rocm-${{ matrix.compiler }}${TAG} --build-jobs 2 --site GitHub --cmake-args @@ -306,7 +308,9 @@ jobs: -DOMNITRACE_PYTHON_PREFIX=/opt/conda/envs -DOMNITRACE_PYTHON_ENVS="py3.6;py3.7;py3.8;py3.9;py3.10" -DOMNITRACE_CI_MPI_RUN_AS_ROOT=${{ matrix.mpi-headers }} + -DOMNITRACE_CI_GPU=OFF -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=OFF + -DOMNITRACE_BUILD_NUMBER=${{ github.run_attempt }} --ctest-args ${{ matrix.ctest-exclude }} @@ -382,7 +386,6 @@ jobs: env: ELFUTILS_DOWNLOAD_VERSION: 0.186 OMNITRACE_VERBOSE: 1 - OMNITRACE_CI: ON steps: - uses: actions/checkout@v3 @@ -420,7 +423,7 @@ jobs: if [ "${{ matrix.mpi }}" = "nompi" ]; then USE_MPI=OFF; else USE_MPI=ON; fi && if [ -z "${{ matrix.deps }}" ]; then TAG=""; else TAG="-external-deps"; fi && ./scripts/run-ci.sh -B ${{ github.workspace }}/build - --name ubuntu-focal-${{ matrix.compiler }}-${{ matrix.mpi }}${TAG} + --name ${{ github.repository_owner }}-${{ github.ref_name }}-ubuntu-focal-${{ matrix.compiler }}-${{ matrix.mpi }}${TAG} --build-jobs 2 --site GitHub --cmake-args @@ -443,6 +446,8 @@ jobs: -DDYNINST_BUILD_STATIC_LIBS=OFF -DDYNINST_ELFUTILS_DOWNLOAD_VERSION=${{ env.ELFUTILS_DOWNLOAD_VERSION }} -DOMNITRACE_MAX_THREADS=32 + -DOMNITRACE_DISABLE_EXAMPLES="transpose;rccl" + -DOMNITRACE_BUILD_NUMBER=${{ github.run_attempt }} - name: Test Build-Tree Env timeout-minutes: 60 @@ -550,7 +555,7 @@ jobs: git config --global --add safe.directory ${PWD} && cmake --version && ./scripts/run-ci.sh -B build - --name ubuntu-focal-codecov-mpi-python-ompt-papi + --name ${{ github.repository_owner }}-${{ github.ref_name }}-ubuntu-focal-codecov-mpi-python-ompt-papi --build-jobs 2 --site GitHub --coverage @@ -564,5 +569,7 @@ jobs: -DOMNITRACE_USE_OMPT=ON -DOMNITRACE_USE_PAPI=ON -DOMNITRACE_USE_HIP=OFF - -DOMNITRACE_USE_RCCL=ON + -DOMNITRACE_USE_RCCL=OFF -DOMNITRACE_MAX_THREADS=32 + -DOMNITRACE_DISABLE_EXAMPLES="transpose;rccl" + -DOMNITRACE_BUILD_NUMBER=${{ github.run_attempt }} diff --git a/.github/workflows/ubuntu-jammy.yml b/.github/workflows/ubuntu-jammy.yml index 78b6420dee..26c7c5ec5c 100644 --- a/.github/workflows/ubuntu-jammy.yml +++ b/.github/workflows/ubuntu-jammy.yml @@ -123,7 +123,7 @@ jobs: append-tagname ${{ matrix.static-libgcc }} libgcc && append-tagname ${{ matrix.static-libstdcxx }} libstdcxx && ./scripts/run-ci.sh -B build - --name ubuntu-jammy-${{ matrix.compiler }}${TAG} + --name ${{ github.repository_owner }}-${{ github.ref_name }}-ubuntu-jammy-${{ matrix.compiler }}${TAG} --build-jobs 2 --site GitHub --cmake-args @@ -147,6 +147,8 @@ jobs: -DOMNITRACE_PYTHON_ENVS="py3.7;py3.8;py3.9;py3.10" -DOMNITRACE_STRIP_LIBRARIES=${{ matrix.strip }} -DOMNITRACE_MAX_THREADS=32 + -DOMNITRACE_DISABLE_EXAMPLES="transpose;rccl" + -DOMNITRACE_BUILD_NUMBER=${{ github.run_attempt }} -DUSE_CLANG_OMP=OFF - name: Install diff --git a/CMakeLists.txt b/CMakeLists.txt index c5d46a040d..2352753abd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,11 +33,21 @@ if(Git_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") execute_process( COMMAND ${GIT_EXECUTABLE} describe --tags OUTPUT_VARIABLE OMNITRACE_GIT_DESCRIBE - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE _GIT_DESCRIBE_RESULT + ERROR_QUIET) + if(NOT _GIT_DESCRIBE_RESULT EQUAL 0) + execute_process( + COMMAND ${GIT_EXECUTABLE} describe + OUTPUT_VARIABLE OMNITRACE_GIT_DESCRIBE + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE _GIT_DESCRIBE_RESULT + ERROR_QUIET) + endif() execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse HEAD OUTPUT_VARIABLE OMNITRACE_GIT_REVISION - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) else() set(OMNITRACE_GIT_DESCRIBE "v${OMNITRACE_VERSION}") set(OMNITRACE_GIT_REVISION "") @@ -184,6 +194,13 @@ endif() if(OMNITRACE_USE_PYTHON) omnitrace_add_option(OMNITRACE_BUILD_PYTHON "Build python bindings with internal pybind11" ON) +elseif("$ENV{OMNITRACE_CI}") + # quiet warnings in dashboard + if(OMNITRACE_PYTHON_ENVS OR OMNITRACE_PYTHON_PREFIX) + omnitrace_message( + STATUS + "Ignoring values of OMNITRACE_PYTHON_ENVS and/or OMNITRACE_PYTHON_PREFIX") + endif() endif() if(NOT OMNITRACE_USE_HIP) diff --git a/cmake/BuildSettings.cmake b/cmake/BuildSettings.cmake index 0895828dad..c91f277cb2 100644 --- a/cmake/BuildSettings.cmake +++ b/cmake/BuildSettings.cmake @@ -27,6 +27,11 @@ omnitrace_add_option(OMNITRACE_BUILD_STATIC_LIBGCC omnitrace_add_option(OMNITRACE_BUILD_STATIC_LIBSTDCXX "Build with -static-libstdc++ if possible" OFF) omnitrace_add_option(OMNITRACE_BUILD_STACK_PROTECTOR "Build with -fstack-protector" ON) +omnitrace_add_cache_option( + OMNITRACE_BUILD_LINKER + "If set to a non-empty value, pass -fuse-ld=\${OMNITRACE_BUILD_LINKER}" STRING "bfd") +omnitrace_add_cache_option(OMNITRACE_BUILD_NUMBER "Internal CI use" STRING "0" ADVANCED + NO_FEATURE) omnitrace_add_interface_library(omnitrace-static-libgcc "Link to static version of libgcc") @@ -224,6 +229,16 @@ if(OMNITRACE_BUILD_DEVELOPER) omnitrace-compile-options "-Werror" "-Wdouble-promotion" "-Wshadow" "-Wextra" "-Wpedantic" "-Wstack-usage=524288" # 512 KB "/showIncludes") + if(OMNITRACE_BUILD_NUMBER LESS 2) + add_target_flag_if_avail(omnitrace-compile-options "-gsplit-dwarf") + endif() +endif() + +if(OMNITRACE_BUILD_LINKER) + target_link_options( + omnitrace-compile-options INTERFACE + $<$:-fuse-ld=${OMNITRACE_BUILD_LINKER}> + $<$:-fuse-ld=${OMNITRACE_BUILD_LINKER}>) endif() # ----------------------------------------------------------------------------------------# diff --git a/cmake/MacroUtilities.cmake b/cmake/MacroUtilities.cmake index 5e993da02d..3636042ea7 100644 --- a/cmake/MacroUtilities.cmake +++ b/cmake/MacroUtilities.cmake @@ -375,6 +375,40 @@ function(OMNITRACE_ADD_OPTION _NAME _MESSAGE _DEFAULT) endif() endfunction() +# ----------------------------------------------------------------------------------------# +# function omnitrace_add_cache_option( +# [NO_FEATURE] [ADVANCED] [CMAKE_DEFINE]) +# +function(OMNITRACE_ADD_CACHE_OPTION _NAME _MESSAGE _TYPE _DEFAULT) + set(_FORCE) + if("FORCE" IN_LIST ARGN) + set(_FORCE FORCE) + endif() + + set(${_NAME} + "${_DEFAULT}" + CACHE ${_TYPE} "${_MESSAGE}" ${_FORCE}) + + if("NO_FEATURE" IN_LIST ARGN) + mark_as_advanced(${_NAME}) + else() + omnitrace_add_feature(${_NAME} "${_MESSAGE}") + + if(OMNITRACE_BUILD_DOCS) + set_property(GLOBAL APPEND PROPERTY ${PROJECT_NAME}_CMAKE_OPTIONS_DOC + "${_NAME}` | ${_MESSAGE} |") + endif() + endif() + + if("ADVANCED" IN_LIST ARGN) + mark_as_advanced(${_NAME}) + endif() + + if("CMAKE_DEFINE" IN_LIST ARGN) + set_property(GLOBAL APPEND PROPERTY ${PROJECT_NAME}_CMAKE_DEFINES ${_NAME}) + endif() +endfunction() + # ----------------------------------------------------------------------------------------# # function omnitrace_report_feature_changes() :: print changes in features # diff --git a/cmake/Modules/FindMPI-Headers.cmake b/cmake/Modules/FindMPI-Headers.cmake index e3d595e447..e9d846a2b1 100644 --- a/cmake/Modules/FindMPI-Headers.cmake +++ b/cmake/Modules/FindMPI-Headers.cmake @@ -109,7 +109,7 @@ elseif("${MPI_HEADERS_VENDOR}" STREQUAL "MPICH") option( MPI_HEADERS_ALLOW_MPICH "Permit the use of MPI headers from MPICH instead of using internal OpenMPI header" - ) + OFF) mark_as_advanced(MPI_HEADERS_ALLOW_MPICH) if(NOT MPI_HEADERS_ALLOW_MPICH) set(_MESSAGE "\nFound MPI headers belonging to a MPICH distribution. ") diff --git a/cmake/Packages.cmake b/cmake/Packages.cmake index 3cd825b227..193b82d475 100644 --- a/cmake/Packages.cmake +++ b/cmake/Packages.cmake @@ -536,8 +536,11 @@ endif() # # ----------------------------------------------------------------------------------------# -target_compile_definitions(omnitrace-timemory-config INTERFACE TIMEMORY_PAPI_ARRAY_SIZE=12 - TIMEMORY_USE_ROOFLINE=0) +target_compile_definitions( + omnitrace-timemory-config + INTERFACE TIMEMORY_PAPI_ARRAY_SIZE=12 TIMEMORY_USE_ROOFLINE=0 TIMEMORY_USE_ERT=0 + TIMEMORY_USE_CONTAINERS=0 TIMEMORY_USE_ERT_EXTERN=0 + TIMEMORY_USE_CONTAINERS_EXTERN=0) if(OMNITRACE_BUILD_STACK_PROTECTOR) add_target_flag_if_avail(omnitrace-timemory-config "-fstack-protector-strong" @@ -628,6 +631,9 @@ set(TIMEMORY_BUILD_EXTRA_OPTIMIZATIONS set(TIMEMORY_BUILD_ERT OFF CACHE BOOL "Disable building ERT support" FORCE) +set(TIMEMORY_BUILD_CONTAINERS + OFF + CACHE BOOL "Disable building container extern templates (unused)" FORCE) # timemory build settings set(TIMEMORY_TLS_MODEL diff --git a/examples/code-coverage/CMakeLists.txt b/examples/code-coverage/CMakeLists.txt index b18f119938..94a265a9b3 100644 --- a/examples/code-coverage/CMakeLists.txt +++ b/examples/code-coverage/CMakeLists.txt @@ -1,6 +1,15 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR) -project(omnitrace-code-coverage LANGUAGES CXX) +project(omnitrace-code-coverage-example LANGUAGES CXX) + +if(OMNITRACE_DISABLE_EXAMPLES) + get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME) + + if(${PROJECT_NAME} IN_LIST OMNITRACE_DISABLE_EXAMPLES OR ${_DIR} IN_LIST + OMNITRACE_DISABLE_EXAMPLES) + return() + endif() +endif() set(CMAKE_BUILD_TYPE "RelWithDebInfo") string(REPLACE " " ";" _FLAGS "${CMAKE_CXX_FLAGS_DEBUG}") diff --git a/examples/lulesh/CMakeLists.txt b/examples/lulesh/CMakeLists.txt index 2dae4a539e..9b42d1f1f5 100644 --- a/examples/lulesh/CMakeLists.txt +++ b/examples/lulesh/CMakeLists.txt @@ -1,6 +1,15 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) -project(lulesh LANGUAGES C CXX) +project(omnitrace-lulesh-example LANGUAGES C CXX) + +if(OMNITRACE_DISABLE_EXAMPLES) + get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME) + + if(${PROJECT_NAME} IN_LIST OMNITRACE_DISABLE_EXAMPLES OR ${_DIR} IN_LIST + OMNITRACE_DISABLE_EXAMPLES) + return() + endif() +endif() set(CMAKE_BUILD_TYPE "RelWithDebInfo") @@ -54,9 +63,9 @@ endif() file(GLOB headers ${PROJECT_SOURCE_DIR}/*.h ${PROJECT_SOURCE_DIR}/*.hxx) file(GLOB sources ${PROJECT_SOURCE_DIR}/*.cc) -add_executable(${PROJECT_NAME} ${sources} ${headers}) -target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/includes) -target_link_libraries(${PROJECT_NAME} PRIVATE Kokkos::kokkos lulesh-mpi) +add_executable(lulesh ${sources} ${headers}) +target_include_directories(lulesh PRIVATE ${PROJECT_SOURCE_DIR}/includes) +target_link_libraries(lulesh PRIVATE Kokkos::kokkos lulesh-mpi) if(OMNITRACE_INSTALL_EXAMPLES) if(LULESH_BUILD_KOKKOS) @@ -64,12 +73,11 @@ if(OMNITRACE_INSTALL_EXAMPLES) TARGETS kokkoscore kokkoscontainers DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT omnitrace-examples) - set_target_properties( - ${PROJECT_NAME} PROPERTIES INSTALL_RPATH - "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") + set_target_properties(lulesh PROPERTIES INSTALL_RPATH + "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") endif() install( - TARGETS ${PROJECT_NAME} + TARGETS lulesh DESTINATION bin COMPONENT omnitrace-examples) endif() diff --git a/examples/mpi/CMakeLists.txt b/examples/mpi/CMakeLists.txt index be8040ee43..4c9452928e 100644 --- a/examples/mpi/CMakeLists.txt +++ b/examples/mpi/CMakeLists.txt @@ -2,9 +2,23 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) project(omnitrace-mpi-examples LANGUAGES C CXX) +if(OMNITRACE_DISABLE_EXAMPLES) + get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME) + + if(${PROJECT_NAME} IN_LIST OMNITRACE_DISABLE_EXAMPLES OR ${_DIR} IN_LIST + OMNITRACE_DISABLE_EXAMPLES) + return() + endif() +endif() + find_package(MPI) if(NOT MPI_FOUND) - message(AUTHOR_WARNING "MPI could not be found. Cannot build omnitrace-mpi target") + if("${CMAKE_PROJECT_NAME}" STREQUAL "omnitrace" AND "$ENV{OMNITRACE_CI}") + set(_MSG_TYPE STATUS) # don't generate warnings during CI + else() + set(_MSG_TYPE AUTHOR_WARNING) + endif() + message(${_MSG_TYPE} "MPI could not be found. Cannot build omnitrace-mpi target") return() endif() diff --git a/examples/parallel-overhead/CMakeLists.txt b/examples/parallel-overhead/CMakeLists.txt index f06177190b..ade34befb8 100644 --- a/examples/parallel-overhead/CMakeLists.txt +++ b/examples/parallel-overhead/CMakeLists.txt @@ -1,6 +1,15 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) -project(omnitrace-parallel-overhead LANGUAGES CXX) +project(omnitrace-parallel-overhead-example LANGUAGES CXX) + +if(OMNITRACE_DISABLE_EXAMPLES) + get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME) + + if(${PROJECT_NAME} IN_LIST OMNITRACE_DISABLE_EXAMPLES OR ${_DIR} IN_LIST + OMNITRACE_DISABLE_EXAMPLES) + return() + endif() +endif() set(CMAKE_BUILD_TYPE "Release") find_package(Threads REQUIRED) diff --git a/examples/python/CMakeLists.txt b/examples/python/CMakeLists.txt index 8a25641471..9f810ed3c0 100644 --- a/examples/python/CMakeLists.txt +++ b/examples/python/CMakeLists.txt @@ -2,6 +2,15 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) project(omnitrace-python) +if(OMNITRACE_DISABLE_EXAMPLES) + get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME) + + if(${PROJECT_NAME} IN_LIST OMNITRACE_DISABLE_EXAMPLES OR ${_DIR} IN_LIST + OMNITRACE_DISABLE_EXAMPLES) + return() + endif() +endif() + set(PYTHON_FILES builtin.py external.py source.py noprofile.py fill.py) find_package(Python3 COMPONENTS Interpreter) diff --git a/examples/rccl/CMakeLists.txt b/examples/rccl/CMakeLists.txt index 226b42aa8d..3142ebd2f5 100644 --- a/examples/rccl/CMakeLists.txt +++ b/examples/rccl/CMakeLists.txt @@ -2,17 +2,46 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) project(omnitrace-rccl-example LANGUAGES CXX) -find_package(rccl) -find_package(hip HINTS ${ROCmVersion_DIR} PATHS ${ROCmVersion_DIR}) +if(OMNITRACE_DISABLE_EXAMPLES) + get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME) -function(rccl_message) + if(${PROJECT_NAME} IN_LIST OMNITRACE_DISABLE_EXAMPLES OR ${_DIR} IN_LIST + OMNITRACE_DISABLE_EXAMPLES) + return() + endif() +endif() + +function(rccl_message _MSG_TYPE) + if("${CMAKE_PROJECT_NAME}" STREQUAL "omnitrace" + AND "$ENV{OMNITRACE_CI}" + AND "${_MSG_TYPE}" MATCHES "WARNING") + set(_MSG_TYPE STATUS) # don't generate warnings during CI + endif() if("${CMAKE_PROJECT_NAME}" STREQUAL "omnitrace") - omnitrace_message(${ARGN}) + omnitrace_message(${_MSG_TYPE} ${ARGN}) else() - message(${ARGN}) + message(${_MSG_TYPE} ${ARGN}) endif() endfunction() +find_package(hip HINTS ${ROCmVersion_DIR} PATHS ${ROCmVersion_DIR}) + +if(NOT hip_FOUND) + rccl_message(AUTHOR_WARNING "${PROJECT_NAME} skipped. Missing HIP...") + return() +endif() + +if("${CMAKE_PROJECT_NAME}" STREQUAL "omnitrace" AND "$ENV{OMNITRACE_CI}") + find_package(rccl QUIET) # avoid generating warning in CI +else() + find_package(rccl) +endif() + +if(NOT rccl_FOUND) + rccl_message(AUTHOR_WARNING "${PROJECT_NAME} skipped. Missing RCCL...") + return() +endif() + if(hip_FOUND AND rccl_FOUND) include(FetchContent) fetchcontent_declare( @@ -56,6 +85,4 @@ if(hip_FOUND AND rccl_FOUND) "${_RCCL_TEST_TARGETS}" CACHE INTERNAL "rccl-test targets") endif() -else() - rccl_message(AUTHOR_WARNING "${PROJECT_NAME} skipped. Missing RCCL and/or HIP...") endif() diff --git a/examples/transpose/CMakeLists.txt b/examples/transpose/CMakeLists.txt index 5ab93b9828..d6a471139b 100644 --- a/examples/transpose/CMakeLists.txt +++ b/examples/transpose/CMakeLists.txt @@ -1,6 +1,15 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) -project(omnitrace-transpose LANGUAGES CXX) +project(omnitrace-transpose-example LANGUAGES CXX) + +if(OMNITRACE_DISABLE_EXAMPLES) + get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME) + + if(${PROJECT_NAME} IN_LIST OMNITRACE_DISABLE_EXAMPLES OR ${_DIR} IN_LIST + OMNITRACE_DISABLE_EXAMPLES) + return() + endif() +endif() find_package(hip QUIET HINTS ${ROCmVersion_DIR} PATHS ${ROCmVersion_DIR}) diff --git a/examples/user-api/CMakeLists.txt b/examples/user-api/CMakeLists.txt index 6d8b502650..754e08eb09 100644 --- a/examples/user-api/CMakeLists.txt +++ b/examples/user-api/CMakeLists.txt @@ -1,6 +1,15 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) -project(omnitrace-user-api LANGUAGES CXX) +project(omnitrace-user-api-example LANGUAGES CXX) + +if(OMNITRACE_DISABLE_EXAMPLES) + get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME) + + if(${PROJECT_NAME} IN_LIST OMNITRACE_DISABLE_EXAMPLES OR ${_DIR} IN_LIST + OMNITRACE_DISABLE_EXAMPLES) + return() + endif() +endif() set(CMAKE_BUILD_TYPE "Debug") find_package(Threads REQUIRED) diff --git a/external/dyninst b/external/dyninst index 65c34d95ea..7ae32b5796 160000 --- a/external/dyninst +++ b/external/dyninst @@ -1 +1 @@ -Subproject commit 65c34d95ea4ce9cb563eca0ecc6e11fa17b99221 +Subproject commit 7ae32b5796a420870c5d6f0bc3f8b610d1587c5a diff --git a/external/timemory b/external/timemory index d5e3987802..7a6a361eb8 160000 --- a/external/timemory +++ b/external/timemory @@ -1 +1 @@ -Subproject commit d5e3987802d18489bcd5cdb47735b12a147877c2 +Subproject commit 7a6a361eb895c30d29cf0652ea26f37c0f7525b4 diff --git a/scripts/run-ci.sh b/scripts/run-ci.sh index 17a6ddb902..03f27b11cf 100755 --- a/scripts/run-ci.sh +++ b/scripts/run-ci.sh @@ -80,7 +80,7 @@ do ;; -n|--name) shift - NAME=$(echo ${1} | sed 's/g++/gcc/g') + NAME=$(echo ${1} | sed 's/g++/gcc/g' | sed 's/\/merge//1') reset-last ;; -s|--site) @@ -249,4 +249,4 @@ EOF verbose-run cat CTestCustom.cmake verbose-run cat dashboard.cmake -verbose-run ctest ${CDASH_ARGS} -S dashboard.cmake --output-on-failure ${CTEST_ARGS} +verbose-run ctest ${CDASH_ARGS} -S dashboard.cmake --output-on-failure -V ${CTEST_ARGS} diff --git a/source/bin/omnitrace/omnitrace.cpp b/source/bin/omnitrace/omnitrace.cpp index 292be99c7b..e820a683f7 100644 --- a/source/bin/omnitrace/omnitrace.cpp +++ b/source/bin/omnitrace/omnitrace.cpp @@ -130,6 +130,12 @@ std::unique_ptr log_ofs = {}; namespace { +namespace process = tim::process; +namespace signals = tim::signals; + +using signal_settings = tim::signals::signal_settings; +using sys_signal = tim::signals::sys_signal; + bool binary_rewrite = false; bool is_attached = false; bool use_mpi = false; @@ -188,9 +194,60 @@ get_cwd(); void find_dyn_api_rt(); -} // namespace -namespace process = tim::process; +void +activate_signal_handlers(const std::vector& _signals) +{ + for(const auto& itr : _signals) + signal_settings::enable(itr); + + static bool _protect = false; + auto _exit_action = [](int nsig) { + if(_protect) return; + _protect = true; + TIMEMORY_PRINTF_FATAL( + stderr, "omnitrace exited with signal %i :: %s\n", nsig, + signal_settings::str(static_cast(nsig)).c_str()); + + // print the last log entries + print_log_entries(std::cerr, num_log_entries); + + // print any forced entries + print_log_entries( + std::cerr, -1, [](const auto& _v) { return _v.forced(); }, + []() { + tim::log::stream(std::cerr, tim::log::color::info()) + << "\n[omnitrace][exe] Potentially important log entries:\n\n"; + }); + + TIMEMORY_PRINTF_FATAL(stderr, "\n"); + TIMEMORY_PRINTF_FATAL( + stderr, + "These were the last %i log entries from omnitrace. You can control the " + "number of log entries via the '--log ' option or OMNITRACE_LOG_COUNT " + "env variable.\n", + num_log_entries); + + if(log_ofs) log_ofs->close(); + log_ofs.reset(); + + _protect = false; + }; + + signal_settings::set_exit_action(_exit_action); + signal_settings::check_environment(); + signals::enable_signal_detection(signal_settings::get_enabled()); +} + +// default signals to catch +auto _activate = + (activate_signal_handlers({ sys_signal::Interrupt, sys_signal::FPE, sys_signal::Stop, + sys_signal::Quit, sys_signal::Illegal, sys_signal::Abort, + sys_signal::Bus, sys_signal::SegFault, + sys_signal::FileSize, sys_signal::CPUtime }), + true); + +} // namespace //======================================================================================// // @@ -201,56 +258,6 @@ namespace process = tim::process; int main(int argc, char** argv) { - { - using signal_settings = tim::signals::signal_settings; - using sys_signal = tim::signals::sys_signal; - - // default signals to catch - for(const auto& itr : - { sys_signal::Interrupt, sys_signal::FPE, sys_signal::Stop, sys_signal::Quit, - sys_signal::Illegal, sys_signal::Abort, sys_signal::Bus, - sys_signal::SegFault, sys_signal::FileSize, sys_signal::CPUtime }) - signal_settings::enable(itr); - - static bool _protect = false; - auto _exit_action = [](int nsig) { - if(_protect) return; - _protect = true; - TIMEMORY_PRINTF_FATAL( - stderr, "omnitrace exited with signal %i :: %s\n", nsig, - signal_settings::str(static_cast(nsig)).c_str()); - - // print the last log entries - print_log_entries(std::cerr, num_log_entries); - - // print any forced entries - print_log_entries( - std::cerr, -1, [](const auto& _v) { return _v.forced(); }, - []() { - tim::log::stream(std::cerr, tim::log::color::info()) - << "\n[omnitrace][exe] Potentially important log entries:\n\n"; - }); - - TIMEMORY_PRINTF_FATAL(stderr, "\n"); - TIMEMORY_PRINTF_FATAL( - stderr, - "These were the last %i log entries from omnitrace. You can control the " - "number of log entries via the '--log ' option or OMNITRACE_LOG_COUNT " - "env variable.\n", - num_log_entries); - - if(log_ofs) log_ofs->close(); - log_ofs.reset(); - - kill(process::get_id(), nsig); - _protect = false; - }; - - signal_settings::set_exit_action(_exit_action); - signal_settings::check_environment(); - tim::signals::enable_signal_detection(signal_settings::get_enabled()); - } - argv0 = argv[0]; OMNITRACE_ADD_LOG_ENTRY(argv[0]); @@ -263,7 +270,7 @@ main(int argc, char** argv) std::vector libname = {}; std::vector sharedlibname = {}; std::vector staticlibname = {}; - tim::process::id_t _pid = -1; + process::id_t _pid = -1; fixed_module_functions = { { &available_module_functions, false }, @@ -881,8 +888,7 @@ main(int argc, char** argv) auto _settings = tim::settings::push(); for(auto&& iitr : *_settings) { - iitr.second->set_config_updated(false); - iitr.second->set_environ_updated(false); + if(iitr.second->get_updated()) iitr.second->set_user_updated(); } _settings->read(itr); for(auto&& iitr : *_settings) @@ -2554,9 +2560,12 @@ find_dyn_api_rt() (_file_exists(tim::get_env("DYNINSTAPI_RT_LIB", ""))) ? 0 : 1; tim::set_env("DYNINSTAPI_RT_LIB", _fname, _overwrite); _fname = tim::get_env("DYNINSTAPI_RT_LIB", _fname); - tim::set_env("DYNINST_REWRITER_PATHS", - TIMEMORY_JOIN(':', dirname(_fname), _rewriter_paths), - 1); + tim::set_env( + "DYNINST_REWRITER_PATHS", + _rewriter_paths.empty() + ? dirname(_fname) + : TIMEMORY_JOIN(':', dirname(_fname), _rewriter_paths), + 1); }; auto _resolved = [&](std::string _fname) { diff --git a/source/bin/omnitrace/omnitrace.hpp b/source/bin/omnitrace/omnitrace.hpp index 9b24f608d5..57a605916a 100644 --- a/source/bin/omnitrace/omnitrace.hpp +++ b/source/bin/omnitrace/omnitrace.hpp @@ -32,6 +32,7 @@ #include #include +#include //======================================================================================// @@ -229,9 +230,11 @@ omnitrace_get_address_space(patch_pointer_t& _bpatch, int _cmdc, char** _cmdv, auto _cmd_msg = ss.str(); if(_cmd_msg.length() > 1) _cmd_msg = _cmd_msg.substr(1); + char** _environ = environ; verbprintf(1, "Creating process '%s'... ", _cmd_msg.c_str()); fflush(stderr); - mutatee = _bpatch->processCreate(_cmdv[0], (const char**) _cmdv, nullptr); + mutatee = _bpatch->processCreate(_cmdv[0], (const char**) _cmdv, + (const char**) _environ); if(!mutatee) { verbprintf(-1, "Failed to create process: '%s'\n", _cmd_msg.c_str()); diff --git a/source/lib/omnitrace/library/components/backtrace.cpp b/source/lib/omnitrace/library/components/backtrace.cpp index e8a6af6997..dfbec0b628 100644 --- a/source/lib/omnitrace/library/components/backtrace.cpp +++ b/source/lib/omnitrace/library/components/backtrace.cpp @@ -80,9 +80,9 @@ backtrace::get() const if(size() == 0) return _v; { - static auto _cache = cache_type{}; + static auto _cache = cache_type{ get_sampling_include_inlines() }; auto_lock_t _lk{ type_mutex() }; - _v = m_data.get(&_cache, true); + _v = m_data.get(&_cache, false); } // put the bottom of the call-stack on top @@ -144,6 +144,7 @@ backtrace::filter_and_patch(const std::vector& _data) }; auto _ret = std::vector{}; + _ret.reserve(_data.size()); for(const auto& itr : _data) { auto _name = tim::demangle(_patch_label(itr.name)); @@ -183,7 +184,7 @@ backtrace::sample(int) { using namespace tim::backtrace; constexpr bool with_signal_frame = false; - constexpr size_t ignore_depth = 3; + constexpr size_t ignore_depth = 4; // ignore depth based on: // 1. this frame // 2. tim::sampling::sampler<...>::sample(...) [always inline] diff --git a/source/lib/omnitrace/library/kokkosp.cpp b/source/lib/omnitrace/library/kokkosp.cpp index 537ee0f154..7b25b4f546 100644 --- a/source/lib/omnitrace/library/kokkosp.cpp +++ b/source/lib/omnitrace/library/kokkosp.cpp @@ -321,7 +321,6 @@ extern "C" void kokkosp_push_profile_region(const char* name) { - if(omnitrace::get_use_perfetto()) return; // perfetto doesn't support regions OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); kokkosp::logger_t{}.mark(1, __FUNCTION__, name); kokkosp::get_profiler_stack().push_back( @@ -331,7 +330,6 @@ extern "C" void kokkosp_pop_profile_region() { - if(omnitrace::get_use_perfetto()) return; // perfetto doesn't support regions OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); kokkosp::logger_t{}.mark(-1, __FUNCTION__); if(kokkosp::get_profiler_stack().empty()) return; @@ -343,7 +341,6 @@ extern "C" void kokkosp_create_profile_section(const char* name, uint32_t* secid) { - if(omnitrace::get_use_perfetto()) return; // perfetto doesn't support regions OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); *secid = kokkosp::get_unique_id(); auto pname = TIMEMORY_JOIN(" ", "[kokkos]", name); @@ -352,7 +349,6 @@ extern "C" void kokkosp_destroy_profile_section(uint32_t secid) { - if(omnitrace::get_use_perfetto()) return; // perfetto doesn't support regions OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); kokkosp::destroy_profiler(secid); } @@ -361,7 +357,6 @@ extern "C" void kokkosp_start_profile_section(uint32_t secid) { - if(omnitrace::get_use_perfetto()) return; // perfetto doesn't support regions OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); kokkosp::logger_t{}.mark(1, __FUNCTION__, secid); kokkosp::start_profiler(secid); @@ -369,7 +364,6 @@ extern "C" void kokkosp_stop_profile_section(uint32_t secid) { - if(omnitrace::get_use_perfetto()) return; // perfetto doesn't support regions OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); kokkosp::logger_t{}.mark(-1, __FUNCTION__, secid); kokkosp::start_profiler(secid); diff --git a/source/lib/omnitrace/library/rocprofiler.cpp b/source/lib/omnitrace/library/rocprofiler.cpp index 2138026277..a318f6fb61 100644 --- a/source/lib/omnitrace/library/rocprofiler.cpp +++ b/source/lib/omnitrace/library/rocprofiler.cpp @@ -513,6 +513,7 @@ post_process_perfetto() for(const auto& itr : _inp) { if(_ts >= itr->entry && _ts <= itr->exit) _v.emplace_back(itr); + if(_ts > itr->exit) break; } return _v; }; @@ -551,11 +552,14 @@ post_process_perfetto() for(auto& ditr : _device_range) { - auto _dev_id = ditr.first; - auto _values = std::vector{}; + auto _dev_id = ditr.first; + auto _values = std::vector{}; + auto _ts_sorted_data = _device_data[_dev_id]; + std::sort(_ts_sorted_data.begin(), _ts_sorted_data.end(), + [](auto* _l, auto* _r) { return _l->exit < _r->exit; }); for(const auto& itr : ditr.second) { - auto _v = _get_events(_device_data[_dev_id], itr); + auto _v = _get_events(_ts_sorted_data, itr); uint64_t _ts = itr; for(auto* vitr : _v) { @@ -629,6 +633,13 @@ post_process_timemory() _device_data[itr.device_id].emplace_back(&itr); } + for(auto& itr : _device_data) + { + // sort according to when it exited + std::sort(itr.second.begin(), itr.second.end(), + [](auto* _lhs, auto* _rhs) { return _lhs->exit < _rhs->exit; }); + } + using storage_type = typename rocm_data_tracker::storage_type; using bundle_type = tim::lightweight_tuple; @@ -646,8 +657,8 @@ post_process_timemory() struct local_event { - rocm_event* parent = nullptr; - std::vector children = {}; + rocm_event* parent = nullptr; + mutable std::vector children = {}; TIMEMORY_DEFAULT_OBJECT(local_event) @@ -657,17 +668,11 @@ post_process_timemory() bool operator()(rocm_event* _v) { - OMNITRACE_CI_THROW(!parent, "Error! '%s' has nullptr", __PRETTY_FUNCTION__); - + if(!parent) return false; if(_v->device_id != parent->device_id) return false; if(_v->entry > parent->entry && _v->exit <= parent->exit) { - for(auto& itr : children) - { - if(itr(_v)) return true; - } children.emplace_back(_v); - std::sort(children.begin(), children.end()); return true; } return false; @@ -675,22 +680,20 @@ post_process_timemory() bool operator<(const local_event& _v) const { - OMNITRACE_CI_THROW(!parent, "Error! '%s' has nullptr", __PRETTY_FUNCTION__); - OMNITRACE_CI_THROW(!_v.parent, "Error! '%s' passed nullptr", - __PRETTY_FUNCTION__); - + if(!parent && _v.parent) return true; + if(parent && !_v.parent) return false; return *parent < *_v.parent; } void operator()(int64_t _index, scope::config _scope) const { - OMNITRACE_CI_THROW(!parent, "Error! '%s' has nullptr", __PRETTY_FUNCTION__); - + if(!parent) return; bundle_type _bundle{ parent->name, _scope }; _bundle.push(parent->queue_id) .start() .store(parent->feature_values.at(_index)); + std::sort(children.begin(), children.end()); for(const auto& itr : children) itr(_index, _scope); @@ -737,6 +740,8 @@ post_process_timemory() for(auto& ditr : _device_data) { + OMNITRACE_VERBOSE_F(1, "Post-processing %zu entries for device %u...\n", + ditr.second.size(), ditr.first); auto _storage = std::vector{}; for(auto& itr : ditr.second) { @@ -752,22 +757,38 @@ post_process_timemory() } auto& _local = _local_data[ditr.first]; + _local.reserve(ditr.second.size()); + double _avg = 0.0; for(auto& itr : ditr.second) { - for(auto& litr : _local) + if(_local.empty() || itr->entry >= _local.back().parent->exit) { - if(litr(itr)) - { - goto _bypass_insert; - } + _local.emplace_back(itr); + } + else + { + size_t _n = 0; + bool _found = false; + for(auto litr = _local.rbegin(); litr != _local.rend(); ++litr) + { + ++_n; + if((*litr)(itr)) + { + _found = true; + break; + } + } + if(!_found) _local.emplace_back(itr); + _avg += _n; } - _local.emplace_back(itr); - _bypass_insert:; } + OMNITRACE_VERBOSE_F(3, "Average # of iterations before match: %.1f\n", + _avg / ditr.second.size() * 100.0); + for(auto& sitr : _storage) { - for(auto& itr : _local_data[ditr.first]) + for(auto& itr : _local) sitr(itr, _scope); } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f30b40d940..3b53027b09 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -180,7 +180,7 @@ endif() # -------------------------------------------------------------------------------------- # set(_VALID_GPU OFF) -if(OMNITRACE_USE_HIP) +if(OMNITRACE_USE_HIP AND (NOT DEFINED OMNITRACE_CI_GPU OR OMNITRACE_CI_GPU)) set(_VALID_GPU ON) find_program( OMNITRACE_ROCM_SMI_EXE