From 147a07fa005eab596c56a455c2d1bb6567180f4a Mon Sep 17 00:00:00 2001 From: Thierry <thierry.gautier@inrialpes.fr> Date: Wed, 25 Sep 2019 10:39:45 +0200 Subject: [PATCH] Add PAPI support --- CMakeLists.txt | 3 +++ cmake/FindPAPI.cmake | 45 +++++++++++++++++++++++++++++++++++++++++ tracelib/CMakeLists.txt | 11 ++++++++-- 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 cmake/FindPAPI.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index a91eb33..9fb0b89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,8 @@ cmake_minimum_required (VERSION 3.7) project (Tikki) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) + include_directories ("includes") include_directories("poti/include" "poti/src") diff --git a/cmake/FindPAPI.cmake b/cmake/FindPAPI.cmake new file mode 100644 index 0000000..86cbf22 --- /dev/null +++ b/cmake/FindPAPI.cmake @@ -0,0 +1,45 @@ +# Try to find PAPI headers and libraries. +# +# Usage of this module as follows: +# +# find_package(PAPI) +# +# Variables used by this module, they can change the default behaviour and need +# to be set before calling find_package: +# +# PAPI_PREFIX Set this variable to the root installation of +# libpapi if the module has problems finding the +# proper installation path. +# +# Variables defined by this module: +# +# PAPI_FOUND System has PAPI libraries and headers +# PAPI_LIBRARIES The PAPI library +# PAPI_INCLUDE_DIRS The location of PAPI headers + +find_path(PAPI_PREFIX + NAMES include/papi.h +) + +find_library(PAPI_LIBRARIES + # Pick the static library first for easier run-time linking. + NAMES libpapi.so libpapi.a papi + HINTS ${PAPI_PREFIX}/lib ${HILTIDEPS}/lib +) + +find_path(PAPI_INCLUDE_DIRS + NAMES papi.h + HINTS ${PAPI_PREFIX}/include ${HILTIDEPS}/include +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PAPI DEFAULT_MSG + PAPI_LIBRARIES + PAPI_INCLUDE_DIRS +) + +mark_as_advanced( + PAPI_PREFIX_DIRS + PAPI_LIBRARIES + PAPI_INCLUDE_DIRS +) diff --git a/tracelib/CMakeLists.txt b/tracelib/CMakeLists.txt index e91301d..629ddb4 100644 --- a/tracelib/CMakeLists.txt +++ b/tracelib/CMakeLists.txt @@ -11,8 +11,15 @@ add_custom_command ( set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) -include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) +find_package(PAPI) +if (${PAPI_FOUND}) + add_compile_options("-DKAAPI_USE_PAPI=1") +else() + add_compile_options("-DKAAPI_USE_PAPI=0") +endif() + +include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${PAPI_INCLUDE_DIRS}) add_library(tracelib SHARED kaapi_recorder.c kaapi_rt.c kaapi_trace_lib.c kaapi_hashmap.c kaapi_trace_rt.c kaapi_parser.c ${CMAKE_CURRENT_BINARY_DIR}/git_hash.h ${CMAKE_CURRENT_BINARY_DIR}/hw_count.h) -target_link_libraries(tracelib Threads::Threads) +target_link_libraries(tracelib Threads::Threads ${PAPI_LIBRARIES}) install(TARGETS tracelib DESTINATION lib) -- GitLab