diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 1e4fae89ff..c8be540e64 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -96,6 +96,17 @@ else fi fi +if test -d "${source_dir}/lib/papi" +then + { echo "papi already in lib... not downloading, building, and installing"; } 2>/dev/null +else + cd "${source_dir}/lib" + git clone https://github.com/icl-utk-edu/papi.git + cd papi/src + ./configure --prefix=${source_dir}/lib/papi/install + make && make install +fi + if test "${VT_ZOLTAN_ENABLED:-0}" -eq 1 then export Zoltan_DIR=${ZOLTAN_DIR:-""} diff --git a/cmake/FindPAPI.cmake b/cmake/FindPAPI.cmake new file mode 100644 index 0000000000..6ccab46b3c --- /dev/null +++ b/cmake/FindPAPI.cmake @@ -0,0 +1,21 @@ +# Set minimum CMake version +cmake_minimum_required(VERSION 3.23 FATAL_ERROR) + +set(PAPI_ROOT "${CMAKE_SOURCE_DIR}/lib/papi/install") + +# Find the PAPI include directory and library +find_path(PAPI_INCLUDE_DIR NAMES papi.h HINTS ${PAPI_ROOT}/include) +find_library(PAPI_LIBRARY NAMES papi HINTS ${PAPI_ROOT}/lib) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PAPI DEFAULT_MSG PAPI_LIBRARY PAPI_INCLUDE_DIR) + +if(PAPI_FOUND AND NOT TARGET PAPI::PAPI) + add_library(PAPI::PAPI UNKNOWN IMPORTED) + set_target_properties(PAPI::PAPI PROPERTIES + IMPORTED_LOCATION "{PAPI_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${PAPI_INCLUDE_DIR}" + ) +endif() + +mark_as_advanced(PAPI_INCLUDE_DIR PAPI_LIBRARY) diff --git a/cmake/link_vt.cmake b/cmake/link_vt.cmake index ffd0b8e821..f97fe4f03f 100644 --- a/cmake/link_vt.cmake +++ b/cmake/link_vt.cmake @@ -34,6 +34,7 @@ function(link_target_with_vt) LINK_FORT LINK_JSON LINK_BROTLI + LINK_PAPI ) set( multiValueArg @@ -221,6 +222,15 @@ function(link_target_with_vt) ) endif() + if (NOT DEFINED ARG_LINK_PAPI AND ${ARG_DEFAULT_LINK_SET} OR ARG_LINK_PAPI) + if (${ARG_DEBUG_LINK}) + message(STATUS "link_target_with_vt: papi=${ARG_LINK_PAPI}") + endif() + target_link_libraries( + ${ARG_TARGET} PUBLIC ${ARG_BUILD_TYPE} ${PAPI_LIBRARY} + ) + endif() + if (${vt_mimalloc_enabled}) if (${ARG_DEBUG_LINK}) message(STATUS "link_target_with_vt: mimalloc=${vt_mimalloc_enabled}") diff --git a/cmake/load_packages.cmake b/cmake/load_packages.cmake index 5932b51939..99ebf241e4 100644 --- a/cmake/load_packages.cmake +++ b/cmake/load_packages.cmake @@ -21,5 +21,8 @@ include(cmake/load_libunwind.cmake) # Optionally link with Zoltan include(cmake/load_zoltan_package.cmake) +# Link with PAPI +include(cmake/load_papi.cmake) + # Tests include(cmake/test_vt.cmake) diff --git a/cmake/load_papi.cmake b/cmake/load_papi.cmake new file mode 100644 index 0000000000..82eff87c61 --- /dev/null +++ b/cmake/load_papi.cmake @@ -0,0 +1,3 @@ +find_package(PAPI REQUIRED) +message(STATUS: "FOUND PAPI: PAPI LIBRARY: ${PAPI_LIBRARY}\n PAPI INCLUDE DIR: ${PAPI_INCLUDE_DIR}") +set(vt_papi_found "1")