808ea7dfa7
## Overview
This is a significant PR which has 3 very notable characteristics:
1. Omnitrace colorizes most of it's logging
2. Completely reworked the sampling
- Samples now record the current instruction pointers instead of strings
- This _dramatically_ decreases the overhead of taking a sample
- The collection of metrics during a sample are split out into another component, enabling that data collection to be disabled -- which decreases the sampling overhead even further
- When both `OMNITRACE_SAMPLING_CPUTIME` and `OMNITRACE_SAMPLING_REALTIME` are ON:
- `OMNITRACE_SAMPLING_CPUTIME_FREQ` and `OMNITRACE_SAMPLING_REALTIME_FREQ` can be used to individually control the sampling frequency
- `OMNITRACE_SAMPLING_CPUTIME_DELAY` and `OMNITRACE_SAMPLING_REALTIME_DELAY` can be used to individually control the delay time before starting
- Now, omnitrace does not start a real-time sampler on the main thread unless `OMNITRACE_SAMPLING_REALTIME` is ON
- In the future, an `OMNITRACE_SAMPLING_TIDS` (and real-time, cpu-time variants) configuration variable(s) will allow you to select which threads will be sampled
3. Files produced by `omnitrace` exe -- `available-instr.txt`, `instrumented-instr.txt`, etc. -- now no longer has `-instr` suffix and are placed in `instrumentation/` subfolder, i.e. `available-instr.txt` -> instrumentation/available.txt`
- This helped de-clutter the output folder
Most of the other edits were reorganization (e.g. internal namespace changes), cleanup, and splitting up functionality.
## Bug Fixes
There is a bug fix with respect to the HSA callbacks which disabled sampling on child threads when an HSA API call was made
## Details
- created thread_info struct for mapping different thread IDs
- reorganized file structure significantly
- added categories.hpp, concepts.hpp
- moved around name trait definitions
- moved all omnitrace components into `omnitrace::component` namespace
- there was a lot of inconsistency b/t using `tim::component` in some places and `omnitrace::component`
- added macros like OMNITRACE_DECLARE_COMPONENT in lieu of TIMEMORY_DECLARE_COMPONENT
- OMNITRACE_CRITICAL_TRACE_NUM_THREADS -> OMNITRACE_THREAD_POOL_SIZE
- roctracer and critical_trace use same thread pool
- critical_trace functions do not lock anymore bc of thread-local TaskGroup
- added `component::local_category_region` to support using `component::category_region` without explicitly passing in name
- removed `component::omnitrace` (unused)
- migrated KokkosP and OMPT to use `component::local_category_region`
- removed `component::user_region` as a result
- migrated omnitrace_{push,pop}_{trace,region}_hidden to use component::category_region
- removed `component::functors` as a result
- migrated some ppdefs
- `api::omnitrace` -> `project::omnitrace`
- `api::(...)` -> `category::(...)`
- improved recording the execution time of threads
- migrated this functionality out of pthread_create_gotcha and into thread_info
- moved mpi_gotcha, fork_gotcha, exit_gotcha, rcclp into omnitrace::component namespace
- split backtrace up into backtrace, backtrace_metrics, backtrace_timestamp components
- sampling.cpp handles setup and post-processing that was formerly in backtrace
- updated logging to use colors
- `OMNITRACE_COLORIZED_LOG` config variable
- updated docs on JSON output from timemory
- instrumentation info in instrumentation subfolder
- added testing for KokkosP entries
- added testing for ompt entries
- add_critical_trace function defined in critical_trace.hpp
- disable push_thread_state and pop_thread_state when thread state is Disabled or Completed
- add comp::page_rss to main bundle
- thread_data supports std::optional instead of std::unique_ptr
- thread_data supports tim::identity<T> to avoid unique_ptr or optional
- tracing::record_thread_start_time()
- tracing::push_timemory and tracing::pop_timemory are templated on CategoryT
- removed anonymous namespace from omnitrace::utility
- sampling backtrace stores instruction pointers instead of strings
- component::category_region updates
- handle disabled thread state
- handle finalized state
- fewer debug messages
- invoke thread_init()
- invoke thread_init_sampling()
- handle push/pop count based on category
- push/pop count only modified when used
- component::cpu_freq
- components/ensure_storage.hpp
- reworked the pthread_create replacement function
- updated parallel-overhead example to report # of times locked
- OMNITRACE_MAX_UNWIND_DEPTH build option
- update timemory submodule
336 line
12 KiB
CMake
336 line
12 KiB
CMake
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
|
|
|
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND CMAKE_CURRENT_SOURCE_DIR STREQUAL
|
|
CMAKE_SOURCE_DIR)
|
|
set(MSG "")
|
|
message(STATUS "Warning! Building from the source directory is not recommended")
|
|
message(STATUS "If unintented, please remove 'CMakeCache.txt' and 'CMakeFiles'")
|
|
message(STATUS "and build from a separate directory")
|
|
message(AUTHOR_WARNING "In-source build")
|
|
endif()
|
|
|
|
if(NOT UNIX OR APPLE)
|
|
message(
|
|
AUTHOR_WARNING
|
|
"omnitrace only supports Linux. Configure and/or build is likely to fail")
|
|
endif()
|
|
|
|
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" FULL_VERSION_STRING LIMIT_COUNT 1)
|
|
string(REGEX REPLACE "(\n|\r)" "" FULL_VERSION_STRING "${FULL_VERSION_STRING}")
|
|
string(REGEX REPLACE "([0-9]+)\.([0-9]+)\.([0-9]+)(.*)" "\\1.\\2.\\3" OMNITRACE_VERSION
|
|
"${FULL_VERSION_STRING}")
|
|
|
|
project(
|
|
omnitrace
|
|
LANGUAGES C CXX
|
|
VERSION ${OMNITRACE_VERSION}
|
|
DESCRIPTION "CPU/GPU Application tracing with static/dynamic binary instrumentation"
|
|
HOMEPAGE_URL "https://github.com/AMDResearch/omnitrace")
|
|
|
|
find_package(Git)
|
|
|
|
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)
|
|
execute_process(
|
|
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
|
|
OUTPUT_VARIABLE OMNITRACE_GIT_REVISION
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
else()
|
|
set(OMNITRACE_GIT_DESCRIBE "v${OMNITRACE_VERSION}")
|
|
set(OMNITRACE_GIT_REVISION "")
|
|
endif()
|
|
|
|
message(
|
|
STATUS
|
|
"[${PROJECT_NAME}] version ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} (${FULL_VERSION_STRING})"
|
|
)
|
|
message(STATUS "[${PROJECT_NAME}] git revision: ${OMNITRACE_GIT_REVISION}")
|
|
message(STATUS "[${PROJECT_NAME}] git describe: ${OMNITRACE_GIT_DESCRIBE}")
|
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${PROJECT_SOURCE_DIR}/cmake/Modules
|
|
${PROJECT_SOURCE_DIR}/source/python/cmake ${CMAKE_MODULE_PATH})
|
|
set(BUILD_SHARED_LIBS
|
|
ON
|
|
CACHE BOOL "Build shared libraries")
|
|
set(BUILD_STATIC_LIBS
|
|
OFF
|
|
CACHE BOOL "Build static libraries")
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE
|
|
ON
|
|
CACHE BOOL "Build position independent code")
|
|
|
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
|
set(CMAKE_BUILD_TYPE
|
|
Release
|
|
CACHE STRING "Build type" FORCE)
|
|
else()
|
|
set(VALID_BUILD_TYPES "Release" "RelWithDebInfo" "Debug" "MinSizeRel")
|
|
if(NOT "${CMAKE_BUILD_TYPE}" IN_LIST VALID_BUILD_TYPES)
|
|
string(REPLACE ";" ", " _VALID_BUILD_TYPES "${VALID_BUILD_TYPES}")
|
|
message(
|
|
FATAL_ERROR
|
|
"Invalid CMAKE_BUILD_TYPE :: ${CMAKE_BUILD_TYPE}. Valid build types are: ${_VALID_BUILD_TYPES}"
|
|
)
|
|
endif()
|
|
endif()
|
|
set(_STRIP_LIBRARIES_DEFAULT OFF)
|
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
|
|
set(_STRIP_LIBRARIES_DEFAULT ON)
|
|
endif()
|
|
|
|
if(DEFINED CMAKE_INSTALL_LIBDIR AND NOT DEFINED CMAKE_DEFAULT_INSTALL_LIBDIR)
|
|
# always have a fresh install
|
|
unset(CMAKE_INSTALL_LIBDIR CACHE)
|
|
include(GNUInstallDirs) # install directories
|
|
# force this because dyninst always installs to lib
|
|
set(CMAKE_DEFAULT_INSTALL_LIBDIR
|
|
"${CMAKE_INSTALL_LIBDIR}"
|
|
CACHE STRING "Object code libraries" FORCE)
|
|
endif()
|
|
|
|
include(GNUInstallDirs) # install directories
|
|
include(MacroUtilities) # various functions and macros
|
|
include(Compilers) # compiler identification
|
|
include(BuildSettings) # compiler flags
|
|
|
|
set(CMAKE_INSTALL_LIBDIR
|
|
"lib"
|
|
CACHE STRING "Object code libraries (lib)" FORCE)
|
|
set(CMAKE_CXX_STANDARD
|
|
17
|
|
CACHE STRING "CXX language standard")
|
|
|
|
omnitrace_add_feature(CMAKE_BUILD_TYPE "Build optimization level")
|
|
omnitrace_add_feature(CMAKE_INSTALL_PREFIX "Installation prefix")
|
|
omnitrace_add_feature(CMAKE_CXX_COMPILER "C++ compiler")
|
|
omnitrace_add_feature(CMAKE_CXX_STANDARD "CXX language standard")
|
|
omnitrace_add_option(CMAKE_CXX_STANDARD_REQUIRED "Require C++ language standard" ON)
|
|
omnitrace_add_option(CMAKE_CXX_EXTENSIONS "Compiler specific language extensions" OFF)
|
|
omnitrace_add_option(CMAKE_INSTALL_RPATH_USE_LINK_PATH "Enable rpath to linked libraries"
|
|
ON)
|
|
set(CMAKE_INSTALL_MESSAGE
|
|
"LAZY"
|
|
CACHE STRING "Installation message")
|
|
mark_as_advanced(CMAKE_INSTALL_MESSAGE)
|
|
|
|
omnitrace_add_option(OMNITRACE_USE_CLANG_TIDY "Enable clang-tidy" OFF)
|
|
omnitrace_add_option(OMNITRACE_USE_MPI "Enable MPI support" OFF)
|
|
omnitrace_add_option(OMNITRACE_USE_HIP "Enable HIP support" ON)
|
|
omnitrace_add_option(OMNITRACE_USE_PAPI "Enable HW counter support via PAPI" ON)
|
|
omnitrace_add_option(OMNITRACE_USE_ROCTRACER "Enable roctracer support"
|
|
${OMNITRACE_USE_HIP})
|
|
omnitrace_add_option(OMNITRACE_USE_ROCPROFILER "Enable rocprofiler support"
|
|
${OMNITRACE_USE_HIP})
|
|
omnitrace_add_option(
|
|
OMNITRACE_USE_ROCM_SMI "Enable rocm-smi support for power/temp/etc. sampling"
|
|
${OMNITRACE_USE_HIP})
|
|
omnitrace_add_option(OMNITRACE_USE_RCCL "Enable RCCL support" ${OMNITRACE_USE_HIP})
|
|
omnitrace_add_option(OMNITRACE_USE_MPI_HEADERS
|
|
"Enable wrapping MPI functions w/o enabling MPI dependency" ON)
|
|
omnitrace_add_option(OMNITRACE_USE_OMPT "Enable OpenMP tools support" ON)
|
|
omnitrace_add_option(OMNITRACE_USE_PYTHON "Enable Python support" OFF)
|
|
omnitrace_add_option(OMNITRACE_BUILD_DYNINST "Build dyninst from submodule" OFF)
|
|
omnitrace_add_option(OMNITRACE_BUILD_LIBUNWIND "Build libunwind from submodule" ON)
|
|
omnitrace_add_option(OMNITRACE_BUILD_EXAMPLES "Enable building the examples" OFF)
|
|
omnitrace_add_option(OMNITRACE_BUILD_TESTING "Enable building the testing suite" OFF)
|
|
omnitrace_add_option(OMNITRACE_CUSTOM_DATA_SOURCE "Enable custom data source" OFF
|
|
ADVANCED)
|
|
omnitrace_add_option(
|
|
OMNITRACE_BUILD_HIDDEN_VISIBILITY
|
|
"Build with hidden visibility (disable for Debug builds)" ON ADVANCED)
|
|
omnitrace_add_option(OMNITRACE_BUILD_CI "Enable internal asserts, etc." OFF ADVANCED
|
|
NO_FEATURE)
|
|
omnitrace_add_option(OMNITRACE_INSTALL_PERFETTO_TOOLS
|
|
"Install perfetto tools (i.e. traced, perfetto, etc.)" OFF)
|
|
omnitrace_add_option(OMNITRACE_STRIP_LIBRARIES "Strip the libraries"
|
|
${_STRIP_LIBRARIES_DEFAULT} ADVANCED)
|
|
|
|
if(OMNITRACE_USE_PAPI)
|
|
omnitrace_add_option(OMNITRACE_BUILD_PAPI "Build PAPI from submodule" ON)
|
|
endif()
|
|
|
|
if(OMNITRACE_USE_PYTHON)
|
|
omnitrace_add_option(OMNITRACE_BUILD_PYTHON
|
|
"Build python bindings with internal pybind11" ON)
|
|
endif()
|
|
|
|
if(NOT "$ENV{OMNITRACE_CI}" STREQUAL "")
|
|
message(
|
|
AUTHOR_WARNING
|
|
"OMNITRACE_CI environment variable ($ENV{OMNITRACE_CI}) is overridding the OMNITRACE_BUILD_CI cache value"
|
|
)
|
|
set(OMNITRACE_BUILD_CI
|
|
"$ENV{OMNITRACE_CI}"
|
|
CACHE BOOL "Enable internal asserts, etc" FORCE)
|
|
endif()
|
|
|
|
if(NOT OMNITRACE_USE_HIP)
|
|
set(OMNITRACE_USE_ROCTRACER
|
|
OFF
|
|
CACHE BOOL "Disabled via OMNITRACE_USE_HIP=OFF" FORCE)
|
|
set(OMNITRACE_USE_ROCPROFILER
|
|
OFF
|
|
CACHE BOOL "Disabled via OMNITRACE_USE_HIP=OFF" FORCE)
|
|
set(OMNITRACE_USE_ROCM_SMI
|
|
OFF
|
|
CACHE BOOL "Disabled via OMNITRACE_USE_HIP=OFF" FORCE)
|
|
set(OMNITRACE_USE_RCCL
|
|
OFF
|
|
CACHE BOOL "Disabled via OMNITRACE_USE_HIP=OFF" FORCE)
|
|
elseif(
|
|
OMNITRACE_USE_HIP
|
|
AND NOT OMNITRACE_USE_ROCTRACER
|
|
AND NOT OMNITRACE_USE_ROCPROFILER
|
|
AND NOT OMNITRACE_USE_ROCM_SMI
|
|
AND NOT OMNITRACE_USE_RCCL)
|
|
omnitrace_message(
|
|
AUTHOR_WARNING
|
|
"Setting OMNITRACE_USE_HIP=OFF because roctracer, rocprofiler, rccl, and rocm-smi options are disabled"
|
|
)
|
|
set(OMNITRACE_USE_HIP OFF)
|
|
endif()
|
|
|
|
if(OMNITRACE_BUILD_TESTING)
|
|
set(OMNITRACE_BUILD_EXAMPLES
|
|
ON
|
|
CACHE BOOL "Enable building the examples" FORCE)
|
|
endif()
|
|
|
|
include(ProcessorCount)
|
|
processorcount(OMNITRACE_PROCESSOR_COUNT)
|
|
math(EXPR OMNITRACE_THREAD_COUNT "16 * ${OMNITRACE_PROCESSOR_COUNT}")
|
|
if(OMNITRACE_THREAD_COUNT LESS 128)
|
|
set(OMNITRACE_THREAD_COUNT 128)
|
|
endif()
|
|
set(OMNITRACE_MAX_THREADS
|
|
"${OMNITRACE_THREAD_COUNT}"
|
|
CACHE
|
|
STRING
|
|
"Maximum number of threads in the host application. Likely only needs to be increased if host app does not use thread-pool but creates many threads"
|
|
)
|
|
omnitrace_add_feature(
|
|
OMNITRACE_MAX_THREADS
|
|
"Maximum number of total threads supported in the host application (default: max of 128 or 16 * nproc)"
|
|
)
|
|
set(OMNITRACE_MAX_UNWIND_DEPTH
|
|
"64"
|
|
CACHE
|
|
STRING
|
|
"Maximum call-stack depth to search during call-stack unwinding. Decreasing this value will result in sampling consuming less memory"
|
|
)
|
|
omnitrace_add_feature(
|
|
OMNITRACE_MAX_UNWIND_DEPTH
|
|
"Maximum call-stack depth to search during call-stack unwinding. Decreasing this value will result in sampling consuming less memory"
|
|
)
|
|
|
|
# default visibility settings
|
|
set(CMAKE_C_VISIBILITY_PRESET
|
|
"default"
|
|
CACHE STRING "Visibility preset for non-inline C functions")
|
|
set(CMAKE_CXX_VISIBILITY_PRESET
|
|
"default"
|
|
CACHE STRING "Visibility preset for non-inline C++ functions/objects")
|
|
set(CMAKE_VISIBILITY_INLINES_HIDDEN
|
|
OFF
|
|
CACHE BOOL "Visibility preset for inline functions")
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
include(Formatting) # format target
|
|
include(Packages) # finds third-party libraries
|
|
|
|
omnitrace_activate_clang_tidy()
|
|
|
|
# custom visibility settings
|
|
if(OMNITRACE_BUILD_HIDDEN_VISIBILITY)
|
|
set(CMAKE_C_VISIBILITY_PRESET "internal")
|
|
set(CMAKE_CXX_VISIBILITY_PRESET "internal")
|
|
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
|
|
endif()
|
|
|
|
if(OMNITRACE_BUILD_TESTING OR "$ENV{OMNITRACE_CI}" MATCHES "[1-9]+|ON|on|y|yes")
|
|
include(CTest)
|
|
enable_testing()
|
|
endif()
|
|
|
|
# ------------------------------------------------------------------------------#
|
|
#
|
|
# library and executables
|
|
#
|
|
# ------------------------------------------------------------------------------#
|
|
|
|
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME core)
|
|
|
|
add_subdirectory(source)
|
|
|
|
# ------------------------------------------------------------------------------#
|
|
#
|
|
# miscellaneous installs
|
|
#
|
|
# ------------------------------------------------------------------------------#
|
|
|
|
configure_file(
|
|
${PROJECT_SOURCE_DIR}/omnitrace.cfg
|
|
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/omnitrace.cfg
|
|
COPYONLY)
|
|
|
|
configure_file(
|
|
${PROJECT_SOURCE_DIR}/cmake/Templates/setup-env.sh.in
|
|
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/setup-env.sh @ONLY)
|
|
|
|
configure_file(
|
|
${PROJECT_SOURCE_DIR}/cmake/Templates/modulefile.in
|
|
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/modulefiles/${PROJECT_NAME}/${OMNITRACE_VERSION}
|
|
@ONLY)
|
|
|
|
install(
|
|
FILES ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/setup-env.sh
|
|
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/omnitrace.cfg
|
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}
|
|
COMPONENT setup)
|
|
|
|
install(
|
|
FILES
|
|
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/modulefiles/${PROJECT_NAME}/${OMNITRACE_VERSION}
|
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/modulefiles/${PROJECT_NAME}
|
|
COMPONENT setup)
|
|
|
|
# ------------------------------------------------------------------------------#
|
|
#
|
|
# examples
|
|
#
|
|
# ------------------------------------------------------------------------------#
|
|
|
|
if(OMNITRACE_BUILD_EXAMPLES)
|
|
add_subdirectory(examples)
|
|
endif()
|
|
|
|
# ------------------------------------------------------------------------------#
|
|
#
|
|
# tests
|
|
#
|
|
# ------------------------------------------------------------------------------#
|
|
|
|
if(OMNITRACE_BUILD_TESTING)
|
|
add_subdirectory(tests)
|
|
endif()
|
|
|
|
# ------------------------------------------------------------------------------#
|
|
#
|
|
# packaging
|
|
#
|
|
# ------------------------------------------------------------------------------#
|
|
|
|
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME core)
|
|
include(ConfigInstall)
|
|
include(ConfigCPack)
|
|
|
|
# ------------------------------------------------------------------------------#
|
|
#
|
|
# config info
|
|
#
|
|
# ------------------------------------------------------------------------------#
|
|
|
|
omnitrace_print_features()
|