From c08d2440735566c5901d5448531a47ce2b73e5c2 Mon Sep 17 00:00:00 2001 From: Christian Heinrich Date: Mon, 29 Feb 2016 10:24:48 +0100 Subject: [PATCH] [SMPI/PAPI] Added cmake switch for SMPI+PAPI This commit includes: - Enable/disable PAPI bindings via ccmake - The FindPAPI.cmake file - The #define for C/C++ --- CMakeLists.txt | 8 +++ tools/cmake/MakeLib.cmake | 4 ++ tools/cmake/Modules/FindPAPI.cmake | 77 ++++++++++++++++++++++++++++ tools/cmake/Option.cmake | 3 ++ tools/cmake/src/internal_config.h.in | 3 ++ 5 files changed, 95 insertions(+) create mode 100644 tools/cmake/Modules/FindPAPI.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index b46a981833..579a485232 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,6 +217,13 @@ endif() if(WIN32) set(Boost_USE_STATIC_LIBS 1) endif() +set(HAVE_PAPI 0) +if(enable_smpi_papi) + include(FindPAPI) + if (NOT HAVE_PAPI) + message(FATAL_ERROR "Cannot find PAPI. Please install it (apt-get install papi-tools libpapi-dev) or disable PAPI bindings.") + endif() +endif() find_package(Boost 1.48) if(Boost_FOUND) @@ -962,6 +969,7 @@ message(" Compile Smpi ................: ${HAVE_SMPI}") message(" Smpi fortran ..............: ${SMPI_FORTRAN}") message(" MPICH3 testsuite ..........: ${enable_smpi_MPICH3_testsuite}") message(" Privatization .............: ${HAVE_PRIVATIZATION}") +message(" PAPI support...............: ${HAVE_PAPI}") message(" Compile Boost.Context support: ${HAVE_BOOST_CONTEXTS}") message("") message(" Maintainer mode .............: ${enable_maintainer_mode}") diff --git a/tools/cmake/MakeLib.cmake b/tools/cmake/MakeLib.cmake index efb9595b9c..ed62a97fe9 100644 --- a/tools/cmake/MakeLib.cmake +++ b/tools/cmake/MakeLib.cmake @@ -56,6 +56,10 @@ if(HAVE_LUA) SET(SIMGRID_DEP "${SIMGRID_DEP} ${LUA_LIBRARY} -ldl") endif() +if(HAVE_PAPI) + SET(SIMGRID_DEP "${SIMGRID_DEP} -lpapi") +endif() + if(HAVE_GRAPHVIZ) if(HAVE_CGRAPH_LIB) SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph") diff --git a/tools/cmake/Modules/FindPAPI.cmake b/tools/cmake/Modules/FindPAPI.cmake new file mode 100644 index 0000000000..afb95bbe37 --- /dev/null +++ b/tools/cmake/Modules/FindPAPI.cmake @@ -0,0 +1,77 @@ +# Try to find PAPI headers and LIBRARY. +# +# 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 LIBRARY and headers +# PAPI_LIBRARY The PAPI library +# PAPI_INCLUDE_DIRS The location of PAPI headers + +set(HAVE_PAPI 0) +set(PAPI_HINT ${papi_path} CACHE PATH "Path to search for PAPI headers and library") + +find_path(PAPI_PREFIX + NAMES include/papi.h + PATHS + ${PAPI_HINT} +) + +message(STATUS "Looking for libpapi") +find_library(PAPI_LIBRARY + NAMES libpapi papi + PATH_SUFFIXES lib64 lib + # HINTS gets searched before PATHS + HINTS + ${PAPI_PREFIX}/lib +) +if(PAPI_LIBRARY) + message(STATUS "Looking for libpapi - found at ${PAPI_LIBRARY}") +else() + message(STATUS "Looking for libpapi - not found") +endif() + +message(STATUS "Looking for papi.h") +find_path(PAPI_INCLUDE_DIRS + NAMES papi.h + # HINTS gets searched before PATHS + HINTS ${PAPI_PREFIX}/include +) +if(PAPI_INCLUDE_DIRS) + message(STATUS "Looking for papi.h - found at ${PAPI_INCLUDE_DIRS}") +else() + message(STATUS "Looking for papi.h - not found") +endif() + + +if (PAPI_LIBRARY) + if(PAPI_INCLUDE_DIRS) + set(HAVE_PAPI 1) + mark_as_advanced(HAVE_PAPI) + endif() +endif() +if(NOT HAVE_PAPI) + message(FATAL_ERROR, "Could not find PAPI LIBRARY and/or papi.h. Make sure they are correctly installed!") +endif() + +#include(FindPackageHandleStandardArgs) +#find_package_handle_standard_args(PAPI DEFAULT_MSG +# PAPI_LIBRARY +# PAPI_INCLUDE_DIRS +#) + +mark_as_advanced( + PAPI_PREFIX_DIRS + PAPI_LIBRARY + PAPI_INCLUDE_DIRS +) + diff --git a/tools/cmake/Option.cmake b/tools/cmake/Option.cmake index dc14fd0f70..511f861184 100644 --- a/tools/cmake/Option.cmake +++ b/tools/cmake/Option.cmake @@ -38,6 +38,9 @@ if(WIN32) option(enable_smpi_MPICH3_testsuite "Whether the test suite form MPICH 3 should be built" off) else() option(enable_smpi "Whether SMPI in included in library." on) + # PAPI does not support windows (they did in 3.7, but not anymore in 5.x) + # See http://icl.cs.utk.edu/papi/custom/index.html?lid=62&slid=96 + option(enable_smpi_papi "Whether SMPI supports PAPI bindings." off) option(enable_smpi_MPICH3_testsuite "Whether the test suite form MPICH 3 should be built" off) endif() option(enable_smpi_ISP_testsuite "Whether the test suite from ISP should be built." off) diff --git a/tools/cmake/src/internal_config.h.in b/tools/cmake/src/internal_config.h.in index 0b8d91baf5..1ad92b1540 100644 --- a/tools/cmake/src/internal_config.h.in +++ b/tools/cmake/src/internal_config.h.in @@ -56,6 +56,9 @@ #define SMPI_FORTRAN @SMPI_FORTRAN@ #define HAVE_PRIVATIZATION @HAVE_PRIVATIZATION@ /* We have mmap and objdump to handle privatization */ +/* Make PAPI available? */ +#define HAVE_PAPI @HAVE_PAPI@ + /* Other function checks */ #define HAVE_BACKTRACE @HAVE_BACKTRACE@ /* Function backtrace */ #define HAVE_MMAP @HAVE_MMAP@ /* Function mmap */ -- 2.20.1