diff --git a/CMake/FindExtrae.cmake b/CMake/FindExtrae.cmake new file mode 100644 index 0000000000000000000000000000000000000000..087e35e963181e77572821dee409dd999092fd5b --- /dev/null +++ b/CMake/FindExtrae.cmake @@ -0,0 +1,492 @@ +#[=======================================================================[.rst: +FindExtrae +--------- + +Find Extrae include dirs and libraries + +Use this module by invoking find_package with the form:: + + find_package(Extrae + [version] [EXACT] # Minimum or EXACT version e.g. 3.7.1 + [REQUIRED] # Fail with error if Extrae is not found + [COMPONENTS ...] # Extrae libraries by their canonical name + ) # e.g. "seqtrace" for "libseqtrace" + + +This module finds headers and requested component libraries. Results are +reported in variables:: + + Extrae_FOUND - True if headers and requested libraries were found + Extrae_INCLUDE_DIRS - Extrae include directories + Extrae_LIBRARY_DIRS - Link directories for Extrae libraries + Extrae_LIBRARIES - Extrae component libraries to be linked + Extrae__FOUND - True if component was found ( is upper-case) + Extrae__LIBRARY - Libraries to link for component (may include + target_link_libraries debug/optimized keywords) + Extrae_VERSION_STRING - Extrae version number in x.y.z format + Extrae_VERSION - Same as Extrae_VERSION_STRING + Extrae_LIB_VERSION - Version string appended to library filenames + Extrae_VERSION_MAJOR - Extrae major version number (X in X.y.z) + Extrae_VERSION_MINOR - Extrae minor version number (Y in x.Y.z) + Extrae_VERSION_PATCH - Extrae subminor version number (Z in x.y.Z) + Extrae_VERSION_COUNT - Amount of version components (3) + +This module reads hints about search locations from variables:: + + EXTRAE_ROOT - Preferred installation prefix + EXTRAE_INCLUDEDIR - Preferred include directory e.g. /include + EXTRAE_LIBRARYDIR - Preferred library directory e.g. /lib + EXTRAE_NO_SYSTEM_PATHS - Set to ON to disable searching in locations not + specified by these hint variables. Default is OFF. + +and saves search results persistently in CMake cache entries:: + + Extrae_INCLUDE_DIR - Directory containing Extrae headers + Extrae_LIBRARY_DIR - Directory containing Extrae libraries + Extrae__LIBRARY - Component library variant + +The following :prop_tgt:`IMPORTED` targets are also defined:: + + Extrae::headers - Target for header-only dependencies + (Extrae include directory) + Extrae:: - Target for specific component dependency + (shared or static library); is lower- + case + +This module first searches for the ``Extrae`` header files using the above +hint variables (excluding ``EXTRAE_LIBRARYDIR``) and saves the result in +``Extrae_INCLUDE_DIR``. Then it searches for requested component libraries +using the above hints (excluding ``EXTRAE_INCLUDEDIR``), "lib" directories +near ``Extrae_INCLUDE_DIR``, and the library name configuration settings below. +It saves the library directories in ``Extrae_LIBRARY_DIR`` and individual +library locations in ``Extrae__LIBRARY``. When one changes settings used by +previous searches in the same build tree (excluding environment variables) this +module discards previous search results affected by the changes and searches +again. + +Extrae libraries come in many variants encoded in their file name. +Users or projects may tell this module which variant to find by +setting variables:: + + Extrae_USE_STATIC_LIBS - Set to ON to force the use of the static + libraries. Default is OFF. + +Other variables one may set to control this module are:: + + Extrae_DEBUG - Set to ON to enable debug output from FindExtrae. + +Example to find Extrae headers only:: + + find_package(Extrae 3.6.1) + if(Extrae_FOUND) + include_directories(${Extrae_INCLUDE_DIRS}) + add_executable(foo foo.cc) + endif() + +Example to find Extrae libraries and use imported targets:: + + find_package(Extrae 3.6.1 REQUIRED COMPONENTS + seqtrace mpitrace pttrace) + add_executable(foo foo.cc) + add_executable(bar bar.cc) + add_executable(baz baz.cc) + target_link_libraries(foo Extrae::seqtrace) + target_link_libraries(bar Extrae::mpitrae) + target_link_libraries(baz Extrae::pttrace) + +Example to find Extrae headers and some *static* libraries:: + + set(Extrae_USE_STATIC_LIBS ON) # only find static libs + find_package(Extrae 3.6.1 COMPONENTS seqtrace mpitrace pttrace ...) + if(Extrae_FOUND) + include_directories(${Extrae_INCLUDE_DIRS}) + add_executable(foo foo.cc) + add_executable(bar bar.cc) + add_executable(baz baz.cc) + target_link_libraries(foo ${Extrae_SEQTRACE_LIBRARY}) + target_link_libraries(bar ${Extrae_MPITRACE_LIBRARY}) + target_link_libraries(baz ${Extrae_PTTRACE_LIBRARY}) + endif() + +#]=======================================================================] + + +#------------------------------------------------------------------------------- +# FindExtrae functions & macros +# + +# +# Print debug text if Extrae_DEBUG is set. +# Call example: +# _Extrae_DEBUG_PRINT("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "debug message") +# +function(_Extrae_DEBUG_PRINT file line text) + if(Extrae_DEBUG) + message(STATUS "[ ${file}:${line} ] ${text}") + endif() +endfunction() + +# +# _Extrae_DEBUG_PRINT_VAR(file line variable_name [ENVIRONMENT] +# [SOURCE "short explanation of origin of var value"]) +# +# ENVIRONMENT - look up environment variable instead of CMake variable +# +# Print variable name and its value if Extrae_DEBUG is set. +# Call example: +# _Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" BOOST_ROOT) +# +function(_Extrae_DEBUG_PRINT_VAR file line name) + if(Extrae_DEBUG) + cmake_parse_arguments(_args "ENVIRONMENT" "SOURCE" "" ${ARGN}) + + unset(source) + if(_args_SOURCE) + set(source " (${_args_SOURCE})") + endif() + + if(_args_ENVIRONMENT) + if(DEFINED ENV{${name}}) + set(value "\"$ENV{${name}}\"") + else() + set(value "") + endif() + set(_name "ENV{${name}}") + else() + if(DEFINED "${name}") + set(value "\"${${name}}\"") + else() + set(value "") + endif() + set(_name "${name}") + endif() + + _Extrae_DEBUG_PRINT("${file}" "${line}" "${_name} = ${value}${source}") + endif() +endfunction() + + +# +# Get component dependencies. +# +# Sets _Extrae_IMPORTED_TARGETS (TRUE if imported targets should be +# defined; FALSE if dependency information is unavailable). +# +# component - the component to check +# _ret - list of library dependencies +# +function(_Extrae_COMPONENT_DEPENDENCIES component _ret) + + set(_Extrae_IMPORTED_TARGETS TRUE) + + if(Extrae_VERSION_STRING) + set(_Extrae_SEQTRACE_DEPENDENCIES seqtrace) + set(_Extrae_MPITRACE_DEPENDENCIES mpitrace) + set(_Extrae_OMPTRACE_DEPENDENCIES omptrace) + set(_Extrae_PTTRACE_DEPENDENCIES pttrace) + set(_Extrae_SMPSSTRACE_DEPENDENCIES smpsstrace) + set(_Extrae_NANOSTRACE_DEPENDENCIES nanostrace) + set(_Extrae_CUDATRACE_DEPENDENCIES cudatrace) + set(_Extrae_OCLTRACE_DEPENDENCIES ocltrace) + set(_Extrae_OMPITRACE_DEPENDENCIES ompitrace) + set(_Extrae_PTMPITRACE_DEPENDENCIES ptmpitrace) + set(_Extrae_SMPSSMPITRACE_DEPENDENCIES smpssmpitrace) + set(_Extrae_NANOSMPITRACE_DEPENDENCIES nanosmpitrace) + set(_Extrae_CUDAMPITRACE_DEPENDENCIES cudampitrace) + set(_Extrae_CUDAOMPITRACE_DEPENDENCIES cudaompitrace) + set(_Extrae_OCLMPITRACE_DEPENDENCIES oclmpitrace) + endif() + + string(TOUPPER ${component} uppercomponent) + set(${_ret} ${_Extrae_${uppercomponent}_DEPENDENCIES} PARENT_SCOPE) + set(_Extrae_IMPORTED_TARGETS ${_Extrae_IMPORTED_TARGETS} PARENT_SCOPE) + + string(REGEX REPLACE ";" " " _extrae_DEPS_STRING "${_Extrae_${uppercomponent}_DEPENDENCIES}") + if (NOT _extrae_DEPS_STRING) + set(_extrae_DEPS_STRING "(none)") + endif() + message(STATUS "Dependencies for Extrae::${component}: ${_extrae_DEPS_STRING}") +endfunction() + +# +# End functions/macros +# +#------------------------------------------------------------------------------- + + + +#------------------------------------------------------------------------------- +# main. +#------------------------------------------------------------------------------- + +_Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "EXTRAE_ROOT") +_Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "EXTRAE_ROOT" ENVIRONMENT) +_Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "EXTRAE_INCLUDEDIR") +_Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "EXTRAE_INCLUDEDIR" ENVIRONMENT) +_Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "EXTRAE_LIBRARYDIR") +_Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "EXTRAE_LIBRARYDIR" ENVIRONMENT) + + +# ------------------------------------------------------------------------ +# Search for Extrae include DIR +# ------------------------------------------------------------------------ + +if(NOT Extrae_INCLUDE_DIR) + + set(_extrae_INCLUDE_SEARCH_DIRS "") + + if(EXTRAE_INCLUDEDIR) + list(APPEND _extrae_INCLUDE_SEARCH_DIRS ${EXTRAE_INCLUDEDIR}) + endif() + + if(EXTRAE_ROOT) + list(APPEND _extrae_INCLUDE_SEARCH_DIRS ${EXTRAE_ROOT}/include ${EXTRAE_ROOT}) + endif() + + if(EXTRAE_NO_SYSTEM_PATHS) + list(APPEND _extrae_INCLUDE_SEARCH_DIRS NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH) + endif() + + _Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_extrae_INCLUDE_SEARCH_DIRS") + + find_path(Extrae_INCLUDE_DIR + NAMES extrae.h + HINTS ${_extrae_INCLUDE_SEARCH_DIRS} + ) + + unset(_extrae_INCLUDE_SEARCH_DIRS) + +endif() + +# ------------------------------------------------------------------------ +# Extract version information from extrae_version.h +# ------------------------------------------------------------------------ + +if(Extrae_INCLUDE_DIR) + _Extrae_DEBUG_PRINT("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" + "location of version.hpp: ${Extrae_INCLUDE_DIR}/version.h") + + file(STRINGS "${Extrae_INCLUDE_DIR}/extrae_version.h" + _extrae_VERSION_HPP_CONTENTS REGEX "#define EXTRAE_MAJOR ") + + if("${_extrae_VERSION_HPP_CONTENTS}" MATCHES "#define EXTRAE_MAJOR ([0-9]+)") + set(_extrae_VERSION_MAJOR "${CMAKE_MATCH_1}") + endif() + + file(STRINGS "${Extrae_INCLUDE_DIR}/extrae_version.h" + _extrae_VERSION_HPP_CONTENTS REGEX "#define EXTRAE_MINOR ") + + if("${_extrae_VERSION_HPP_CONTENTS}" MATCHES "#define EXTRAE_MINOR ([0-9]+)") + set(_extrae_VERSION_MINOR "${CMAKE_MATCH_1}") + endif() + + file(STRINGS "${Extrae_INCLUDE_DIR}/extrae_version.h" + _extrae_VERSION_HPP_CONTENTS REGEX "#define EXTRAE_MICRO ") + + if("${_extrae_VERSION_HPP_CONTENTS}" MATCHES "#define EXTRAE_MICRO ([0-9]+)") + set(_extrae_VERSION_MICRO "${CMAKE_MATCH_1}") + endif() + + unset(_extrae_VERSION_HPP_CONTENTS) + + set(Extrae_VERSION_COUNT 3) + set(Extrae_VERSION_MAJOR ${_extrae_VERSION_MAJOR}) + set(Extrae_VERSION_MINOR ${_extrae_VERSION_MINOR}) + set(Extrae_VERSION_PATCH ${_extrae_VERSION_MICRO}) + set(Extrae_VERSION_STRING "${Extrae_VERSION_MAJOR}.${Extrae_VERSION_MINOR}.${Extrae_VERSION_PATCH}") + set(Extrae_VERSION ${Extrae_VERSION_STRING}) + set(Extrae_LIB_VERSION ${Extrae_VERSION_STRING}) + + unset(_extrae_VERSION_MAJOR) + unset(_extrae_VERSION_MINOR) + unset(_extrae_VERSION_MICRO) + + _Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Extrae_VERSION") + _Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Extrae_VERSION_STRING") + _Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Extrae_VERSION_MAJOR") + _Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Extrae_VERSION_MINOR") + _Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Extrae_VERSION_PATCH") + _Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Extrae_VERSION_COUNT") + _Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Extrae_VERSION_STRING") + +endif() + + +# ------------------------------------------------------------------------ +# Begin finding Extrae libraries +# ------------------------------------------------------------------------ + +set(_extrae_LIBRARY_SEARCH_DIRS "") + +if(EXTRAE_LIBRARYDIR) + list(APPEND _extrae_LIBRARY_SEARCH_DIRS ${EXTRAE_LIBRARYDIR}) +endif() + +if(EXTRAE_ROOT) + list(APPEND _extrae_LIBRARY_SEARCH_DIRS ${EXTRAE_ROOT}/lib) +endif() + +list(APPEND _extrae_LIBRARY_SEARCH_DIRS + ${Extrae_INCLUDE_DIR}/lib + ${Extrae_INCLUDE_DIR}/../lib + ) + +if(EXTRAE_NO_SYSTEM_PATHS) + list(APPEND _extrae_LIBRARY_SEARCH_DIRS NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH) +endif() + +_Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_extrae_LIBRARY_SEARCH_DIRS") + +# Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES +if(Extrae_USE_STATIC_LIBS) + set( _extrae_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set(CMAKE_FIND_LIBRARY_SUFFIXES .a) +endif() + +if(NOT Extrae_FIND_COMPONENTS) + set(Extrae_FIND_COMPONENTS) + list(APPEND Extrae_FIND_COMPONENTS + "seqtrace" "mpitrace" "omptrace" "pttrace" "smpsstrace" "nanostrace" + "cudatrace" "ocltrace" "ompitrace" "ptmpitrace" "smpssmpitrace" + "nanosmpitrace" "cudampitrace" "cudaompitrace" "oclmpitrace") + _Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Extrae_FIND_COMPONENTS") +endif() + +foreach(COMPONENT ${Extrae_FIND_COMPONENTS}) + _Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "COMPONENT") + + string(TOUPPER ${COMPONENT} UPPERCOMPONENT) + _Extrae_COMPONENT_DEPENDENCIES("${COMPONENT}" _Extrae_${UPPERCOMPONENT}_DEPENDENCIES) + + unset(Extrae_${UPPERCOMPONENT}_LIBRARY CACHE) + + foreach(d ${_Extrae_${UPPERCOMPONENT}_DEPENDENCIES}) + find_library(Extrae_${UPPERCOMPONENT}_LIBRARY + NAMES ${COMPONENT} + HINTS ${_extrae_LIBRARY_SEARCH_DIRS} + ) + + if(Extrae_${UPPERCOMPONENT}_LIBRARY) + set(Extrae_${UPPERCOMPONENT}_FOUND ON) + endif() + + _Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Extrae_${UPPERCOMPONENT}_LIBRARY") + endforeach() +endforeach() + +# Restore the original find library ordering +if(Extrae_USE_STATIC_LIBS) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${_extrae_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) +endif() + + +# ------------------------------------------------------------------------ +# End finding Extrae libraries +# ------------------------------------------------------------------------ + +set(Extrae_INCLUDE_DIRS ${Extrae_INCLUDE_DIR}) +set(Extrae_LIBRARY_DIRS) + +if(Extrae_LIBRARY_DIR) + list(APPEND Extrae_LIBRARY_DIRS ${Extrae_LIBRARY_DIR}) +endif() + +if(_extrae_LIBRARY_SEARCH_DIRS) + list(APPEND Extrae_LIBRARY_DIRS ${_extrae_LIBRARY_SEARCH_DIRS}) +endif() + +if(Extrae_LIBRARY_DIRS) + list(REMOVE_DUPLICATES Extrae_LIBRARY_DIRS) +endif() + +_Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Extrae_INCLUDE_DIR") +_Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Extrae_LIBRARY_DIRS") + +# ------------------------------------------------------------------------ +# Call FPHSA helper, see https://cmake.org/cmake/help/latest/module/FindPackageHandleStandardArgs.html +# +# The FPHSA helper provides standard way of reporting final search results to +# the user including the version and component checks. +# ------------------------------------------------------------------------ + +# Define aliases as needed by the component handler in the FPHSA helper below +foreach(COMPONENT IN LISTS Extrae_FIND_COMPONENTS) + string(TOUPPER ${COMPONENT} UPPERCOMPONENT) + if(DEFINED Extrae_${UPPERCOMPONENT}_FOUND) + set(Extrae_${COMPONENT}_FOUND ${Extrae_${UPPERCOMPONENT}_FOUND}) + endif() +endforeach() + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args( + Extrae + REQUIRED_VARS Extrae_INCLUDE_DIR + VERSION_VAR Extrae_VERSION_STRING + HANDLE_COMPONENTS +) + +if(NOT Extrae_FOUND) + foreach(COMPONENT ${Extrae_FIND_COMPONENTS}) + string(TOUPPER ${COMPONENT} UPPERCOMPONENT) + set(Extrae_${UPPERCOMPONENT}_FOUND 0) + endforeach() +endif() + + +# ------------------------------------------------------------------------ +# Add imported targets +# ------------------------------------------------------------------------ + +if(Extrae_FOUND) + + if(NOT TARGET Extrae::headers) + add_library(Extrae::headers INTERFACE IMPORTED) + if(Extrae_INCLUDE_DIRS) + set_target_properties(Extrae::headers PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Extrae_INCLUDE_DIRS}") + endif() + endif() + + foreach(COMPONENT ${Extrae_FIND_COMPONENTS}) + if(_Extrae_IMPORTED_TARGETS AND NOT TARGET Extrae::${COMPONENT}) + string(TOUPPER ${COMPONENT} UPPERCOMPONENT) + + if(Extrae_${UPPERCOMPONENT}_FOUND) + if(Extrae_USE_STATIC_LIBS) + add_library(Extrae::${COMPONENT} STATIC IMPORTED) + else() + # Even if Extrae_USE_STATIC_LIBS is OFF, we might have found + # static libraries as a result + add_library(Extrae::${COMPONENT} UNKNOWN IMPORTED) + endif() + + if(Extrae_INCLUDE_DIRS) + set_target_properties(Extrae::${COMPONENT} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Extrae_INCLUDE_DIRS}") + endif() + + if(EXISTS "${Extrae_${UPPERCOMPONENT}_LIBRARY}") + set_target_properties(Extrae::${COMPONENT} PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${Extrae_${UPPERCOMPONENT}_LIBRARY}") + endif() + endif() + endif() + endforeach() +endif() + +# ------------------------------------------------------------------------ +# Finalize +# ------------------------------------------------------------------------ + +# Report Extrae_LIBRARIES +set(Extrae_LIBRARIES "") +foreach(COMPONENT IN LISTS Extrae_FIND_COMPONENTS) + string(TOUPPER ${COMPONENT} UPPERCOMPONENT) + if(Extrae_${UPPERCOMPONENT}_FOUND) + list(APPEND Extrae_LIBRARIES ${Extrae_${UPPERCOMPONENT}_LIBRARY}) + endif() +endforeach() + +_Extrae_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Extrae_LIBRARIES") diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e6d61290c9cd164b509ad2abb17b0d1b793380b..174cc59d9c02d886610fe35937221a667a83b0b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,6 +204,37 @@ include_directories( include(GNUInstallDirs) +# ------------------------------------------------------------------------------ +# Instrumentation support +# ------------------------------------------------------------------------------ +option(GKFS_ENABLE_INSTRUMENTATION "Enable GekkoFS instrumentation" OFF) + +if(GKFS_ENABLE_INSTRUMENTATION) + + option(GKFS_INSTRUMENTATION_USE_EXTRAE "Use Extrae for GekkoFS instrumentation" ON) + + if(GKFS_INSTRUMENTATION_USE_EXTRAE) + + set(GKFS_EXTRAE_LIBRARY "pttrace" CACHE STRING "Extrae library to use for instrumentation") + + # valid tracing libraries provided by Extrae + set_property(CACHE GKFS_EXTRAE_LIBRARY PROPERTY STRINGS + "seqtrace" "mpitrace" "omptrace" "pttrace" "smpsstrace" "nanostrace" + "cudatrace" "ocltrace" "ompitrace" "ptmpitrace" "smpssmpitrace" + "nanosmpitrace" "cudampitrace" "cudaompitrace" "oclmpitrace" + ) + + find_package(Extrae 3.7.1 + REQUIRED + COMPONENTS ${GKFS_EXTRAE_LIBRARY}) + + if(Extrae_FOUND) + add_definitions(-DGKFS_ENABLE_INSTRUMENTATION) + add_definitions(-DGKFS_INSTRUMENTATION_USE_EXTRAE) + endif() + endif() +endif() + # Global components add_subdirectory(src/global) # Daemon diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 0be20f8eae41115f6c389c81ed93cd48e35ed4d8..7adf94939d4bdc0ad8ab4900b1f05c47520d9cb9 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -67,6 +67,12 @@ target_link_libraries(gkfs_intercept Date::TZ ) +if(GKFS_ENABLE_INSTRUMENTATION) + if(GKFS_INSTRUMENTATION_USE_EXTRAE) + target_link_libraries(gkfs_intercept Extrae::${GKFS_EXTRAE_LIBRARY}) + endif() +endif() + target_include_directories(gkfs_intercept PRIVATE ${ABT_INCLUDE_DIRS} diff --git a/src/client/intercept.cpp b/src/client/intercept.cpp index 9905a0b5db5282a5e61b7e738aa7b50664bd8f3f..59ff6bed2860e023ffd9161b1bb3d926272fbac3 100644 --- a/src/client/intercept.cpp +++ b/src/client/intercept.cpp @@ -21,6 +21,12 @@ #include +#ifdef GKFS_ENABLE_INSTRUMENTATION +#ifdef GKFS_INSTRUMENTATION_USE_EXTRAE +#include +#endif // GKFS_INSTRUMENTATION_USE_EXTRAE +#endif // GKFS_ENABLE_INSTRUMENTATION + extern "C" { #include #include @@ -914,4 +920,4 @@ void stop_interception() { } } // namespace preload -} // namespace gkfs \ No newline at end of file +} // namespace gkfs diff --git a/src/client/preload.cpp b/src/client/preload.cpp index ad09cff3291be0ce05df43a4135e746eba5be6d9..c11425b20a760da79e57a795cd4a78c77952d663 100644 --- a/src/client/preload.cpp +++ b/src/client/preload.cpp @@ -28,6 +28,12 @@ extern "C" { #include } +#ifdef GKFS_ENABLE_INSTRUMENTATION +#ifdef GKFS_INSTRUMENTATION_USE_EXTRAE +#include +#endif // GKFS_INSTRUMENTATION_USE_EXTRAE +#endif // GKFS_ENABLE_INSTRUMENTATION + using namespace std; std::unique_ptr ld_network_service; // extern variable