Skip to content

Commit

Permalink
#2302: Add papi as dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrepebay committed Jun 12, 2024
1 parent ea8b2c1 commit 690613e
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
11 changes: 11 additions & 0 deletions ci/build_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,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

Check warning on line 83 in ci/build_cpp.sh

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

ci/build_cpp.sh#L83

Double quote to prevent globbing and word splitting.
make && make install
fi

if test "${VT_ZOLTAN_ENABLED:-0}" -eq 1
then
export Zoltan_DIR=${ZOLTAN_DIR:-""}
Expand Down
21 changes: 21 additions & 0 deletions cmake/FindPAPI.cmake
Original file line number Diff line number Diff line change
@@ -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)
12 changes: 11 additions & 1 deletion cmake/link_vt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function(link_target_with_vt)
LINK_FORT
LINK_JSON
LINK_BROTLI
LINK_PAPI
)
set(
multiValueArg
Expand All @@ -41,7 +42,7 @@ function(link_target_with_vt)
set(allKeywords ${noValOption} ${singleValArg} ${multiValueArg})

cmake_parse_arguments(
ARG "${noValOption}" "${singleValArg}" "${multiValueArgs}" ${ARGN}
ARG "${noValOption}" "${singleValArg}" "${multiValueArg}" ${ARGN}
)

if (${ARG_DEBUG_LINK})
Expand Down Expand Up @@ -211,6 +212,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}")
Expand Down
3 changes: 3 additions & 0 deletions cmake/load_packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ include(cmake/load_doxygen.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)
3 changes: 3 additions & 0 deletions cmake/load_papi.cmake
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 690613e

Please sign in to comment.