diff --git a/projects/rocprofiler-systems/.gitmodules b/projects/rocprofiler-systems/.gitmodules new file mode 100644 index 0000000000..2a1df91aa5 --- /dev/null +++ b/projects/rocprofiler-systems/.gitmodules @@ -0,0 +1,6 @@ +[submodule "external/timemory"] + path = external/timemory + url = https://github.com/NERSC/timemory.git +[submodule "external/perfetto"] + path = external/perfetto + url = https://android.googlesource.com/platform/external/perfetto diff --git a/projects/rocprofiler-systems/CMakeLists.txt b/projects/rocprofiler-systems/CMakeLists.txt index 76d727fd86..deed8cb1ea 100644 --- a/projects/rocprofiler-systems/CMakeLists.txt +++ b/projects/rocprofiler-systems/CMakeLists.txt @@ -11,7 +11,7 @@ endif() project( hosttrace - LANGUAGES CXX + LANGUAGES C CXX VERSION 0.0.1) message(STATUS "[${PROJECT_NAME}] version ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") @@ -41,6 +41,8 @@ hosttrace_activate_clang_tidy() # #------------------------------------------------------------------------------# +option(HOSTTRACE_CUSTOM_DATA_SOURCE "Enable custom data source" OFF) + add_library(hosttrace-library SHARED ${CMAKE_CURRENT_LIST_DIR}/src/library.cpp ${perfetto_DIR}/sdk/perfetto.cc) @@ -51,8 +53,13 @@ target_include_directories(hosttrace-library PRIVATE target_include_directories(hosttrace-library SYSTEM PRIVATE ${perfetto_DIR}/sdk) +target_compile_definitions(hosttrace-library PRIVATE + $,CUSTOM_DATA_SOURCE,>) + target_link_libraries(hosttrace-library PRIVATE hosttrace::hosttrace-threading + $ + $ $,hosttrace::hosttrace-sanitizer,>) set_target_properties(hosttrace-library PROPERTIES @@ -78,6 +85,7 @@ target_include_directories(hosttrace-exe PRIVATE ${CMAKE_CURRENT_LIST_DIR}/include) target_link_libraries(hosttrace-exe PRIVATE + $ hosttrace::hosttrace-dyninst hosttrace::hosttrace-compile-options) @@ -90,35 +98,6 @@ install( DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL) -#------------------------------------------------------------------------------# -# -# clang-format target -# -#------------------------------------------------------------------------------# - -find_program(CLANG_FORMAT_EXE - NAMES - clang-format-12 - clang-format-11 - clang-format-10 - clang-format-9 - clang-format) - -if(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 - ${CLANG_FORMAT_EXE} -i ${sources} ${headers} ${examples} - COMMENT "Running ${CLANG_FORMAT_EXE}...") -else() - message(AUTHOR_WARNING "clang-format could not be found. format build target not available.") -endif() - #------------------------------------------------------------------------------# # # examples diff --git a/projects/rocprofiler-systems/cmake/Compilers.cmake b/projects/rocprofiler-systems/cmake/Compilers.cmake index d1c228888c..bd655efc46 100644 --- a/projects/rocprofiler-systems/cmake/Compilers.cmake +++ b/projects/rocprofiler-systems/cmake/Compilers.cmake @@ -94,12 +94,12 @@ endmacro(set_no_duplicates _VAR) #----------------------------------------------------------------------------------------# # call before running check_{c,cxx}_compiler_flag #----------------------------------------------------------------------------------------# -macro(timemory_begin_flag_check) - if(TIMEMORY_QUIET_CONFIG) +macro(hosttrace_begin_flag_check) + if(HOSTTRACE_QUIET_CONFIG) if(NOT DEFINED CMAKE_REQUIRED_QUIET) set(CMAKE_REQUIRED_QUIET OFF) endif() - timemory_save_variables(FLAG_CHECK + hosttrace_save_variables(FLAG_CHECK VARIABLES CMAKE_REQUIRED_QUIET) set(CMAKE_REQUIRED_QUIET ON) endif() @@ -108,9 +108,9 @@ endmacro() #----------------------------------------------------------------------------------------# # call after running check_{c,cxx}_compiler_flag #----------------------------------------------------------------------------------------# -macro(timemory_end_flag_check) - if(TIMEMORY_QUIET_CONFIG) - timemory_restore_variables(FLAG_CHECK +macro(hosttrace_end_flag_check) + if(HOSTTRACE_QUIET_CONFIG) + hosttrace_restore_variables(FLAG_CHECK VARIABLES CMAKE_REQUIRED_QUIET) endif() endmacro() @@ -127,7 +127,7 @@ endmacro() #----------------------------------------------------------------------------------------# macro(ADD_TARGET_C_FLAG _TARG) string(REPLACE "-" "_" _MAKE_TARG "${_TARG}") - list(APPEND TIMEMORY_MAKE_TARGETS ${_MAKE_TARG}) + list(APPEND HOSTTRACE_MAKE_TARGETS ${_MAKE_TARG}) target_compile_options(${_TARG} INTERFACE $<$:${ARGN}>) list(APPEND ${_MAKE_TARG}_C_FLAGS ${ARGN}) @@ -163,7 +163,7 @@ endmacro() #----------------------------------------------------------------------------------------# macro(ADD_C_FLAG_IF_AVAIL FLAG) set(_ENABLE ON) - if(DEFINED TIMEMORY_BUILD_C AND NOT TIMEMORY_BUILD_C) + if(DEFINED HOSTTRACE_BUILD_C AND NOT HOSTTRACE_BUILD_C) set(_ENABLE OFF) endif() set(_TARG ) @@ -178,17 +178,17 @@ macro(ADD_C_FLAG_IF_AVAIL FLAG) string(REPLACE "-" "_" FLAG_NAME "${FLAG_NAME}") string(REPLACE " " "_" FLAG_NAME "${FLAG_NAME}") string(REPLACE "=" "_" FLAG_NAME "${FLAG_NAME}") - if(NOT TIMEMORY_BUILD_C) + if(NOT HOSTTRACE_BUILD_C) set(${FLAG_NAME} ON) else() - timemory_begin_flag_check() + hosttrace_begin_flag_check() check_c_compiler_flag("-Werror" c_werror) if(c_werror) check_c_compiler_flag("${FLAG} -Werror" ${FLAG_NAME}) else() check_c_compiler_flag("${FLAG}" ${FLAG_NAME}) endif() - timemory_end_flag_check() + hosttrace_end_flag_check() if(${FLAG_NAME}) if("${_LTARG}" STREQUAL "") list(APPEND ${PROJECT_NAME}_C_FLAGS "${FLAG}") @@ -228,7 +228,7 @@ endmacro() #----------------------------------------------------------------------------------------# macro(ADD_TARGET_CXX_FLAG _TARG) string(REPLACE "-" "_" _MAKE_TARG "${_TARG}") - list(APPEND TIMEMORY_MAKE_TARGETS ${_MAKE_TARG}) + list(APPEND HOSTTRACE_MAKE_TARGETS ${_MAKE_TARG}) target_compile_options(${_TARG} INTERFACE $<$:${ARGN}>) list(APPEND ${_MAKE_TARG}_CXX_FLAGS ${ARGN}) @@ -284,14 +284,14 @@ macro(ADD_CXX_FLAG_IF_AVAIL FLAG) string(REPLACE " " "_" FLAG_NAME "${FLAG_NAME}") string(REPLACE "=" "_" FLAG_NAME "${FLAG_NAME}") string(REPLACE "/" "_" FLAG_NAME "${FLAG_NAME}") - timemory_begin_flag_check() + hosttrace_begin_flag_check() check_cxx_compiler_flag("-Werror" cxx_werror) if(cxx_werror) check_cxx_compiler_flag("${FLAG} -Werror" ${FLAG_NAME}) else() check_cxx_compiler_flag("${FLAG}" ${FLAG_NAME}) endif() - timemory_end_flag_check() + hosttrace_end_flag_check() if(${FLAG_NAME}) if("${_LTARG}" STREQUAL "") list(APPEND ${PROJECT_NAME}_CXX_FLAGS "${FLAG}") @@ -371,7 +371,7 @@ endmacro() #----------------------------------------------------------------------------------------# # check flag #----------------------------------------------------------------------------------------# -function(TIMEMORY_TARGET_FLAG _TARG_TARGET) +function(HOSTTRACE_TARGET_FLAG _TARG_TARGET) cmake_parse_arguments(_TARG "IF_AVAIL" "MODE" "FLAGS;LANGUAGES" ${ARGN}) if(NOT _TARG_MODE) @@ -399,14 +399,14 @@ function(TIMEMORY_TARGET_FLAG _TARG_TARGET) string(REPLACE "-" "_" FLAG_NAME "${FLAG_NAME}") string(REPLACE " " "_" FLAG_NAME "${FLAG_NAME}") string(REPLACE "=" "_" FLAG_NAME "${FLAG_NAME}") - timemory_begin_flag_check() + hosttrace_begin_flag_check() check_c_compiler_flag("-Werror" c_werror) if(c_werror) check_c_compiler_flag("${FLAG} -Werror" ${FLAG_NAME}) else() check_c_compiler_flag("${FLAG}" ${FLAG_NAME}) endif() - timemory_end_flag_check() + hosttrace_end_flag_check() if(${FLAG_NAME}) target_compile_options(${_TARG_TARGET} ${_TARG_MODE} $<$:${_FLAG}>) @@ -417,14 +417,14 @@ function(TIMEMORY_TARGET_FLAG _TARG_TARGET) string(REPLACE "-" "_" FLAG_NAME "${FLAG_NAME}") string(REPLACE " " "_" FLAG_NAME "${FLAG_NAME}") string(REPLACE "=" "_" FLAG_NAME "${FLAG_NAME}") - timemory_begin_flag_check() + hosttrace_begin_flag_check() check_cxx_compiler_flag("-Werror" cxx_werror) if(cxx_werror) check_cxx_compiler_flag("${FLAG} -Werror" ${FLAG_NAME}) else() check_cxx_compiler_flag("${FLAG}" ${FLAG_NAME}) endif() - timemory_end_flag_check() + hosttrace_end_flag_check() if(${FLAG_NAME}) target_compile_options(${_TARG_TARGET} ${_TARG_MODE} $<$:${_FLAG}>) @@ -447,7 +447,7 @@ endfunction() #----------------------------------------------------------------------------------------# macro(ADD_TARGET_CUDA_FLAG _TARG) string(REPLACE "-" "_" _MAKE_TARG "${_TARG}") - list(APPEND TIMEMORY_MAKE_TARGETS ${_MAKE_TARG}) + list(APPEND HOSTTRACE_MAKE_TARGETS ${_MAKE_TARG}) target_compile_options(${_TARG} INTERFACE $<$:${ARGN}>) list(APPEND ${_MAKE_TARG}_CUDA_FLAGS ${ARGN}) @@ -476,7 +476,7 @@ endfunction() #----------------------------------------------------------------------------------------# # add compiler definition #----------------------------------------------------------------------------------------# -function(TIMEMORY_TARGET_COMPILE_DEFINITIONS _TARG _VIS) +function(HOSTTRACE_TARGET_COMPILE_DEFINITIONS _TARG _VIS) foreach(_DEF ${ARGN}) target_compile_definitions(${_TARG} ${_VIS} $<$:${_DEF}>) diff --git a/projects/rocprofiler-systems/cmake/Packages.cmake b/projects/rocprofiler-systems/cmake/Packages.cmake index 0a211e9e15..b4b9e0f2cb 100644 --- a/projects/rocprofiler-systems/cmake/Packages.cmake +++ b/projects/rocprofiler-systems/cmake/Packages.cmake @@ -121,12 +121,13 @@ endif() # #----------------------------------------------------------------------------------------# -set(perfetto_DIR ${PROJECT_BINARY_DIR}/stuff/hosttrace-dyninst/perfetto) -if(NOT EXISTS "${perfetto_DIR}/.git") - find_package(Git REQUIRED) - execute_process(COMMAND - ${GIT_EXECUTABLE} clone -b v17.0 https://android.googlesource.com/platform/external/perfetto/ ${perfetto_DIR}) -endif() +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) #----------------------------------------------------------------------------------------# # @@ -157,3 +158,57 @@ macro(HOSTTRACE_ACTIVATE_CLANG_TIDY) endif() endif() endmacro() + +#------------------------------------------------------------------------------# +# +# clang-format target +# +#------------------------------------------------------------------------------# + +find_program(CLANG_FORMAT_EXE + NAMES + clang-format-12 + clang-format-11 + clang-format-10 + clang-format-9 + clang-format) + +if(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 + ${CLANG_FORMAT_EXE} -i ${sources} ${headers} ${examples} + COMMENT "Running ${CLANG_FORMAT_EXE}...") +else() + message(AUTHOR_WARNING "clang-format could not be found. format build target not available.") +endif() + +#----------------------------------------------------------------------------------------# +# 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_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") +# timemory feature build settings +set(TIMEMORY_BUILD_GOTCHA ON CACHE BOOL "Enable building GOTCHA library from submodule") + +checkout_git_submodule( + RELATIVE_PATH external/timemory + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + REPO_URL https://github.com/NERSC/timemory.git + REPO_BRANCH develop) + +add_subdirectory(external/timemory) diff --git a/projects/rocprofiler-systems/examples/transpose/CMakeLists.txt b/projects/rocprofiler-systems/examples/transpose/CMakeLists.txt index a48c93fffa..7346985adb 100644 --- a/projects/rocprofiler-systems/examples/transpose/CMakeLists.txt +++ b/projects/rocprofiler-systems/examples/transpose/CMakeLists.txt @@ -20,6 +20,7 @@ endif() string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE) set(transpose_CXX_FLAGS "-W -Wall ${CMAKE_CXX_FLAGS_${BUILD_TYPE}} ${CMAKE_CXX_FLAGS}") +set(transpose_LINK_FLAGS "") if(CMAKE_CXX_COMPILER_IS_CLANG AND TARGET hosttrace::hosttrace-compile-options) set(transpose_CXX_FLAGS "${transpose_CXX_FLAGS} ${hosttrace_CXX_FLAGS}") @@ -27,6 +28,40 @@ if(CMAKE_CXX_COMPILER_IS_CLANG AND TARGET hosttrace::hosttrace-compile-options) set(transpose_CXX_FLAGS "${transpose_CXX_FLAGS} ${COMPILE_OPTS}") endif() +option(TRANSPOSE_USE_MPI "Enable MPI support in transpose exe" ${TIMEMORY_USE_MPI}) + +if(TRANSPOSE_USE_MPI) + find_package(MPI REQUIRED) +endif() + +if(TARGET MPI::MPI_C) + set(transpose_CXX_FLAGS "${transpose_CXX_FLAGS} -DUSE_MPI") + get_target_property(COMPILE_OPTS MPI::MPI_C INTERFACE_COMPILE_OPTIONS) + foreach(_COPT ${COMPILE_OPTS}) + if(NOT "${_COPT}" MATCHES "COMPILE_LANG") + set(transpose_CXX_FLAGS "${transpose_CXX_FLAGS} ${_COPT}") + endif() + endforeach() + get_target_property(INCLUDE_DIRS MPI::MPI_C INTERFACE_INCLUDE_DIRECTORIES) + foreach(_IDIR ${INCLUDE_DIRS}) + set(transpose_CXX_FLAGS "${transpose_CXX_FLAGS} -I${_IDIR}") + get_filename_component(_LIBDIR "${_IDIR}" DIRECTORY) + foreach(_LDIR lib lib64) + set(_LIBDIR_SAVE "${_LIBDIR}") + if(NOT EXISTS "${_LIBDIR}/${_LDIR}") + get_filename_component(_LIBDIR "${_LIBDIR}" DIRECTORY) + endif() + if(EXISTS "${_LIBDIR}/${_LDIR}") + set(transpose_LINK_FLAGS "${transpose_LINK_FLAGS} -L${_LIBDIR}/${_LDIR} -lmpi") + endif() + set(_LIBDIR "${_LIBDIR_SAVE}") + endforeach() + endforeach() + if(MPI_C_LINK_FLAGS) + set(transpose_LINK_FLAGS "${transpose_LINK_FLAGS} ${MPI_C_LINK_FLAGS}") + endif() +endif() + # remove generator expressions string(REPLACE "$<" "" transpose_CXX_FLAGS "${transpose_CXX_FLAGS}") string(REPLACE ">:" ":" transpose_CXX_FLAGS "${transpose_CXX_FLAGS}") diff --git a/projects/rocprofiler-systems/examples/transpose/Makefile b/projects/rocprofiler-systems/examples/transpose/Makefile index 3c0011ae6b..f5c2277a0e 100644 --- a/projects/rocprofiler-systems/examples/transpose/Makefile +++ b/projects/rocprofiler-systems/examples/transpose/Makefile @@ -1,11 +1,13 @@ CXXFLAGS += -std=c++17 -O3 -Wno-unused-result -g +LINK_FLAGS := + all: transpose debug: CXXFLAGS += -ggdb -g debug: transpose transpose: transpose.cpp - hipcc ${CXXFLAGS} -o $@ $^ + hipcc ${CXXFLAGS} -o $@ $^ ${LINK_FLAGS} .PHONY: clean diff --git a/projects/rocprofiler-systems/examples/transpose/Makefile.in b/projects/rocprofiler-systems/examples/transpose/Makefile.in index 71339e7db5..d3c62eb59e 100644 --- a/projects/rocprofiler-systems/examples/transpose/Makefile.in +++ b/projects/rocprofiler-systems/examples/transpose/Makefile.in @@ -1,11 +1,13 @@ CXXFLAGS += -std=c++@CMAKE_CXX_STANDARD@ @transpose_CXX_FLAGS@ +LINKFLAGS := @transpose_LINK_FLAGS@ + all: transpose debug: CXXFLAGS += -ggdb -g debug: transpose transpose: transpose.cpp - hipcc ${CXXFLAGS} -o $@ $^ + hipcc ${CXXFLAGS} -o $@ $^ ${LINKFLAGS} .PHONY: clean diff --git a/projects/rocprofiler-systems/examples/transpose/transpose.cpp b/projects/rocprofiler-systems/examples/transpose/transpose.cpp index aea2e28e0f..e7fd3d88df 100644 --- a/projects/rocprofiler-systems/examples/transpose/transpose.cpp +++ b/projects/rocprofiler-systems/examples/transpose/transpose.cpp @@ -148,9 +148,19 @@ run(int argc, char** argv) free(out_matrix); } +#if defined(USE_MPI) +# include +#endif + int main(int argc, char** argv) { +#if defined(USE_MPI) + MPI_Init(&argc, &argv); +#endif run(argc, argv); +#if defined(USE_MPI) + MPI_Finalize(); +#endif return 0; } diff --git a/projects/rocprofiler-systems/external/perfetto b/projects/rocprofiler-systems/external/perfetto new file mode 160000 index 0000000000..dd1f2f378f --- /dev/null +++ b/projects/rocprofiler-systems/external/perfetto @@ -0,0 +1 @@ +Subproject commit dd1f2f378fe2f292f78af922828f93a9f101d373 diff --git a/projects/rocprofiler-systems/external/timemory b/projects/rocprofiler-systems/external/timemory new file mode 160000 index 0000000000..7542f48e65 --- /dev/null +++ b/projects/rocprofiler-systems/external/timemory @@ -0,0 +1 @@ +Subproject commit 7542f48e651d5164d5b85dc9c1f51e8b1bb073d9 diff --git a/projects/rocprofiler-systems/include/timemory/.clang-format b/projects/rocprofiler-systems/include/timemory/.clang-format deleted file mode 100644 index 0af3d6d017..0000000000 --- a/projects/rocprofiler-systems/include/timemory/.clang-format +++ /dev/null @@ -1,65 +0,0 @@ -# requires clang-tidy version 6.0+ ---- -AccessModifierOffset: -4 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: true -AlignConsecutiveDeclarations: true -AlignEscapedNewlinesLeft: false -AlignOperands: true -AlignTrailingComments: true -AllowShortCaseLabelsOnASingleLine: true -AllowShortFunctionsOnASingleLine: All -AllowShortIfStatementsOnASingleLine: false -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 -BreakBeforeBraces: Custom -BreakBeforeInheritanceComma: true -ColumnLimit: 90 -CompactNamespaces: true -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 0 -ContinuationIndentWidth: 4 -FixNamespaceComments: true -IndentCaseLabels: true -IndentPPDirectives: AfterHash -IndentWidth: 4 -KeepEmptyLinesAtTheStartOfBlocks: false -Language: Cpp -PointerAlignment: Left -SortIncludes: true -SortUsingDeclarations: true -SpaceAfterCStyleCast: true -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeParens: false -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 2 -SpacesInAngles: false -SpacesInContainerLiterals: true -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: Cpp11 -TabWidth: 4 -UseTab: Never -... diff --git a/projects/rocprofiler-systems/include/timemory/api.hpp b/projects/rocprofiler-systems/include/timemory/api.hpp deleted file mode 100644 index 3900e5d33e..0000000000 --- a/projects/rocprofiler-systems/include/timemory/api.hpp +++ /dev/null @@ -1,221 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "timemory/api/macros.hpp" -#include "timemory/macros/os.hpp" -#include "timemory/mpl/concepts.hpp" - -#include - -// -// General APIs -// -TIMEMORY_DEFINE_NS_API(project, none) // dummy type -TIMEMORY_DEFINE_NS_API(project, timemory) // provided by timemory API exclusively -TIMEMORY_DEFINE_NS_API(project, python) // provided by timemory python interface -TIMEMORY_DEFINE_NS_API(project, kokkosp) // kokkos profiling API -// -// Device APIs -// -TIMEMORY_DECLARE_NS_API(device, cpu) // collects data on CPU -TIMEMORY_DECLARE_NS_API(device, gpu) // collects data on GPU -// -// Category APIs -// -TIMEMORY_DEFINE_NS_API(category, debugger) // provided debugging utilities -TIMEMORY_DEFINE_NS_API(category, decorator) // decorates external profiler -TIMEMORY_DEFINE_NS_API(category, external) // relies on external package -TIMEMORY_DEFINE_NS_API(category, io) // collects I/O data -TIMEMORY_DEFINE_NS_API(category, logger) // logs generic data or messages -TIMEMORY_DEFINE_NS_API(category, hardware_counter) // collects HW counter data -TIMEMORY_DEFINE_NS_API(category, memory) // collects memory data -TIMEMORY_DEFINE_NS_API(category, resource_usage) // collects resource usage data -TIMEMORY_DEFINE_NS_API(category, timing) // collects timing data -TIMEMORY_DEFINE_NS_API(category, visualization) // related to viz (currently unused) -// -// External Third-party library APIs -// -TIMEMORY_DEFINE_NS_API(tpls, allinea) -TIMEMORY_DEFINE_NS_API(tpls, caliper) -TIMEMORY_DEFINE_NS_API(tpls, craypat) -TIMEMORY_DEFINE_NS_API(tpls, gotcha) -TIMEMORY_DEFINE_NS_API(tpls, gperftools) -TIMEMORY_DEFINE_NS_API(tpls, intel) -TIMEMORY_DEFINE_NS_API(tpls, likwid) -TIMEMORY_DEFINE_NS_API(tpls, nvidia) -TIMEMORY_DEFINE_NS_API(tpls, openmp) -TIMEMORY_DEFINE_NS_API(tpls, rocm) -TIMEMORY_DEFINE_NS_API(tpls, papi) -TIMEMORY_DEFINE_NS_API(tpls, tau) -// -// OS-specific APIs -// -TIMEMORY_DEFINE_NS_API(os, agnostic) -TIMEMORY_DEFINE_NS_API(os, supports_unix) -TIMEMORY_DEFINE_NS_API(os, supports_linux) -TIMEMORY_DEFINE_NS_API(os, supports_darwin) -TIMEMORY_DEFINE_NS_API(os, supports_windows) -// -//--------------------------------------------------------------------------------------// -// -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, project::timemory, true_type) -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, project::python, true_type) -// -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, category::debugger, true_type) -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, category::decorator, true_type) -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, category::external, true_type) -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, category::io, true_type) -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, category::logger, true_type) -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, category::hardware_counter, - true_type) -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, category::resource_usage, - true_type) -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, category::timing, true_type) -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, category::visualization, - true_type) -// -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::allinea, true_type) -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::caliper, true_type) -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::craypat, true_type) -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::gotcha, true_type) -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::gperftools, true_type) -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::intel, true_type) -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::likwid, true_type) -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::nvidia, true_type) -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::openmp, true_type) -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::papi, true_type) -TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::tau, true_type) -// -namespace tim -{ -namespace api -{ -using native_tag = project::timemory; -} -// -namespace trait -{ -// -#if !defined(TIMEMORY_UNIX) -template <> -struct is_available : false_type -{}; -#endif -// -#if !defined(TIMEMORY_LINUX) -template <> -struct is_available : false_type -{}; -#endif -// -#if !defined(TIMEMORY_MACOS) -template <> -struct is_available : false_type -{}; -#endif -// -#if !defined(TIMEMORY_WINDOWS) -template <> -struct is_available : false_type -{}; -#endif -// -} // namespace trait -// -} // namespace tim -// -//--------------------------------------------------------------------------------------// -// -namespace tim -{ -namespace cereal -{ -class JSONInputArchive; -class XMLInputArchive; -class XMLOutputArchive; -} // namespace cereal -} // namespace tim -// -//--------------------------------------------------------------------------------------// -// -// Default pre-processor settings -// -//--------------------------------------------------------------------------------------// -// - -#if !defined(TIMEMORY_DEFAULT_API) -# define TIMEMORY_DEFAULT_API ::tim::project::timemory -#endif - -#if !defined(TIMEMORY_API) -# define TIMEMORY_API TIMEMORY_DEFAULT_API -#endif - -#if defined(DISABLE_TIMEMORY) || defined(TIMEMORY_DISABLED) -# if !defined(TIMEMORY_DEFAULT_AVAILABLE) -# define TIMEMORY_DEFAULT_AVAILABLE false_type -# endif -#else -# if !defined(TIMEMORY_DEFAULT_AVAILABLE) -# define TIMEMORY_DEFAULT_AVAILABLE true_type -# endif -#endif - -#if !defined(TIMEMORY_DEFAULT_STATISTICS_TYPE) -# if defined(TIMEMORY_USE_STATISTICS) -# define TIMEMORY_DEFAULT_STATISTICS_TYPE true_type -# else -# define TIMEMORY_DEFAULT_STATISTICS_TYPE false_type -# endif -#endif - -#if !defined(TIMEMORY_DEFAULT_PLOTTING) -# define TIMEMORY_DEFAULT_PLOTTING false -#endif - -#if !defined(TIMEMORY_DEFAULT_ENABLED) -# define TIMEMORY_DEFAULT_ENABLED true -#endif - -#if !defined(TIMEMORY_PYTHON_PLOTTER) -# define TIMEMORY_PYTHON_PLOTTER "python" -#endif - -#if !defined(TIMEMORY_DEFAULT_INPUT_ARCHIVE) -# define TIMEMORY_DEFAULT_INPUT_ARCHIVE cereal::JSONInputArchive -#endif - -#if !defined(TIMEMORY_DEFAULT_OUTPUT_ARCHIVE) -# define TIMEMORY_DEFAULT_OUTPUT_ARCHIVE ::tim::type_list<> -#endif - -#if !defined(TIMEMORY_INPUT_ARCHIVE) -# define TIMEMORY_INPUT_ARCHIVE TIMEMORY_DEFAULT_INPUT_ARCHIVE -#endif - -#if !defined(TIMEMORY_OUTPUT_ARCHIVE) -# define TIMEMORY_OUTPUT_ARCHIVE TIMEMORY_DEFAULT_OUTPUT_ARCHIVE -#endif diff --git a/projects/rocprofiler-systems/include/timemory/api/macros.hpp b/projects/rocprofiler-systems/include/timemory/api/macros.hpp deleted file mode 100644 index caf6f95c6c..0000000000 --- a/projects/rocprofiler-systems/include/timemory/api/macros.hpp +++ /dev/null @@ -1,76 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "timemory/mpl/concepts.hpp" - -/// \macro TIMEMORY_DECLARE_NS_API(NS, NAME) -/// \brief Declare an API category. APIs are used to designate -/// different project implementations, different external library tools, etc. -/// -#if !defined(TIMEMORY_DECLARE_NS_API) -# define TIMEMORY_DECLARE_NS_API(NS, NAME) \ - namespace tim \ - { \ - namespace NS \ - { \ - struct NAME; \ - } \ - } -#endif - -#if !defined(TIMEMORY_DECLARE_API) -# define TIMEMORY_DECLARE_API(NAME) TIMEMORY_DECLARE_NS_API(api, NAME) -#endif - -// -/// \macro TIMEMORY_DEFINE_NS_API(NS, NAME) -/// \param NS sub-namespace within tim:: -/// \param NAME the name of the API -/// -/// \brief Define an API category within a namespace -/// -#if !defined(TIMEMORY_DEFINE_NS_API) -# define TIMEMORY_DEFINE_NS_API(NS, NAME) \ - namespace tim \ - { \ - namespace NS \ - { \ - struct NAME : public concepts::api \ - {}; \ - } \ - } -#endif - -/// -/// \macro TIMEMORY_DEFINE_API -/// \brief Define an API category. APIs are used to designate -/// different project implementations, different external library tools, etc. -/// Note: this macro inherits from \ref concepts::api instead of specializing -/// is_api<...>, thus allowing specialization from tools downstream -/// -#if !defined(TIMEMORY_DEFINE_API) -# define TIMEMORY_DEFINE_API(NAME) TIMEMORY_DEFINE_NS_API(api, NAME) -#endif diff --git a/projects/rocprofiler-systems/include/timemory/backends/process.hpp b/projects/rocprofiler-systems/include/timemory/backends/process.hpp deleted file mode 100644 index d4fd0ecf75..0000000000 --- a/projects/rocprofiler-systems/include/timemory/backends/process.hpp +++ /dev/null @@ -1,110 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/** \file backends/process.hpp - * \headerfile backends/process.hpp "timemory/backends/process.hpp" - * Defines process backend functions - * - */ - -#pragma once - -#include "timemory/macros/os.hpp" -#include "timemory/utility/macros.hpp" - -#include -#include - -#if defined(TIMEMORY_UNIX) -# include -# include -# if defined(TIMEMORY_MACOS) -# include -# include -# endif -#elif defined(TIMEMORY_WINDOWS) -# if !defined(NOMINMAX) -# define NOMINMAX -# endif -# if !defined(WIN32_LEAN_AND_MEAN) -# define WIN32_LEAN_AND_MEAN -# endif -# include -#endif - -namespace tim -{ -namespace process -{ -// -//--------------------------------------------------------------------------------------// -// -#if defined(TIMEMORY_UNIX) -using id_t = pid_t; -#elif defined(TIMEMORY_WINDOWS) -using id_t = DWORD; -#else -using id_t = int; -#endif -// -//--------------------------------------------------------------------------------------// -// -/// \fn pid_t tim::process::get_id() -/// \brief get the process id of this process -/// -inline id_t -get_id() -{ -#if defined(TIMEMORY_WINDOWS) - static auto instance = GetCurrentProcessId(); -#elif defined(TIMEMORY_UNIX) - static auto instance = getpid(); -#else - static auto instance = 0; -#endif - return instance; -} -// -//--------------------------------------------------------------------------------------// -// -/// \fn pid_t& tim::process::get_target_id() -/// \brief get the target process id of this process (may differ from process::get_id) -/// -inline id_t& -get_target_id() -{ -#if defined(TIMEMORY_WINDOWS) - static auto instance = GetCurrentProcessId(); -#elif defined(TIMEMORY_UNIX) - static auto instance = getpid(); -#else - static auto instance = 0; -#endif - return instance; -} -// -//--------------------------------------------------------------------------------------// -// -} // namespace process -} // namespace tim diff --git a/projects/rocprofiler-systems/include/timemory/compat/macros.h b/projects/rocprofiler-systems/include/timemory/compat/macros.h deleted file mode 100644 index c14a3e2a5f..0000000000 --- a/projects/rocprofiler-systems/include/timemory/compat/macros.h +++ /dev/null @@ -1,289 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#define _TIM_STRINGIZE(X) _TIM_STRINGIZE2(X) -#define _TIM_STRINGIZE2(X) #X -#define _TIM_VAR_NAME_COMBINE(X, Y) X##Y -#define _TIM_VARIABLE(Y) _TIM_VAR_NAME_COMBINE(timemory_variable_, Y) -#define _TIM_SCOPE_DTOR(Y) _TIM_VAR_NAME_COMBINE(timemory_scoped_dtor_, Y) -#define _TIM_TYPEDEF(Y) _TIM_VAR_NAME_COMBINE(timemory_typedef_, Y) -#define _TIM_STORAGE_INIT(Y) _TIM_VAR_NAME_COMBINE(timemory_storage_initializer_, Y) - -#define _TIM_LINESTR _TIM_STRINGIZE(__LINE__) - -#if defined(TIMEMORY_PRETTY_FUNCTION) && !defined(_WINDOWS) -# define _TIM_FUNC __PRETTY_FUNCTION__ -#elif defined(TIMEMORY_PRETTY_FUNCTION) && defined(_WINDOWS) -# define _TIM_FUNC __FUNCSIG__ -#else -# define _TIM_FUNC __FUNCTION__ -#endif - -#if defined(DISABLE_TIMEMORY) || defined(TIMEMORY_DISABLED) -# if !defined(TIMEMORY_SPRINTF) -# define TIMEMORY_SPRINTF(...) -# endif -#else -# if !defined(TIMEMORY_SPRINTF) -# define TIMEMORY_SPRINTF(VAR, LEN, FMT, ...) \ - char VAR[LEN]; \ - snprintf(VAR, LEN, FMT, __VA_ARGS__); -# endif -#endif - -#if !defined(TIMEMORY_CODE) -# if defined(DISABLE_TIMEMORY) || defined(TIMEMORY_DISABLED) -# define TIMEMORY_CODE(...) -# else -# define TIMEMORY_CODE(...) __VA_ARGS__ -# endif -#endif - -//======================================================================================// -// -// Operating System -// -//======================================================================================// - -#if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64) -# if !defined(_WINDOWS) -# define _WINDOWS 1 -# endif -#elif defined(__APPLE__) || defined(__MACH__) -# if !defined(_MACOS) -# define _MACOS 1 -# endif -# if !defined(_UNIX) -# define _UNIX 1 -# endif -#elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__) -# if !defined(_LINUX) -# define _LINUX 1 -# endif -# if !defined(_UNIX) -# define _UNIX 1 -# endif -#elif defined(__unix__) || defined(__unix) || defined(unix) -# if !defined(_UNIX) -# define _UNIX 1 -# endif -#endif - -#if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64) -# if !defined(TIMEMORY_WINDOWS) -# define TIMEMORY_WINDOWS 1 -# endif -#elif defined(__APPLE__) || defined(__MACH__) -# if !defined(TIMEMORY_MACOS) -# define TIMEMORY_MACOS 1 -# endif -# if !defined(TIMEMORY_UNIX) -# define TIMEMORY_UNIX 1 -# endif -#elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__) -# if !defined(TIMEMORY_LINUX) -# define TIMEMORY_LINUX 1 -# endif -# if !defined(TIMEMORY_UNIX) -# define TIMEMORY_UNIX 1 -# endif -#elif defined(__unix__) || defined(__unix) || defined(unix) -# if !defined(TIMEMORY_UNIX) -# define TIMEMORY_UNIX 1 -# endif -#endif - -//======================================================================================// -// -// General attribute -// -//======================================================================================// - -#if !defined(TIMEMORY_ATTRIBUTE) -# if !defined(_MSC_VER) -# define TIMEMORY_ATTRIBUTE(attr) __attribute__((attr)) -# else -# define TIMEMORY_ATTRIBUTE(attr) __declspec(attr) -# endif -#endif - -//======================================================================================// -// -// Windows DLL settings -// -//======================================================================================// - -#if !defined(TIMEMORY_CDLL) -# if defined(_WINDOWS) -# if defined(TIMEMORY_CDLL_EXPORT) -# define TIMEMORY_CDLL __declspec(dllexport) -# elif defined(TIMEMORY_CDLL_IMPORT) -# define TIMEMORY_CDLL __declspec(dllimport) -# else -# define TIMEMORY_CDLL -# endif -# else -# define TIMEMORY_CDLL -# endif -#endif - -#if !defined(TIMEMORY_DLL) -# if defined(_WINDOWS) -# if defined(TIMEMORY_DLL_EXPORT) -# define TIMEMORY_DLL __declspec(dllexport) -# elif defined(TIMEMORY_DLL_IMPORT) -# define TIMEMORY_DLL __declspec(dllimport) -# else -# define TIMEMORY_DLL -# endif -# else -# define TIMEMORY_DLL -# endif -#endif - -//======================================================================================// -// -// Visibility -// -//======================================================================================// - -#if !defined(TIMEMORY_VISIBILITY) -# if !defined(_MSC_VER) -# define TIMEMORY_VISIBILITY(mode) TIMEMORY_ATTRIBUTE(visibility(mode)) -# else -# define TIMEMORY_VISIBILITY(mode) -# endif -#endif - -#if !defined(TIMEMORY_VISIBLE) -# define TIMEMORY_VISIBLE TIMEMORY_VISIBILITY("default") -#endif - -#if !defined(TIMEMORY_HIDDEN) -# define TIMEMORY_HIDDEN TIMEMORY_VISIBILITY("hidden") -#endif - -//======================================================================================// -// -// Instrumentation -// -//======================================================================================// - -#if !defined(_WINDOWS) -# if !defined(TIMEMORY_NEVER_INSTRUMENT) -# if defined(__clang__) -# define TIMEMORY_NEVER_INSTRUMENT \ - TIMEMORY_ATTRIBUTE(no_instrument_function) \ - TIMEMORY_ATTRIBUTE(xray_never_instrument) -# else -# define TIMEMORY_NEVER_INSTRUMENT TIMEMORY_ATTRIBUTE(no_instrument_function) -# endif -# endif -// -# if !defined(TIMEMORY_INSTRUMENT) -# define TIMEMORY_INSTRUMENT TIMEMORY_ATTRIBUTE(xray_always_instrument) -# endif -#else -# if !defined(TIMEMORY_NEVER_INSTRUMENT) -# define TIMEMORY_NEVER_INSTRUMENT -# endif -// -# if !defined(TIMEMORY_INSTRUMENT) -# define TIMEMORY_INSTRUMENT -# endif -#endif - -//======================================================================================// -// -// Symbol override -// -//======================================================================================// - -#if !defined(TIMEMORY_WEAK_PREFIX) -# if !defined(_MSC_VER) -# if defined(__clang__) && defined(__APPLE__) -# define TIMEMORY_WEAK_PREFIX -# else -# define TIMEMORY_WEAK_PREFIX TIMEMORY_ATTRIBUTE(weak) -# endif -# else -# define TIMEMORY_WEAK_PREFIX -# endif -#endif - -#if !defined(TIMEMORY_WEAK_POSTFIX) -# if !defined(_MSC_VER) -# if defined(__clang__) && defined(__APPLE__) -# define TIMEMORY_WEAK_POSTFIX TIMEMORY_ATTRIBUTE(weak_import) -# else -# define TIMEMORY_WEAK_POSTFIX -# endif -# else -# define TIMEMORY_WEAK_POSTFIX -# endif -#endif - -//======================================================================================// -// -// Library Constructor/Destructor -// -//======================================================================================// - -#if !defined(TIMEMORY_CTOR) -# if !defined(_WINDOWS) -# define TIMEMORY_CTOR TIMEMORY_ATTRIBUTE(constructor) -# else -# define TIMEMORY_CTOR -# endif -#endif -// -//--------------------------------------------------------------------------------------// -// -#if !defined(TIMEMORY_DTOR) -# if !defined(_WINDOWS) -# define TIMEMORY_DTOR TIMEMORY_ATTRIBUTE(destructor) -# else -# define TIMEMORY_DTOR -# endif -#endif - -//======================================================================================// -// -// WINDOWS WARNINGS (apply to C code) -// -//======================================================================================// - -// MSVC compiler -#if defined(_MSC_VER) && _MSC_VER > 0 && !defined(TIMEMORY_MSVC_COMPILER) -# define TIMEMORY_MSVC_COMPILER -#endif - -#if defined(TIMEMORY_MSVC_COMPILER) && !defined(TIMEMORY_MSVC_WARNINGS) - -# pragma warning(disable : 4996) // function may be unsafe -# pragma warning(disable : 5105) // macro produce 'defined' has undefined behavior - -#endif diff --git a/projects/rocprofiler-systems/include/timemory/environment.hpp b/projects/rocprofiler-systems/include/timemory/environment.hpp deleted file mode 100644 index 45d2157578..0000000000 --- a/projects/rocprofiler-systems/include/timemory/environment.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "timemory/environment/declaration.hpp" -#include "timemory/environment/macros.hpp" -#include "timemory/environment/types.hpp" - -#if !defined(TIMEMORY_USE_ENVIRONMENT_EXTERN) -# include "timemory/environment/definition.hpp" -#endif diff --git a/projects/rocprofiler-systems/include/timemory/environment/declaration.hpp b/projects/rocprofiler-systems/include/timemory/environment/declaration.hpp deleted file mode 100644 index 11f854e048..0000000000 --- a/projects/rocprofiler-systems/include/timemory/environment/declaration.hpp +++ /dev/null @@ -1,268 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "timemory/environment/macros.hpp" -#include "timemory/environment/types.hpp" -#include "timemory/macros/compiler.hpp" -#include "timemory/macros/os.hpp" -#include "timemory/tpls/cereal/cereal.hpp" -#include "timemory/utility/macros.hpp" -#include "timemory/utility/utility.hpp" - -#include -#include -#include -#include -#include -#include -#include - -namespace tim -{ -// -//--------------------------------------------------------------------------------------// -// -// environment -// -//--------------------------------------------------------------------------------------// -// -class env_settings -{ -public: - using string_t = std::string; - using env_map_t = std::map; - using env_uomap_t = std::map; - using env_pair_t = std::pair; - using iterator = typename env_map_t::iterator; - using const_iterator = typename env_map_t::const_iterator; - -public: - static env_settings* instance(); - -private: - // if passed a global, insert m_env into it's array - env_settings(env_settings* _global = nullptr, int _id = 0); - - // only the zero id deletes - ~env_settings(); - -public: - template - void insert(const std::string& env_id, Tp val); - - env_map_t get() const; - iterator get(const string_t& _entry) { return m_env->find(_entry); } - const_iterator get(const string_t& _entry) const { return m_env->find(_entry); } - iterator begin() { return m_env->begin(); } - iterator end() { return m_env->end(); } - const_iterator begin() const { return m_env->begin(); } - const_iterator end() const { return m_env->end(); } - - void print(std::ostream&) const; - friend std::ostream& operator<<(std::ostream& os, const env_settings& env) - { - env.print(os); - return os; - } - - //----------------------------------------------------------------------------------// - // serialization - // - template - void serialize(Archive& ar, unsigned int); - - template - static void serialize_environment(Archive& ar) - { - if(instance()) - instance()->serialize(ar, TIMEMORY_GET_CLASS_VERSION(tim::env_settings)); - } - -private: - static std::atomic_bool& lock_flag() - { - static std::atomic_bool _instance(false); - return _instance; - } - - void collapse(); - -private: - int m_id = 0; - env_uomap_t* m_env = new env_uomap_t{}; - std::vector m_env_other; -}; -// -//--------------------------------------------------------------------------------------// -// -template -void -env_settings::insert(const std::string& env_id, Tp val) -{ -#if !defined(TIMEMORY_DISABLE_STORE_ENVIRONMENT) - std::stringstream ss; - ss << std::boolalpha << val; - - auto_lock_t lk(type_mutex(), std::defer_lock); - if(lock_flag().load() && !lk.owns_lock()) - lk.lock(); - - if(m_env && - (m_env->find(env_id) == m_env->end() || m_env->find(env_id)->second != ss.str())) - (*m_env)[env_id] = ss.str(); -#else - consume_parameters(env_id, val); -#endif -} -// -//--------------------------------------------------------------------------------------// -// -template -void -env_settings::serialize(Archive& ar, const unsigned int) -{ - auto _tmp = env_uomap_t{}; - if(!m_env) - m_env = &_tmp; - - collapse(); - - auto_lock_t lk(type_mutex(), std::defer_lock); - lock_flag().store(true); - - if(!lk.owns_lock()) - lk.lock(); - - ar(cereal::make_nvp("environment", *m_env)); - - if(m_env == &_tmp) - m_env = nullptr; - - lock_flag().store(false); -} -// -//--------------------------------------------------------------------------------------// -// -template -Tp -get_env(const std::string& env_id, Tp _default, bool _store) -{ - if(env_id.empty()) - return _default; - - auto* _env_settings = env_settings::instance(); - char* env_var = std::getenv(env_id.c_str()); - if(env_var) - { - std::string str_var = std::string(env_var); - std::stringstream iss{ str_var }; - auto var = Tp{}; - iss >> var; - if(_env_settings && _store) - _env_settings->insert(env_id, var); - return var; - } - // record default value - if(_env_settings && _store) - _env_settings->insert(env_id, _default); - - // return default if not specified in environment - return _default; -} -// -//--------------------------------------------------------------------------------------// -// -template -Tp -get_env_choice(const std::string& env_id, Tp _default, std::set _choices) -{ - assert(!_choices.empty()); - auto _choice = get_env(env_id, _default); - - // check that the choice is valid - if(_choices.find(_choice) == _choices.end()) - { - std::ostringstream _msg{}; - _msg << "Error! Invalid value \"" << _choice << "\" for " << env_id - << ". Valid choices are: "; - std::ostringstream _opts{}; - for(const auto& itr : _choices) - _opts << ", \"" << itr << "\""; - _msg << _opts.str().substr(2); - throw std::runtime_error(_msg.str()); - } - - return _choice; -} -// -//--------------------------------------------------------------------------------------// -// -template -Tp -load_env(const std::string& env_id, Tp _default) -{ - if(env_id.empty()) - return _default; - - auto* _env_settings = env_settings::instance(); - if(!_env_settings) - return _default; - - auto itr = _env_settings->get(env_id); - if(itr != _env_settings->end()) - { - std::stringstream iss{ itr->second }; - auto var = Tp{}; - iss >> var; - return var; - } - - // return default if not specified in environment - return _default; -} -// -//--------------------------------------------------------------------------------------// -// -template -void -set_env(const std::string& env_var, const Tp& _val, int override) -{ - std::stringstream ss_val; - ss_val << _val; -#if defined(TIMEMORY_MACOS) || (defined(TIMEMORY_LINUX) && (_POSIX_C_SOURCE >= 200112L)) - setenv(env_var.c_str(), ss_val.str().c_str(), override); -#elif defined(TIMEMORY_WINDOWS) - auto _curr = get_env(env_var, ""); - if(_curr.empty() || override > 0) - _putenv_s(env_var.c_str(), ss_val.str().c_str()); -#else - consume_parameters(env_var, _val, override, ss_val); -#endif -} -// -//--------------------------------------------------------------------------------------// -// -} // namespace tim diff --git a/projects/rocprofiler-systems/include/timemory/environment/definition.hpp b/projects/rocprofiler-systems/include/timemory/environment/definition.hpp deleted file mode 100644 index daa266998e..0000000000 --- a/projects/rocprofiler-systems/include/timemory/environment/definition.hpp +++ /dev/null @@ -1,362 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/** - * \file timemory/environment/definition.hpp - * \brief The definitions for the types in environment - */ - -#pragma once - -#include "timemory/environment/declaration.hpp" -#include "timemory/environment/macros.hpp" -#include "timemory/environment/types.hpp" -#include "timemory/utility/transient_function.hpp" -#include "timemory/utility/utility.hpp" - -#include -#include -#include -#include -#include -#include - -namespace tim -{ -// -//--------------------------------------------------------------------------------------// -// -namespace regex_const = std::regex_constants; -// -//--------------------------------------------------------------------------------------// -// -#if !defined(TIMEMORY_USE_ENVIRONMENT_EXTERN) -// -//--------------------------------------------------------------------------------------// -// -// environment -// -//--------------------------------------------------------------------------------------// -// -// if passed a global, insert m_env into it's array -// -TIMEMORY_ENVIRONMENT_LINKAGE(env_settings::env_settings) -(env_settings* _global, int _id) -: m_id(_id) -, m_env(new env_uomap_t) -{ - if(_global && _id != 0) - { - auto_lock_t lk(type_mutex(), std::defer_lock); - lock_flag().store(true); - if(!lk.owns_lock()) - lk.lock(); - _global->m_env_other.emplace_back(m_env); - lock_flag().store(false); - } -} -// -//--------------------------------------------------------------------------------------// -// -// only the zero id deletes -// -TIMEMORY_ENVIRONMENT_LINKAGE(env_settings::~env_settings()) -{ - if(m_id == 0) - { - delete m_env; - for(auto& itr : m_env_other) - delete itr; - } -} -// -//--------------------------------------------------------------------------------------// -// -TIMEMORY_ENVIRONMENT_LINKAGE(env_settings::env_map_t) -env_settings::get() const -{ - auto_lock_t lk(type_mutex(), std::defer_lock); - lock_flag().store(true); - if(!lk.owns_lock()) - lk.lock(); - - auto _tmp = *m_env; - env_map_t _ret; - for(const auto& itr : _tmp) - _ret[itr.first] = itr.second; - - lock_flag().store(false); - return _ret; -} -// -//--------------------------------------------------------------------------------------// -// -TIMEMORY_ENVIRONMENT_LINKAGE(void) -env_settings::print(std::ostream& os) const -{ - if(m_id == 0) - const_cast(*this).collapse(); - - auto _data = get(); - - size_t _w = 35; - for(const auto& itr : _data) - _w = std::max(itr.first.length(), _w); - - std::stringstream filler; - filler.fill('-'); - filler << '#'; - filler << std::setw(88) << ""; - filler << '#'; - - std::stringstream ss; - ss << filler.str() << '\n'; - ss << "# Environment settings:\n"; - for(const auto& itr : _data) - { - ss << "# " << std::setw(_w) << std::right << itr.first << "\t = \t" << std::left - << itr.second << '\n'; - } - ss << filler.str(); - os << ss.str() << '\n'; -} -// -//--------------------------------------------------------------------------------------// -// -// NOLINTNEXTLINE -TIMEMORY_ENVIRONMENT_LINKAGE(void) -env_settings::collapse() -{ - if(m_id != 0) - return; - - auto_lock_t lk(type_mutex(), std::defer_lock); - if(!lk.owns_lock()) - lk.lock(); - - lock_flag().store(true); - - // insert all the other maps into this map - for(size_t i = 0; i < m_env_other.size(); ++i) - { - // get the map instance - auto* itr = m_env_other[i]; - if(itr) - { - // loop over entries - for(const auto& mitr : *m_env_other[i]) - { - auto key = mitr.first; - if(m_env->find(key) != m_env->end()) - { - // if the key already exists and if the entries differ, - // create a new unique entry for the index - if(m_env->find(key)->second != mitr.second) - { - key += string_t("[@") + std::to_string(i + 1) + string_t("]"); - (*m_env)[key] = mitr.second; - } - } - else - { - // if a new entry, insert without unique tag to avoid duplication - // when thread count is very high - (*m_env)[key] = mitr.second; - } - } - } - } - lock_flag().store(false); -} -// -//--------------------------------------------------------------------------------------// -// -// specialization for string since the above will have issues if string includes spaces -// -template <> -TIMEMORY_ENVIRONMENT_LINKAGE(std::string) -get_env(const std::string& env_id, std::string _default, bool _store) -{ - if(env_id.empty()) - return _default; - - auto* _env_settings = env_settings::instance(); - char* env_var = std::getenv(env_id.c_str()); - if(env_var) - { - std::stringstream ss; - ss << env_var; - if(_env_settings && _store) - _env_settings->insert(env_id, ss.str()); - return ss.str(); - } - // record default value - if(_env_settings && _store) - _env_settings->insert(env_id, _default); - - // return default if not specified in environment - return _default; -} -// -//--------------------------------------------------------------------------------------// -// -// overload for boolean -// -template <> -TIMEMORY_ENVIRONMENT_LINKAGE(bool) -get_env(const std::string& env_id, bool _default, bool _store) -{ - if(env_id.empty()) - return _default; - - auto* _env_settings = env_settings::instance(); - char* env_var = std::getenv(env_id.c_str()); - if(env_var) - { - std::string var = std::string(env_var); - bool val = true; - if(var.find_first_not_of("0123456789") == std::string::npos) - { - val = (bool) atoi(var.c_str()); - } - else - { - for(auto& itr : var) - itr = tolower(itr); - for(const auto& itr : { "off", "false", "no", "n", "f", "0" }) - { - if(var == itr) - { - if(_env_settings && _store) - _env_settings->insert(env_id, false); - return false; - } - } - } - if(_env_settings && _store) - _env_settings->insert(env_id, val); - return val; - } - // record default value - if(_env_settings && _store) - _env_settings->insert(env_id, _default); - - // return default if not specified in environment - return _default; -} -// -//--------------------------------------------------------------------------------------// -// -// specialization for string since the above will have issues if string includes spaces -// -template <> -TIMEMORY_ENVIRONMENT_LINKAGE(std::string) -load_env(const std::string& env_id, std::string _default) -{ - if(env_id.empty()) - return _default; - - auto* _env_settings = env_settings::instance(); - auto itr = _env_settings->get(env_id); - if(itr != _env_settings->end()) - return itr->second; - - // return default if not specified in environment - return _default; -} -// -//--------------------------------------------------------------------------------------// -// -// overload for boolean -// -template <> -TIMEMORY_ENVIRONMENT_LINKAGE(bool) -load_env(const std::string& env_id, bool _default) -{ - if(env_id.empty()) - return _default; - - auto* _env_settings = env_settings::instance(); - auto itr = _env_settings->get(env_id); - if(itr != _env_settings->end()) - { - auto val = itr->second; - const auto regex_constants = regex_const::egrep | regex_const::icase; - const std::string pattern = "^(off|false|no|n|f|0)$"; - bool _match = false; - try - { - _match = std::regex_match(val, std::regex(pattern, regex_constants)); - } catch(std::bad_cast&) - { - for(auto& vitr : val) - vitr = tolower(vitr); - for(const auto& vitr : { "off", "false", "no", "n", "f", "0" }) - { - if(val == vitr) - { - _match = true; - break; - } - } - } - return (_match) ? false : true; - } - - // return default if not specified in environment - return _default; -} -// -//--------------------------------------------------------------------------------------// -// -TIMEMORY_ENVIRONMENT_LINKAGE(void) -print_env(std::ostream& os) { os << (*env_settings::instance()); } -// -//--------------------------------------------------------------------------------------// -// -TIMEMORY_ENVIRONMENT_LINKAGE(tim::env_settings*) -env_settings::instance() -{ - static std::atomic _count{ 0 }; - static env_settings _instance{}; - static thread_local int _id = _count++; - static thread_local env_settings* _local = - (_id == 0) ? (&_instance) : new env_settings{ &_instance, _id }; - static thread_local auto _ldtor = scope::destructor{ []() { - if(_local == &_instance || _id == 0) - return; - delete _local; - _local = nullptr; - } }; - return _local; - (void) _ldtor; -} -// -//--------------------------------------------------------------------------------------// -// -#endif // !defined(TIMEMORY_USE_ENVIRONMENT_EXTERN) -// -//--------------------------------------------------------------------------------------// -// -} // namespace tim diff --git a/projects/rocprofiler-systems/include/timemory/environment/macros.hpp b/projects/rocprofiler-systems/include/timemory/environment/macros.hpp deleted file mode 100644 index 1c3cbe99f5..0000000000 --- a/projects/rocprofiler-systems/include/timemory/environment/macros.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "timemory/utility/macros.hpp" - -#if defined(TIMEMORY_CORE_SOURCE) -# define TIMEMORY_ENVIRONMENT_SOURCE -#elif defined(TIMEMORY_USE_CORE_EXTERN) -# define TIMEMORY_USE_ENVIRONMENT_EXTERN -#endif -// -#if defined(TIMEMORY_USE_EXTERN) && !defined(TIMEMORY_USE_ENVIRONMENT_EXTERN) -# define TIMEMORY_USE_ENVIRONMENT_EXTERN -#endif - -#if defined(TIMEMORY_ENVIRONMENT_SOURCE) -# define TIMEMORY_ENVIRONMENT_LINKAGE(...) __VA_ARGS__ -#elif defined(TIMEMORY_USE_ENVIRONMENT_EXTERN) -# define TIMEMORY_ENVIRONMENT_LINKAGE(...) extern __VA_ARGS__ -#else -# define TIMEMORY_ENVIRONMENT_LINKAGE(...) inline __VA_ARGS__ -#endif -// -//--------------------------------------------------------------------------------------// -// -#if !defined(TIMEMORY_ENVIRONMENT_EXTERN_TEMPLATE) -# if defined(TIMEMORY_ENVIRONMENT_SOURCE) -# define TIMEMORY_ENVIRONMENT_EXTERN_TEMPLATE(TYPE) \ - namespace tim \ - { \ - template TYPE get_env(const std::string&, TYPE); \ - template void set_env(const std::string&, const TYPE&, int); \ - } -# elif defined(TIMEMORY_USE_ENVIRONMENT_EXTERN) -# define TIMEMORY_ENVIRONMENT_EXTERN_TEMPLATE(TYPE) \ - namespace tim \ - { \ - extern template TYPE get_env(const std::string&, TYPE); \ - extern template void set_env(const std::string&, const TYPE&, int); \ - } -# endif -#else -# define TIMEMORY_ENVIRONMENT_EXTERN_TEMPLATE(...) -#endif -// -//======================================================================================// diff --git a/projects/rocprofiler-systems/include/timemory/environment/types.hpp b/projects/rocprofiler-systems/include/timemory/environment/types.hpp deleted file mode 100644 index 588b369e3a..0000000000 --- a/projects/rocprofiler-systems/include/timemory/environment/types.hpp +++ /dev/null @@ -1,103 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "timemory/environment/macros.hpp" -#include "timemory/utility/types.hpp" - -#include -#include -#include -#include - -namespace tim -{ -// -//--------------------------------------------------------------------------------------// -// -// environment -// -//--------------------------------------------------------------------------------------// -// -class env_settings; -// -//--------------------------------------------------------------------------------------// -// -template -Tp -get_env(const std::string& env_id, Tp _default = Tp{}, bool _store = true); -// -//--------------------------------------------------------------------------------------// -// -template <> -std::string -get_env(const std::string& env_id, std::string _default, bool _store); -// -//--------------------------------------------------------------------------------------// -// -template <> -bool -get_env(const std::string& env_id, bool _default, bool _store); -// -//--------------------------------------------------------------------------------------// -// -template -Tp -get_env_choice(const std::string& env_id, Tp _default, std::set _choices); -// -//--------------------------------------------------------------------------------------// -// -template -Tp -load_env(const std::string& env_id, Tp _default = Tp{}); -// -//--------------------------------------------------------------------------------------// -// -template <> -std::string -load_env(const std::string& env_id, std::string _default); -// -//--------------------------------------------------------------------------------------// -// -template <> -bool -load_env(const std::string& env_id, bool _default); -// -//--------------------------------------------------------------------------------------// -// -void -print_env(std::ostream& os = std::cout); -// -//--------------------------------------------------------------------------------------// -// -template -void -set_env(const std::string& env_var, const Tp& _val, int override = 0); -// -//--------------------------------------------------------------------------------------// -// -} // namespace tim - -TIMEMORY_SET_CLASS_VERSION(0, tim::env_settings) diff --git a/projects/rocprofiler-systems/include/timemory/general/source_location.hpp b/projects/rocprofiler-systems/include/timemory/general/source_location.hpp deleted file mode 100644 index f8dba4a555..0000000000 --- a/projects/rocprofiler-systems/include/timemory/general/source_location.hpp +++ /dev/null @@ -1,366 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "timemory/general/types.hpp" -#include "timemory/hash/declaration.hpp" -#include "timemory/mpl/apply.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace tim -{ -namespace impl -{ -template -struct source_location_constant_char; - -template <> -struct source_location_constant_char<> -{ - static constexpr bool value = true; -}; - -template <> -struct source_location_constant_char -{ - static constexpr bool value = true; -}; - -template -struct source_location_constant_char -{ - static constexpr bool value = std::is_same::value; -}; - -template -struct source_location_constant_char -{ - static constexpr bool value = source_location_constant_char::value && - source_location_constant_char::value && - source_location_constant_char::value; -}; - -} // namespace impl - -/// \class tim::source_location -/// \brief Provides source location information and variadic joining of source location -/// tags -class source_location -{ -public: - using join_type = mpl::apply; - using result_type = std::tuple; - -private: - template - static constexpr bool is_constant_char() - { - return impl::source_location_constant_char...>::value; - } - -public: - // - // Public types - // - - //==================================================================================// - // - enum class mode : short - { - blank = 0, - basic = 1, - full = 2, - complete = 3 - }; - - //==================================================================================// - // - struct captured - { - public: - const result_type& get() const { return m_result; } - const std::string& get_id() const { return std::get<0>(m_result); } - const hash_value_t& get_hash() const { return std::get<1>(m_result); } - - explicit captured(result_type _result) - : m_result(std::move(_result)) - {} - - TIMEMORY_DEFAULT_OBJECT(captured) - - private: - friend class source_location; - result_type m_result = result_type("", 0); - - template 0), int> = 0> - captured& set(const source_location& obj, ArgsT&&... _args) - { - switch(obj.m_mode) - { - case mode::blank: - { - auto&& _tmp = join_type::join("", std::forward(_args)...); - m_result = result_type(_tmp, add_hash_id(_tmp)); - break; - } - case mode::basic: - case mode::full: - case mode::complete: - { - auto&& _suffix = join_type::join("", std::forward(_args)...); - if(_suffix.empty()) - { - m_result = result_type(obj.m_prefix, add_hash_id(obj.m_prefix)); - } - else - { - auto _tmp = join_type::join('/', obj.m_prefix.c_str(), _suffix); - m_result = result_type(_tmp, add_hash_id(_tmp)); - } - break; - } - } - return *this; - } - - template = 0> - captured& set(const source_location& obj, ArgsT&&... _args) - { - tim::consume_parameters(std::forward(_args)...); - m_result = result_type(obj.m_prefix, add_hash_id(obj.m_prefix)); - return *this; - } - }; - -public: - // - // Static functions - // - - //==================================================================================// - // - template - static captured get_captured_inline(const mode& _mode, const char* _func, int _line, - const char* _fname, ArgsT&&... _args) - { - source_location _loc{ _mode, _func, _line, _fname, - std::forward(_args)... }; - return _loc.get_captured(std::forward(_args)...); - } - -public: - // - // Constructors, destructors, etc. - // - - //----------------------------------------------------------------------------------// - // - template (), int> = 0> - source_location(const mode& _mode, const char* _func, int _line, const char* _fname, - ArgsT&&...) - : m_mode(_mode) - { - switch(m_mode) - { - case mode::blank: break; - case mode::basic: compute_data(_func); break; - case mode::complete: - case mode::full: - compute_data(_func, _line, _fname, m_mode == mode::full); - break; - } - } - - //----------------------------------------------------------------------------------// - // if a const char* is passed, assume it is constant - // - template (), int> = 0> - source_location(const mode& _mode, const char* _func, int _line, const char* _fname, - ArgsT&&... _args) - : m_mode(_mode) - { - auto _arg = join_type::join("", _args...); - switch(m_mode) - { - case mode::blank: - { - // label and hash - auto&& _label = _arg; - auto&& _hash = add_hash_id(_label); - m_captured = captured(result_type{ _label, _hash }); - break; - } - case mode::basic: - { - compute_data(_func); - auto&& _label = _join(_arg.c_str()); - auto&& _hash = add_hash_id(_label); - m_captured = captured(result_type{ _label, _hash }); - break; - } - case mode::full: - case mode::complete: - { - compute_data(_func, _line, _fname, m_mode == mode::full); - // label and hash - auto&& _label = _join(_arg.c_str()); - auto&& _hash = add_hash_id(_label); - m_captured = captured(result_type{ _label, _hash }); - break; - } - } - } - - //----------------------------------------------------------------------------------// - // - source_location() = delete; - ~source_location() = default; - source_location(const source_location&) = delete; - source_location(source_location&&) = default; - source_location& operator=(const source_location&) = delete; - source_location& operator=(source_location&&) = default; - -protected: - //----------------------------------------------------------------------------------// - // - void compute_data(const char* _func) { m_prefix = _func; } - - //----------------------------------------------------------------------------------// - // - void compute_data(const char* _func, int _line, const char* _fname, bool shorten) - { -#if defined(TIMEMORY_WINDOWS) - static const char delim = '\\'; -#else - static const char delim = '/'; -#endif - std::string _filename(_fname); - if(shorten) - { - if(_filename.find(delim) != std::string::npos) - _filename = _filename.substr(_filename.find_last_of(delim) + 1); - } - - if(_line < 0) - { - if(_filename.length() > 0) - { - m_prefix = join_type::join("", _func, '@', _filename); - } - else - { - m_prefix = _func; - } - } - else - { - if(_filename.length() > 0) - { - m_prefix = join_type::join("", _func, '@', _filename, ':', _line); - } - else - { - m_prefix = join_type::join("", _func, ':', _line); - } - } - } - -public: - //----------------------------------------------------------------------------------// - // - template < - typename... ArgsT, - enable_if_t<(sizeof...(ArgsT) > 0) && !is_constant_char(), int> = 0> - const captured& get_captured(ArgsT&&... _args) - { - return m_captured.set(*this, std::forward(_args)...); - } - - //----------------------------------------------------------------------------------// - // - const captured& get_captured() const { return m_captured; } - - //----------------------------------------------------------------------------------// - // - template < - typename... ArgsT, - enable_if_t<(sizeof...(ArgsT) > 0) && is_constant_char(), int> = 0> - const captured& get_captured(ArgsT&&...) - { - return m_captured; - } - -private: - mode m_mode; - std::string m_prefix = {}; - captured m_captured; - -private: - std::string _join(const char* _arg) - { - return (strcmp(_arg, "") == 0) ? m_prefix - : join_type::join('/', m_prefix.c_str(), _arg); - } -}; -// -namespace internal -{ -namespace -{ -// anonymous namespace to make sure the static instance is local to each .cpp -// making it static also helps ensure this -template -static inline auto& -get_static_source_location(Args&&... args) -{ - static source_location _instance{ std::forward(args)... }; - consume_parameters(std::forward(args)...); - return _instance; -} -} // namespace -} // namespace internal -// -// static function should be local to each .cpp -// -// LineN should be '__LINE__': this ensures that each use in a source file is unique -// CountN should be '__COUNTER__': this ensures that each source file has unique integer -template -static inline auto& -get_static_source_location(Args&&... args) -{ - return internal::get_static_source_location( - std::forward(args)...); - consume_parameters(std::forward(args)...); -} -// -} // namespace tim diff --git a/projects/rocprofiler-systems/include/timemory/general/types.hpp b/projects/rocprofiler-systems/include/timemory/general/types.hpp deleted file mode 100644 index daa7ed5fc5..0000000000 --- a/projects/rocprofiler-systems/include/timemory/general/types.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -/** \headerfile "timemory/general/types.hpp" - */ - -#pragma once - -#include - -namespace tim -{ -// -//--------------------------------------------------------------------------------------// -// -class source_location; -// -template -static inline auto& -get_static_source_location(Args&&... args); -// -//--------------------------------------------------------------------------------------// -// -} // namespace tim - -#if !defined(TIMEMORY_SOURCE_LOCATION) - -# define _AUTO_LOCATION_COMBINE(X, Y) X##Y -# define _AUTO_LOCATION(Y) _AUTO_LOCATION_COMBINE(timemory_source_location_, Y) - -# define TIMEMORY_SOURCE_LOCATION(MODE, ...) \ - ::tim::source_location(MODE, __FUNCTION__, __LINE__, __FILE__, __VA_ARGS__) - -# define TIMEMORY_CAPTURE_MODE(MODE_TYPE) ::tim::source_location::mode::MODE_TYPE - -# define TIMEMORY_CAPTURE_ARGS(...) _AUTO_LOCATION(__LINE__).get_captured(__VA_ARGS__) - -# define TIMEMORY_INLINE_SOURCE_LOCATION(MODE, ...) \ - ::tim::get_static_source_location<__LINE__, __COUNTER__>( \ - TIMEMORY_CAPTURE_MODE(MODE), __FUNCTION__, __LINE__, __FILE__, __VA_ARGS__) \ - .get_captured(__VA_ARGS__) - -# define _TIM_STATIC_SRC_LOCATION(MODE, ...) \ - static thread_local auto _AUTO_LOCATION(__LINE__) = \ - TIMEMORY_SOURCE_LOCATION(TIMEMORY_CAPTURE_MODE(MODE), __VA_ARGS__) - -#endif diff --git a/projects/rocprofiler-systems/include/timemory/hash/declaration.hpp b/projects/rocprofiler-systems/include/timemory/hash/declaration.hpp deleted file mode 100644 index 85185df13b..0000000000 --- a/projects/rocprofiler-systems/include/timemory/hash/declaration.hpp +++ /dev/null @@ -1,85 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "timemory/hash/macros.hpp" -#include "timemory/hash/types.hpp" -#include "timemory/utility/macros.hpp" - -#include -#include -#include - -namespace tim -{ -// -//--------------------------------------------------------------------------------------// -// -template -PairT& -get_shared_ptr_pair() -{ - static auto _master = std::make_shared(); - static std::atomic _count{ 0 }; - static thread_local auto _inst = - PairT{ _master, PtrT{ (_count++ == 0) ? nullptr : new Tp{} } }; - return _inst; -} -// -//--------------------------------------------------------------------------------------// -// -template -PtrT -get_shared_ptr_pair_instance() -{ - static thread_local auto& _pinst = get_shared_ptr_pair(); - static thread_local auto& _inst = _pinst.second ? _pinst.second : _pinst.first; - return _inst; -} -// -//--------------------------------------------------------------------------------------// -// -template -PtrT -get_shared_ptr_pair_main_instance() -{ - static auto& _pinst = get_shared_ptr_pair(); - static auto _inst = _pinst.first; - return _inst; -} -// -//--------------------------------------------------------------------------------------// -// -template -PtrT -get_shared_ptr_lone_instance() -{ - static auto _instance = std::make_shared(); - return _instance; -} -// -//--------------------------------------------------------------------------------------// -// -} // namespace tim diff --git a/projects/rocprofiler-systems/include/timemory/hash/macros.hpp b/projects/rocprofiler-systems/include/timemory/hash/macros.hpp deleted file mode 100644 index 927c9bb44a..0000000000 --- a/projects/rocprofiler-systems/include/timemory/hash/macros.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#if defined(TIMEMORY_CORE_SOURCE) -# define TIMEMORY_HASH_SOURCE -#elif defined(TIMEMORY_USE_CORE_EXTERN) -# define TIMEMORY_USE_HASH_EXTERN -#endif -// -#if defined(TIMEMORY_USE_EXTERN) && !defined(TIMEMORY_USE_HASH_EXTERN) -# define TIMEMORY_USE_HASH_EXTERN -#endif -// -#if defined(TIMEMORY_HASH_SOURCE) -# define TIMEMORY_HASH_LINKAGE(...) __VA_ARGS__ -#elif defined(TIMEMORY_USE_HASH_EXTERN) -# define TIMEMORY_HASH_LINKAGE(...) extern __VA_ARGS__ -#else -# define TIMEMORY_HASH_LINKAGE(...) inline __VA_ARGS__ -#endif diff --git a/projects/rocprofiler-systems/include/timemory/hash/types.hpp b/projects/rocprofiler-systems/include/timemory/hash/types.hpp deleted file mode 100644 index 2fef34555a..0000000000 --- a/projects/rocprofiler-systems/include/timemory/hash/types.hpp +++ /dev/null @@ -1,290 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "timemory/api.hpp" -#include "timemory/hash/macros.hpp" -#include "timemory/macros/attributes.hpp" -#include "timemory/macros/language.hpp" -#include "timemory/mpl/concepts.hpp" - -#include -#include -#include -#include -#include -#include -#include - -namespace tim -{ -// -//--------------------------------------------------------------------------------------// -// -// GENERAL PURPOSE TLS DATA -// -//--------------------------------------------------------------------------------------// -// -template , - typename PairT = std::pair> -PairT& -get_shared_ptr_pair(); -// -//--------------------------------------------------------------------------------------// -// -template , - typename PairT = std::pair> -PtrT -get_shared_ptr_pair_instance(); -// -//--------------------------------------------------------------------------------------// -// -template , - typename PairT = std::pair> -PtrT -get_shared_ptr_pair_main_instance(); -// -//--------------------------------------------------------------------------------------// -// -template > -PtrT -get_shared_ptr_lone_instance(); -// -//--------------------------------------------------------------------------------------// -// -// HASH ALIASES -// -//--------------------------------------------------------------------------------------// -// -using hash_value_t = size_t; -using hash_map_t = std::unordered_map; -using hash_alias_map_t = std::unordered_map; -using hash_map_ptr_t = std::shared_ptr; -using hash_map_ptr_pair_t = std::pair; -using hash_alias_ptr_t = std::shared_ptr; -using hash_resolver_t = std::function; -using hash_resolver_vec_t = std::vector; -// -//--------------------------------------------------------------------------------------// -// -// HASH DATA STRUCTURES -// -//--------------------------------------------------------------------------------------// -// -hash_map_ptr_t& -get_hash_ids() TIMEMORY_HOT; -// -//--------------------------------------------------------------------------------------// -// -hash_alias_ptr_t& -get_hash_aliases() TIMEMORY_HOT; -// -//--------------------------------------------------------------------------------------// -// -std::shared_ptr& -get_hash_resolvers() TIMEMORY_HOT; -// -//--------------------------------------------------------------------------------------// -// -// STRING -> HASH CONVERSION -// -//--------------------------------------------------------------------------------------// -// -// declarations -// -template >::value, int> = 0> -TIMEMORY_INLINE hash_value_t - get_hash_id(Tp&& _prefix); -// -template >::value, int> = 0> -TIMEMORY_INLINE hash_value_t - get_hash_id(Tp&& _prefix); -// -TIMEMORY_INLINE hash_value_t - get_combined_hash_id(hash_value_t _lhs, hash_value_t _rhs); -// -template >::value, int> = 0> -TIMEMORY_INLINE hash_value_t - get_combined_hash_id(hash_value_t _lhs, Tp&& _rhs); -// -// get hash of a string type -// -template >::value, int>> -hash_value_t -get_hash_id(Tp&& _prefix) -{ - return std::hash{}(std::forward(_prefix)); -} -// -// get hash of a non-string type -// -template >::value, int>> -hash_value_t -get_hash_id(Tp&& _prefix) -{ - return std::hash>{}(std::forward(_prefix)); -} -// -// combine two existing hashes -// -hash_value_t -get_combined_hash_id(hash_value_t _lhs, hash_value_t _rhs) -{ - return (_lhs ^= _rhs + 0x9e3779b9 + (_lhs << 6) + (_lhs >> 2)); -} -// -// compute the hash and combine it with an existing hash -// -template >::value, int>> -hash_value_t -get_combined_hash_id(hash_value_t _lhs, Tp&& _rhs) -{ - return get_combined_hash_id(_lhs, get_hash_id(std::forward(_rhs))); -} -// -//--------------------------------------------------------------------------------------// -// -hash_value_t -get_hash_id(const hash_alias_ptr_t& _hash_alias, hash_value_t _hash_id) TIMEMORY_HOT; -// -//--------------------------------------------------------------------------------------// -// -/// \fn hash_value_t add_hash_id(hash_map_ptr_t&, const string_view_t&) -/// \brief add an string to the given hash-map (if it doesn't already exist) and return -/// the hash -/// -hash_value_t -add_hash_id(hash_map_ptr_t& _hash_map, const string_view_t& _prefix) TIMEMORY_HOT; -// -inline hash_value_t -add_hash_id(hash_map_ptr_t& _hash_map, const string_view_t& _prefix) -{ - hash_value_t _hash_id = get_hash_id(_prefix); - if(_hash_map && _hash_map->find(_hash_id) == _hash_map->end()) - { - (*_hash_map)[_hash_id] = std::string{ _prefix }; - } - return _hash_id; -} -// -//--------------------------------------------------------------------------------------// -// -/// \fn hash_value_t add_hash_id(const string_view_t&) -/// \brief add an string to the default hash-map (if it doesn't already exist) and return -/// the hash -/// -hash_value_t -add_hash_id(const string_view_t& _prefix) TIMEMORY_HOT; -// -inline hash_value_t -add_hash_id(const string_view_t& _prefix) -{ - return add_hash_id(get_hash_ids(), _prefix); -} -// -//--------------------------------------------------------------------------------------// -// -void -add_hash_id(const hash_map_ptr_t& _hash_map, const hash_alias_ptr_t& _hash_alias, - hash_value_t _hash_id, hash_value_t _alias_hash_id) TIMEMORY_HOT; -// -//--------------------------------------------------------------------------------------// -// -void -add_hash_id(hash_value_t _hash_id, hash_value_t _alias_hash_id) TIMEMORY_HOT; -// -//--------------------------------------------------------------------------------------// -// -// HASH -> STRING CONVERSION -// -//--------------------------------------------------------------------------------------// -// -/// \fn string_view_t get_hash_identifier_fast(hash_value_t) -/// \brief this does not check other threads or aliases. Only call this function when -/// you know that the hash exists on the thread and is not an alias -// -string_view_t -get_hash_identifier_fast(hash_value_t _hash) TIMEMORY_HOT; -// -inline string_view_t -get_hash_identifier_fast(hash_value_t _hash) -{ - auto& _hash_ids = get_hash_ids(); - auto itr = _hash_ids->find(_hash); - if(itr != _hash_ids->end()) - return itr->second; - return ""; -} -// -//--------------------------------------------------------------------------------------// -// -std::string -get_hash_identifier(const hash_map_ptr_t& _hash_map, const hash_alias_ptr_t& _hash_alias, - hash_value_t _hash_id); -// -//--------------------------------------------------------------------------------------// -// -std::string -get_hash_identifier(hash_value_t _hash_id); -// -//--------------------------------------------------------------------------------------// -// -template -size_t -add_hash_resolver(FuncT&& _func) -{ - auto _resolvers = get_hash_resolvers(); - if(!_resolvers) - return 0; - _resolvers->emplace_back(std::forward(_func)); - return _resolvers->size(); -} -// -//--------------------------------------------------------------------------------------// -// -// HASH STRING DEMANGLING -// -//--------------------------------------------------------------------------------------// -// -std::string -demangle_hash_identifier(std::string, char bdelim = '[', char edelim = ']'); -// -//--------------------------------------------------------------------------------------// -// -template -auto -get_demangled_hash_identifier(Args&&... _args) -{ - return demangle_hash_identifier(get_hash_identifier(std::forward(_args)...)); -} -// -//--------------------------------------------------------------------------------------// -// -} // namespace tim diff --git a/projects/rocprofiler-systems/include/timemory/macros/attributes.hpp b/projects/rocprofiler-systems/include/timemory/macros/attributes.hpp deleted file mode 100644 index 5b4db304fa..0000000000 --- a/projects/rocprofiler-systems/include/timemory/macros/attributes.hpp +++ /dev/null @@ -1,193 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "timemory/macros/compiler.hpp" -#include "timemory/macros/language.hpp" -#include "timemory/macros/os.hpp" - -//======================================================================================// -// -#if !defined(TIMEMORY_ATTRIBUTE) -# if defined(TIMEMORY_MSVC_COMPILER) -# define TIMEMORY_ATTRIBUTE(...) __declspec(__VA_ARGS__) -# else -# define TIMEMORY_ATTRIBUTE(...) __attribute__((__VA_ARGS__)) -# endif -#endif - -//======================================================================================// -// -#if !defined(TIMEMORY_ALWAYS_INLINE) -# if defined(TIMEMORY_MSVC_COMPILER) -# define TIMEMORY_ALWAYS_INLINE __forceinline -# else -# define TIMEMORY_ALWAYS_INLINE TIMEMORY_ATTRIBUTE(always_inline) inline -# endif -#endif - -#if !defined(TIMEMORY_INLINE) -# define TIMEMORY_INLINE TIMEMORY_ALWAYS_INLINE -#endif - -//======================================================================================// -// -#if !defined(TIMEMORY_NODISCARD) -# if defined(CXX17) -# define TIMEMORY_NODISCARD [[nodiscard]] -# else -# define TIMEMORY_NODISCARD -# endif -#endif - -//======================================================================================// -// -#if !defined(TIMEMORY_FLATTEN) -# if !defined(TIMEMORY_MSVC_COMPILER) -# define TIMEMORY_FLATTEN [[gnu::flatten]] -# else -# define TIMEMORY_FLATTEN -# endif -#endif - -//======================================================================================// -// -#if !defined(TIMEMORY_HOT) -# if !defined(TIMEMORY_MSVC_COMPILER) -# define TIMEMORY_HOT TIMEMORY_ATTRIBUTE(hot) -# else -# define TIMEMORY_HOT -# endif -#endif - -//======================================================================================// -// -#if !defined(TIMEMORY_COLD) -# if !defined(TIMEMORY_MSVC_COMPILER) -# define TIMEMORY_COLD TIMEMORY_ATTRIBUTE(cold) -# else -# define TIMEMORY_COLD -# endif -#endif - -//======================================================================================// -// -#if !defined(TIMEMORY_CONST) -# define TIMEMORY_CONST [[gnu::const]] -#endif - -//======================================================================================// -// -#if !defined(TIMEMORY_DEPRECATED) -# define TIMEMORY_DEPRECATED(...) [[gnu::deprecated(__VA_ARGS__)]] -#endif - -//======================================================================================// -// -#if !defined(TIMEMORY_EXTERN_VISIBLE) -# define TIMEMORY_EXTERN_VISIBLE [[gnu::externally_visible]] -#endif - -//======================================================================================// -// -#if !defined(TIMEMORY_HIDDEN) -# if !defined(TIMEMORY_MSVC_COMPILER) -# define TIMEMORY_HIDDEN TIMEMORY_ATTRIBUTE(visibility("hidden")) -# else -# define TIMEMORY_HIDDEN -# endif -#endif - -//======================================================================================// -// -#if !defined(TIMEMORY_ALIAS) -# define TIMEMORY_ALIAS(...) [[gnu::alias(__VA_ARGS__)]] -#endif - -//======================================================================================// -// -#if !defined(TIMEMORY_NOINLINE) -# define TIMEMORY_NOINLINE TIMEMORY_ATTRIBUTE(noinline) -#endif - -//======================================================================================// -// -#if !defined(TIMEMORY_NOCLONE) -# if defined(TIMEMORY_GNU_COMPILER) -# define TIMEMORY_NOCLONE TIMEMORY_ATTRIBUTE(noclone) -# else -# define TIMEMORY_NOCLONE -# endif -#endif - -//======================================================================================// -// -#if !defined(TIMEMORY_HOT_INLINE) -# define TIMEMORY_HOT_INLINE TIMEMORY_HOT TIMEMORY_INLINE -#endif - -//======================================================================================// -// -#if !defined(TIMEMORY_DATA_ALIGNMENT) -# define TIMEMORY_DATA_ALIGNMENT 8 -#endif - -#if !defined(TIMEMORY_PACKED_ALIGNMENT) -# if defined(_WIN32) // Windows 32- and 64-bit -# define TIMEMORY_PACKED_ALIGNMENT __declspec(align(TIMEMORY_DATA_ALIGNMENT)) -# elif defined(__GNUC__) // GCC -# define TIMEMORY_PACKED_ALIGNMENT \ - __attribute__((__packed__)) __attribute__((aligned(TIMEMORY_DATA_ALIGNMENT))) -# else // all other compilers -# define TIMEMORY_PACKED_ALIGNMENT -# endif -#endif - -//======================================================================================// -// device decorators -// -#if defined(__CUDACC__) || defined(__HIPCC__) -# define TIMEMORY_LAMBDA __host__ __device__ -# define TIMEMORY_HOST_LAMBDA __host__ -# define TIMEMORY_HOST_FUNCTION __host__ -# define TIMEMORY_DEVICE_LAMBDA __device__ -# define TIMEMORY_DEVICE_FUNCTION __device__ -# define TIMEMORY_GLOBAL_FUNCTION __global__ -# define TIMEMORY_HOST_DEVICE_FUNCTION __host__ __device__ -# define TIMEMORY_DEVICE_INLINE __device__ __inline__ -# define TIMEMORY_GLOBAL_INLINE __global__ __inline__ -# define TIMEMORY_HOST_DEVICE_INLINE __host__ __device__ __inline__ -#else -# define TIMEMORY_LAMBDA -# define TIMEMORY_HOST_LAMBDA -# define TIMEMORY_HOST_FUNCTION -# define TIMEMORY_DEVICE_LAMBDA -# define TIMEMORY_DEVICE_FUNCTION -# define TIMEMORY_GLOBAL_FUNCTION -# define TIMEMORY_HOST_DEVICE_FUNCTION -# define TIMEMORY_DEVICE_INLINE inline -# define TIMEMORY_GLOBAL_INLINE inline -# define TIMEMORY_HOST_DEVICE_INLINE inline -#endif diff --git a/projects/rocprofiler-systems/include/timemory/macros/compiler.hpp b/projects/rocprofiler-systems/include/timemory/macros/compiler.hpp deleted file mode 100644 index f101851f3a..0000000000 --- a/projects/rocprofiler-systems/include/timemory/macros/compiler.hpp +++ /dev/null @@ -1,205 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "timemory/macros/os.hpp" - -//======================================================================================// -// -// Compiler -// -//======================================================================================// - -// clang compiler -#if defined(__clang__) && !defined(TIMEMORY_CLANG_COMPILER) -# define TIMEMORY_CLANG_COMPILER 1 -#endif - -//--------------------------------------------------------------------------------------// - -// GNU compiler -#if defined(__GNUC__) && !defined(TIMEMORY_CLANG_COMPILER) && \ - !defined(TIMEMORY_GNU_COMPILER) -# if(__GNUC__ <= 4 && __GNUC_MINOR__ < 9) -# warning "GCC compilers < 4.9 have been known to have compiler errors" -# define TIMEMORY_GNU_COMPILER 1 -# elif(__GNUC__ >= 4 && __GNUC_MINOR__ >= 9) || __GNUC__ >= 5 -# define TIMEMORY_GNU_COMPILER -# endif -#endif - -//--------------------------------------------------------------------------------------// - -// Intel compiler -#if defined(__INTEL_COMPILER) && !defined(TIMEMORY_INTEL_COMPILER) -# define TIMEMORY_INTEL_COMPILER 1 -# if __INTEL_COMPILER < 1500 -# warning "Intel compilers < 1500 have been known to have compiler errors" -# endif -#endif - -//--------------------------------------------------------------------------------------// - -// nvcc compiler -#if defined(__NVCC__) && !defined(TIMEMORY_NVCC_COMPILER) -# define TIMEMORY_NVCC_COMPILER 1 -#endif - -//--------------------------------------------------------------------------------------// - -// cuda compilation mode -#if defined(__CUDACC__) && !defined(TIMEMORY_CUDACC) -# define TIMEMORY_CUDACC 1 -#endif - -//--------------------------------------------------------------------------------------// - -// hcc or hip-clang compiler -#if(defined(__HCC__) || (defined(__clang__) && defined(__HIP__))) && \ - !defined(TIMEMORY_HIP_COMPILER) -# define TIMEMORY_HIP_COMPILER 1 -#endif - -//--------------------------------------------------------------------------------------// - -// hip compilation mode -#if defined(__HIPCC__) && !defined(TIMEMORY_HIPCC) -# define TIMEMORY_HIPCC 1 -#endif - -//--------------------------------------------------------------------------------------// - -// gpu compilation mode (may be host or device code) -#if(defined(__CUDACC__) || defined(__HIPCC__)) && !defined(TIMEMORY_GPUCC) -# define TIMEMORY_GPUCC 1 -#endif - -//--------------------------------------------------------------------------------------// - -// cuda compilation - device code -#if defined(__CUDA_ARCH__) && !defined(TIMEMORY_CUDA_DEVICE_COMPILE) -# define TIMEMORY_CUDA_DEVICE_COMPILE 1 -#endif - -//--------------------------------------------------------------------------------------// - -// hip compilation - device code -#if defined(__HIP_DEVICE_COMPILE__) && !defined(TIMEMORY_HIP_DEVICE_COMPILE) -# define TIMEMORY_HIP_DEVICE_COMPILE 1 -#endif - -//--------------------------------------------------------------------------------------// - -// gpu compiler - device code -#if(defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)) && \ - !defined(TIMEMORY_GPU_DEVICE_COMPILE) -# define TIMEMORY_GPU_DEVICE_COMPILE 1 -#endif - -//--------------------------------------------------------------------------------------// - -// assume openmp target is enabled -// #if defined(TIMEMORY_CUDACC) && defined(_OPENMP) && !defined(TIMEMORY_OPENMP_TARGET) -// # define TIMEMORY_OPENMP_TARGET 1 -// #endif - -//--------------------------------------------------------------------------------------// - -// MSVC compiler -#if defined(_MSC_VER) && _MSC_VER > 0 && !defined(TIMEMORY_MSVC_COMPILER) -# define TIMEMORY_MSVC_COMPILER 1 -#endif - -//======================================================================================// -// -// Demangling -// -//======================================================================================// - -#if(defined(TIMEMORY_GNU_COMPILER) || defined(TIMEMORY_CLANG_COMPILER) || \ - defined(TIMEMORY_INTEL_COMPILER) || defined(TIMEMORY_NVCC_COMPILER) || \ - defined(TIMEMORY_HIP_COMPILER)) && \ - defined(TIMEMORY_UNIX) -# if !defined(TIMEMORY_ENABLE_DEMANGLE) -# define TIMEMORY_ENABLE_DEMANGLE 1 -# endif -#endif - -//======================================================================================// -// -// WINDOWS WARNINGS -// -//======================================================================================// - -#if defined(TIMEMORY_MSVC_COMPILER) && !defined(TIMEMORY_MSVC_WARNINGS) - -# pragma warning(disable : 4003) // not enough actual params -# pragma warning(disable : 4061) // enum in switch of enum not explicitly handled -# pragma warning(disable : 4068) // unknown pragma -# pragma warning(disable : 4127) // conditional expr is constant -# pragma warning(disable : 4129) // unrecognized char escape -# pragma warning(disable : 4146) // unsigned -# pragma warning(disable : 4217) // locally defined symbol -# pragma warning(disable : 4244) // possible loss of data -# pragma warning(disable : 4251) // needs to have dll-interface to be used -# pragma warning(disable : 4242) // possible loss of data (assignment) -# pragma warning(disable : 4244) // conversion from 'double' to 'LONGLONG' -# pragma warning(disable : 4245) // signed/unsigned mismatch (init conversion) -# pragma warning(disable : 4267) // possible loss of data (implicit conversion) -# pragma warning(disable : 4305) // truncation from 'double' to 'float' -# pragma warning(disable : 4355) // this used in base member init list -# pragma warning(disable : 4365) // signed/unsigned mismatch -# pragma warning(disable : 4464) // relative include path contains '..' -# pragma warning(disable : 4522) // multiple assignment operators specified -# pragma warning(disable : 4625) // copy ctor implicitly defined as deleted -# pragma warning(disable : 4626) // copy assign implicitly defined as deleted -# pragma warning(disable : 4661) // no suitable definition for template inst -# pragma warning(disable : 4700) // uninitialized local variable used -# pragma warning(disable : 4710) // function not inlined -# pragma warning(disable : 4711) // function selected for auto inline expansion -# pragma warning(disable : 4786) // ID truncated to '255' char in debug info -# pragma warning(disable : 4820) // bytes padded after data member -# pragma warning(disable : 4834) // discarding return value with 'nodiscard' -# pragma warning(disable : 4996) // function may be unsafe -# pragma warning(disable : 5219) // implicit conversion; possible loss of data -# pragma warning(disable : 5026) // move ctor implicitly defined as deleted -# pragma warning(disable : 5027) // move assign implicitly defined as deleted -# pragma warning(disable : 26495) // Always initialize member variable - -#endif - -//======================================================================================// -// -// DISABLE WINDOWS MIN/MAX macros -// -//======================================================================================// - -#if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64) - -# if !defined(NOMINMAX) -# define NOMINMAX -# endif - -#endif diff --git a/projects/rocprofiler-systems/include/timemory/macros/language.hpp b/projects/rocprofiler-systems/include/timemory/macros/language.hpp deleted file mode 100644 index 74ecb7a752..0000000000 --- a/projects/rocprofiler-systems/include/timemory/macros/language.hpp +++ /dev/null @@ -1,105 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -//======================================================================================// -// -// LANGUAGE -// -//======================================================================================// - -// Define C++20 -#if !defined(CXX20) -# if __cplusplus > 201703L // C++20 -# define CXX20 -# endif -#endif - -//--------------------------------------------------------------------------------------// - -// Define C++17 -#if !defined(CXX17) -# if __cplusplus > 201402L // C++17 -# define CXX17 -# endif -#endif - -//--------------------------------------------------------------------------------------// - -// Define C++14 -#if !defined(CXX14) -# if __cplusplus > 201103L // C++14 -# define CXX14 -# endif -#endif - -//--------------------------------------------------------------------------------------// - -#if !defined(CXX14) -# if !defined(TIMEMORY_WINDOWS) -# error "timemory requires __cplusplus > 201103L (C++14)" -# endif -#endif - -//--------------------------------------------------------------------------------------// - -#if !defined(IF_CONSTEXPR) -# if defined(CXX17) -# define IF_CONSTEXPR(...) if constexpr(__VA_ARGS__) -# else -# define IF_CONSTEXPR(...) if(__VA_ARGS__) -# endif -#endif - -//--------------------------------------------------------------------------------------// - -#if defined(CXX17) -# include -// -# if !defined(TIMEMORY_STRING_VIEW) -# define TIMEMORY_STRING_VIEW 1 -# endif -// -namespace tim -{ -using string_view_t = std::string_view; -} -// -#else -// -# include -// -# if !defined(TIMEMORY_STRING_VIEW) -# define TIMEMORY_STRING_VIEW 0 -# endif -// -namespace tim -{ -using string_view_t = std::string; -} -// -#endif - -//--------------------------------------------------------------------------------------// diff --git a/projects/rocprofiler-systems/include/timemory/macros/os.hpp b/projects/rocprofiler-systems/include/timemory/macros/os.hpp deleted file mode 100644 index 04cd1d997b..0000000000 --- a/projects/rocprofiler-systems/include/timemory/macros/os.hpp +++ /dev/null @@ -1,118 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -//======================================================================================// -// -// Operating System -// -//======================================================================================// - -#if defined(__x86_64__) -# if !defined(TIMEMORY_64BIT) -# define TIMEMORY_64BIT 1 -# endif -#else -# if !defined(TIMEMORY_32BIT) -# define TIMEMORY_32BIT 1 -# endif -#endif - -//--------------------------------------------------------------------------------------// -// timemory prefixed os preprocessor definitions -// -#if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64) -# if !defined(TIMEMORY_WINDOWS) -# define TIMEMORY_WINDOWS 1 -# endif -#elif defined(__APPLE__) || defined(__MACH__) -# if !defined(TIMEMORY_MACOS) -# define TIMEMORY_MACOS 1 -# endif -# if !defined(TIMEMORY_UNIX) -# define TIMEMORY_UNIX 1 -# endif -#elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__) -# if !defined(TIMEMORY_LINUX) -# define TIMEMORY_LINUX 1 -# endif -# if !defined(TIMEMORY_UNIX) -# define TIMEMORY_UNIX 1 -# endif -#elif defined(__unix__) || defined(__unix) || defined(unix) -# if !defined(TIMEMORY_UNIX) -# define TIMEMORY_UNIX 1 -# endif -#endif - -//--------------------------------------------------------------------------------------// -// non-timemory prefixed os preprocessor definitions (deprecated) -// -#if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64) -# if !defined(_WINDOWS) -# define _WINDOWS 1 -# endif -#elif defined(__APPLE__) || defined(__MACH__) -# if !defined(_MACOS) -# define _MACOS 1 -# endif -# if !defined(_UNIX) -# define _UNIX 1 -# endif -#elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__) -# if !defined(_LINUX) -# define _LINUX 1 -# endif -# if !defined(_UNIX) -# define _UNIX 1 -# endif -#elif defined(__unix__) || defined(__unix) || defined(unix) -# if !defined(_UNIX) -# define _UNIX 1 -# endif -#endif - -//--------------------------------------------------------------------------------------// -// this ensures that winnt.h never causes a 64-bit build to fail -// also solves issue with ws2def.h and winsock2.h: -// https://www.zachburlingame.com/2011/05/ -// resolving-redefinition-errors-betwen-ws2def-h-and-winsock-h/ -#if defined(_WINDOWS) -# if !defined(NOMINMAX) -# define NOMINMAX -# endif -# if !defined(WIN32_LEAN_AND_MEAN) -# define WIN32_LEAN_AND_MEAN -# endif -# if !defined(WIN32) -# define WIN32 -# endif -# if defined(TIMEMORY_USE_WINSOCK) -# include -# endif -# include -#endif - -//--------------------------------------------------------------------------------------// diff --git a/projects/rocprofiler-systems/include/timemory/mpl/apply.hpp b/projects/rocprofiler-systems/include/timemory/mpl/apply.hpp deleted file mode 100644 index a0690fe342..0000000000 --- a/projects/rocprofiler-systems/include/timemory/mpl/apply.hpp +++ /dev/null @@ -1,684 +0,0 @@ -// MIT License -// -// Copyright (c) 2020, The Regents of the University of California, -// through Lawrence Berkeley National Laboratory (subject to receipt of any -// required approvals from the U.S. Dept. of Energy). All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to -// deal in the Software without restriction, including without limitation the -// rights to use, copy, modify, merge, publish, distribute, sublicense, and -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. - -#pragma once - -#include "timemory/macros/attributes.hpp" -#include "timemory/mpl/math.hpp" -#include "timemory/mpl/stl.hpp" - -#include -#include -#include -#include -#include -#include -#include - -//======================================================================================// - -namespace tim -{ -// clang-format off -namespace device { struct cpu; struct gpu; } // namespace device -// clang-format on - -namespace internal -{ -template -struct apply -{ - //----------------------------------------------------------------------------------// - // invoke a function with a tuple - // - template - static TIMEMORY_HOT_INLINE Ret invoke(Fn&& __f, Tuple&& __t, index_sequence) - { - return __f(std::get(std::forward(__t))...); - } - - //----------------------------------------------------------------------------------// - // prefix with _sep - // - template ::value, char> = 0> - static TIMEMORY_HOT_INLINE Ret join_tail(std::stringstream& _ss, const SepT& _sep, - Arg&& _arg) - { - _ss << _sep << std::forward(_arg); - return _ss.str(); - } - - //----------------------------------------------------------------------------------// - // prefix with _sep - // - template ::value, char> = 0> - static TIMEMORY_HOT_INLINE Ret join_tail(std::stringstream& _ss, const SepT& _sep, - Arg&& _arg, Args&&... __args) - { - _ss << _sep << std::forward(_arg); - return join_tail(_ss, _sep, std::forward(__args)...); - } - - //----------------------------------------------------------------------------------// - // don't prefix - // - template ::value, char> = 0> - static TIMEMORY_HOT_INLINE Ret join(std::stringstream& _ss, const SepT&, Arg&& _arg) - { - _ss << std::forward(_arg); - return _ss.str(); - } - - //----------------------------------------------------------------------------------// - // don't prefix - // - template ::value, char> = 0, - enable_if_t<(sizeof...(Args) > 0), int> = 0> - static TIMEMORY_HOT_INLINE Ret join(std::stringstream& _ss, const SepT& _sep, - Arg&& _arg, Args&&... __args) - { - _ss << std::forward(_arg); - return join_tail(_ss, _sep, std::forward(__args)...); - } - - //----------------------------------------------------------------------------------// -}; - -//======================================================================================// - -template <> -struct apply -{ - using Ret = void; - - //----------------------------------------------------------------------------------// - - template - struct get_index_of; - - template - struct get_index_of> - { - static constexpr int value = 0; - }; - - template - struct get_index_of> - { - static constexpr int value = 0; - }; - - template - struct get_index_of> - { - static constexpr int value = 0; - }; - - template - struct get_index_of> - { - static constexpr int value = 1 + get_index_of>::value; - }; - - template - struct get_index_of> - { - static_assert(sizeof...(Tail) != 0, "Error! Type not found!"); - }; - - //----------------------------------------------------------------------------------// - // invoke a function with a tuple - // - template - static TIMEMORY_HOT_INLINE Ret invoke(Fn&& __f, Tuple&& __t, index_sequence) - { - __f(std::get(std::forward(__t))...); - } - - //----------------------------------------------------------------------------------// - // temporary construction - // - template - static TIMEMORY_HOT_INLINE void construct(Args&&... _args) - { - Type(std::forward(_args)...); - } - - //----------------------------------------------------------------------------------// - // temporary construction - // - template - static TIMEMORY_HOT_INLINE void construct_tuple(std::tuple&& _args, - index_sequence...) - { - construct(std::get(_args)...); - } - - //----------------------------------------------------------------------------------// - - template