cmake-format + miscellaneous tweaks (#13)
* cmake-format + miscellaneous tweaks
* Formatted cmake in examples and tests
* Updated linux-ci.yml artifacts naming
* Updated clang-format
* Fixed submodule branches
[ROCm/rocprofiler-systems commit: 6c93674f92]
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8bda450acf
Коммит
f3e7a1664a
@@ -1,65 +1,148 @@
|
||||
# requires clang-tidy version 6.0+
|
||||
# clang-format v11
|
||||
---
|
||||
Language: Cpp
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveMacros: true
|
||||
AlignConsecutiveAssignments: true
|
||||
AlignConsecutiveBitFields: true
|
||||
AlignConsecutiveDeclarations: true
|
||||
AlignEscapedNewlinesLeft: false
|
||||
AlignOperands: true
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: TopLevel
|
||||
AlwaysBreakAfterReturnType: TopLevel
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
BasedOnStyle: Mozilla
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterClass: true
|
||||
AfterControlStatement: true
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: true
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
AfterExternBlock: true
|
||||
BeforeCatch: false
|
||||
BeforeElse: true
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: false
|
||||
AfterCaseLabel: true
|
||||
AfterClass: true
|
||||
AfterControlStatement: Always
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: true
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
AfterExternBlock: true
|
||||
BeforeCatch: false
|
||||
BeforeElse: true
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: false
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeInheritanceComma: true
|
||||
BreakInheritanceList: BeforeComma
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeComma
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 90
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: true
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 0
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: false
|
||||
DeriveLineEnding: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentCaseLabels: true
|
||||
IndentCaseBlocks: false
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: AfterHash
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertTrailingCommas: None
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
Language: Cpp
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: true
|
||||
ObjCSpaceBeforeProtocolList: false
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 200
|
||||
PointerAlignment: Left
|
||||
ReflowComments: true
|
||||
SortIncludes: true
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: true
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeParens: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: Never
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SpacesInAngles: false
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Cpp11
|
||||
SpaceBeforeSquareBrackets: false
|
||||
Standard: Latest
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
UseCRLF: false
|
||||
UseTab: Never
|
||||
WhitespaceSensitiveMacros:
|
||||
- STRINGIZE
|
||||
- PP_STRINGIZE
|
||||
- BOOST_PP_STRINGIZE
|
||||
...
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
parse:
|
||||
additional_commands:
|
||||
checkout_git_submodule:
|
||||
flags:
|
||||
- RECURSIVE
|
||||
kwargs:
|
||||
RELATIVE_PATH: '*'
|
||||
WORKING_DIRECTORY: '*'
|
||||
TEST_FILE: '*'
|
||||
REPO_URL: '*'
|
||||
REPO_BRANCH: '*'
|
||||
ADDITIONAL_COMMANDS: '*'
|
||||
hosttrace_save_variables:
|
||||
kwargs:
|
||||
VARIABLES: '*'
|
||||
CONDITION: '*'
|
||||
hosttrace_restore_variables:
|
||||
kwargs:
|
||||
VARIABLES: '*'
|
||||
CONDITION: '*'
|
||||
override_spec: {}
|
||||
vartags: []
|
||||
proptags: []
|
||||
format:
|
||||
disable: false
|
||||
line_width: 90
|
||||
tab_size: 4
|
||||
use_tabchars: false
|
||||
fractional_tab_policy: use-space
|
||||
max_subgroups_hwrap: 2
|
||||
max_pargs_hwrap: 8
|
||||
max_rows_cmdline: 2
|
||||
separate_ctrl_name_with_space: false
|
||||
separate_fn_name_with_space: false
|
||||
dangle_parens: false
|
||||
dangle_align: child
|
||||
min_prefix_chars: 4
|
||||
max_prefix_chars: 10
|
||||
max_lines_hwrap: 2
|
||||
line_ending: unix
|
||||
command_case: lower
|
||||
keyword_case: upper
|
||||
always_wrap: []
|
||||
enable_sort: true
|
||||
autosort: false
|
||||
require_valid_layout: false
|
||||
layout_passes: {}
|
||||
markup:
|
||||
bullet_char: '*'
|
||||
enum_char: .
|
||||
first_comment_is_literal: false
|
||||
literal_comment_pattern: null
|
||||
fence_pattern: ^\s*([`~]{3}[`~]*)(.*)$
|
||||
ruler_pattern: ^\s*[^\w\s]{3}.*[^\w\s]{3}$
|
||||
explicit_trailing_pattern: '#<'
|
||||
hashruler_min_length: 10
|
||||
canonicalize_hashrulers: true
|
||||
enable_markup: true
|
||||
lint:
|
||||
disabled_codes: []
|
||||
function_pattern: '[0-9a-z_]+'
|
||||
macro_pattern: '[0-9A-Z_]+'
|
||||
global_var_pattern: '[A-Z][0-9A-Z_]+'
|
||||
internal_var_pattern: _[A-Z][0-9A-Z_]+
|
||||
local_var_pattern: '[a-z][a-z0-9_]+'
|
||||
private_var_pattern: _[0-9a-z_]+
|
||||
public_var_pattern: '[A-Z][0-9A-Z_]+'
|
||||
argument_var_pattern: '[a-z][a-z0-9_]+'
|
||||
keyword_pattern: '[A-Z][0-9A-Z_]+'
|
||||
max_conditionals_custom_parser: 2
|
||||
min_statement_spacing: 1
|
||||
max_statement_spacing: 2
|
||||
max_returns: 6
|
||||
max_branches: 12
|
||||
max_arguments: 5
|
||||
max_localvars: 15
|
||||
max_statements: 50
|
||||
encode:
|
||||
emit_byteorder_mark: false
|
||||
input_encoding: utf-8
|
||||
output_encoding: utf-8
|
||||
misc:
|
||||
per_command: {}
|
||||
+25
-2
@@ -10,8 +10,31 @@ on:
|
||||
branches: [ main, develop ]
|
||||
|
||||
jobs:
|
||||
formatting:
|
||||
runs-on: ubuntu-18.04
|
||||
cmake-format:
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3-pip
|
||||
python3 -m pip install cmake-format
|
||||
- name: cmake-format
|
||||
run: |
|
||||
set +e
|
||||
cmake-format -i $(find . -type f | egrep 'CMakeLists.txt|\.cmake$')
|
||||
if [ $(git diff | wc -l) -gt 0 ]; then
|
||||
echo -e "\nError! CMake code not formatted. Run cmake-format...\n"
|
||||
echo -e "\nFiles:\n"
|
||||
git diff --name-only
|
||||
echo -e "\nFull diff:\n"
|
||||
git diff
|
||||
exit 1
|
||||
fi
|
||||
|
||||
clang-format:
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
+8
-8
@@ -63,7 +63,7 @@ jobs:
|
||||
- name: Test
|
||||
working-directory: ${{ github.workspace }}/build
|
||||
run:
|
||||
ctest -V --output-log ${{ github.workspace }}/build/hosttrace-ctest.log
|
||||
ctest -V --output-log ${{ github.workspace }}/build/hosttrace-ctest-ubuntu-focal.log
|
||||
|
||||
- name: Test Install
|
||||
run:
|
||||
@@ -78,7 +78,7 @@ jobs:
|
||||
with:
|
||||
name: ctest-log
|
||||
path: |
|
||||
${{ github.workspace }}/build/hosttrace-ctest.log
|
||||
${{ github.workspace }}/build/hosttrace-ctest-ubuntu-focal.log
|
||||
|
||||
ubuntu-bionic:
|
||||
runs-on: ubuntu-18.04
|
||||
@@ -132,7 +132,7 @@ jobs:
|
||||
- name: Test
|
||||
working-directory: ${{ github.workspace }}/build
|
||||
run:
|
||||
ctest -V --output-log ${{ github.workspace }}/build/hosttrace-ctest.log
|
||||
ctest -V --output-log ${{ github.workspace }}/build/hosttrace-ctest-ubuntu-bionic.log
|
||||
|
||||
- name: Test Install
|
||||
run:
|
||||
@@ -147,7 +147,7 @@ jobs:
|
||||
with:
|
||||
name: ctest-log
|
||||
path: |
|
||||
${{ github.workspace }}/build/hosttrace-ctest.log
|
||||
${{ github.workspace }}/build/hosttrace-ctest-ubuntu-bionic.log
|
||||
|
||||
ubuntu-focal-external:
|
||||
runs-on: ubuntu-20.04
|
||||
@@ -223,7 +223,7 @@ jobs:
|
||||
run:
|
||||
ldd ./hosttrace &&
|
||||
./hosttrace --help &&
|
||||
ctest -V --output-log ${{ github.workspace }}/build/hosttrace-ctest.log
|
||||
ctest -V --output-log ${{ github.workspace }}/build/hosttrace-ctest-ubuntu-focal-external.log
|
||||
|
||||
- name: Test Install
|
||||
run:
|
||||
@@ -239,7 +239,7 @@ jobs:
|
||||
with:
|
||||
name: ctest-log
|
||||
path: |
|
||||
${{ github.workspace }}/build/hosttrace-ctest.log
|
||||
${{ github.workspace }}/build/hosttrace-ctest-ubuntu-focal-external.log
|
||||
|
||||
ubuntu-focal-dyninst-package:
|
||||
runs-on: ubuntu-20.04
|
||||
@@ -308,7 +308,7 @@ jobs:
|
||||
run:
|
||||
ldd ./hosttrace &&
|
||||
./hosttrace --help &&
|
||||
ctest -V --output-log ${{ github.workspace }}/build/hosttrace-ctest.log
|
||||
ctest -V --output-log ${{ github.workspace }}/build/hosttrace-ctest-ubuntu-focal-dyninst-package.log
|
||||
|
||||
- name: Test Install
|
||||
run:
|
||||
@@ -324,4 +324,4 @@ jobs:
|
||||
with:
|
||||
name: ctest-log
|
||||
path: |
|
||||
${{ github.workspace }}/build/hosttrace-ctest.log
|
||||
${{ github.workspace }}/build/hosttrace-ctest-ubuntu-focal-dyninst-package.log
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
|
||||
|
||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND
|
||||
CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||
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'")
|
||||
@@ -12,21 +12,37 @@ endif()
|
||||
project(
|
||||
hosttrace
|
||||
LANGUAGES C CXX
|
||||
VERSION 0.0.1)
|
||||
VERSION 0.0.1)
|
||||
|
||||
message(STATUS "[${PROJECT_NAME}] version ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
||||
message(
|
||||
STATUS
|
||||
"[${PROJECT_NAME}] version ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
|
||||
)
|
||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/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 RelWithDebInfo CACHE STRING "Build type" FORCE)
|
||||
set(CMAKE_BUILD_TYPE
|
||||
RelWithDebInfo
|
||||
CACHE STRING "Build type" FORCE)
|
||||
endif()
|
||||
|
||||
include(GNUInstallDirs) # install directories
|
||||
include(MacroUtilities) # various functions and macros
|
||||
include(Compilers) # compiler identification
|
||||
include(BuildSettings) # compiler flags
|
||||
include(GNUInstallDirs) # install directories
|
||||
include(MacroUtilities) # various functions and macros
|
||||
include(Compilers) # compiler identification
|
||||
include(BuildSettings) # compiler flags
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17 CACHE STRING "CXX language standard")
|
||||
set(CMAKE_CXX_STANDARD
|
||||
17
|
||||
CACHE STRING "CXX language standard")
|
||||
add_option(CMAKE_CXX_STANDARD_REQUIRED "Require C++ language standard" ON)
|
||||
add_option(CMAKE_CXX_EXTENSIONS "Compiler specific language extensions" OFF)
|
||||
add_option(CMAKE_INSTALL_RPATH_USE_LINK_PATH "Enable rpath to linked libraries" ON)
|
||||
@@ -37,10 +53,14 @@ add_option(HOSTTRACE_USE_ROCTRACER "Enable roctracer support" ON)
|
||||
add_option(HOSTTRACE_BUILD_DYNINST "Build dyninst from submodule" OFF)
|
||||
|
||||
# ensure synced
|
||||
set(TIMEMORY_USE_MPI ${HOSTTRACE_USE_MPI} CACHE BOOL "Enable MPI support" FORCE)
|
||||
set(TRANSPOSE_USE_MPI ${HOSTTRACE_USE_MPI} CACHE BOOL "Enable MPI support" FORCE)
|
||||
set(TIMEMORY_USE_MPI
|
||||
${HOSTTRACE_USE_MPI}
|
||||
CACHE BOOL "Enable MPI support" FORCE)
|
||||
set(TRANSPOSE_USE_MPI
|
||||
${HOSTTRACE_USE_MPI}
|
||||
CACHE BOOL "Enable MPI support" FORCE)
|
||||
|
||||
include(Packages) # finds third-party libraries
|
||||
include(Packages) # finds third-party libraries
|
||||
|
||||
hosttrace_activate_clang_tidy()
|
||||
|
||||
@@ -48,127 +68,127 @@ set(CMAKE_C_VISIBILITY_PRESET "hidden")
|
||||
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
|
||||
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# ------------------------------------------------------------------------------#
|
||||
#
|
||||
# hosttrace-library target
|
||||
# hosttrace-library target
|
||||
#
|
||||
#------------------------------------------------------------------------------#
|
||||
# ------------------------------------------------------------------------------#
|
||||
|
||||
add_library(hosttrace-library SHARED
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/library.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/libmisc.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/library.hpp
|
||||
${perfetto_DIR}/sdk/perfetto.cc)
|
||||
add_library(
|
||||
hosttrace-library SHARED
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/library.cpp ${CMAKE_CURRENT_LIST_DIR}/src/libmisc.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/library.hpp ${perfetto_DIR}/sdk/perfetto.cc)
|
||||
|
||||
if(HOSTTRACE_USE_ROCTRACER)
|
||||
target_sources(hosttrace-library PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/roctracer.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/roctracer.cpp)
|
||||
target_sources(
|
||||
hosttrace-library PRIVATE ${CMAKE_CURRENT_LIST_DIR}/include/roctracer.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/roctracer.cpp)
|
||||
endif()
|
||||
|
||||
target_include_directories(hosttrace-library PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
target_include_directories(hosttrace-library PRIVATE ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
|
||||
target_include_directories(hosttrace-library SYSTEM PRIVATE
|
||||
${perfetto_DIR}/sdk)
|
||||
target_include_directories(hosttrace-library SYSTEM PRIVATE ${perfetto_DIR}/sdk)
|
||||
|
||||
target_compile_definitions(hosttrace-library PRIVATE
|
||||
$<IF:$<BOOL:${HOSTTRACE_CUSTOM_DATA_SOURCE}>,CUSTOM_DATA_SOURCE,>)
|
||||
target_compile_definitions(
|
||||
hosttrace-library
|
||||
PRIVATE $<IF:$<BOOL:${HOSTTRACE_CUSTOM_DATA_SOURCE}>,CUSTOM_DATA_SOURCE,>)
|
||||
|
||||
target_link_libraries(hosttrace-library PRIVATE
|
||||
hosttrace::hosttrace-threading
|
||||
hosttrace::hosttrace-compile-options
|
||||
hosttrace::hosttrace-roctracer
|
||||
$<BUILD_INTERFACE:timemory::timemory-headers>
|
||||
$<BUILD_INTERFACE:timemory::timemory-gotcha>
|
||||
$<BUILD_INTERFACE:timemory::timemory-cxx-shared>
|
||||
$<IF:$<BOOL:${HOSTTRACE_USE_SANITIZER}>,hosttrace::hosttrace-sanitizer,>)
|
||||
target_link_libraries(
|
||||
hosttrace-library
|
||||
PRIVATE hosttrace::hosttrace-threading
|
||||
hosttrace::hosttrace-compile-options
|
||||
hosttrace::hosttrace-roctracer
|
||||
$<BUILD_INTERFACE:timemory::timemory-headers>
|
||||
$<BUILD_INTERFACE:timemory::timemory-gotcha>
|
||||
$<BUILD_INTERFACE:timemory::timemory-cxx-shared>
|
||||
$<IF:$<BOOL:${HOSTTRACE_USE_SANITIZER}>,hosttrace::hosttrace-sanitizer,>)
|
||||
|
||||
if(DYNINST_API_RT)
|
||||
get_filename_component(DYNINST_API_RT_DIR "${DYNINST_API_RT}" DIRECTORY)
|
||||
endif()
|
||||
|
||||
set_target_properties(hosttrace-library PROPERTIES
|
||||
OUTPUT_NAME hosttrace
|
||||
INSTALL_RPATH "\$ORIGIN:${DYNINST_API_RT_DIR}")
|
||||
set_target_properties(
|
||||
hosttrace-library PROPERTIES OUTPUT_NAME hosttrace INSTALL_RPATH
|
||||
"\$ORIGIN:${DYNINST_API_RT_DIR}")
|
||||
|
||||
install(
|
||||
TARGETS hosttrace-library
|
||||
TARGETS hosttrace-library
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
OPTIONAL)
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# ------------------------------------------------------------------------------#
|
||||
#
|
||||
# hosttrace-exe target
|
||||
# hosttrace-exe target
|
||||
#
|
||||
#------------------------------------------------------------------------------#
|
||||
# ------------------------------------------------------------------------------#
|
||||
|
||||
add_executable(hosttrace-exe ${_EXCLUDE}
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/hosttrace.cpp
|
||||
add_executable(
|
||||
hosttrace-exe
|
||||
${_EXCLUDE} ${CMAKE_CURRENT_LIST_DIR}/src/hosttrace.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/hosttrace.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/hosttrace-details.cpp)
|
||||
|
||||
target_include_directories(hosttrace-exe PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
target_include_directories(hosttrace-exe PRIVATE ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
|
||||
target_link_libraries(hosttrace-exe PRIVATE
|
||||
hosttrace::hosttrace-dyninst
|
||||
hosttrace::hosttrace-compile-options
|
||||
$<BUILD_INTERFACE:timemory::timemory-headers>
|
||||
$<IF:$<BOOL:${HOSTTRACE_USE_SANITIZER}>,hosttrace::hosttrace-sanitizer,>)
|
||||
target_link_libraries(
|
||||
hosttrace-exe
|
||||
PRIVATE hosttrace::hosttrace-dyninst hosttrace::hosttrace-compile-options
|
||||
$<BUILD_INTERFACE:timemory::timemory-headers>
|
||||
$<IF:$<BOOL:${HOSTTRACE_USE_SANITIZER}>,hosttrace::hosttrace-sanitizer,>)
|
||||
|
||||
set_target_properties(hosttrace-exe PROPERTIES
|
||||
OUTPUT_NAME hosttrace
|
||||
INSTALL_RPATH_USE_LINK_PATH ON
|
||||
INSTALL_RPATH "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:${DYNINST_API_RT_DIR}")
|
||||
set_target_properties(
|
||||
hosttrace-exe
|
||||
PROPERTIES OUTPUT_NAME hosttrace
|
||||
INSTALL_RPATH_USE_LINK_PATH ON
|
||||
INSTALL_RPATH "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:${DYNINST_API_RT_DIR}")
|
||||
|
||||
install(
|
||||
TARGETS hosttrace-exe
|
||||
TARGETS hosttrace-exe
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
OPTIONAL)
|
||||
|
||||
# build the timemory-avail exe
|
||||
add_dependencies(hosttrace-exe timemory-avail)
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# ------------------------------------------------------------------------------#
|
||||
#
|
||||
# miscellaneous installs
|
||||
# miscellaneous installs
|
||||
#
|
||||
#------------------------------------------------------------------------------#
|
||||
# ------------------------------------------------------------------------------#
|
||||
|
||||
install(
|
||||
PROGRAMS ${PROJECT_SOURCE_DIR}/scripts/hosttrace-merge.jl
|
||||
PROGRAMS ${PROJECT_SOURCE_DIR}/scripts/hosttrace-merge.jl
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
OPTIONAL)
|
||||
|
||||
install(
|
||||
FILES ${PROJECT_SOURCE_DIR}/roctrace.cfg
|
||||
FILES ${PROJECT_SOURCE_DIR}/roctrace.cfg
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}
|
||||
OPTIONAL)
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# ------------------------------------------------------------------------------#
|
||||
#
|
||||
# examples
|
||||
# examples
|
||||
#
|
||||
#------------------------------------------------------------------------------#
|
||||
# ------------------------------------------------------------------------------#
|
||||
|
||||
add_subdirectory(examples)
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# ------------------------------------------------------------------------------#
|
||||
#
|
||||
# tests
|
||||
# tests
|
||||
#
|
||||
#------------------------------------------------------------------------------#
|
||||
# ------------------------------------------------------------------------------#
|
||||
|
||||
include(CTest)
|
||||
enable_testing()
|
||||
|
||||
add_subdirectory(tests)
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# ------------------------------------------------------------------------------#
|
||||
#
|
||||
# packaging
|
||||
# packaging
|
||||
#
|
||||
#------------------------------------------------------------------------------#
|
||||
# ------------------------------------------------------------------------------#
|
||||
|
||||
include(ConfigCPack)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# include guard
|
||||
include_guard(DIRECTORY)
|
||||
|
||||
##########################################################################################
|
||||
# ########################################################################################
|
||||
#
|
||||
# Handles the build settings
|
||||
# Handles the build settings
|
||||
#
|
||||
##########################################################################################
|
||||
# ########################################################################################
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(Compilers)
|
||||
@@ -21,14 +21,18 @@ option(HOSTTRACE_USE_SANITIZER "" OFF)
|
||||
|
||||
target_compile_definitions(hosttrace-compile-options INTERFACE $<$<CONFIG:DEBUG>:DEBUG>)
|
||||
|
||||
set(HOSTTRACE_SANITIZER_TYPE "leak" CACHE STRING "Sanitizer type")
|
||||
set(HOSTTRACE_SANITIZER_TYPE
|
||||
"leak"
|
||||
CACHE STRING "Sanitizer type")
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# dynamic linking and runtime libraries
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# dynamic linking and runtime libraries
|
||||
#
|
||||
if(CMAKE_DL_LIBS AND NOT "${CMAKE_DL_LIBS}" STREQUAL "dl")
|
||||
# if cmake provides dl library, use that
|
||||
set(dl_LIBRARY ${CMAKE_DL_LIBS} CACHE FILEPATH "dynamic linking system library")
|
||||
set(dl_LIBRARY
|
||||
${CMAKE_DL_LIBS}
|
||||
CACHE FILEPATH "dynamic linking system library")
|
||||
endif()
|
||||
|
||||
foreach(_TYPE dl rt dw)
|
||||
@@ -45,17 +49,12 @@ if(dl_LIBRARY)
|
||||
target_link_libraries(hosttrace-compile-options INTERFACE ${dl_LIBRARY})
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# set the compiler flags
|
||||
#
|
||||
add_flag_if_avail(
|
||||
"-W"
|
||||
"-Wall"
|
||||
"-Wno-unknown-pragmas"
|
||||
"-Wno-unused-function"
|
||||
"-Wno-ignored-attributes"
|
||||
"-Wno-attributes"
|
||||
"-Wno-missing-field-initializers")
|
||||
"-W" "-Wall" "-Wno-unknown-pragmas" "-Wno-unused-function" "-Wno-ignored-attributes"
|
||||
"-Wno-attributes" "-Wno-missing-field-initializers")
|
||||
|
||||
if(WIN32)
|
||||
# suggested by MSVC for spectre mitigation in rapidjson implementation
|
||||
@@ -63,37 +62,39 @@ if(WIN32)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_IS_CLANG)
|
||||
add_cxx_flag_if_avail(
|
||||
"-Wno-mismatched-tags")
|
||||
add_cxx_flag_if_avail("-Wno-mismatched-tags")
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# extra flags for debug information in debug or optimized binaries
|
||||
#
|
||||
add_interface_library(hosttrace-compile-debuginfo
|
||||
"Attempts to set best flags for more expressive profiling information in debug or optimized binaries")
|
||||
add_interface_library(
|
||||
hosttrace-compile-debuginfo
|
||||
"Attempts to set best flags for more expressive profiling information in debug or optimized binaries"
|
||||
)
|
||||
|
||||
add_target_flag_if_avail(hosttrace-compile-debuginfo
|
||||
"-g"
|
||||
"-fno-omit-frame-pointer"
|
||||
"-fno-optimize-sibling-calls")
|
||||
add_target_flag_if_avail(hosttrace-compile-debuginfo "-g" "-fno-omit-frame-pointer"
|
||||
"-fno-optimize-sibling-calls")
|
||||
|
||||
if(CMAKE_CUDA_COMPILER_IS_NVIDIA)
|
||||
add_target_cuda_flag(hosttrace-compile-debuginfo "-lineinfo")
|
||||
endif()
|
||||
|
||||
target_compile_options(hosttrace-compile-debuginfo INTERFACE
|
||||
$<$<COMPILE_LANGUAGE:C>:$<$<C_COMPILER_ID:GNU>:-rdynamic>>
|
||||
$<$<COMPILE_LANGUAGE:CXX>:$<$<CXX_COMPILER_ID:GNU>:-rdynamic>>)
|
||||
target_compile_options(
|
||||
hosttrace-compile-debuginfo
|
||||
INTERFACE $<$<COMPILE_LANGUAGE:C>:$<$<C_COMPILER_ID:GNU>:-rdynamic>>
|
||||
$<$<COMPILE_LANGUAGE:CXX>:$<$<CXX_COMPILER_ID:GNU>:-rdynamic>>)
|
||||
|
||||
if(NOT APPLE)
|
||||
target_link_options(hosttrace-compile-debuginfo INTERFACE
|
||||
$<$<CXX_COMPILER_ID:GNU>:-rdynamic>)
|
||||
$<$<CXX_COMPILER_ID:GNU>:-rdynamic>)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CUDA_COMPILER_IS_NVIDIA)
|
||||
target_compile_options(hosttrace-compile-debuginfo INTERFACE
|
||||
$<$<COMPILE_LANGUAGE:CUDA>:$<$<CXX_COMPILER_ID:GNU>:-Xcompiler=-rdynamic>>)
|
||||
target_compile_options(
|
||||
hosttrace-compile-debuginfo
|
||||
INTERFACE
|
||||
$<$<COMPILE_LANGUAGE:CUDA>:$<$<CXX_COMPILER_ID:GNU>:-Xcompiler=-rdynamic>>)
|
||||
endif()
|
||||
|
||||
if(dl_LIBRARY)
|
||||
@@ -104,34 +105,27 @@ if(rt_LIBRARY)
|
||||
target_link_libraries(hosttrace-compile-debuginfo INTERFACE ${rt_LIBRARY})
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# non-debug optimizations
|
||||
#
|
||||
add_interface_library(hosttrace-compile-extra "Extra optimization flags")
|
||||
if(NOT HOSTTRACE_USE_COVERAGE)
|
||||
add_target_flag_if_avail(hosttrace-compile-extra
|
||||
"-finline-functions"
|
||||
"-funroll-loops"
|
||||
"-ftree-vectorize"
|
||||
"-ftree-loop-optimize"
|
||||
"-ftree-loop-vectorize")
|
||||
add_target_flag_if_avail(
|
||||
hosttrace-compile-extra "-finline-functions" "-funroll-loops" "-ftree-vectorize"
|
||||
"-ftree-loop-optimize" "-ftree-loop-vectorize")
|
||||
endif()
|
||||
|
||||
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND HOSTTRACE_BUILD_EXTRA_OPTIMIZATIONS)
|
||||
target_link_libraries(hosttrace-compile-options INTERFACE
|
||||
$<BUILD_INTERFACE:hosttrace-compile-extra>)
|
||||
target_link_libraries(hosttrace-compile-options
|
||||
INTERFACE $<BUILD_INTERFACE:hosttrace-compile-extra>)
|
||||
add_flag_if_avail(
|
||||
"-fno-signaling-nans"
|
||||
"-fno-trapping-math"
|
||||
"-fno-signed-zeros"
|
||||
"-ffinite-math-only"
|
||||
"-fno-math-errno"
|
||||
"-fpredictive-commoning"
|
||||
"-fno-signaling-nans" "-fno-trapping-math" "-fno-signed-zeros"
|
||||
"-ffinite-math-only" "-fno-math-errno" "-fpredictive-commoning"
|
||||
"-fvariable-expansion-in-unroller")
|
||||
# add_flag_if_avail("-freciprocal-math" "-fno-signed-zeros" "-mfast-fp")
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# debug-safe optimizations
|
||||
#
|
||||
add_cxx_flag_if_avail("-faligned-new")
|
||||
@@ -140,8 +134,7 @@ if(HOSTTRACE_BUILD_LTO)
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
|
||||
endif()
|
||||
|
||||
hosttrace_save_variables(FLTO
|
||||
VARIABLES CMAKE_CXX_FLAGS)
|
||||
hosttrace_save_variables(FLTO VARIABLES CMAKE_CXX_FLAGS)
|
||||
set(CMAKE_CXX_FLAGS "-flto=thin ${CMAKE_CXX_FLAGS}")
|
||||
|
||||
add_interface_library(hosttrace-lto "Adds link-time-optimization flags")
|
||||
@@ -163,14 +156,13 @@ if(HOSTTRACE_BUILD_LTO)
|
||||
target_link_libraries(hosttrace-compile-options INTERFACE hosttrace::hosttrace-lto)
|
||||
endif()
|
||||
|
||||
hosttrace_restore_variables(FLTO
|
||||
VARIABLES CMAKE_CXX_FLAGS)
|
||||
hosttrace_restore_variables(FLTO VARIABLES CMAKE_CXX_FLAGS)
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# print compilation timing reports (Clang compiler)
|
||||
#
|
||||
add_interface_library(hosttrace-compile-timing
|
||||
"Adds compiler flags which report compilation timing metrics")
|
||||
"Adds compiler flags which report compilation timing metrics")
|
||||
if(CMAKE_CXX_COMPILER_IS_CLANG)
|
||||
add_target_flag_if_avail(hosttrace-compile-timing "-ftime-trace")
|
||||
if(NOT cxx_hosttrace_compile_timing_ftime_trace)
|
||||
@@ -184,37 +176,33 @@ if(HOSTTRACE_USE_COMPILE_TIMING)
|
||||
target_link_libraries(hosttrace-compile-options INTERFACE hosttrace-compile-timing)
|
||||
endif()
|
||||
|
||||
if(NOT cxx_hosttrace_compile_timing_ftime_report AND NOT cxx_hosttrace_compile_timing_ftime_trace)
|
||||
if(NOT cxx_hosttrace_compile_timing_ftime_report
|
||||
AND NOT cxx_hosttrace_compile_timing_ftime_trace)
|
||||
add_disabled_interface(hosttrace-compile-timing)
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# developer build flags
|
||||
#
|
||||
add_interface_library(hosttrace-develop-options "Adds developer compiler flags")
|
||||
if(HOSTTRACE_BUILD_DEVELOPER)
|
||||
add_target_flag_if_avail(hosttrace-develop-options
|
||||
add_target_flag_if_avail(
|
||||
hosttrace-develop-options
|
||||
# "-Wabi"
|
||||
"-Wdouble-promotion"
|
||||
"-Wshadow"
|
||||
"-Wextra"
|
||||
"-Wpedantic"
|
||||
"-Werror"
|
||||
"/showIncludes")
|
||||
"-Wdouble-promotion" "-Wshadow" "-Wextra" "-Wpedantic" "-Werror" "/showIncludes")
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# visibility build flags
|
||||
#
|
||||
add_interface_library(hosttrace-default-visibility
|
||||
"Adds -fvisibility=default compiler flag")
|
||||
"Adds -fvisibility=default compiler flag")
|
||||
add_interface_library(hosttrace-hidden-visibility
|
||||
"Adds -fvisibility=hidden compiler flag")
|
||||
"Adds -fvisibility=hidden compiler flag")
|
||||
|
||||
add_target_flag_if_avail(hosttrace-default-visibility
|
||||
"-fvisibility=default")
|
||||
add_target_flag_if_avail(hosttrace-hidden-visibility
|
||||
"-fvisibility=hidden" "-fvisibility-inlines-hidden")
|
||||
add_target_flag_if_avail(hosttrace-default-visibility "-fvisibility=default")
|
||||
add_target_flag_if_avail(hosttrace-hidden-visibility "-fvisibility=hidden"
|
||||
"-fvisibility-inlines-hidden")
|
||||
|
||||
foreach(_TYPE default hidden)
|
||||
if(NOT cxx_hosttrace_${_TYPE}_visibility_fvisibility_${_TYPE})
|
||||
@@ -222,7 +210,7 @@ foreach(_TYPE default hidden)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# developer build flags
|
||||
#
|
||||
if(dl_LIBRARY)
|
||||
@@ -232,27 +220,41 @@ if(dl_LIBRARY)
|
||||
add_flag_if_avail("-rdynamic")
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# sanitizer
|
||||
#
|
||||
set(HOSTTRACE_SANITIZER_TYPES address memory thread leak undefined unreachable null bounds alignment)
|
||||
set_property(CACHE HOSTTRACE_SANITIZER_TYPE PROPERTY STRINGS "${HOSTTRACE_SANITIZER_TYPES}")
|
||||
add_interface_library(hosttrace-sanitizer-compile-options "Adds compiler flags for sanitizers")
|
||||
add_interface_library(hosttrace-sanitizer
|
||||
"Adds compiler flags to enable ${HOSTTRACE_SANITIZER_TYPE} sanitizer (-fsanitizer=${HOSTTRACE_SANITIZER_TYPE})")
|
||||
set(HOSTTRACE_SANITIZER_TYPES
|
||||
address
|
||||
memory
|
||||
thread
|
||||
leak
|
||||
undefined
|
||||
unreachable
|
||||
null
|
||||
bounds
|
||||
alignment)
|
||||
set_property(CACHE HOSTTRACE_SANITIZER_TYPE PROPERTY STRINGS
|
||||
"${HOSTTRACE_SANITIZER_TYPES}")
|
||||
add_interface_library(hosttrace-sanitizer-compile-options
|
||||
"Adds compiler flags for sanitizers")
|
||||
add_interface_library(
|
||||
hosttrace-sanitizer
|
||||
"Adds compiler flags to enable ${HOSTTRACE_SANITIZER_TYPE} sanitizer (-fsanitizer=${HOSTTRACE_SANITIZER_TYPE})"
|
||||
)
|
||||
|
||||
set(COMMON_SANITIZER_FLAGS "-fno-optimize-sibling-calls" "-fno-omit-frame-pointer" "-fno-inline-functions")
|
||||
set(COMMON_SANITIZER_FLAGS "-fno-optimize-sibling-calls" "-fno-omit-frame-pointer"
|
||||
"-fno-inline-functions")
|
||||
add_target_flag(hosttrace-sanitizer-compile-options ${COMMON_SANITIZER_FLAGS})
|
||||
|
||||
foreach(_TYPE ${HOSTTRACE_SANITIZER_TYPES})
|
||||
set(_FLAG "-fsanitize=${_TYPE}")
|
||||
add_interface_library(hosttrace-${_TYPE}-sanitizer
|
||||
"Adds compiler flags to enable ${_TYPE} sanitizer (${_FLAG})")
|
||||
"Adds compiler flags to enable ${_TYPE} sanitizer (${_FLAG})")
|
||||
add_target_flag(hosttrace-${_TYPE}-sanitizer ${_FLAG})
|
||||
target_link_libraries(hosttrace-${_TYPE}-sanitizer INTERFACE
|
||||
hosttrace-sanitizer-compile-options)
|
||||
set_property(TARGET hosttrace-${_TYPE}-sanitizer PROPERTY
|
||||
INTERFACE_LINK_OPTIONS ${_FLAG} ${COMMON_SANITIZER_FLAGS})
|
||||
target_link_libraries(hosttrace-${_TYPE}-sanitizer
|
||||
INTERFACE hosttrace-sanitizer-compile-options)
|
||||
set_property(TARGET hosttrace-${_TYPE}-sanitizer
|
||||
PROPERTY INTERFACE_LINK_OPTIONS ${_FLAG} ${COMMON_SANITIZER_FLAGS})
|
||||
endforeach()
|
||||
|
||||
unset(_FLAG)
|
||||
@@ -261,9 +263,12 @@ unset(COMMON_SANITIZER_FLAGS)
|
||||
if(HOSTTRACE_USE_SANITIZER)
|
||||
foreach(_TYPE ${HOSTTRACE_SANITIZER_TYPE})
|
||||
if(TARGET hosttrace-${_TYPE}-sanitizer)
|
||||
target_link_libraries(hosttrace-sanitizer INTERFACE hosttrace-${_TYPE}-sanitizer)
|
||||
target_link_libraries(hosttrace-sanitizer
|
||||
INTERFACE hosttrace-${_TYPE}-sanitizer)
|
||||
else()
|
||||
message(FATAL_ERROR "Error! Target 'hosttrace-${_TYPE}-sanitizer' does not exist!")
|
||||
message(
|
||||
FATAL_ERROR "Error! Target 'hosttrace-${_TYPE}-sanitizer' does not exist!"
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
else()
|
||||
@@ -271,14 +276,14 @@ else()
|
||||
inform_empty_interface(hosttrace-sanitizer "${HOSTTRACE_SANITIZER_TYPE} sanitizer")
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
# VTune is much more helpful when debug information is included in the
|
||||
# generated release code.
|
||||
if(MSVC)
|
||||
# VTune is much more helpful when debug information is included in the generated
|
||||
# release code.
|
||||
add_flag_if_avail("/Zi")
|
||||
add_flag_if_avail("/DEBUG")
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# user customization
|
||||
#
|
||||
get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
|
||||
@@ -1,28 +1,18 @@
|
||||
# include guard
|
||||
include_guard(DIRECTORY)
|
||||
|
||||
##########################################################################################
|
||||
# ########################################################################################
|
||||
#
|
||||
# Compilers
|
||||
# Compilers
|
||||
#
|
||||
##########################################################################################
|
||||
# ########################################################################################
|
||||
#
|
||||
# sets (cached):
|
||||
# sets (cached):
|
||||
#
|
||||
# CMAKE_C_COMPILER_IS_<TYPE>
|
||||
# CMAKE_CXX_COMPILER_IS_<TYPE>
|
||||
# CMAKE_C_COMPILER_IS_<TYPE> CMAKE_CXX_COMPILER_IS_<TYPE>
|
||||
#
|
||||
# where TYPE is:
|
||||
# - GNU
|
||||
# - CLANG
|
||||
# - INTEL
|
||||
# - INTEL_ICC
|
||||
# - INTEL_ICPC
|
||||
# - PGI
|
||||
# - XLC
|
||||
# - HP_ACC
|
||||
# - MIPS
|
||||
# - MSVC
|
||||
# where TYPE is: - GNU - CLANG - INTEL - INTEL_ICC - INTEL_ICPC - PGI - XLC - HP_ACC -
|
||||
# MIPS - MSVC
|
||||
#
|
||||
|
||||
include(CheckCCompilerFlag)
|
||||
@@ -42,28 +32,32 @@ if("${LIBNAME}" STREQUAL "")
|
||||
endif()
|
||||
|
||||
add_interface_library(${LIBNAME}-compile-options
|
||||
"Adds the standard set of compiler flags used by timemory")
|
||||
"Adds the standard set of compiler flags used by timemory")
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# macro converting string to list
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
macro(to_list _VAR _STR)
|
||||
STRING(REPLACE " " " " ${_VAR} "${_STR}")
|
||||
STRING(REPLACE " " ";" ${_VAR} "${_STR}")
|
||||
endmacro(to_list _VAR _STR)
|
||||
string(REPLACE " " " " ${_VAR} "${_STR}")
|
||||
string(REPLACE " " ";" ${_VAR} "${_STR}")
|
||||
endmacro(
|
||||
to_list
|
||||
_VAR
|
||||
_STR)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# macro converting string to list
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
macro(to_string _VAR _STR)
|
||||
STRING(REPLACE ";" " " ${_VAR} "${_STR}")
|
||||
endmacro(to_string _VAR _STR)
|
||||
string(REPLACE ";" " " ${_VAR} "${_STR}")
|
||||
endmacro(
|
||||
to_string
|
||||
_VAR
|
||||
_STR)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# Macro to add to string
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# Macro to add to string
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
macro(add _VAR _FLAG)
|
||||
if(NOT "${_FLAG}" STREQUAL "")
|
||||
if("${${_VAR}}" STREQUAL "")
|
||||
@@ -74,10 +68,9 @@ macro(add _VAR _FLAG)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# macro to remove duplicates from string
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
macro(set_no_duplicates _VAR)
|
||||
if(NOT "${ARGN}" STREQUAL "")
|
||||
set(${_VAR} "${ARGN}")
|
||||
@@ -91,40 +84,37 @@ macro(set_no_duplicates _VAR)
|
||||
endif(NOT "${${_VAR}}" STREQUAL "")
|
||||
endmacro(set_no_duplicates _VAR)
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# call before running check_{c,cxx}_compiler_flag
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
macro(hosttrace_begin_flag_check)
|
||||
if(HOSTTRACE_QUIET_CONFIG)
|
||||
if(NOT DEFINED CMAKE_REQUIRED_QUIET)
|
||||
set(CMAKE_REQUIRED_QUIET OFF)
|
||||
endif()
|
||||
hosttrace_save_variables(FLAG_CHECK
|
||||
VARIABLES CMAKE_REQUIRED_QUIET)
|
||||
hosttrace_save_variables(FLAG_CHECK VARIABLES CMAKE_REQUIRED_QUIET)
|
||||
set(CMAKE_REQUIRED_QUIET ON)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# call after running check_{c,cxx}_compiler_flag
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
macro(hosttrace_end_flag_check)
|
||||
if(HOSTTRACE_QUIET_CONFIG)
|
||||
hosttrace_restore_variables(FLAG_CHECK
|
||||
VARIABLES CMAKE_REQUIRED_QUIET)
|
||||
hosttrace_restore_variables(FLAG_CHECK VARIABLES CMAKE_REQUIRED_QUIET)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
##########################################################################################
|
||||
# ########################################################################################
|
||||
#
|
||||
# C compiler flags
|
||||
# C compiler flags
|
||||
#
|
||||
##########################################################################################
|
||||
# ########################################################################################
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# add C flag to target
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
macro(ADD_TARGET_C_FLAG _TARG)
|
||||
string(REPLACE "-" "_" _MAKE_TARG "${_TARG}")
|
||||
list(APPEND HOSTTRACE_MAKE_TARGETS ${_MAKE_TARG})
|
||||
@@ -133,13 +123,12 @@ macro(ADD_TARGET_C_FLAG _TARG)
|
||||
list(APPEND ${_MAKE_TARG}_C_FLAGS ${ARGN})
|
||||
endmacro()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# add C flag w/o check
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
macro(ADD_C_FLAG FLAG)
|
||||
set(_TARG )
|
||||
set(_LTARG )
|
||||
set(_TARG)
|
||||
set(_LTARG)
|
||||
if(NOT "${ARGN}" STREQUAL "")
|
||||
set(_TARG ${ARGN})
|
||||
string(TOLOWER "_${ARGN}" _LTARG)
|
||||
@@ -157,17 +146,16 @@ macro(ADD_C_FLAG FLAG)
|
||||
unset(_LTARG)
|
||||
endmacro()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# check C flag
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
macro(ADD_C_FLAG_IF_AVAIL FLAG)
|
||||
set(_ENABLE ON)
|
||||
if(DEFINED HOSTTRACE_BUILD_C AND NOT HOSTTRACE_BUILD_C)
|
||||
set(_ENABLE OFF)
|
||||
endif()
|
||||
set(_TARG )
|
||||
set(_LTARG )
|
||||
set(_TARG)
|
||||
set(_LTARG)
|
||||
if(NOT "${ARGN}" STREQUAL "")
|
||||
set(_TARG ${ARGN})
|
||||
string(TOLOWER "_${ARGN}" _LTARG)
|
||||
@@ -204,28 +192,24 @@ macro(ADD_C_FLAG_IF_AVAIL FLAG)
|
||||
unset(_LTARG)
|
||||
endmacro()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# add C flag to target
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
macro(ADD_TARGET_C_FLAG_IF_AVAIL _TARG)
|
||||
foreach(_FLAG ${ARGN})
|
||||
add_c_flag_if_avail(${_FLAG} ${_TARG})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
##########################################################################################
|
||||
# ########################################################################################
|
||||
#
|
||||
# CXX compiler flags
|
||||
# CXX compiler flags
|
||||
#
|
||||
##########################################################################################
|
||||
# ########################################################################################
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# add CXX flag to target
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
macro(ADD_TARGET_CXX_FLAG _TARG)
|
||||
string(REPLACE "-" "_" _MAKE_TARG "${_TARG}")
|
||||
list(APPEND HOSTTRACE_MAKE_TARGETS ${_MAKE_TARG})
|
||||
@@ -234,7 +218,8 @@ macro(ADD_TARGET_CXX_FLAG _TARG)
|
||||
list(APPEND ${_MAKE_TARG}_CXX_FLAGS ${ARGN})
|
||||
get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
if(CMAKE_CUDA_COMPILER_IS_NVIDIA)
|
||||
target_compile_options(${_TARG} INTERFACE $<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=${ARGN}>)
|
||||
target_compile_options(${_TARG}
|
||||
INTERFACE $<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=${ARGN}>)
|
||||
list(APPEND ${_MAKE_TARG}_CUDA_FLAGS -Xcompiler=${ARGN})
|
||||
elseif(CMAKE_CUDA_COMPILER_IS_CLANG)
|
||||
target_compile_options(${_TARG} INTERFACE $<$<COMPILE_LANGUAGE:CUDA>:${ARGN}>)
|
||||
@@ -242,13 +227,12 @@ macro(ADD_TARGET_CXX_FLAG _TARG)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# add CXX flag w/o check
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
macro(ADD_CXX_FLAG FLAG)
|
||||
set(_TARG )
|
||||
set(_LTARG )
|
||||
set(_TARG)
|
||||
set(_LTARG)
|
||||
if(NOT "${ARGN}" STREQUAL "")
|
||||
set(_TARG ${ARGN})
|
||||
string(TOLOWER "_${ARGN}" _LTARG)
|
||||
@@ -266,13 +250,12 @@ macro(ADD_CXX_FLAG FLAG)
|
||||
unset(_LTARG)
|
||||
endmacro()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# check CXX flag
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
macro(ADD_CXX_FLAG_IF_AVAIL FLAG)
|
||||
set(_TARG )
|
||||
set(_LTARG )
|
||||
set(_TARG)
|
||||
set(_LTARG)
|
||||
if(NOT "${ARGN}" STREQUAL "")
|
||||
set(_TARG ${ARGN})
|
||||
string(TOLOWER "_${ARGN}" _LTARG)
|
||||
@@ -306,71 +289,64 @@ macro(ADD_CXX_FLAG_IF_AVAIL FLAG)
|
||||
unset(_LTARG)
|
||||
endmacro()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# add CXX flag to target
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
macro(ADD_TARGET_CXX_FLAG_IF_AVAIL _TARG)
|
||||
foreach(_FLAG ${ARGN})
|
||||
add_cxx_flag_if_avail(${_FLAG} ${_TARG})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
##########################################################################################
|
||||
# ########################################################################################
|
||||
#
|
||||
# Common
|
||||
# Common
|
||||
#
|
||||
##########################################################################################
|
||||
# ########################################################################################
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# check C and CXX flag to compile-options w/o checking
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
macro(ADD_FLAG)
|
||||
foreach(_ARG ${ARGN})
|
||||
ADD_C_FLAG("${_ARG}")
|
||||
ADD_CXX_FLAG("${_ARG}")
|
||||
add_c_flag("${_ARG}")
|
||||
add_cxx_flag("${_ARG}")
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# add C and CXX flag w/o checking
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
macro(ADD_TARGET_FLAG _TARG)
|
||||
foreach(_ARG ${ARGN})
|
||||
ADD_TARGET_C_FLAG(${_TARG} ${_ARG})
|
||||
ADD_TARGET_CXX_FLAG(${_TARG} ${_ARG})
|
||||
add_target_c_flag(${_TARG} ${_ARG})
|
||||
add_target_cxx_flag(${_TARG} ${_ARG})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# check C and CXX flag
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
macro(ADD_FLAG_IF_AVAIL)
|
||||
foreach(_ARG ${ARGN})
|
||||
ADD_C_FLAG_IF_AVAIL("${_ARG}")
|
||||
ADD_CXX_FLAG_IF_AVAIL("${_ARG}")
|
||||
add_c_flag_if_avail("${_ARG}")
|
||||
add_cxx_flag_if_avail("${_ARG}")
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# check C and CXX flag
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
macro(ADD_TARGET_FLAG_IF_AVAIL _TARG)
|
||||
foreach(_ARG ${ARGN})
|
||||
ADD_TARGET_C_FLAG_IF_AVAIL(${_TARG} ${_ARG})
|
||||
ADD_TARGET_CXX_FLAG_IF_AVAIL(${_TARG} ${_ARG})
|
||||
add_target_c_flag_if_avail(${_TARG} ${_ARG})
|
||||
add_target_cxx_flag_if_avail(${_TARG} ${_ARG})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# check flag
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
function(HOSTTRACE_TARGET_FLAG _TARG_TARGET)
|
||||
cmake_parse_arguments(_TARG "IF_AVAIL" "MODE" "FLAGS;LANGUAGES" ${ARGN})
|
||||
|
||||
@@ -389,7 +365,8 @@ function(HOSTTRACE_TARGET_FLAG _TARG_TARGET)
|
||||
foreach(_FLAG ${_TARG_FLAGS})
|
||||
foreach(_LANG ${_TARG_LANGUAGES})
|
||||
if(NOT _TARG_IF_AVAIL)
|
||||
target_compile_options(${_TARG_TARGET} ${_TARG_MODE} $<$<COMPILE_LANGUAGE:${_LANG}>:${_FLAG}>)
|
||||
target_compile_options(${_TARG_TARGET} ${_TARG_MODE}
|
||||
$<$<COMPILE_LANGUAGE:${_LANG}>:${_FLAG}>)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
@@ -409,7 +386,7 @@ function(HOSTTRACE_TARGET_FLAG _TARG_TARGET)
|
||||
hosttrace_end_flag_check()
|
||||
if(${FLAG_NAME})
|
||||
target_compile_options(${_TARG_TARGET} ${_TARG_MODE}
|
||||
$<$<COMPILE_LANGUAGE:${_LANG}>:${_FLAG}>)
|
||||
$<$<COMPILE_LANGUAGE:${_LANG}>:${_FLAG}>)
|
||||
endif()
|
||||
elseif("${_LANG}" STREQUAL "CXX")
|
||||
string(REGEX REPLACE "^/" "cxx${_LTARG}_" FLAG_NAME "${_FLAG}")
|
||||
@@ -427,13 +404,14 @@ function(HOSTTRACE_TARGET_FLAG _TARG_TARGET)
|
||||
hosttrace_end_flag_check()
|
||||
if(${FLAG_NAME})
|
||||
target_compile_options(${_TARG_TARGET} ${_TARG_MODE}
|
||||
$<$<COMPILE_LANGUAGE:${_LANG}>:${_FLAG}>)
|
||||
$<$<COMPILE_LANGUAGE:${_LANG}>:${_FLAG}>)
|
||||
if(CMAKE_CUDA_COMPILER_IS_NVIDIA)
|
||||
target_compile_options(${_TARG_TARGET} ${_TARG_MODE}
|
||||
target_compile_options(
|
||||
${_TARG_TARGET} ${_TARG_MODE}
|
||||
$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=${_FLAG}>)
|
||||
elseif(CMAKE_CUDA_COMPILER_IS_CLANG)
|
||||
target_compile_options(${_TARG_TARGET} ${_TARG_MODE}
|
||||
$<$<COMPILE_LANGUAGE:CUDA>:${_FLAG}>)
|
||||
$<$<COMPILE_LANGUAGE:CUDA>:${_FLAG}>)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
@@ -441,10 +419,9 @@ function(HOSTTRACE_TARGET_FLAG _TARG_TARGET)
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# add CUDA flag to target
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
macro(ADD_TARGET_CUDA_FLAG _TARG)
|
||||
string(REPLACE "-" "_" _MAKE_TARG "${_TARG}")
|
||||
list(APPEND HOSTTRACE_MAKE_TARGETS ${_MAKE_TARG})
|
||||
@@ -453,46 +430,47 @@ macro(ADD_TARGET_CUDA_FLAG _TARG)
|
||||
list(APPEND ${_MAKE_TARG}_CUDA_FLAGS ${ARGN})
|
||||
endmacro()
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# add to any language
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
function(ADD_USER_FLAGS _TARGET _LANGUAGE)
|
||||
|
||||
set(_FLAGS ${${_LANGUAGE}FLAGS} $ENV{${_LANGUAGE}FLAGS}
|
||||
${${_LANGUAGE}_FLAGS} $ENV{${_LANGUAGE}_FLAGS})
|
||||
set(_FLAGS ${${_LANGUAGE}FLAGS} $ENV{${_LANGUAGE}FLAGS} ${${_LANGUAGE}_FLAGS}
|
||||
$ENV{${_LANGUAGE}_FLAGS})
|
||||
|
||||
string(REPLACE " " ";" _FLAGS "${_FLAGS}")
|
||||
|
||||
set(${PROJECT_NAME}_${_LANGUAGE}_FLAGS
|
||||
${${PROJECT_NAME}_${_LANGUAGE}_FLAGS} ${_FLAGS} PARENT_SCOPE)
|
||||
${${PROJECT_NAME}_${_LANGUAGE}_FLAGS} ${_FLAGS}
|
||||
PARENT_SCOPE)
|
||||
|
||||
set(${PROJECT_NAME}_${_LANGUAGE}_COMPILE_OPTIONS
|
||||
${${PROJECT_NAME}_${_LANGUAGE}_COMPILE_OPTIONS} ${_FLAGS} PARENT_SCOPE)
|
||||
${${PROJECT_NAME}_${_LANGUAGE}_COMPILE_OPTIONS} ${_FLAGS}
|
||||
PARENT_SCOPE)
|
||||
|
||||
target_compile_options(${_TARGET} INTERFACE
|
||||
$<$<COMPILE_LANGUAGE:${_LANGUAGE}>:${_FLAGS}>)
|
||||
target_compile_options(${_TARGET}
|
||||
INTERFACE $<$<COMPILE_LANGUAGE:${_LANGUAGE}>:${_FLAGS}>)
|
||||
endfunction()
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# add compiler definition
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
function(HOSTTRACE_TARGET_COMPILE_DEFINITIONS _TARG _VIS)
|
||||
foreach(_DEF ${ARGN})
|
||||
target_compile_definitions(${_TARG} ${_VIS}
|
||||
$<$<COMPILE_LANGUAGE:CXX>:${_DEF}>)
|
||||
target_compile_definitions(${_TARG} ${_VIS} $<$<COMPILE_LANGUAGE:CXX>:${_DEF}>)
|
||||
if(CMAKE_CUDA_COMPILER_IS_NVIDIA)
|
||||
target_compile_definitions(${_TARG} ${_VIS}
|
||||
$<$<COMPILE_LANGUAGE:CUDA>:${_DEF}>)
|
||||
$<$<COMPILE_LANGUAGE:CUDA>:${_DEF}>)
|
||||
elseif(CMAKE_CUDA_COMPILER_IS_CLANG)
|
||||
target_compile_definitions(${_TARG} ${_VIS}
|
||||
$<$<COMPILE_LANGUAGE:CUDA>:${_DEF}>)
|
||||
$<$<COMPILE_LANGUAGE:CUDA>:${_DEF}>)
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# determine compiler types for each language
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
foreach(LANG C CXX CUDA)
|
||||
|
||||
@@ -505,95 +483,110 @@ foreach(LANG C CXX CUDA)
|
||||
endif()
|
||||
|
||||
function(SET_COMPILER_VAR VAR _BOOL)
|
||||
set(CMAKE_${LANG}_COMPILER_IS_${VAR} ${_BOOL} CACHE INTERNAL
|
||||
"CMake ${LANG} compiler identification (${VAR})" FORCE)
|
||||
set(CMAKE_${LANG}_COMPILER_IS_${VAR}
|
||||
${_BOOL}
|
||||
CACHE INTERNAL "CMake ${LANG} compiler identification (${VAR})" FORCE)
|
||||
mark_as_advanced(CMAKE_${LANG}_COMPILER_IS_${VAR})
|
||||
endfunction()
|
||||
|
||||
if(("${LANG}" STREQUAL "C" AND CMAKE_COMPILER_IS_GNUCC)
|
||||
OR
|
||||
("${LANG}" STREQUAL "CXX" AND CMAKE_COMPILER_IS_GNUCXX))
|
||||
OR ("${LANG}" STREQUAL "CXX" AND CMAKE_COMPILER_IS_GNUCXX))
|
||||
|
||||
# GNU compiler
|
||||
SET_COMPILER_VAR( GNU 1)
|
||||
set_compiler_var(GNU 1)
|
||||
|
||||
elseif(CMAKE_${LANG}_COMPILER MATCHES "icc.*")
|
||||
|
||||
# Intel icc compiler
|
||||
SET_COMPILER_VAR( INTEL 1)
|
||||
SET_COMPILER_VAR( INTEL_ICC 1)
|
||||
set_compiler_var(INTEL 1)
|
||||
set_compiler_var(INTEL_ICC 1)
|
||||
|
||||
elseif(CMAKE_${LANG}_COMPILER MATCHES "icpc.*")
|
||||
|
||||
# Intel icpc compiler
|
||||
SET_COMPILER_VAR( INTEL 1)
|
||||
SET_COMPILER_VAR( INTEL_ICPC 1)
|
||||
set_compiler_var(INTEL 1)
|
||||
set_compiler_var(INTEL_ICPC 1)
|
||||
|
||||
elseif(CMAKE_${LANG}_COMPILER_ID MATCHES "AppleClang")
|
||||
|
||||
# Clang/LLVM compiler
|
||||
SET_COMPILER_VAR( CLANG 1)
|
||||
SET_COMPILER_VAR( APPLE_CLANG 1)
|
||||
|
||||
set_compiler_var(CLANG 1)
|
||||
set_compiler_var(APPLE_CLANG 1)
|
||||
|
||||
elseif(CMAKE_${LANG}_COMPILER_ID MATCHES "Clang")
|
||||
|
||||
# Clang/LLVM compiler
|
||||
SET_COMPILER_VAR( CLANG 1)
|
||||
set_compiler_var(CLANG 1)
|
||||
|
||||
# HIP Clang compiler
|
||||
if(CMAKE_${LANG}_COMPILER MATCHES "hipcc")
|
||||
SET_COMPILER_VAR( HIPCC 1)
|
||||
set_compiler_var(HIPCC 1)
|
||||
endif()
|
||||
|
||||
elseif(CMAKE_${LANG}_COMPILER_ID MATCHES "PGI")
|
||||
|
||||
# PGI compiler
|
||||
SET_COMPILER_VAR( PGI 1)
|
||||
set_compiler_var(PGI 1)
|
||||
|
||||
elseif(CMAKE_${LANG}_COMPILER MATCHES "xlC" AND UNIX)
|
||||
|
||||
# IBM xlC compiler
|
||||
SET_COMPILER_VAR( XLC 1)
|
||||
set_compiler_var(XLC 1)
|
||||
|
||||
elseif(CMAKE_${LANG}_COMPILER MATCHES "aCC" AND UNIX)
|
||||
|
||||
# HP aC++ compiler
|
||||
SET_COMPILER_VAR( HP_ACC 1)
|
||||
set_compiler_var(HP_ACC 1)
|
||||
|
||||
elseif(CMAKE_${LANG}_COMPILER MATCHES "CC" AND
|
||||
CMAKE_SYSTEM_NAME MATCHES "IRIX" AND UNIX)
|
||||
elseif(
|
||||
CMAKE_${LANG}_COMPILER MATCHES "CC"
|
||||
AND CMAKE_SYSTEM_NAME MATCHES "IRIX"
|
||||
AND UNIX)
|
||||
|
||||
# IRIX MIPSpro CC Compiler
|
||||
SET_COMPILER_VAR( MIPS 1)
|
||||
set_compiler_var(MIPS 1)
|
||||
|
||||
elseif(CMAKE_${LANG}_COMPILER_ID MATCHES "Intel")
|
||||
|
||||
SET_COMPILER_VAR( INTEL 1)
|
||||
set_compiler_var(INTEL 1)
|
||||
|
||||
set(CTYPE ICC)
|
||||
if("${LANG}" STREQUAL "CXX")
|
||||
set(CTYPE ICPC)
|
||||
endif()
|
||||
|
||||
SET_COMPILER_VAR( INTEL_${CTYPE} 1)
|
||||
set_compiler_var(INTEL_${CTYPE} 1)
|
||||
|
||||
elseif(CMAKE_${LANG}_COMPILER MATCHES "MSVC")
|
||||
|
||||
# Windows Visual Studio compiler
|
||||
SET_COMPILER_VAR( MSVC 1)
|
||||
set_compiler_var(MSVC 1)
|
||||
|
||||
elseif(CMAKE_${LANG}_COMPILER_ID MATCHES "NVIDIA")
|
||||
|
||||
# NVCC
|
||||
SET_COMPILER_VAR( NVIDIA 1)
|
||||
set_compiler_var(NVIDIA 1)
|
||||
|
||||
endif()
|
||||
|
||||
# set other to no
|
||||
foreach(TYPE GNU INTEL INTEL_ICC INTEL_ICPC APPLE_CLANG CLANG PGI XLC HP_ACC MIPS MSVC NVIDIA HIPCC)
|
||||
foreach(
|
||||
TYPE
|
||||
GNU
|
||||
INTEL
|
||||
INTEL_ICC
|
||||
INTEL_ICPC
|
||||
APPLE_CLANG
|
||||
CLANG
|
||||
PGI
|
||||
XLC
|
||||
HP_ACC
|
||||
MIPS
|
||||
MSVC
|
||||
NVIDIA
|
||||
HIPCC)
|
||||
if(NOT DEFINED CMAKE_${LANG}_COMPILER_IS_${TYPE})
|
||||
SET_COMPILER_VAR(${TYPE} 0)
|
||||
set_compiler_var(${TYPE} 0)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
|
||||
@@ -1,17 +1,32 @@
|
||||
|
||||
# Add packaging directives for timemory
|
||||
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
|
||||
set(CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc.")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Runtime instrumentation and binary rewriting for Perfetto via Dyninst")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
|
||||
"Runtime instrumentation and binary rewriting for Perfetto via Dyninst")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
|
||||
set(CPACK_PACKAGE_CONTACT "jonathan.madsen@amd.com")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
|
||||
|
||||
if(DYNINST_BUILD_BOOST
|
||||
OR DYNINST_BUILD_TBB
|
||||
OR DYNINST_BUILD_ELFUTILS
|
||||
OR DYNINST_BUILD_LIBIBERTY)
|
||||
set(CPACK_INSTALLED_DIRECTORIES
|
||||
"${CMAKE_INSTALL_PREFIX}/lib/dyninst-tpls/include" "lib/dyninst-tpls/include"
|
||||
"${CMAKE_INSTALL_PREFIX}/lib/dyninst-tpls/lib" "lib/dyninst-tpls/lib")
|
||||
endif()
|
||||
|
||||
if(DYNINST_BUILD_ELFUTILS)
|
||||
list(APPEND CPACK_INSTALLED_DIRECTORIES
|
||||
"${CMAKE_INSTALL_PREFIX}/lib/dyninst-tpls/bin" "lib/dyninst-tpls/bin"
|
||||
"${CMAKE_INSTALL_PREFIX}/lib/dyninst-tpls/share" "lib/dyninst-tpls/share")
|
||||
endif()
|
||||
|
||||
# Debian package specific variables
|
||||
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/AARInternal/hosttrace-dyninst")
|
||||
if (DEFINED ENV{CPACK_DEBIAN_PACKAGE_RELEASE})
|
||||
if(DEFINED ENV{CPACK_DEBIAN_PACKAGE_RELEASE})
|
||||
set(CPACK_DEBIAN_PACKAGE_RELEASE $ENV{CPACK_DEBIAN_PACKAGE_RELEASE})
|
||||
else()
|
||||
set(CPACK_DEBIAN_PACKAGE_RELEASE "local")
|
||||
@@ -34,7 +49,9 @@ if(CPACK_RPM_PACKAGE_RELEASE)
|
||||
endif()
|
||||
|
||||
# Prepare final version for the CPACK use
|
||||
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
||||
set(CPACK_PACKAGE_VERSION
|
||||
"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}"
|
||||
)
|
||||
|
||||
# Set the names now using CPACK utility
|
||||
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
|
||||
|
||||
@@ -1,65 +1,72 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying file
|
||||
# Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
|
||||
set(_ROCM_PATHS $ENV{ROCM_HOME} /opt/rocm /opt/rocm/roctracer)
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
|
||||
find_path(roctracer_ROOT_DIR
|
||||
NAMES include/roctracer.h
|
||||
HINTS ${_ROCM_PATHS}
|
||||
PATHS ${_ROCM_PATHS}
|
||||
PATH_SUFFIXES roctracer)
|
||||
find_path(
|
||||
roctracer_ROOT_DIR
|
||||
NAMES include/roctracer.h
|
||||
HINTS ${_ROCM_PATHS}
|
||||
PATHS ${_ROCM_PATHS}
|
||||
PATH_SUFFIXES roctracer)
|
||||
|
||||
mark_as_advanced(roctracer_ROOT_DIR)
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
|
||||
find_path(roctracer_INCLUDE_DIR
|
||||
NAMES roctracer.h
|
||||
HINTS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATHS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATH_SUFFIXES roctracer/include include)
|
||||
find_path(
|
||||
roctracer_INCLUDE_DIR
|
||||
NAMES roctracer.h
|
||||
HINTS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATHS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATH_SUFFIXES roctracer/include include)
|
||||
|
||||
mark_as_advanced(roctracer_INCLUDE_DIR)
|
||||
|
||||
find_path(roctracer_hsa_INCLUDE_DIR
|
||||
NAMES hsa.h
|
||||
HINTS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATHS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATH_SUFFIXES include include/hsa)
|
||||
find_path(
|
||||
roctracer_hsa_INCLUDE_DIR
|
||||
NAMES hsa.h
|
||||
HINTS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATHS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATH_SUFFIXES include include/hsa)
|
||||
|
||||
mark_as_advanced(roctracer_hsa_INCLUDE_DIR)
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
|
||||
find_library(roctracer_LIBRARY
|
||||
NAMES roctracer64 roctracer
|
||||
HINTS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATHS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATH_SUFFIXES lib lib64)
|
||||
find_library(
|
||||
roctracer_LIBRARY
|
||||
NAMES roctracer64 roctracer
|
||||
HINTS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATHS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATH_SUFFIXES lib lib64)
|
||||
|
||||
find_library(roctracer_roctx_LIBRARY
|
||||
NAMES roctx64 roctx
|
||||
HINTS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATHS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATH_SUFFIXES lib lib64)
|
||||
find_library(
|
||||
roctracer_roctx_LIBRARY
|
||||
NAMES roctx64 roctx
|
||||
HINTS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATHS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATH_SUFFIXES lib lib64)
|
||||
|
||||
find_library(roctracer_kfdwrapper_LIBRARY
|
||||
NAMES kfdwrapper64 kfdwrapper
|
||||
HINTS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATHS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATH_SUFFIXES lib lib64)
|
||||
find_library(
|
||||
roctracer_kfdwrapper_LIBRARY
|
||||
NAMES kfdwrapper64 kfdwrapper
|
||||
HINTS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATHS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATH_SUFFIXES lib lib64)
|
||||
|
||||
find_library(roctracer_hsakmt_LIBRARY
|
||||
NAMES hsakmt
|
||||
HINTS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATHS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATH_SUFFIXES lib lib64)
|
||||
find_library(
|
||||
roctracer_hsakmt_LIBRARY
|
||||
NAMES hsakmt
|
||||
HINTS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATHS ${roctracer_ROOT_DIR} ${_ROCM_PATHS}
|
||||
PATH_SUFFIXES lib lib64)
|
||||
|
||||
if(roctracer_LIBRARY)
|
||||
get_filename_component(roctracer_LIBRARY_DIR "${roctracer_LIBRARY}" PATH CACHE)
|
||||
@@ -67,16 +74,13 @@ endif()
|
||||
|
||||
mark_as_advanced(roctracer_LIBRARY roctracer_roctx_LIBRARY)
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
|
||||
find_package_handle_standard_args(roctracer DEFAULT_MSG
|
||||
roctracer_ROOT_DIR
|
||||
roctracer_INCLUDE_DIR
|
||||
roctracer_hsa_INCLUDE_DIR
|
||||
roctracer_LIBRARY
|
||||
roctracer_roctx_LIBRARY)
|
||||
find_package_handle_standard_args(
|
||||
roctracer DEFAULT_MSG roctracer_ROOT_DIR roctracer_INCLUDE_DIR
|
||||
roctracer_hsa_INCLUDE_DIR roctracer_LIBRARY roctracer_roctx_LIBRARY)
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# ------------------------------------------------------------------------------#
|
||||
|
||||
if(roctracer_FOUND)
|
||||
add_library(roctracer::roctracer INTERFACE IMPORTED)
|
||||
@@ -85,16 +89,23 @@ if(roctracer_FOUND)
|
||||
set(roctracer_LIBRARIES ${roctracer_LIBRARY} ${roctracer_roctx_LIBRARY})
|
||||
set(roctracer_LIBRARY_DIRS ${roctracer_LIBRARY_DIR})
|
||||
|
||||
target_include_directories(roctracer::roctracer INTERFACE ${roctracer_INCLUDE_DIR} ${roctracer_hsa_INCLUDE_DIR})
|
||||
target_include_directories(roctracer::roctx INTERFACE ${roctracer_INCLUDE_DIR} ${roctracer_hsa_INCLUDE_DIR})
|
||||
target_include_directories(
|
||||
roctracer::roctracer INTERFACE ${roctracer_INCLUDE_DIR}
|
||||
${roctracer_hsa_INCLUDE_DIR})
|
||||
target_include_directories(roctracer::roctx INTERFACE ${roctracer_INCLUDE_DIR}
|
||||
${roctracer_hsa_INCLUDE_DIR})
|
||||
|
||||
target_link_libraries(roctracer::roctracer INTERFACE ${roctracer_LIBRARY})
|
||||
target_link_libraries(roctracer::roctx INTERFACE ${roctracer_roctx_LIBRARY})
|
||||
|
||||
if(roctracer_kfdwrapper_LIBRARY)
|
||||
list(APPEND roctracer_LIBRARIES ${roctracer_kfdwrapper_LIBRARY})
|
||||
target_compile_definitions(roctracer::roctracer INTERFACE HOSTTRACE_ROCTRACER_LIBKFDWRAPPER=\"${roctracer_kfdwrapper_LIBRARY}\")
|
||||
target_link_libraries(roctracer::roctracer INTERFACE ${roctracer_kfdwrapper_LIBRARY})
|
||||
target_compile_definitions(
|
||||
roctracer::roctracer
|
||||
INTERFACE
|
||||
HOSTTRACE_ROCTRACER_LIBKFDWRAPPER=\"${roctracer_kfdwrapper_LIBRARY}\")
|
||||
target_link_libraries(roctracer::roctracer
|
||||
INTERFACE ${roctracer_kfdwrapper_LIBRARY})
|
||||
target_link_libraries(roctracer::roctx INTERFACE ${roctracer_kfdwrapper_LIBRARY})
|
||||
endif()
|
||||
|
||||
@@ -106,8 +117,8 @@ if(roctracer_FOUND)
|
||||
|
||||
endif()
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# ------------------------------------------------------------------------------#
|
||||
|
||||
unset(_ROCM_PATHS)
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# ------------------------------------------------------------------------------#
|
||||
|
||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -1,29 +1,28 @@
|
||||
# include guard
|
||||
include_guard(DIRECTORY)
|
||||
|
||||
##########################################################################################
|
||||
# ########################################################################################
|
||||
#
|
||||
# External Packages are found here
|
||||
# External Packages are found here
|
||||
#
|
||||
##########################################################################################
|
||||
# ########################################################################################
|
||||
|
||||
add_interface_library(hosttrace-headers
|
||||
"Provides minimal set of include flags to compile with hosttrace")
|
||||
add_interface_library(hosttrace-threading
|
||||
"Enables multithreading support")
|
||||
add_interface_library(hosttrace-dyninst
|
||||
"Provides minimal set of include flags to compile with hosttrace")
|
||||
add_interface_library(hosttrace-threading "Enables multithreading support")
|
||||
add_interface_library(
|
||||
hosttrace-dyninst
|
||||
"Provides flags and libraries for Dyninst (dynamic instrumentation)")
|
||||
add_interface_library(hosttrace-roctracer
|
||||
"Provides flags and libraries for roctracer")
|
||||
add_interface_library(hosttrace-roctracer "Provides flags and libraries for roctracer")
|
||||
|
||||
# include threading because of rooflines
|
||||
target_link_libraries(hosttrace-headers INTERFACE hosttrace-threading)
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
#
|
||||
# Threading
|
||||
# Threading
|
||||
#
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
|
||||
if(NOT WIN32)
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD ON)
|
||||
@@ -42,12 +41,11 @@ if(pthread_LIBRARY AND NOT WIN32)
|
||||
target_link_libraries(hosttrace-threading INTERFACE ${pthread_LIBRARY})
|
||||
endif()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
#
|
||||
# roctracer
|
||||
# roctracer
|
||||
#
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
|
||||
if(HOSTTRACE_USE_ROCTRACER)
|
||||
list(APPEND CMAKE_PREFIX_PATH /opt/rocm)
|
||||
@@ -58,31 +56,41 @@ if(HOSTTRACE_USE_ROCTRACER)
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${roctracer_LIBRARY_DIRS}")
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
#
|
||||
# Dyninst
|
||||
# Dyninst
|
||||
#
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
|
||||
if(HOSTTRACE_BUILD_DYNINST)
|
||||
checkout_git_submodule(
|
||||
RELATIVE_PATH external/dyninst
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
REPO_URL https://github.com/jrmadsen/dyninst.git
|
||||
REPO_BRANCH hosttrace-submodule)
|
||||
RELATIVE_PATH external/dyninst
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
REPO_URL https://github.com/jrmadsen/dyninst.git
|
||||
REPO_BRANCH formatting)
|
||||
|
||||
set(DYNINST_OPTION_PREFIX ON)
|
||||
set(DYNINST_BUILD_DOCS OFF)
|
||||
set(DYNINST_QUIET_CONFIG ON CACHE BOOL "Suppress dyninst cmake messages")
|
||||
set(DYNINST_BUILD_PARSE_THAT OFF CACHE BOOL "Build dyninst parseThat executable")
|
||||
set(DYNINST_BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared dyninst libraries")
|
||||
set(DYNINST_BUILD_STATIC_LIBS ON CACHE BOOL "Build static dyninst libraries")
|
||||
set(DYNINST_ENABLE_LTO ON CACHE BOOL "Enable LTO for dyninst libraries")
|
||||
set(DYNINST_OPTION_PREFIX ON)
|
||||
set(DYNINST_BUILD_DOCS OFF)
|
||||
set(DYNINST_QUIET_CONFIG
|
||||
ON
|
||||
CACHE BOOL "Suppress dyninst cmake messages")
|
||||
set(DYNINST_BUILD_PARSE_THAT
|
||||
OFF
|
||||
CACHE BOOL "Build dyninst parseThat executable")
|
||||
set(DYNINST_BUILD_SHARED_LIBS
|
||||
OFF
|
||||
CACHE BOOL "Build shared dyninst libraries")
|
||||
set(DYNINST_BUILD_STATIC_LIBS
|
||||
ON
|
||||
CACHE BOOL "Build static dyninst libraries")
|
||||
set(DYNINST_ENABLE_LTO
|
||||
ON
|
||||
CACHE BOOL "Enable LTO for dyninst libraries")
|
||||
|
||||
hosttrace_save_variables(PIC CMAKE_POSITION_INDEPENDENT_CODE)
|
||||
hosttrace_save_variables(PIC VARIABLES CMAKE_POSITION_INDEPENDENT_CODE)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
add_subdirectory(external/dyninst)
|
||||
hosttrace_restore_variables(PIC CMAKE_POSITION_INDEPENDENT_CODE)
|
||||
hosttrace_restore_variables(PIC VARIABLES CMAKE_POSITION_INDEPENDENT_CODE)
|
||||
|
||||
add_library(Dyninst::Dyninst INTERFACE IMPORTED)
|
||||
foreach(_LIB common dyninstAPI parseAPI instructionAPI symtabAPI stackwalk Boost TBB)
|
||||
@@ -91,43 +99,52 @@ if(HOSTTRACE_BUILD_DYNINST)
|
||||
|
||||
target_link_libraries(hosttrace-dyninst INTERFACE Dyninst::Dyninst)
|
||||
|
||||
set(HOSTTRACE_DYNINST_API_RT ${PROJECT_BINARY_DIR}/external/dyninst/dyninstAPI_RT/libdyninstAPI_RT${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
set(HOSTTRACE_DYNINST_API_RT
|
||||
${PROJECT_BINARY_DIR}/external/dyninst/dyninstAPI_RT/libdyninstAPI_RT${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
)
|
||||
|
||||
if(HOSTTRACE_DYNINST_API_RT)
|
||||
target_compile_definitions(hosttrace-dyninst INTERFACE
|
||||
DYNINST_API_RT="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}:$<TARGET_FILE_DIR:Dyninst::dyninstAPI_RT>:${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:Dyninst::dyninstAPI_RT>:$<TARGET_FILE:Dyninst::dyninstAPI_RT>")
|
||||
target_compile_definitions(
|
||||
hosttrace-dyninst
|
||||
INTERFACE
|
||||
DYNINST_API_RT="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}:$<TARGET_FILE_DIR:Dyninst::dyninstAPI_RT>:${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:Dyninst::dyninstAPI_RT>:$<TARGET_FILE:Dyninst::dyninstAPI_RT>"
|
||||
)
|
||||
endif()
|
||||
|
||||
else()
|
||||
find_package(Dyninst ${hosttrace_FIND_QUIETLY} REQUIRED COMPONENTS dyninstAPI parseAPI instructionAPI symtabAPI)
|
||||
find_package(Dyninst ${hosttrace_FIND_QUIETLY} REQUIRED
|
||||
COMPONENTS dyninstAPI parseAPI instructionAPI symtabAPI)
|
||||
|
||||
if(TARGET Dyninst::Dyninst) # updated Dyninst CMake system was found
|
||||
if(TARGET Dyninst::Dyninst) # updated Dyninst CMake system was found
|
||||
# useful for defining the location of the runtime API
|
||||
find_library(HOSTTRACE_DYNINST_API_RT dyninstAPI_RT
|
||||
find_library(
|
||||
HOSTTRACE_DYNINST_API_RT dyninstAPI_RT
|
||||
HINTS ${Dyninst_ROOT_DIR} ${Dyninst_DIR}
|
||||
PATHS ${Dyninst_ROOT_DIR} ${Dyninst_DIR}
|
||||
PATH_SUFFIXES lib)
|
||||
|
||||
if(HOSTTRACE_DYNINST_API_RT)
|
||||
target_compile_definitions(hosttrace-dyninst INTERFACE
|
||||
DYNINST_API_RT="${HOSTTRACE_DYNINST_API_RT}")
|
||||
target_compile_definitions(
|
||||
hosttrace-dyninst INTERFACE DYNINST_API_RT="${HOSTTRACE_DYNINST_API_RT}")
|
||||
endif()
|
||||
|
||||
add_rpath(${Dyninst_LIBRARIES})
|
||||
target_link_libraries(hosttrace-dyninst INTERFACE Dyninst::Dyninst)
|
||||
else() # updated Dyninst CMake system was not found
|
||||
else() # updated Dyninst CMake system was not found
|
||||
set(_BOOST_COMPONENTS atomic system thread date_time)
|
||||
set(hosttrace_BOOST_COMPONENTS "${_BOOST_COMPONENTS}" CACHE STRING
|
||||
"Boost components used by Dyninst in hosttrace")
|
||||
set(hosttrace_BOOST_COMPONENTS
|
||||
"${_BOOST_COMPONENTS}"
|
||||
CACHE STRING "Boost components used by Dyninst in hosttrace")
|
||||
set(Boost_NO_BOOST_CMAKE ON)
|
||||
find_package(Boost QUIET REQUIRED
|
||||
COMPONENTS ${hosttrace_BOOST_COMPONENTS})
|
||||
find_package(Boost QUIET REQUIRED COMPONENTS ${hosttrace_BOOST_COMPONENTS})
|
||||
|
||||
# some installs of dyninst don't set this properly
|
||||
if(EXISTS "${DYNINST_INCLUDE_DIR}" AND NOT DYNINST_HEADER_DIR)
|
||||
get_filename_component(DYNINST_HEADER_DIR "${DYNINST_INCLUDE_DIR}" REALPATH CACHE)
|
||||
get_filename_component(DYNINST_HEADER_DIR "${DYNINST_INCLUDE_DIR}" REALPATH
|
||||
CACHE)
|
||||
else()
|
||||
find_path(DYNINST_HEADER_DIR
|
||||
find_path(
|
||||
DYNINST_HEADER_DIR
|
||||
NAMES BPatch.h dyninstAPI_RT.h
|
||||
HINTS ${Dyninst_ROOT_DIR} ${Dyninst_DIR} ${Dyninst_DIR}/../../..
|
||||
PATHS ${Dyninst_ROOT_DIR} ${Dyninst_DIR} ${Dyninst_DIR}/../../..
|
||||
@@ -135,7 +152,8 @@ else()
|
||||
endif()
|
||||
|
||||
# useful for defining the location of the runtime API
|
||||
find_library(DYNINST_API_RT dyninstAPI_RT
|
||||
find_library(
|
||||
DYNINST_API_RT dyninstAPI_RT
|
||||
HINTS ${Dyninst_ROOT_DIR} ${Dyninst_DIR}
|
||||
PATHS ${Dyninst_ROOT_DIR} ${Dyninst_DIR}
|
||||
PATH_SUFFIXES lib)
|
||||
@@ -150,14 +168,15 @@ else()
|
||||
endif()
|
||||
|
||||
if(NOT TBB_FOUND)
|
||||
find_path(TBB_INCLUDE_DIR
|
||||
find_path(
|
||||
TBB_INCLUDE_DIR
|
||||
NAMES tbb/tbb.h
|
||||
PATH_SUFFIXES include)
|
||||
endif()
|
||||
|
||||
if(DYNINST_API_RT)
|
||||
target_compile_definitions(hosttrace-dyninst INTERFACE
|
||||
DYNINST_API_RT="${DYNINST_API_RT}")
|
||||
target_compile_definitions(hosttrace-dyninst
|
||||
INTERFACE DYNINST_API_RT="${DYNINST_API_RT}")
|
||||
endif()
|
||||
|
||||
if(Boost_DIR)
|
||||
@@ -169,9 +188,21 @@ else()
|
||||
endif()
|
||||
|
||||
add_rpath(${DYNINST_LIBRARIES} ${Boost_LIBRARIES})
|
||||
target_link_libraries(hosttrace-dyninst INTERFACE
|
||||
${DYNINST_LIBRARIES} ${Boost_LIBRARIES})
|
||||
foreach(_TARG dyninst dyninstAPI instructionAPI symtabAPI parseAPI headers atomic system thread date_time TBB)
|
||||
target_link_libraries(hosttrace-dyninst INTERFACE ${DYNINST_LIBRARIES}
|
||||
${Boost_LIBRARIES})
|
||||
foreach(
|
||||
_TARG
|
||||
dyninst
|
||||
dyninstAPI
|
||||
instructionAPI
|
||||
symtabAPI
|
||||
parseAPI
|
||||
headers
|
||||
atomic
|
||||
system
|
||||
thread
|
||||
date_time
|
||||
TBB)
|
||||
if(TARGET Dyninst::${_TARG})
|
||||
target_link_libraries(hosttrace-dyninst INTERFACE Dyninst::${_TARG})
|
||||
elseif(TARGET Boost::${_TARG})
|
||||
@@ -180,49 +211,48 @@ else()
|
||||
target_link_libraries(hosttrace-dyninst INTERFACE ${_TARG})
|
||||
endif()
|
||||
endforeach()
|
||||
target_include_directories(hosttrace-dyninst SYSTEM INTERFACE
|
||||
${TBB_INCLUDE_DIR}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${DYNINST_HEADER_DIR})
|
||||
target_include_directories(
|
||||
hosttrace-dyninst SYSTEM INTERFACE ${TBB_INCLUDE_DIR} ${Boost_INCLUDE_DIRS}
|
||||
${DYNINST_HEADER_DIR})
|
||||
target_compile_definitions(hosttrace-dyninst INTERFACE hosttrace_USE_DYNINST)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
#
|
||||
# Perfetto
|
||||
# Perfetto
|
||||
#
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
|
||||
set(perfetto_DIR ${PROJECT_SOURCE_DIR}/external/perfetto)
|
||||
checkout_git_submodule(
|
||||
RELATIVE_PATH external/perfetto
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
REPO_URL https://android.googlesource.com/platform/external/perfetto
|
||||
REPO_BRANCH v17.0
|
||||
TEST_FILE sdk/perfetto.cc)
|
||||
RELATIVE_PATH external/perfetto
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
REPO_URL https://android.googlesource.com/platform/external/perfetto
|
||||
REPO_BRANCH v17.0
|
||||
TEST_FILE sdk/perfetto.cc)
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
#
|
||||
# ELFIO
|
||||
# ELFIO
|
||||
#
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
|
||||
if(HOSTTRACE_BUILD_DEVICETRACE)
|
||||
checkout_git_submodule(
|
||||
RELATIVE_PATH external/elfio
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
REPO_URL https://github.com/jrmadsen/ELFIO.git
|
||||
REPO_BRANCH set-offset-support)
|
||||
RELATIVE_PATH external/elfio
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
REPO_URL https://github.com/jrmadsen/ELFIO.git
|
||||
REPO_BRANCH set-offset-support)
|
||||
|
||||
add_subdirectory(external/elfio)
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
#
|
||||
# Clang Tidy
|
||||
# Clang Tidy
|
||||
#
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
|
||||
# clang-tidy
|
||||
macro(HOSTTRACE_ACTIVATE_CLANG_TIDY)
|
||||
@@ -230,17 +260,18 @@ macro(HOSTTRACE_ACTIVATE_CLANG_TIDY)
|
||||
find_program(CLANG_TIDY_COMMAND NAMES clang-tidy)
|
||||
add_feature(CLANG_TIDY_COMMAND "Path to clang-tidy command")
|
||||
if(NOT CLANG_TIDY_COMMAND)
|
||||
timemory_message(WARNING "HOSTTRACE_USE_CLANG_TIDY is ON but clang-tidy is not found!")
|
||||
timemory_message(
|
||||
WARNING "HOSTTRACE_USE_CLANG_TIDY is ON but clang-tidy is not found!")
|
||||
set(HOSTTRACE_USE_CLANG_TIDY OFF)
|
||||
else()
|
||||
set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_COMMAND})
|
||||
|
||||
# Create a preprocessor definition that depends on .clang-tidy content so
|
||||
# the compile command will change when .clang-tidy changes. This ensures
|
||||
# that a subsequent build re-runs clang-tidy on all sources even if they
|
||||
# do not otherwise need to be recompiled. Nothing actually uses this
|
||||
# definition. We add it to targets on which we run clang-tidy just to
|
||||
# get the build dependency on the .clang-tidy file.
|
||||
# Create a preprocessor definition that depends on .clang-tidy content so the
|
||||
# compile command will change when .clang-tidy changes. This ensures that a
|
||||
# subsequent build re-runs clang-tidy on all sources even if they do not
|
||||
# otherwise need to be recompiled. Nothing actually uses this definition. We
|
||||
# add it to targets on which we run clang-tidy just to get the build
|
||||
# dependency on the .clang-tidy file.
|
||||
file(SHA1 ${CMAKE_CURRENT_LIST_DIR}/.clang-tidy clang_tidy_sha1)
|
||||
set(CLANG_TIDY_DEFINITIONS "CLANG_TIDY_SHA1=${clang_tidy_sha1}")
|
||||
unset(clang_tidy_sha1)
|
||||
@@ -248,75 +279,91 @@ macro(HOSTTRACE_ACTIVATE_CLANG_TIDY)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# ------------------------------------------------------------------------------#
|
||||
#
|
||||
# clang-format target
|
||||
# clang-format target
|
||||
#
|
||||
#------------------------------------------------------------------------------#
|
||||
# ------------------------------------------------------------------------------#
|
||||
|
||||
find_program(HOSTTRACE_CLANG_FORMAT_EXE
|
||||
NAMES
|
||||
clang-format-12
|
||||
clang-format-11
|
||||
clang-format-10
|
||||
clang-format-9
|
||||
clang-format)
|
||||
find_program(HOSTTRACE_CLANG_FORMAT_EXE NAMES clang-format-11 clang-format-mp-11
|
||||
clang-format)
|
||||
|
||||
if(HOSTTRACE_CLANG_FORMAT_EXE)
|
||||
file(GLOB sources
|
||||
${PROJECT_SOURCE_DIR}/src/*.cpp)
|
||||
file(GLOB headers
|
||||
${PROJECT_SOURCE_DIR}/include/*.hpp)
|
||||
file(GLOB_RECURSE examples
|
||||
${PROJECT_SOURCE_DIR}/examples/*.cpp
|
||||
${PROJECT_SOURCE_DIR}/examples/*.hpp)
|
||||
add_custom_target(format
|
||||
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cpp)
|
||||
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hpp)
|
||||
file(GLOB_RECURSE examples ${PROJECT_SOURCE_DIR}/examples/*.cpp
|
||||
${PROJECT_SOURCE_DIR}/examples/*.hpp)
|
||||
add_custom_target(
|
||||
format
|
||||
${HOSTTRACE_CLANG_FORMAT_EXE} -i ${sources} ${headers} ${examples}
|
||||
COMMENT "Running ${HOSTTRACE_CLANG_FORMAT_EXE}...")
|
||||
else()
|
||||
message(AUTHOR_WARNING "clang-format could not be found. format build target not available.")
|
||||
message(
|
||||
AUTHOR_WARNING
|
||||
"clang-format could not be found. format build target not available.")
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# configure submodule
|
||||
#----------------------------------------------------------------------------------------#
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# configure submodule
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
|
||||
set(TIMEMORY_INSTALL_HEADERS OFF CACHE BOOL "Disable timemory header install")
|
||||
set(TIMEMORY_INSTALL_CONFIG OFF CACHE BOOL "Disable timemory cmake configuration install")
|
||||
set(TIMEMORY_INSTALL_ALL OFF CACHE BOOL "Disable install target depending on all target")
|
||||
set(TIMEMORY_BUILD_C OFF CACHE BOOL "Disable timemory C library")
|
||||
set(TIMEMORY_BUILD_FORTRAN OFF CACHE BOOL "Disable timemory Fortran library")
|
||||
set(TIMEMORY_BUILD_TOOLS OFF CACHE BOOL "Ensure timem executable is built")
|
||||
set(TIMEMORY_BUILD_EXCLUDE_FROM_ALL ON CACHE BOOL "Set timemory to only build dependencies")
|
||||
set(TIMEMORY_QUIET_CONFIG ON CACHE BOOL "Make timemory configuration quieter")
|
||||
set(TIMEMORY_INSTALL_HEADERS
|
||||
OFF
|
||||
CACHE BOOL "Disable timemory header install")
|
||||
set(TIMEMORY_INSTALL_CONFIG
|
||||
OFF
|
||||
CACHE BOOL "Disable timemory cmake configuration install")
|
||||
set(TIMEMORY_INSTALL_ALL
|
||||
OFF
|
||||
CACHE BOOL "Disable install target depending on all target")
|
||||
set(TIMEMORY_BUILD_C
|
||||
OFF
|
||||
CACHE BOOL "Disable timemory C library")
|
||||
set(TIMEMORY_BUILD_FORTRAN
|
||||
OFF
|
||||
CACHE BOOL "Disable timemory Fortran library")
|
||||
set(TIMEMORY_BUILD_TOOLS
|
||||
OFF
|
||||
CACHE BOOL "Ensure timem executable is built")
|
||||
set(TIMEMORY_BUILD_EXCLUDE_FROM_ALL
|
||||
ON
|
||||
CACHE BOOL "Set timemory to only build dependencies")
|
||||
set(TIMEMORY_QUIET_CONFIG
|
||||
ON
|
||||
CACHE BOOL "Make timemory configuration quieter")
|
||||
|
||||
# timemory feature settings
|
||||
set(TIMEMORY_USE_GOTCHA ON CACHE BOOL "Enable GOTCHA support in timemory")
|
||||
set(TIMEMORY_USE_PERFETTO OFF CACHE BOOL "Disable perfetto support in timemory")
|
||||
set(TIMEMORY_USE_GOTCHA
|
||||
ON
|
||||
CACHE BOOL "Enable GOTCHA support in timemory")
|
||||
set(TIMEMORY_USE_PERFETTO
|
||||
OFF
|
||||
CACHE BOOL "Disable perfetto support in timemory")
|
||||
# timemory feature build settings
|
||||
set(TIMEMORY_BUILD_GOTCHA ON CACHE BOOL "Enable building GOTCHA library from submodule")
|
||||
set(TIMEMORY_BUILD_GOTCHA
|
||||
ON
|
||||
CACHE BOOL "Enable building GOTCHA library from submodule")
|
||||
# timemory build settings
|
||||
set(TIMEMORY_TLS_MODEL "global-dynamic" CACHE STRING "Thread-local static model" FORCE)
|
||||
set(TIMEMORY_TLS_MODEL
|
||||
"global-dynamic"
|
||||
CACHE STRING "Thread-local static model" FORCE)
|
||||
|
||||
checkout_git_submodule(
|
||||
RELATIVE_PATH external/timemory
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
REPO_URL https://github.com/NERSC/timemory.git
|
||||
REPO_BRANCH develop)
|
||||
RELATIVE_PATH external/timemory
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
REPO_URL https://github.com/NERSC/timemory.git
|
||||
REPO_BRANCH gpu-kernel-instrumentation)
|
||||
|
||||
hosttrace_save_variables(BUILD_CONFIG
|
||||
BUILD_SHARED_LIBS
|
||||
BUILD_STATIC_LIBS
|
||||
CMAKE_POSITION_INDEPENDENT_CODE)
|
||||
hosttrace_save_variables(BUILD_CONFIG VARIABLES BUILD_SHARED_LIBS BUILD_STATIC_LIBS
|
||||
CMAKE_POSITION_INDEPENDENT_CODE)
|
||||
|
||||
# ensure timemory builds PIC static libs so that we don't have to install timemory shared lib
|
||||
# ensure timemory builds PIC static libs so that we don't have to install timemory shared
|
||||
# lib
|
||||
set(BUILD_SHARED_LIBS ON)
|
||||
set(BUILD_STATIC_LIBS OFF)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
add_subdirectory(external/timemory)
|
||||
|
||||
hosttrace_restore_variables(BUILD_CONFIG
|
||||
BUILD_SHARED_LIBS
|
||||
BUILD_STATIC_LIBS
|
||||
CMAKE_POSITION_INDEPENDENT_CODE)
|
||||
hosttrace_restore_variables(BUILD_CONFIG VARIABLES BUILD_SHARED_LIBS BUILD_STATIC_LIBS
|
||||
CMAKE_POSITION_INDEPENDENT_CODE)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
|
||||
|
||||
project(hosttrace-dyninst-examples
|
||||
LANGUAGES CXX)
|
||||
project(hosttrace-dyninst-examples LANGUAGES CXX)
|
||||
|
||||
add_subdirectory(transpose)
|
||||
add_subdirectory(parallel-overhead)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
|
||||
|
||||
project(hosttrace-parallel-overhead
|
||||
LANGUAGES CXX)
|
||||
project(hosttrace-parallel-overhead LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
find_package(Threads REQUIRED)
|
||||
@@ -9,6 +8,6 @@ add_executable(parallel-overhead parallel-overhead.cpp)
|
||||
target_link_libraries(parallel-overhead Threads::Threads)
|
||||
|
||||
if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||
set_target_properties(parallel-overhead PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
set_target_properties(parallel-overhead PROPERTIES RUNTIME_OUTPUT_DIRECTORY
|
||||
${CMAKE_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
+3
-6
@@ -32,12 +32,9 @@ main(int argc, char** argv)
|
||||
size_t nthread = 16;
|
||||
size_t nitr = 50000;
|
||||
long nfib = 10;
|
||||
if(argc > 1)
|
||||
nfib = atol(argv[1]);
|
||||
if(argc > 2)
|
||||
nthread = atol(argv[2]);
|
||||
if(argc > 3)
|
||||
nitr = atol(argv[3]);
|
||||
if(argc > 1) nfib = atol(argv[1]);
|
||||
if(argc > 2) nthread = atol(argv[2]);
|
||||
if(argc > 3) nitr = atol(argv[3]);
|
||||
|
||||
std::vector<std::thread> threads{};
|
||||
for(size_t i = 0; i < nthread; ++i)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
|
||||
|
||||
project(hosttrace-transpose
|
||||
LANGUAGES CXX)
|
||||
project(hosttrace-transpose LANGUAGES CXX)
|
||||
|
||||
find_program(HIPCC_EXECUTABLE NAMES hipcc)
|
||||
|
||||
@@ -31,13 +29,11 @@ if(TRANSPOSE_USE_MPI)
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||
set_target_properties(transpose PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
set_target_properties(transpose PROPERTIES RUNTIME_OUTPUT_DIRECTORY
|
||||
${CMAKE_BINARY_DIR})
|
||||
|
||||
if(NOT CMAKE_CXX_COMPILER_IS_HIPCC AND HIPCC_EXECUTABLE)
|
||||
# defined in MacroUtilities.cmake
|
||||
hosttrace_custom_compilation(
|
||||
COMPILER ${HIPCC_EXECUTABLE}
|
||||
TARGET transpose)
|
||||
hosttrace_custom_compilation(COMPILER ${HIPCC_EXECUTABLE} TARGET transpose)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -161,8 +161,7 @@ main(int argc, char** argv)
|
||||
MPI_Init(&argc, &argv);
|
||||
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
||||
#endif
|
||||
if(rank == 0)
|
||||
run(argc, argv);
|
||||
if(rank == 0) run(argc, argv);
|
||||
#if defined(USE_MPI)
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
MPI_Finalize();
|
||||
|
||||
@@ -130,18 +130,14 @@ main(int argc, char** argv)
|
||||
{
|
||||
int nx = 32;
|
||||
int ny = 32;
|
||||
if(argc > 1)
|
||||
nx = atoi(argv[1]);
|
||||
if(argc > 2)
|
||||
ny = atoi(argv[2]);
|
||||
if(argc > 1) nx = atoi(argv[1]);
|
||||
if(argc > 2) ny = atoi(argv[2]);
|
||||
|
||||
unsigned int M = 4960;
|
||||
unsigned int N = 4960;
|
||||
|
||||
if(argc > 3)
|
||||
M = atoi(argv[3]);
|
||||
if(argc > 4)
|
||||
N = atoi(argv[4]);
|
||||
if(argc > 3) M = atoi(argv[3]);
|
||||
if(argc > 4) N = atoi(argv[4]);
|
||||
|
||||
std::cout << "M: " << M << " N: " << N << std::endl;
|
||||
size_t size = sizeof(int) * M * N;
|
||||
|
||||
поставляемый
+1
-1
Submodule projects/rocprofiler-systems/external/dyninst updated: c7e4924022...b96fa72a02
поставляемый
+1
-1
Submodule projects/rocprofiler-systems/external/timemory updated: f2dc618160...174607ac8c
@@ -58,9 +58,9 @@
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
|
||||
#define MUTNAMELEN 1024
|
||||
#define FUNCNAMELEN 32 * 1024
|
||||
#define NO_ERROR -1
|
||||
#define MUTNAMELEN 1024
|
||||
#define FUNCNAMELEN 32 * 1024
|
||||
#define NO_ERROR -1
|
||||
#define TIMEMORY_BIN_DIR "bin"
|
||||
|
||||
#if !defined(PATH_MAX)
|
||||
@@ -165,14 +165,12 @@ static auto regex_opts = std::regex_constants::egrep | std::regex_constants::opt
|
||||
|
||||
// control debug printf statements
|
||||
#define dprintf(...) \
|
||||
if(debug_print || verbose_level > 0) \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
if(debug_print || verbose_level > 0) fprintf(stderr, __VA_ARGS__); \
|
||||
fflush(stderr);
|
||||
|
||||
// control verbose printf statements
|
||||
#define verbprintf(LEVEL, ...) \
|
||||
if(verbose_level >= LEVEL) \
|
||||
fprintf(stdout, __VA_ARGS__); \
|
||||
if(verbose_level >= LEVEL) fprintf(stdout, __VA_ARGS__); \
|
||||
fflush(stdout);
|
||||
|
||||
//======================================================================================//
|
||||
@@ -316,11 +314,9 @@ struct function_signature
|
||||
string_t get() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
if(use_return_info)
|
||||
ss << m_return << " ";
|
||||
if(use_return_info) ss << m_return << " ";
|
||||
ss << m_name;
|
||||
if(use_args_info)
|
||||
ss << m_params;
|
||||
if(use_args_info) ss << m_params;
|
||||
if(m_loop && m_info_beg)
|
||||
{
|
||||
if(m_info_end)
|
||||
@@ -335,10 +331,8 @@ struct function_signature
|
||||
}
|
||||
else
|
||||
{
|
||||
if(use_file_info && m_file.length() > 0)
|
||||
ss << '/' << m_file;
|
||||
if(use_line_info && m_row.first > 0)
|
||||
ss << ":" << m_row.first;
|
||||
if(use_file_info && m_file.length() > 0) ss << '/' << m_file;
|
||||
if(use_line_info && m_row.first > 0) ss << ":" << m_row.first;
|
||||
}
|
||||
|
||||
m_signature = ss.str();
|
||||
@@ -472,8 +466,7 @@ dump_info(std::ostream& _os, const fmodset_t& _data)
|
||||
static inline void
|
||||
dump_info(const string_t& _oname, const fmodset_t& _data, int _level)
|
||||
{
|
||||
if(!debug_print && verbose_level < _level)
|
||||
return;
|
||||
if(!debug_print && verbose_level < _level) return;
|
||||
|
||||
std::ofstream ofs(_oname);
|
||||
if(ofs)
|
||||
@@ -585,8 +578,7 @@ hosttrace_get_address_space(patch_pointer_t _bpatch, int _cmdc, char** _cmdv,
|
||||
{
|
||||
verbprintf(1, "Opening '%s' for binary rewrite... ", _name.c_str());
|
||||
fflush(stderr);
|
||||
if(!_name.empty())
|
||||
mutatee = _bpatch->openBinary(_name.c_str(), false);
|
||||
if(!_name.empty()) mutatee = _bpatch->openBinary(_name.c_str(), false);
|
||||
if(!mutatee)
|
||||
{
|
||||
fprintf(stderr, "[hosttrace]> Failed to open binary '%s'\n", _name.c_str());
|
||||
@@ -617,8 +609,7 @@ hosttrace_get_address_space(patch_pointer_t _bpatch, int _cmdc, char** _cmdv,
|
||||
std::stringstream ss;
|
||||
for(int i = 0; i < _cmdc; ++i)
|
||||
{
|
||||
if(!_cmdv[i])
|
||||
continue;
|
||||
if(!_cmdv[i]) continue;
|
||||
ss << _cmdv[i] << " ";
|
||||
}
|
||||
fprintf(stderr, "[hosttrace]> Failed to create process: '%s'\n",
|
||||
@@ -636,8 +627,7 @@ hosttrace_get_address_space(patch_pointer_t _bpatch, int _cmdc, char** _cmdv,
|
||||
TIMEMORY_NOINLINE inline void
|
||||
hosttrace_thread_exit(thread_t* thread, BPatch_exitType exit_type)
|
||||
{
|
||||
if(!thread)
|
||||
return;
|
||||
if(!thread) return;
|
||||
|
||||
BPatch_process* app = thread->getProcess();
|
||||
|
||||
@@ -650,16 +640,19 @@ hosttrace_thread_exit(thread_t* thread, BPatch_exitType exit_type)
|
||||
|
||||
switch(exit_type)
|
||||
{
|
||||
case ExitedNormally: {
|
||||
case ExitedNormally:
|
||||
{
|
||||
fprintf(stderr, "[hosttrace]> Thread exited normally\n");
|
||||
break;
|
||||
}
|
||||
case ExitedViaSignal: {
|
||||
case ExitedViaSignal:
|
||||
{
|
||||
fprintf(stderr, "[hosttrace]> Thread terminated unexpectedly\n");
|
||||
break;
|
||||
}
|
||||
case NoExit:
|
||||
default: {
|
||||
default:
|
||||
{
|
||||
fprintf(stderr, "[hosttrace]> %s invoked with NoExit\n", __FUNCTION__);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -43,8 +43,7 @@ function_signature
|
||||
get_loop_file_line_info(module_t* mutatee_module, procedure_t* f, flow_graph_t* cfGraph,
|
||||
basic_loop_t* loopToInstrument)
|
||||
{
|
||||
if(!cfGraph || !loopToInstrument || !f)
|
||||
return function_signature("", "", "");
|
||||
if(!cfGraph || !loopToInstrument || !f) return function_signature{ "", "", "" };
|
||||
|
||||
char fname[MUTNAMELEN];
|
||||
char mname[MUTNAMELEN];
|
||||
@@ -57,8 +56,7 @@ get_loop_file_line_info(module_t* mutatee_module, procedure_t* f, flow_graph_t*
|
||||
bpvector_t<point_t*>* loopExitInst =
|
||||
cfGraph->findLoopInstPoints(BPatch_locLoopEndIter, loopToInstrument);
|
||||
|
||||
if(!loopStartInst || !loopExitInst)
|
||||
return function_signature("", "", "");
|
||||
if(!loopStartInst || !loopExitInst) return function_signature{ "", "", "" };
|
||||
|
||||
unsigned long baseAddr = (unsigned long) (*loopStartInst)[0]->getAddress();
|
||||
unsigned long lastAddr =
|
||||
@@ -85,8 +83,7 @@ get_loop_file_line_info(module_t* mutatee_module, procedure_t* f, flow_graph_t*
|
||||
for(auto itr : *params)
|
||||
{
|
||||
string_t _name = itr->getType()->getName();
|
||||
if(_name.empty())
|
||||
_name = itr->getName();
|
||||
if(_name.empty()) _name = itr->getName();
|
||||
_params.push_back(_name);
|
||||
}
|
||||
}
|
||||
@@ -103,8 +100,7 @@ get_loop_file_line_info(module_t* mutatee_module, procedure_t* f, flow_graph_t*
|
||||
// filename = lines[0].fileName();
|
||||
auto row1 = lines[0].lineNumber();
|
||||
auto col1 = lines[0].lineOffset();
|
||||
if(col1 < 0)
|
||||
col1 = 0;
|
||||
if(col1 < 0) col1 = 0;
|
||||
|
||||
// This following section is attempting to remedy the limitations of
|
||||
// getSourceLines for loops. As the program goes through the loop, the resulting
|
||||
@@ -122,10 +118,8 @@ get_loop_file_line_info(module_t* mutatee_module, procedure_t* f, flow_graph_t*
|
||||
{
|
||||
auto row2 = linesEnd[0].lineNumber();
|
||||
auto col2 = linesEnd[0].lineOffset();
|
||||
if(col2 < 0)
|
||||
col2 = 0;
|
||||
if(row2 < row1)
|
||||
row1 = row2; /* Fix for wrong line numbers*/
|
||||
if(col2 < 0) col2 = 0;
|
||||
if(row2 < row1) row1 = row2; // Fix for wrong line numbers
|
||||
|
||||
return function_signature(typeName, fname, filename, _params, { row1, row2 },
|
||||
{ col1, col2 }, true, info1, info2);
|
||||
@@ -180,8 +174,7 @@ get_func_file_line_info(module_t* mutatee_module, procedure_t* f)
|
||||
for(auto itr : *params)
|
||||
{
|
||||
string_t _name = itr->getType()->getName();
|
||||
if(_name.empty())
|
||||
_name = itr->getName();
|
||||
if(_name.empty()) _name = itr->getName();
|
||||
_params.push_back(_name);
|
||||
}
|
||||
}
|
||||
@@ -196,17 +189,14 @@ get_func_file_line_info(module_t* mutatee_module, procedure_t* f)
|
||||
row1 = lines[0].lineNumber();
|
||||
col1 = lines[0].lineOffset();
|
||||
|
||||
if(col1 < 0)
|
||||
col1 = 0;
|
||||
if(col1 < 0) col1 = 0;
|
||||
info2 = mutatee_module->getSourceLines((unsigned long) (lastAddr - 1), lines);
|
||||
if(info2)
|
||||
{
|
||||
row2 = lines[1].lineNumber();
|
||||
col2 = lines[1].lineOffset();
|
||||
if(col2 < 0)
|
||||
col2 = 0;
|
||||
if(row2 < row1)
|
||||
row1 = row2;
|
||||
if(col2 < 0) col2 = 0;
|
||||
if(row2 < row1) row1 = row2;
|
||||
return function_signature(typeName, fname, filename, _params, { row1, 0 },
|
||||
{ 0, 0 }, false, info1, info2);
|
||||
}
|
||||
@@ -239,8 +229,7 @@ errorFunc(error_level_t level, int num, const char** params)
|
||||
{
|
||||
printf("Error #%d (level %d): %s\n", num, level, line);
|
||||
// We consider some errors fatal.
|
||||
if(num == 101)
|
||||
exit(-1);
|
||||
if(num == 101) exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,15 +240,13 @@ errorFunc(error_level_t level, int num, const char** params)
|
||||
procedure_t*
|
||||
find_function(image_t* app_image, const std::string& _name, strset_t _extra)
|
||||
{
|
||||
if(_name.empty())
|
||||
return nullptr;
|
||||
if(_name.empty()) return nullptr;
|
||||
|
||||
auto _find = [app_image](const string_t& _f) -> procedure_t* {
|
||||
// Extract the vector of functions
|
||||
bpvector_t<procedure_t*> _found;
|
||||
auto ret = app_image->findFunction(_f.c_str(), _found, false, true, true);
|
||||
if(ret == nullptr || _found.empty())
|
||||
return nullptr;
|
||||
if(ret == nullptr || _found.empty()) return nullptr;
|
||||
return _found.at(0);
|
||||
};
|
||||
|
||||
@@ -271,8 +258,7 @@ find_function(image_t* app_image, const std::string& _name, strset_t _extra)
|
||||
++itr;
|
||||
}
|
||||
|
||||
if(!_func)
|
||||
verbprintf(2, "hosttrace: Unable to find function %s\n", _name.c_str());
|
||||
if(!_func) verbprintf(2, "hosttrace: Unable to find function %s\n", _name.c_str());
|
||||
|
||||
return _func;
|
||||
}
|
||||
@@ -289,8 +275,7 @@ error_func_real(error_level_t level, int num, const char* const* params)
|
||||
{
|
||||
if(level == BPatchInfo)
|
||||
{
|
||||
if(error_print > 1)
|
||||
printf("%s\n", params[0]);
|
||||
if(error_print > 1) printf("%s\n", params[0]);
|
||||
}
|
||||
else
|
||||
printf("%s", params[0]);
|
||||
@@ -306,8 +291,7 @@ error_func_real(error_level_t level, int num, const char* const* params)
|
||||
{
|
||||
printf("Error #%d (level %d): %s\n", num, level, line);
|
||||
// We consider some errors fatal.
|
||||
if(num == 101)
|
||||
exit(-1);
|
||||
if(num == 101) exit(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,8 +186,7 @@ main(int argc, char** argv)
|
||||
if(_cmdc > 0)
|
||||
std::cout << "\n[hosttrace][command]: " << cmd_string(_cmdc, _cmdv) << "\n\n";
|
||||
|
||||
if(_cmdc > 0)
|
||||
cmdv0 = _cmdv[0];
|
||||
if(_cmdc > 0) cmdv0 = _cmdv[0];
|
||||
|
||||
std::stringstream jump_description;
|
||||
jump_description
|
||||
@@ -417,8 +416,7 @@ main(int argc, char** argv)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(parser.exists("e"))
|
||||
werror = true;
|
||||
if(parser.exists("e")) werror = true;
|
||||
|
||||
if(parser.exists("v"))
|
||||
{
|
||||
@@ -434,11 +432,9 @@ main(int argc, char** argv)
|
||||
debug_print = true;
|
||||
}
|
||||
|
||||
if(parser.exists("m"))
|
||||
main_fname = parser.get<string_t>("m");
|
||||
if(parser.exists("m")) main_fname = parser.get<string_t>("m");
|
||||
|
||||
if(parser.exists("l"))
|
||||
loop_level_instr = true;
|
||||
if(parser.exists("l")) loop_level_instr = true;
|
||||
|
||||
if(_cmdc == 0 && parser.exists("c"))
|
||||
{
|
||||
@@ -485,17 +481,13 @@ main(int argc, char** argv)
|
||||
inputlib = parser.get<strvec_t>("L");
|
||||
}
|
||||
|
||||
if(parser.exists("S"))
|
||||
stl_func_instr = true;
|
||||
if(parser.exists("S")) stl_func_instr = true;
|
||||
|
||||
if(parser.exists("cstdlib"))
|
||||
cstd_func_instr = true;
|
||||
if(parser.exists("cstdlib")) cstd_func_instr = true;
|
||||
|
||||
if(parser.exists("mpi"))
|
||||
use_mpi = true;
|
||||
if(parser.exists("mpi")) use_mpi = true;
|
||||
|
||||
if(parser.exists("p"))
|
||||
_pid = parser.get<int>("p");
|
||||
if(parser.exists("p")) _pid = parser.get<int>("p");
|
||||
|
||||
if(parser.exists("d"))
|
||||
{
|
||||
@@ -509,8 +501,7 @@ main(int argc, char** argv)
|
||||
break;
|
||||
}
|
||||
default_components += _components.at(i);
|
||||
if(i + 1 < _components.size())
|
||||
default_components += ",";
|
||||
if(i + 1 < _components.size()) default_components += ",";
|
||||
}
|
||||
if(default_components == "none")
|
||||
default_components = {};
|
||||
@@ -531,8 +522,7 @@ main(int argc, char** argv)
|
||||
instr_pop_hash = "hosttrace_pop_" + instr_mode + "_hash";
|
||||
}
|
||||
|
||||
if(parser.exists("prefer"))
|
||||
prefer_library = parser.get<string_t>("prefer");
|
||||
if(parser.exists("prefer")) prefer_library = parser.get<string_t>("prefer");
|
||||
|
||||
if(parser.exists("load"))
|
||||
{
|
||||
@@ -564,8 +554,7 @@ main(int argc, char** argv)
|
||||
fini_stub_names = parser.get<strvec_t>("fini-functions");
|
||||
auto env_vars = parser.get<strvec_t>("env");
|
||||
|
||||
if(verbose_level >= 0)
|
||||
tim::makedir(modfunc_dump_dir);
|
||||
if(verbose_level >= 0) tim::makedir(modfunc_dump_dir);
|
||||
|
||||
//----------------------------------------------------------------------------------//
|
||||
//
|
||||
@@ -576,8 +565,7 @@ main(int argc, char** argv)
|
||||
// Helper function for adding regex expressions
|
||||
//
|
||||
auto add_regex = [](auto& regex_array, const string_t& regex_expr) {
|
||||
if(!regex_expr.empty())
|
||||
regex_array.push_back(std::regex(regex_expr, regex_opts));
|
||||
if(!regex_expr.empty()) regex_array.push_back(std::regex(regex_expr, regex_opts));
|
||||
};
|
||||
|
||||
add_regex(func_include, tim::get_env<string_t>("HOSTTRACE_REGEX_INCLUDE", ""));
|
||||
@@ -783,8 +771,7 @@ main(int argc, char** argv)
|
||||
auto itr = module_names.begin();
|
||||
std::advance(itr, i);
|
||||
std::cout << std::setw(mwid) << *itr << " | ";
|
||||
if(i % ncol == ncol - 1)
|
||||
std::cout << "\n| ";
|
||||
if(i % ncol == ncol - 1) std::cout << "\n| ";
|
||||
}
|
||||
std::cout << '\n' << std::endl;
|
||||
}
|
||||
@@ -833,8 +820,7 @@ main(int argc, char** argv)
|
||||
result = (addr_space->loadLibrary(_libname.c_str()) != nullptr);
|
||||
verbprintf(1, "loadLibrary(%s) result = %s\n", _libname.c_str(),
|
||||
(result) ? "success" : "failure");
|
||||
if(result)
|
||||
break;
|
||||
if(result) break;
|
||||
}
|
||||
if(!result)
|
||||
{
|
||||
@@ -906,18 +892,15 @@ main(int argc, char** argv)
|
||||
auto* mpi_init_func = find_function(app_image, "MPI_Init", { "MPI_Init_thread" });
|
||||
auto* mpi_fini_func = find_function(app_image, "MPI_Finalize");
|
||||
|
||||
if(!main_func && main_fname == "main")
|
||||
main_func = find_function(app_image, "_main");
|
||||
if(!main_func && main_fname == "main") main_func = find_function(app_image, "_main");
|
||||
|
||||
verbprintf(0, "Instrumenting with '%s' and '%s'...\n", instr_push_func.c_str(),
|
||||
instr_pop_func.c_str());
|
||||
|
||||
if(mpi_init_func && mpi_fini_func)
|
||||
use_mpi = true;
|
||||
if(mpi_init_func && mpi_fini_func) use_mpi = true;
|
||||
|
||||
bool use_mpip = false;
|
||||
if(use_mpi)
|
||||
use_mpip = true;
|
||||
if(use_mpi) use_mpip = true;
|
||||
|
||||
//----------------------------------------------------------------------------------//
|
||||
//
|
||||
@@ -930,8 +913,7 @@ main(int argc, char** argv)
|
||||
verbprintf(3,
|
||||
"Attempting to find instrumentation for '%s' via '%s' and '%s'...\n",
|
||||
_name.c_str(), _beg.c_str(), _end.c_str());
|
||||
if(_beg.empty() || _end.empty())
|
||||
return false;
|
||||
if(_beg.empty() || _end.empty()) return false;
|
||||
auto* _beg_func = find_function(app_image, _beg);
|
||||
auto* _end_func = find_function(app_image, _end);
|
||||
if(_beg_func && _end_func)
|
||||
@@ -957,17 +939,14 @@ main(int argc, char** argv)
|
||||
{
|
||||
string_t _name = itr;
|
||||
size_t _pos = _name.find_last_of('/');
|
||||
if(_pos != npos_v)
|
||||
_name = _name.substr(_pos + 1);
|
||||
if(_pos != npos_v) _name = _name.substr(_pos + 1);
|
||||
_pos = _name.find('.');
|
||||
if(_pos != npos_v)
|
||||
_name = _name.substr(0, _pos);
|
||||
if(_pos != npos_v) _name = _name.substr(0, _pos);
|
||||
_pos = _name.find("libhosttrace-");
|
||||
if(_pos != npos_v)
|
||||
_name = _name.erase(_pos, std::string("libhosttrace-").length());
|
||||
_pos = _name.find("lib");
|
||||
if(_pos == 0)
|
||||
_name = _name.substr(_pos + std::string("lib").length());
|
||||
if(_pos == 0) _name = _name.substr(_pos + std::string("lib").length());
|
||||
while((_pos = _name.find('-')) != npos_v)
|
||||
_name.replace(_pos, 1, "_");
|
||||
|
||||
@@ -1005,18 +984,15 @@ main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
if(add_instr_library(_name, best_init_name, base_fini_name))
|
||||
continue;
|
||||
if(add_instr_library(_name, best_init_name, base_fini_name)) continue;
|
||||
|
||||
// check user-specified signatures first
|
||||
for(const auto& bitr : init_stub_names)
|
||||
{
|
||||
if(used_stub_names.find(bitr) != used_stub_names.end())
|
||||
continue;
|
||||
if(used_stub_names.find(bitr) != used_stub_names.end()) continue;
|
||||
for(const auto& fitr : fini_stub_names)
|
||||
{
|
||||
if(used_stub_names.find(fitr) != used_stub_names.end())
|
||||
continue;
|
||||
if(used_stub_names.find(fitr) != used_stub_names.end()) continue;
|
||||
if(add_instr_library(_name, bitr, fitr))
|
||||
goto found_instr_functions; // exit loop after match
|
||||
}
|
||||
@@ -1065,8 +1041,7 @@ main(int argc, char** argv)
|
||||
pair_t(fini_func, "hosttrace_trace_finalize"),
|
||||
pair_t(env_func, "hosttrace_trace_set_env") })
|
||||
{
|
||||
if(itr.first == main_func && !is_driver)
|
||||
continue;
|
||||
if(itr.first == main_func && !is_driver) continue;
|
||||
if(!itr.first)
|
||||
{
|
||||
stringstream_t ss;
|
||||
@@ -1092,8 +1067,7 @@ main(int argc, char** argv)
|
||||
{
|
||||
char moduleName[MUTNAMELEN];
|
||||
_module->getName(moduleName, MUTNAMELEN);
|
||||
if(strcmp(moduleName, "DEFAULT_MODULE") != 0)
|
||||
_has_debug_info = true;
|
||||
if(strcmp(moduleName, "DEFAULT_MODULE") != 0) _has_debug_info = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1153,8 +1127,7 @@ main(int argc, char** argv)
|
||||
{
|
||||
verbprintf(2, "Getting main function signature...\n");
|
||||
main_sign = get_func_file_line_info(main_func->getModule(), main_func);
|
||||
if(main_sign.m_params == "()")
|
||||
main_sign.m_params = "(int argc, char** argv)";
|
||||
if(main_sign.m_params == "()") main_sign.m_params = "(int argc, char** argv)";
|
||||
}
|
||||
|
||||
verbprintf(2, "Getting call expressions... ");
|
||||
@@ -1221,23 +1194,16 @@ main(int argc, char** argv)
|
||||
//
|
||||
//----------------------------------------------------------------------------------//
|
||||
|
||||
if(trace_env_call)
|
||||
init_names.push_back(trace_env_call.get());
|
||||
if(mode_env_call)
|
||||
init_names.push_back(mode_env_call.get());
|
||||
if(mpii_env_call)
|
||||
init_names.push_back(mpii_env_call.get());
|
||||
if(mpif_env_call)
|
||||
init_names.push_back(mpif_env_call.get());
|
||||
if(use_mpi && use_mpi_env_call)
|
||||
init_names.push_back(use_mpi_env_call.get());
|
||||
if(use_mpip && use_mpip_env_call)
|
||||
init_names.push_back(use_mpip_env_call.get());
|
||||
if(trace_env_call) init_names.push_back(trace_env_call.get());
|
||||
if(mode_env_call) init_names.push_back(mode_env_call.get());
|
||||
if(mpii_env_call) init_names.push_back(mpii_env_call.get());
|
||||
if(mpif_env_call) init_names.push_back(mpif_env_call.get());
|
||||
if(use_mpi && use_mpi_env_call) init_names.push_back(use_mpi_env_call.get());
|
||||
if(use_mpip && use_mpip_env_call) init_names.push_back(use_mpip_env_call.get());
|
||||
|
||||
for(const auto& itr : env_variables)
|
||||
{
|
||||
if(itr)
|
||||
init_names.push_back(itr.get());
|
||||
if(itr) init_names.push_back(itr.get());
|
||||
}
|
||||
|
||||
for(const auto& itr : beg_expr)
|
||||
@@ -1253,11 +1219,9 @@ main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
if(use_mpi && umpi_call)
|
||||
init_names.push_back(umpi_call.get());
|
||||
if(use_mpi && umpi_call) init_names.push_back(umpi_call.get());
|
||||
|
||||
if(init_call && binary_rewrite)
|
||||
init_names.push_back(init_call.get());
|
||||
if(init_call && binary_rewrite) init_names.push_back(init_call.get());
|
||||
|
||||
if(binary_rewrite)
|
||||
{
|
||||
@@ -1299,13 +1263,11 @@ main(int argc, char** argv)
|
||||
verbprintf(0, "No binary_rewrite and no app_thread!...\n");
|
||||
}
|
||||
|
||||
if(fini_call)
|
||||
fini_names.push_back(fini_call.get());
|
||||
if(fini_call) fini_names.push_back(fini_call.get());
|
||||
|
||||
for(const auto& itr : end_expr)
|
||||
{
|
||||
if(itr.second)
|
||||
fini_names.push_back(itr.second.get());
|
||||
if(itr.second) fini_names.push_back(itr.second.get());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------//
|
||||
@@ -1321,8 +1283,7 @@ main(int argc, char** argv)
|
||||
(unsigned long) procedures.size());
|
||||
for(auto* itr : procedures)
|
||||
{
|
||||
if(itr == main_func)
|
||||
continue;
|
||||
if(itr == main_func) continue;
|
||||
|
||||
char modname[MUTNAMELEN];
|
||||
char fname[FUNCNAMELEN];
|
||||
@@ -1339,14 +1300,11 @@ main(int argc, char** argv)
|
||||
continue;
|
||||
}
|
||||
|
||||
if(std::string{ modname }.find("libdyninst") != std::string::npos)
|
||||
continue;
|
||||
if(std::string{ modname }.find("libdyninst") != std::string::npos) continue;
|
||||
|
||||
if(module_constraint(modname))
|
||||
continue;
|
||||
if(module_constraint(modname)) continue;
|
||||
|
||||
if(!instrument_module(modname))
|
||||
continue;
|
||||
if(!instrument_module(modname)) continue;
|
||||
|
||||
itr->getName(fname, FUNCNAMELEN);
|
||||
|
||||
@@ -1358,11 +1316,9 @@ main(int argc, char** argv)
|
||||
continue;
|
||||
}
|
||||
|
||||
if(routine_constraint(name.m_name.c_str()))
|
||||
continue;
|
||||
if(routine_constraint(name.m_name.c_str())) continue;
|
||||
|
||||
if(!instrument_entity(name.m_name))
|
||||
continue;
|
||||
if(!instrument_entity(name.m_name)) continue;
|
||||
|
||||
if(is_static_exe && has_debug_info && string_t{ fname } == "_fini" &&
|
||||
string_t{ modname } == "DEFAULT_MODULE")
|
||||
@@ -1389,8 +1345,7 @@ main(int argc, char** argv)
|
||||
// try to get loops via the control flow graph
|
||||
flow_graph_t* cfg = itr->getCFG();
|
||||
basic_loop_vec_t basic_loop{};
|
||||
if(cfg)
|
||||
cfg->getOuterLoops(basic_loop);
|
||||
if(cfg) cfg->getOuterLoops(basic_loop);
|
||||
|
||||
// if the function has dynamic callsites and user specified instrumenting
|
||||
// dynamic callsites, force the instrumentation
|
||||
@@ -1502,8 +1457,7 @@ main(int argc, char** argv)
|
||||
{
|
||||
char modname[1024];
|
||||
m->getName(modname, 1024);
|
||||
if(strstr(modname, "libdyninst") != nullptr)
|
||||
continue;
|
||||
if(strstr(modname, "libdyninst") != nullptr) continue;
|
||||
|
||||
if(!m->getProcedures())
|
||||
{
|
||||
@@ -1513,8 +1467,7 @@ main(int argc, char** argv)
|
||||
|
||||
verbprintf(1, "Parsing module: %s\n", modname);
|
||||
bpvector_t<procedure_t*>* p = m->getProcedures();
|
||||
if(!p)
|
||||
continue;
|
||||
if(!p) continue;
|
||||
|
||||
instr_procedures(*p);
|
||||
}
|
||||
@@ -1692,8 +1645,7 @@ main(int argc, char** argv)
|
||||
}
|
||||
for(auto& mitr : _data)
|
||||
{
|
||||
if(_mode != "modules")
|
||||
std::cout << "\n" << mitr.first << ":\n";
|
||||
if(_mode != "modules") std::cout << "\n" << mitr.first << ":\n";
|
||||
for(auto& itr : mitr.second)
|
||||
{
|
||||
std::cout << " " << itr << "\n";
|
||||
@@ -1701,23 +1653,20 @@ main(int argc, char** argv)
|
||||
}
|
||||
};
|
||||
|
||||
if(!print_available.empty())
|
||||
_dump_info(print_available, available_module_functions);
|
||||
if(!print_available.empty()) _dump_info(print_available, available_module_functions);
|
||||
if(!print_instrumented.empty())
|
||||
_dump_info(print_instrumented, instrumented_module_functions);
|
||||
if(!print_overlapping.empty())
|
||||
_dump_info(print_overlapping, overlapping_module_functions);
|
||||
|
||||
if(_dump_and_exit)
|
||||
exit(EXIT_SUCCESS);
|
||||
if(_dump_and_exit) exit(EXIT_SUCCESS);
|
||||
|
||||
//----------------------------------------------------------------------------------//
|
||||
//
|
||||
// Either write the instrumented binary or execute the application
|
||||
//
|
||||
//----------------------------------------------------------------------------------//
|
||||
if(binary_rewrite)
|
||||
addr_space->finalizeInsertionSet(false, nullptr);
|
||||
if(binary_rewrite) addr_space->finalizeInsertionSet(false, nullptr);
|
||||
|
||||
int code = -1;
|
||||
if(binary_rewrite)
|
||||
@@ -1753,8 +1702,7 @@ main(int argc, char** argv)
|
||||
strvec_t linked_libraries = tim::popen::read_fork(ldd);
|
||||
|
||||
auto perr = tim::popen::pclose(ldd);
|
||||
if(perr != 0)
|
||||
perror("Error in hosttrace_fork");
|
||||
if(perr != 0) perror("Error in hosttrace_fork");
|
||||
|
||||
for(const auto& itr : linked_libraries)
|
||||
printf("\t%s\n", itr.c_str());
|
||||
@@ -1847,13 +1795,11 @@ instrument_module(const string_t& file_name)
|
||||
};
|
||||
|
||||
auto is_include = [&](bool _if_empty) {
|
||||
if(file_include.empty())
|
||||
return _if_empty;
|
||||
if(file_include.empty()) return _if_empty;
|
||||
// NOLINTNEXTLINE(readability-use-anyofallof)
|
||||
for(auto& itr : file_include)
|
||||
{
|
||||
if(std::regex_search(file_name, itr))
|
||||
return true;
|
||||
if(std::regex_search(file_name, itr)) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
@@ -1862,8 +1808,7 @@ instrument_module(const string_t& file_name)
|
||||
// NOLINTNEXTLINE(readability-use-anyofallof)
|
||||
for(auto& itr : file_exclude)
|
||||
{
|
||||
if(std::regex_search(file_name, itr))
|
||||
return true;
|
||||
if(std::regex_search(file_name, itr)) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
@@ -1939,8 +1884,7 @@ instrument_module(const string_t& file_name)
|
||||
return false;
|
||||
}*/
|
||||
|
||||
if(_user_exclude)
|
||||
return (_report("Excluding", "user-regex", 2), false);
|
||||
if(_user_exclude) return (_report("Excluding", "user-regex", 2), false);
|
||||
|
||||
_report("Including", "no constraint", 2);
|
||||
|
||||
@@ -1953,13 +1897,11 @@ bool
|
||||
instrument_entity(const string_t& function_name)
|
||||
{
|
||||
auto is_include = [&](bool _if_empty) {
|
||||
if(func_include.empty())
|
||||
return _if_empty;
|
||||
if(func_include.empty()) return _if_empty;
|
||||
// NOLINTNEXTLINE(readability-use-anyofallof)
|
||||
for(auto& itr : func_include)
|
||||
{
|
||||
if(std::regex_search(function_name, itr))
|
||||
return true;
|
||||
if(std::regex_search(function_name, itr)) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
@@ -2073,8 +2015,7 @@ insert_instr(address_space_t* mutatee, procedure_t* funcToInstr, Tp traceFunc,
|
||||
basic_loop_t* loopToInstrument)
|
||||
{
|
||||
module_t* module = funcToInstr->getModule();
|
||||
if(!module || !traceFunc)
|
||||
return;
|
||||
if(!module || !traceFunc) return;
|
||||
|
||||
bpvector_t<point_t*>* _points = nullptr;
|
||||
auto _trace = traceFunc.get();
|
||||
@@ -2091,10 +2032,8 @@ insert_instr(address_space_t* mutatee, procedure_t* funcToInstr, Tp traceFunc,
|
||||
_points = funcToInstr->findPoint(traceLoc);
|
||||
}
|
||||
|
||||
if(_points == nullptr)
|
||||
return;
|
||||
if(_points->empty())
|
||||
return;
|
||||
if(_points == nullptr) return;
|
||||
if(_points->empty()) return;
|
||||
|
||||
/*if(loop_level_instr)
|
||||
{
|
||||
@@ -2140,15 +2079,12 @@ module_constraint(char* fname)
|
||||
string_t _fname = fname;
|
||||
|
||||
// never instrumentat any module matching hosttrace
|
||||
if(_fname.find("hosttrace") != string_t::npos)
|
||||
return true;
|
||||
if(_fname.find("hosttrace") != string_t::npos) return true;
|
||||
|
||||
// always instrument these modules
|
||||
if(_fname == "DEFAULT_MODULE" || _fname == "LIBRARY_MODULE")
|
||||
return false;
|
||||
if(_fname == "DEFAULT_MODULE" || _fname == "LIBRARY_MODULE") return false;
|
||||
|
||||
if(instrument_module(_fname))
|
||||
return false;
|
||||
if(instrument_module(_fname)) return false;
|
||||
|
||||
// do not instrument
|
||||
return true;
|
||||
@@ -2161,8 +2097,7 @@ bool
|
||||
routine_constraint(const char* fname)
|
||||
{
|
||||
string_t _fname = fname;
|
||||
if(_fname.find("hosttrace") != string_t::npos)
|
||||
return true;
|
||||
if(_fname.find("hosttrace") != string_t::npos) return true;
|
||||
|
||||
auto npos = std::string::npos;
|
||||
if(_fname.find("FunctionInfo") != npos || _fname.find("_L_lock") != npos ||
|
||||
|
||||
@@ -56,8 +56,7 @@ void
|
||||
mpi_gotcha::audit(const gotcha_data_t& _data, audit::incoming, int*, char***)
|
||||
{
|
||||
HOSTTRACE_DEBUG("[%s] %s(int*, char***)\n", __FUNCTION__, _data.tool_id.c_str());
|
||||
if(get_state() == ::State::DelayedInit)
|
||||
get_state() = ::State::PreInit;
|
||||
if(get_state() == ::State::DelayedInit) get_state() = ::State::PreInit;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -65,8 +64,7 @@ mpi_gotcha::audit(const gotcha_data_t& _data, audit::incoming, int*, char***, in
|
||||
{
|
||||
HOSTTRACE_DEBUG("[%s] %s(int*, char***, int, int*)\n", __FUNCTION__,
|
||||
_data.tool_id.c_str());
|
||||
if(get_state() == ::State::DelayedInit)
|
||||
get_state() = ::State::PreInit;
|
||||
if(get_state() == ::State::DelayedInit) get_state() = ::State::PreInit;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -96,15 +94,13 @@ mpi_gotcha::audit(const gotcha_data_t& _data, audit::outgoing, int _retval)
|
||||
void
|
||||
hosttrace_component::start()
|
||||
{
|
||||
if(m_prefix)
|
||||
hosttrace_push_trace(m_prefix);
|
||||
if(m_prefix) hosttrace_push_trace(m_prefix);
|
||||
}
|
||||
|
||||
void
|
||||
hosttrace_component::stop()
|
||||
{
|
||||
if(m_prefix)
|
||||
hosttrace_pop_trace(m_prefix);
|
||||
if(m_prefix) hosttrace_pop_trace(m_prefix);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -68,8 +68,7 @@ void
|
||||
setup_gotchas()
|
||||
{
|
||||
static bool _initialized = false;
|
||||
if(_initialized)
|
||||
return;
|
||||
if(_initialized) return;
|
||||
_initialized = true;
|
||||
|
||||
HOSTTRACE_DEBUG(
|
||||
@@ -168,8 +167,7 @@ bool
|
||||
hosttrace_init_tooling()
|
||||
{
|
||||
static bool _once = false;
|
||||
if(get_state() != State::PreInit || _once)
|
||||
return false;
|
||||
if(get_state() != State::PreInit || _once) return false;
|
||||
_once = true;
|
||||
|
||||
HOSTTRACE_DEBUG("[%s]\n", __FUNCTION__);
|
||||
@@ -195,19 +193,16 @@ hosttrace_init_tooling()
|
||||
"HOSTTRACE_COMPONENTS", "wall_clock", get_use_timemory());
|
||||
|
||||
// enable timestamp directories when perfetto + mpi is activated
|
||||
if(get_use_perfetto() && get_use_mpi())
|
||||
tim::settings::time_output() = true;
|
||||
if(get_use_perfetto() && get_use_mpi()) tim::settings::time_output() = true;
|
||||
|
||||
auto _cmd = tim::read_command_line(process::get_id());
|
||||
auto _exe = (_cmd.empty()) ? "hosttrace" : _cmd.front();
|
||||
auto _pos = _exe.find_last_of('/');
|
||||
if(_pos < _exe.length() - 1)
|
||||
_exe = _exe.substr(_pos + 1);
|
||||
if(_pos < _exe.length() - 1) _exe = _exe.substr(_pos + 1);
|
||||
|
||||
tim::timemory_init({ _exe }, "hosttrace-");
|
||||
|
||||
if(get_sample_rate() < 1)
|
||||
get_sample_rate() = 1;
|
||||
if(get_sample_rate() < 1) get_sample_rate() = 1;
|
||||
get_sample_data().reserve(512);
|
||||
|
||||
if(get_use_timemory())
|
||||
@@ -269,10 +264,8 @@ hosttrace_init_tooling()
|
||||
|
||||
args.shmem_size_hint_kb = shmem_size_hint;
|
||||
|
||||
if(get_backend() != "inprocess")
|
||||
args.backends |= perfetto::kSystemBackend;
|
||||
if(get_backend() != "system")
|
||||
args.backends |= perfetto::kInProcessBackend;
|
||||
if(get_backend() != "inprocess") args.backends |= perfetto::kSystemBackend;
|
||||
if(get_backend() != "system") args.backends |= perfetto::kInProcessBackend;
|
||||
|
||||
perfetto::Tracing::Initialize(args);
|
||||
perfetto::TrackEvent::Register();
|
||||
@@ -395,8 +388,7 @@ hosttrace_init_tooling()
|
||||
// ends the tracing session
|
||||
static auto _ensure_finalization = ensure_finalization();
|
||||
|
||||
if(dmp::rank() == 0)
|
||||
puts("");
|
||||
if(dmp::rank() == 0) puts("");
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
@@ -408,8 +400,7 @@ extern "C"
|
||||
void hosttrace_push_trace(const char* name)
|
||||
{
|
||||
// return if not active
|
||||
if(get_state() == State::Finalized)
|
||||
return;
|
||||
if(get_state() == State::Finalized) return;
|
||||
|
||||
if(get_state() != State::Active && !hosttrace_init_tooling())
|
||||
{
|
||||
@@ -426,8 +417,7 @@ extern "C"
|
||||
static thread_local size_t _sample_idx = 0;
|
||||
auto _enabled = (_sample_idx++ % _sample_rate == 0);
|
||||
get_sample_data().emplace_back(_enabled);
|
||||
if(_enabled)
|
||||
get_functors().first(name);
|
||||
if(_enabled) get_functors().first(name);
|
||||
}
|
||||
|
||||
void hosttrace_pop_trace(const char* name)
|
||||
@@ -438,8 +428,7 @@ extern "C"
|
||||
auto& _sample_data = get_sample_data();
|
||||
if(!_sample_data.empty())
|
||||
{
|
||||
if(_sample_data.back())
|
||||
get_functors().second(name);
|
||||
if(_sample_data.back()) get_functors().second(name);
|
||||
_sample_data.pop_back();
|
||||
}
|
||||
}
|
||||
@@ -458,13 +447,11 @@ extern "C"
|
||||
void hosttrace_trace_finalize(void)
|
||||
{
|
||||
// return if not active
|
||||
if(get_state() != State::Active)
|
||||
return;
|
||||
if(get_state() != State::Active) return;
|
||||
|
||||
HOSTTRACE_DEBUG("[%s]\n", __FUNCTION__);
|
||||
|
||||
if(dmp::rank() == 0)
|
||||
puts("");
|
||||
if(dmp::rank() == 0) puts("");
|
||||
|
||||
get_state() = State::Finalized;
|
||||
|
||||
|
||||
@@ -80,8 +80,7 @@ hsa_api_callback(uint32_t domain, uint32_t cid, const void* callback_data, void*
|
||||
static thread_local timestamp_t hsa_begin_timestamp = 0;
|
||||
static auto& timer = get_hsa_timer();
|
||||
|
||||
if(!timer)
|
||||
return;
|
||||
if(!timer) return;
|
||||
|
||||
switch(cid)
|
||||
{
|
||||
@@ -126,7 +125,8 @@ hsa_api_callback(uint32_t domain, uint32_t cid, const void* callback_data, void*
|
||||
case HSA_API_ID_hsa_system_get_info:
|
||||
case HSA_API_ID_hsa_system_get_major_extension_table:
|
||||
case HSA_API_ID_hsa_wavefront_get_info: break;
|
||||
default: {
|
||||
default:
|
||||
{
|
||||
if(data->phase == ACTIVITY_API_PHASE_ENTER)
|
||||
{
|
||||
hsa_begin_timestamp = timer->timestamp_fn_ns();
|
||||
@@ -176,8 +176,7 @@ hsa_activity_callback(uint32_t op, activity_record_t* record, void* arg)
|
||||
default: break;
|
||||
}
|
||||
|
||||
if(!_name)
|
||||
return;
|
||||
if(!_name) return;
|
||||
|
||||
if(get_use_perfetto())
|
||||
{
|
||||
@@ -209,7 +208,8 @@ hip_api_callback(uint32_t domain, uint32_t cid, const void* callback_data, void*
|
||||
{
|
||||
case HIP_API_ID___hipPushCallConfiguration:
|
||||
case HIP_API_ID___hipPopCallConfiguration: break;
|
||||
case HIP_API_ID_hipLaunchKernel: {
|
||||
case HIP_API_ID_hipLaunchKernel:
|
||||
{
|
||||
const char* _name =
|
||||
hipKernelNameRefByPtr(data->args.hipLaunchKernel.function_address,
|
||||
data->args.hipLaunchKernel.stream);
|
||||
@@ -221,13 +221,13 @@ hip_api_callback(uint32_t domain, uint32_t cid, const void* callback_data, void*
|
||||
}
|
||||
if(get_use_timemory())
|
||||
{
|
||||
get_roctracer_hip_data().emplace(
|
||||
data->correlation_id,
|
||||
roctracer_bundle_t{ tim::static_string{ _name }(), _scope });
|
||||
get_roctracer_hip_data().emplace(data->correlation_id,
|
||||
roctracer_bundle_t{ _name, _scope });
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HIP_API_ID_hipModuleLaunchKernel: {
|
||||
case HIP_API_ID_hipModuleLaunchKernel:
|
||||
{
|
||||
const char* _name = hipKernelNameRef(data->args.hipModuleLaunchKernel.f);
|
||||
tim::auto_lock_t _lk{ tim::type_mutex<data_type_mutex_t>() };
|
||||
get_roctracer_kernels().emplace(data->correlation_id);
|
||||
@@ -237,13 +237,13 @@ hip_api_callback(uint32_t domain, uint32_t cid, const void* callback_data, void*
|
||||
}
|
||||
if(get_use_timemory())
|
||||
{
|
||||
get_roctracer_hip_data().emplace(
|
||||
data->correlation_id,
|
||||
roctracer_bundle_t{ tim::static_string{ _name }(), _scope });
|
||||
get_roctracer_hip_data().emplace(data->correlation_id,
|
||||
roctracer_bundle_t{ _name, _scope });
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
{
|
||||
tim::auto_lock_t _lk{ tim::type_mutex<data_type_mutex_t>() };
|
||||
const char* _name = roctracer_op_string(domain, cid, 0);
|
||||
if(get_use_perfetto())
|
||||
@@ -252,9 +252,8 @@ hip_api_callback(uint32_t domain, uint32_t cid, const void* callback_data, void*
|
||||
}
|
||||
if(get_use_timemory())
|
||||
{
|
||||
get_roctracer_hip_data().emplace(
|
||||
data->correlation_id,
|
||||
roctracer_bundle_t{ tim::static_string{ _name }(), _scope });
|
||||
get_roctracer_hip_data().emplace(data->correlation_id,
|
||||
roctracer_bundle_t{ _name, _scope });
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -269,8 +268,7 @@ hip_api_callback(uint32_t domain, uint32_t cid, const void* callback_data, void*
|
||||
void
|
||||
hip_activity_callback(const char* begin, const char* end, void*)
|
||||
{
|
||||
if(!trait::runtime_enabled<comp::roctracer>::get())
|
||||
return;
|
||||
if(!trait::runtime_enabled<comp::roctracer>::get()) return;
|
||||
static auto _kernel_names = std::unordered_map<const char*, std::string>{};
|
||||
const roctracer_record_t* record = reinterpret_cast<const roctracer_record_t*>(begin);
|
||||
const roctracer_record_t* end_record =
|
||||
@@ -386,15 +384,13 @@ struct dynamic_library
|
||||
, flags{ _flags }
|
||||
{
|
||||
handle = dlopen(filename.c_str(), flags);
|
||||
if(!handle)
|
||||
fprintf(stderr, "%s\n", dlerror());
|
||||
if(!handle) fprintf(stderr, "%s\n", dlerror());
|
||||
dlerror(); // Clear any existing error
|
||||
}
|
||||
|
||||
~dynamic_library()
|
||||
{
|
||||
if(handle)
|
||||
dlclose(handle);
|
||||
if(handle) dlclose(handle);
|
||||
}
|
||||
|
||||
std::string envname = {};
|
||||
@@ -464,12 +460,10 @@ roctracer::remove_tear_down(const std::string& _lbl)
|
||||
void
|
||||
roctracer::setup()
|
||||
{
|
||||
if(!get_use_timemory() && !get_use_perfetto())
|
||||
return;
|
||||
if(!get_use_timemory() && !get_use_perfetto()) return;
|
||||
|
||||
auto_lock_t _lk{ type_mutex<roctracer>() };
|
||||
if(roctracer_is_setup())
|
||||
return;
|
||||
if(roctracer_is_setup()) return;
|
||||
roctracer_is_setup() = true;
|
||||
HOSTTRACE_DEBUG("[%s]\n", __FUNCTION__);
|
||||
|
||||
@@ -503,8 +497,7 @@ void
|
||||
roctracer::tear_down()
|
||||
{
|
||||
auto_lock_t _lk{ type_mutex<roctracer>() };
|
||||
if(!roctracer_is_setup())
|
||||
return;
|
||||
if(!roctracer_is_setup()) return;
|
||||
roctracer_is_setup() = false;
|
||||
HOSTTRACE_DEBUG("[%s]\n", __FUNCTION__);
|
||||
|
||||
@@ -529,15 +522,13 @@ roctracer::tear_down()
|
||||
void
|
||||
roctracer::start()
|
||||
{
|
||||
if(tracker_type::start() == 0)
|
||||
setup();
|
||||
if(tracker_type::start() == 0) setup();
|
||||
}
|
||||
|
||||
void
|
||||
roctracer::stop()
|
||||
{
|
||||
if(tracker_type::stop() == 0)
|
||||
tear_down();
|
||||
if(tracker_type::stop() == 0) tear_down();
|
||||
}
|
||||
} // namespace component
|
||||
} // namespace tim
|
||||
@@ -548,15 +539,14 @@ TIMEMORY_INSTANTIATE_EXTERN_COMPONENT(roctracer_data, true, double)
|
||||
// HSA-runtime tool on-load method
|
||||
extern "C"
|
||||
{
|
||||
TIMEMORY_VISIBILITY("default")
|
||||
bool OnLoad(HsaApiTable* table, uint64_t runtime_version, uint64_t failed_tool_count,
|
||||
const char* const* failed_tool_names);
|
||||
TIMEMORY_VISIBILITY("default") void OnUnload();
|
||||
const char* const* failed_tool_names) TIMEMORY_VISIBILITY("default");
|
||||
void OnUnload() TIMEMORY_VISIBILITY("default");
|
||||
|
||||
bool OnLoad(HsaApiTable* table, uint64_t runtime_version, uint64_t failed_tool_count,
|
||||
const char* const* failed_tool_names)
|
||||
{
|
||||
puts(__FUNCTION__);
|
||||
HOSTTRACE_DEBUG("[%s]\n", __FUNCTION__);
|
||||
tim::consume_parameters(table, runtime_version, failed_tool_count,
|
||||
failed_tool_names);
|
||||
|
||||
@@ -589,8 +579,7 @@ extern "C"
|
||||
// initialize HSA tracing
|
||||
roctracer_set_properties(ACTIVITY_DOMAIN_HSA_API, (void*) table);
|
||||
|
||||
fprintf(stdout, " HSA-trace(");
|
||||
fflush(stdout);
|
||||
HOSTTRACE_DEBUG(" HSA-trace(");
|
||||
if(!hsa_api_vec.empty())
|
||||
{
|
||||
for(unsigned i = 0; i < hsa_api_vec.size(); ++i)
|
||||
@@ -601,7 +590,8 @@ extern "C"
|
||||
&cid, nullptr));
|
||||
ROCTRACER_CALL(roctracer_enable_op_callback(
|
||||
ACTIVITY_DOMAIN_HSA_API, cid, hsa_api_callback, nullptr));
|
||||
printf(" %s", api);
|
||||
|
||||
HOSTTRACE_DEBUG(" %s", api);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -609,7 +599,7 @@ extern "C"
|
||||
ROCTRACER_CALL(roctracer_enable_domain_callback(
|
||||
ACTIVITY_DOMAIN_HSA_API, hsa_api_callback, nullptr));
|
||||
}
|
||||
printf(")\n");
|
||||
HOSTTRACE_DEBUG("\n");
|
||||
}
|
||||
|
||||
bool trace_hsa_activity =
|
||||
@@ -625,8 +615,7 @@ extern "C"
|
||||
};
|
||||
roctracer_set_properties(ACTIVITY_DOMAIN_HSA_OPS, &ops_properties);
|
||||
|
||||
fprintf(stdout, " HSA-activity-trace()\n");
|
||||
fflush(stdout);
|
||||
HOSTTRACE_DEBUG(" HSA-activity-trace()\n");
|
||||
ROCTRACER_CALL(roctracer_enable_op_activity(ACTIVITY_DOMAIN_HSA_OPS,
|
||||
HSA_OP_ID_COPY));
|
||||
}
|
||||
@@ -639,8 +628,7 @@ extern "C"
|
||||
roctracer_disable_op_activity(ACTIVITY_DOMAIN_HSA_OPS, HSA_OP_ID_COPY));
|
||||
};
|
||||
|
||||
if(comp::roctracer::is_setup())
|
||||
_setup();
|
||||
if(comp::roctracer::is_setup()) _setup();
|
||||
|
||||
comp::roctracer::add_setup("hsa", std::move(_setup));
|
||||
comp::roctracer::add_tear_down("hsa", std::move(_tear_down));
|
||||
@@ -651,7 +639,7 @@ extern "C"
|
||||
// HSA-runtime on-unload method
|
||||
void OnUnload()
|
||||
{
|
||||
puts(__FUNCTION__);
|
||||
HOSTTRACE_DEBUG("[%s]\n", __FUNCTION__);
|
||||
// ONLOAD_TRACE("");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
|
||||
if(NOT DYNINST_API_RT_DIR AND DYNINST_API_RT)
|
||||
get_filename_component(DYNINST_API_RT_DIR "${DYNINST_API_RT}" DIRECTORY)
|
||||
endif()
|
||||
|
||||
if(HOSTTRACE_BUILD_DYNINST)
|
||||
set(DYNINST_API_RT_DIR "${PROJECT_BINARY_DIR}/external/dyninst/dyninstAPI_RT:${PROJECT_BINARY_DIR}/external/dyninst/dyninstAPI")
|
||||
set(DYNINST_API_RT_DIR
|
||||
"${PROJECT_BINARY_DIR}/external/dyninst/dyninstAPI_RT:${PROJECT_BINARY_DIR}/external/dyninst/dyninstAPI"
|
||||
)
|
||||
endif()
|
||||
|
||||
set(_test_environment
|
||||
@@ -14,69 +15,53 @@ set(_test_environment
|
||||
if(TARGET transpose)
|
||||
add_test(
|
||||
NAME transpose-binary-rewrite
|
||||
COMMAND $<TARGET_FILE:hosttrace-exe> -o $<TARGET_FILE_DIR:transpose>/transpose.inst -v 2 -- $<TARGET_FILE:transpose>
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
)
|
||||
COMMAND
|
||||
$<TARGET_FILE:hosttrace-exe> -o $<TARGET_FILE_DIR:transpose>/transpose.inst -v
|
||||
2 -- $<TARGET_FILE:transpose>
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
|
||||
add_test(
|
||||
NAME transpose-binary-rewrite-run
|
||||
COMMAND $<TARGET_FILE_DIR:transpose>/transpose.inst
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
)
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
|
||||
add_test(
|
||||
NAME transpose-runtime-instrument
|
||||
COMMAND $<TARGET_FILE:hosttrace-exe> -v 2 -- $<TARGET_FILE:transpose>
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
)
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
|
||||
set_tests_properties(transpose-binary-rewrite-run PROPERTIES DEPENDS
|
||||
transpose-binary-rewrite)
|
||||
|
||||
set_tests_properties(
|
||||
transpose-binary-rewrite-run
|
||||
PROPERTIES
|
||||
DEPENDS transpose-binary-rewrite
|
||||
)
|
||||
|
||||
set_tests_properties(
|
||||
transpose-binary-rewrite
|
||||
transpose-binary-rewrite-run
|
||||
transpose-runtime-instrument
|
||||
PROPERTIES
|
||||
ENVIRONMENT "${_test_environment}"
|
||||
TIMEOUT 600
|
||||
)
|
||||
transpose-binary-rewrite transpose-binary-rewrite-run transpose-runtime-instrument
|
||||
PROPERTIES ENVIRONMENT "${_test_environment}" TIMEOUT 600)
|
||||
endif()
|
||||
|
||||
if(TARGET parallel-overhead)
|
||||
add_test(
|
||||
NAME parallel-overhead-binary-rewrite
|
||||
COMMAND $<TARGET_FILE:hosttrace-exe> -o $<TARGET_FILE_DIR:parallel-overhead>/parallel-overhead.inst -v 2 -- $<TARGET_FILE:parallel-overhead>
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
)
|
||||
COMMAND
|
||||
$<TARGET_FILE:hosttrace-exe> -o
|
||||
$<TARGET_FILE_DIR:parallel-overhead>/parallel-overhead.inst -v 2 --
|
||||
$<TARGET_FILE:parallel-overhead>
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
|
||||
add_test(
|
||||
NAME parallel-overhead-binary-rewrite-run
|
||||
COMMAND $<TARGET_FILE_DIR:parallel-overhead>/parallel-overhead.inst
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
)
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
|
||||
add_test(
|
||||
NAME parallel-overhead-runtime-instrument
|
||||
COMMAND $<TARGET_FILE:hosttrace-exe> -v 2 -- $<TARGET_FILE:parallel-overhead>
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
)
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
|
||||
set_tests_properties(parallel-overhead-binary-rewrite-run
|
||||
PROPERTIES DEPENDS parallel-overhead-binary-rewrite)
|
||||
|
||||
set_tests_properties(
|
||||
parallel-overhead-binary-rewrite-run
|
||||
PROPERTIES
|
||||
DEPENDS parallel-overhead-binary-rewrite
|
||||
)
|
||||
|
||||
set_tests_properties(
|
||||
parallel-overhead-binary-rewrite
|
||||
parallel-overhead-binary-rewrite-run
|
||||
parallel-overhead-binary-rewrite parallel-overhead-binary-rewrite-run
|
||||
parallel-overhead-runtime-instrument
|
||||
PROPERTIES
|
||||
ENVIRONMENT "${_test_environment}"
|
||||
TIMEOUT 600
|
||||
)
|
||||
PROPERTIES ENVIRONMENT "${_test_environment}" TIMEOUT 600)
|
||||
endif()
|
||||
|
||||
Ссылка в новой задаче
Block a user