From 343d35e21bed9366611ce9f7cfacfde5d91988df Mon Sep 17 00:00:00 2001 From: Francesco Rizzi Date: Mon, 14 Aug 2023 15:23:26 +0200 Subject: [PATCH 01/56] remove unused macros --- docs/source/keywords.rst | 8 -------- include/pressio/pressio_cmake_config.h.in | 2 -- 2 files changed, 10 deletions(-) diff --git a/docs/source/keywords.rst b/docs/source/keywords.rst index 966fc7944..4c062af4d 100644 --- a/docs/source/keywords.rst +++ b/docs/source/keywords.rst @@ -42,14 +42,6 @@ The following options control enabling TPLs: - self-explanatory - ``OFF`` automatically ``ON`` if ``PRESSIO_ENABLE_TPL_TRILINOS=ON`` - * - ``PRESSIO_ENABLE_TPL_BLAS`` - - self-explanatory - - ``OFF``\ ; automatically ``ON`` if ``PRESSIO_ENABLE_TPL_LAPACK=ON`` or ``PRESSIO_ENABLE_TPL_TRILINOS=ON`` - - * - ``PRESSIO_ENABLE_TPL_LAPACK`` - - self-explanatory - - ``OFF``\ ; automatically ``ON`` if ``PRESSIO_ENABLE_TPL_BLAS=ON`` or ``PRESSIO_ENABLE_TPL_TRILINOS=ON`` - Obviously, the choice of which TPLs to enable is related to your application's dependency requirements. diff --git a/include/pressio/pressio_cmake_config.h.in b/include/pressio/pressio_cmake_config.h.in index e529c47de..d2dffb1f0 100644 --- a/include/pressio/pressio_cmake_config.h.in +++ b/include/pressio/pressio_cmake_config.h.in @@ -56,8 +56,6 @@ #cmakedefine PRESSIO_ENABLE_TEUCHOS_TIMERS #cmakedefine PRESSIO_ENABLE_TPL_PYBIND11 #cmakedefine PRESSIO_ENABLE_TPL_KOKKOS -#cmakedefine PRESSIO_ENABLE_TPL_BLAS -#cmakedefine PRESSIO_ENABLE_TPL_LAPACK #cmakedefine PRESSIO_ENABLE_TPL_MPI #cmakedefine PRESSIO_ENABLE_CXX14 #cmakedefine PRESSIO_ENABLE_CXX17 From 6d3e5bf3864b061f9adf41609711e432a8a29bc6 Mon Sep 17 00:00:00 2001 From: Francesco Rizzi Date: Mon, 14 Aug 2023 15:24:39 +0200 Subject: [PATCH 02/56] remove macros --- include/pressio/pressio_cmake_config.h.in | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/include/pressio/pressio_cmake_config.h.in b/include/pressio/pressio_cmake_config.h.in index d2dffb1f0..c65e39140 100644 --- a/include/pressio/pressio_cmake_config.h.in +++ b/include/pressio/pressio_cmake_config.h.in @@ -61,20 +61,4 @@ #cmakedefine PRESSIO_ENABLE_CXX17 #cmakedefine PRESSIO_ENABLE_CXX20 -// macros for catching compiler -#if defined( __INTEL_COMPILER ) -#define PRESSIO_COMPILER_INTEL __INTEL_COMPILER -#endif - -#if !defined( __clang__ ) && !defined( PRESSIO_COMPILER_INTEL ) &&defined( __GNUC__ ) -#define PRESSIO_COMPILER_GNU __GNUC__*100+__GNUC_MINOR__*10+__GNUC_PATCHLEVEL__ -#endif - -// macros for deprecation (need to adjust when we can move to c++14) -#if defined(PRESSIO_COMPILER_GNU) || defined(PRESSIO_COMPILER_CLANG) -#define PRESSIO_DEPRECATED __attribute__ ((deprecated)) -#else -#define PRESSIO_DEPRECATED -#endif - #endif From 70887a0b14e12adb90a360ec7e4743c519f9bd88 Mon Sep 17 00:00:00 2001 From: Francesco Rizzi Date: Fri, 25 Aug 2023 03:44:03 -0700 Subject: [PATCH 03/56] wip --- CMakeLists.txt | 219 +++++------------- cmake/helperFunctions.cmake | 20 -- cmake/macrosForCreatingUnitTests.cmake | 48 ---- cmake/options.cmake | 30 +++ cmake/pressioConfig.cmake.in | 6 + cmake/pressioUninstall.cmake | 38 --- cmake/tpls/tplBlas.cmake | 24 -- cmake/tpls/tplEigen.cmake | 27 --- cmake/tpls/tplKokkos.cmake | 34 --- cmake/tpls/tplLapack.cmake | 24 -- cmake/tpls/tplMPI.cmake | 12 - cmake/tpls/tplPybind11.cmake | 34 --- cmake/tpls/tplTrilinos.cmake | 60 ----- cmake/version_parse.cmake | 17 -- include/pressio/macros.hpp | 129 +++++++++++ include/pressio/mpl.hpp | 2 +- include/pressio/pressio_cmake_config.h.in | 64 ----- include/pressio/utils.hpp | 29 --- tests/CMakeLists.txt | 174 ++++++++++++-- tests/cmake/googletest/CMakeLists.txt.in | 16 ++ .../cmake}/macrosForCreatingTests.cmake | 0 tests/cmake/macrosForCreatingUnitTests.cmake | 15 ++ tests/cmake/tpls.cmake | 170 ++++++++++++++ tests/functional_small/CMakeLists.txt | 13 +- version.txt | 4 +- 25 files changed, 591 insertions(+), 618 deletions(-) delete mode 100644 cmake/helperFunctions.cmake delete mode 100644 cmake/macrosForCreatingUnitTests.cmake create mode 100644 cmake/options.cmake create mode 100644 cmake/pressioConfig.cmake.in delete mode 100644 cmake/pressioUninstall.cmake delete mode 100644 cmake/tpls/tplBlas.cmake delete mode 100644 cmake/tpls/tplEigen.cmake delete mode 100644 cmake/tpls/tplKokkos.cmake delete mode 100644 cmake/tpls/tplLapack.cmake delete mode 100644 cmake/tpls/tplMPI.cmake delete mode 100644 cmake/tpls/tplPybind11.cmake delete mode 100644 cmake/tpls/tplTrilinos.cmake delete mode 100644 cmake/version_parse.cmake create mode 100644 include/pressio/macros.hpp delete mode 100644 include/pressio/pressio_cmake_config.h.in create mode 100644 tests/cmake/googletest/CMakeLists.txt.in rename {cmake => tests/cmake}/macrosForCreatingTests.cmake (100%) create mode 100644 tests/cmake/macrosForCreatingUnitTests.cmake create mode 100644 tests/cmake/tpls.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 001ca13fb..c92226e77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,191 +1,98 @@ cmake_minimum_required(VERSION 3.18.0 FATAL_ERROR) project(pressio C CXX) -# setting where other cmake commands are -set(CMAKE_MODULE_PATH - ${PROJECT_SOURCE_DIR}/cmake;${PROJECT_SOURCE_DIR}/cmake/tpls) - -# include commands for coloring prints +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(colors) #===================================================================== # versioning #===================================================================== -include(version_parse) -get_version_number("version.txt" Pressio_VERSION_MAJOR) -get_version_number("version.txt" Pressio_VERSION_MINOR) -get_version_number("version.txt" Pressio_VERSION_PATCH) -set(Pressio_VERSION "${Pressio_VERSION_MAJOR}.${Pressio_VERSION_MINOR}.${Pressio_VERSION_PATCH}") -message("${Magenta}>> Pressio version = ${Pressio_VERSION} ${ColourReset}") - -#===================================================================== -# guard against in-source builds -if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) - message(FATAL_ERROR "In-source builds are not allowed. - Please make a new directory (called a build directory) and run CMake from there. - You may need to remove CMakeCache.txt.") -endif() - -#===================================================================== -# check build type -if (NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") -endif() - -# convert cmake build type to lower string -string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_tolower) -if( NOT cmake_build_type_tolower STREQUAL "debug" - AND NOT cmake_build_type_tolower STREQUAL "release") - message(FATAL_ERROR "Unknown build type \"${CMAKE_BUILD_TYPE}\". - Allowed values are Debug, Release (case-insensitive).") -endif() +# adapted from Eigen +file(READ "${PROJECT_SOURCE_DIR}/include/pressio/macros.hpp" _pressio_macros) +string(REGEX MATCH "define[ \t]+PRESSIO_MAJOR_VERSION[ \t]+([0-9]+)" _pressio_major_version_match "${_pressio_macros}") +set(PRESSIO_MAJOR_VERSION "${CMAKE_MATCH_1}") +string(REGEX MATCH "define[ \t]+PRESSIO_MINOR_VERSION[ \t]+([0-9]+)" _pressio_minor_version_match "${_pressio_macros}") +set(PRESSIO_MINOR_VERSION "${CMAKE_MATCH_1}") +string(REGEX MATCH "define[ \t]+PRESSIO_PATCH_VERSION[ \t]+([0-9]+)" _pressio_patch_version_match "${_pressio_macros}") +set(PRESSIO_PATCH_VERSION "${CMAKE_MATCH_1}") +set(PRESSIO_VERSION_NUMBER ${PRESSIO_MAJOR_VERSION}.${PRESSIO_MINOR_VERSION}.${PRESSIO_PATCH_VERSION}) +message("${Magenta}>> PRESSIO: version = ${PRESSIO_VERSION_NUMBER} ${ColourReset}") #===================================================================== # c++ standard #===================================================================== -SET(PRESSIO_ENABLE_CXX14 OFF) -SET(PRESSIO_ENABLE_CXX17 OFF) -SET(PRESSIO_ENABLE_CXX20 OFF) - IF (NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) ENDIF() -include(CheckCXXCompilerFlag) +message("${Magenta}>> PRESSIO: CMAKE_CXX_STANDARD is set to ${CMAKE_CXX_STANDARD} ${ColourReset}") + IF(CMAKE_CXX_STANDARD STREQUAL "14") - SET(PRESSIO_ENABLE_CXX14 ON) - check_cxx_compiler_flag("-std=c++14" COMPILER_SUPPORT_TARGET_CPP14) - if(NOT COMPILER_SUPPORT_TARGET_CPP14) - message(FATAL_ERROR "Compiler does not support -std=c++14. This is required.") + if(NOT "cxx_std_14" IN_LIST CMAKE_CXX_COMPILE_FEATURES) + message(FATAL_ERROR "Compiler does not support C++14. This is required.") endif() - MESSAGE(STATUS "Setting PRESSIO_ENABLE_CXX14=ON") ELSEIF(CMAKE_CXX_STANDARD STREQUAL "17") - SET(PRESSIO_ENABLE_CXX14 ON) - SET(PRESSIO_ENABLE_CXX17 ON) - check_cxx_compiler_flag("-std=c++17" COMPILER_SUPPORT_TARGET_CPP17) - if(NOT COMPILER_SUPPORT_TARGET_CPP17) - message(FATAL_ERROR "Compiler does not support -std=c++17. This is required.") + if(NOT "cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES) + message(FATAL_ERROR "Compiler does not support C++17. This is required.") endif() - MESSAGE(STATUS "Setting PRESSIO_ENABLE_CXX14=ON") - MESSAGE(STATUS "Setting PRESSIO_ENABLE_CXX17=ON") ELSEIF(CMAKE_CXX_STANDARD STREQUAL "20") - SET(PRESSIO_ENABLE_CXX14 ON) - SET(PRESSIO_ENABLE_CXX17 ON) - SET(PRESSIO_ENABLE_CXX20 ON) - check_cxx_compiler_flag("-std=c++20" COMPILER_SUPPORT_TARGET_CPP20) - if(NOT COMPILER_SUPPORT_TARGET_CPP20) - message(FATAL_ERROR "Compiler does not support -std=c++20. This is required.") + message("${Magenta}>> PRESSIO: CMAKE_CXX_STANDARD = 20 ${ColourReset}") + if(NOT "cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES) + message(FATAL_ERROR "Compiler does not support C++20. This is required.") endif() - MESSAGE(STATUS "Setting PRESSIO_ENABLE_CXX14=ON") - MESSAGE(STATUS "Setting PRESSIO_ENABLE_CXX17=ON") - MESSAGE(STATUS "Setting PRESSIO_ENABLE_CXX20=ON") - ENDIF() -MESSAGE("${Magenta}>> Setting CXX standard to ${CMAKE_CXX_STANDARD} ${ColourReset}") +################################################################################ -#===================================================================== -# do processing -#===================================================================== include(GNUInstallDirs) - -message("") -message("${Magenta}>> Processing:${ColourReset}") - -if( cmake_build_type_tolower STREQUAL "debug") - set(PRESSIO_DEBUG_BUILD ON) - message( ">> PRESSIO_DEBUG_BUILD is ON since CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" ) - message("") -endif() - -if( cmake_build_type_tolower STREQUAL "debug" AND NOT PRESSIO_ENABLE_DEBUG_PRINT) - set(PRESSIO_ENABLE_DEBUG_PRINT ON) - message( ">> CMAKE_BUILD_TYPE==Debug, setting PRESSIO_ENABLE_DEBUG_PRINT=${PRESSIO_ENABLE_DEBUG_PRINT}" ) - message( " To disable: reconfigure with -DPRESSIO_ENABLE_DEBUG_PRINT=OFF" ) - message("") -endif() -if(PRESSIO_ENABLE_DEBUG_PRINT) - message( ">> Enabling debug prints since PRESSIO_ENABLE_DEBUG_PRINT=ON" ) - message( " To disable: reconfigure with -DPRESSIO_ENABLE_DEBUG_PRINT=OFF" ) - message("") -endif() - -option(PRESSIO_ENABLE_TESTS "Enable ALL pressio tests." OFF) -option(PRESSIO_ENABLE_FUNCTIONAL_SMALL_TESTS "Enabling pressio functional small testing." OFF) -option(PRESSIO_ENABLE_FUNCTIONAL_MEDIUM_TESTS "Enabling pressio functional medium testing." OFF) -option(PRESSIO_ENABLE_FUNCTIONAL_LARGE_TESTS "Enabling pressio functional large testing." OFF) - -#===================================================================== -# note that here we don't link anything, the TPLs are only needed -# when building tests or when the user builds their app. -# For just installing pressio, we only need to set the cmake vars. -#===================================================================== -option(PRESSIO_ENABLE_TPL_EIGEN "Enable Eigen TPL" ON) -option(PRESSIO_ENABLE_TPL_TRILINOS "Enable Trilinos TPL" OFF) -option(PRESSIO_ENABLE_TPL_BLAS "Enable BLAS TPL" OFF) -option(PRESSIO_ENABLE_TPL_LAPACK "Enable LAPACK TPL" OFF) -option(PRESSIO_ENABLE_TPL_KOKKOS "Enable Kokkos TPL" OFF) -option(PRESSIO_ENABLE_TPL_MPI "Enable MPI" OFF) -option(PRESSIO_ENABLE_TPL_PYBIND11 "Enable Pybind11 TPL" OFF) - -include(tplEigen) -include(tplPybind11) -include(tplMPI) -include(tplTrilinos) -include(tplBlas) -include(tplLapack) -include(tplKokkos) -message("") - -#===================================================================== -# install -#===================================================================== -set(INC_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/pressio) - -configure_file(include/pressio/pressio_cmake_config.h.in pressio_cmake_config.h @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pressio_cmake_config.h DESTINATION ${INC_INSTALL_DIR}) - -file(GLOB include_helpers "${CMAKE_CURRENT_SOURCE_DIR}/include/pressio/*.hpp") -install(FILES ${include_helpers} DESTINATION ${INC_INSTALL_DIR}) - -foreach(X IN ITEMS mpl utils type_traits concepts expressions ops qr solvers_linear solvers_nonlinear ode rom) - install( - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/pressio/${X} - DESTINATION ${INC_INSTALL_DIR} FILES_MATCHING PATTERN "*.hpp") -endforeach() - -#===================================================================== -# Add uninstall target -#===================================================================== -add_custom_target (uninstall COMMAND ${CMAKE_COMMAND} -P - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/pressioUninstall.cmake) +include(CMakePackageConfigHelpers) + +install( + DIRECTORY include/pressio + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +add_library(pressio INTERFACE) + +target_include_directories( + pressio INTERFACE + $ + $ +) + +install( + TARGETS pressio + EXPORT pressioTargets + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install( + EXPORT pressioTargets + FILE pressioTargets.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pressio) +export( + TARGETS pressio + FILE pressioTargets.cmake) + +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/pressioConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/pressioConfig.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pressio) + +write_basic_package_version_file (pressioConfigVersion.cmake + VERSION ${PRESSIO_VERSION_NUMBER} + COMPATIBILITY SameMajorVersion + ARCH_INDEPENDENT) + +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/pressioConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/pressioConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pressio) + +################################################################################ if(PRESSIO_ENABLE_FUNCTIONAL_TESTS OR PRESSIO_ENABLE_TESTS) enable_testing() add_subdirectory(tests) endif() - -#===================================================================== -# log to screen -#===================================================================== -message(STATUS "") -message(STATUS "${Green}Configure completed ${ColourReset}") -string(TOLOWER "${CMAKE_GENERATOR}" cmake_generator_tolower) -# if(cmake_generator_tolower MATCHES "makefile") -# message(STATUS "Things you can do now:") -# message(STATUS "----------------|--------------------------------------------------------") -# message(STATUS "Command | Description") -# message(STATUS "----------------|--------------------------------------------------------") -# message(STATUS "make install | Install headers to:") -# message(STATUS " | ${CMAKE_INSTALL_PREFIX}/include") -# message(STATUS " | Change the install location using:") -# message(STATUS " | cmake . -DCMAKE_INSTALL_PREFIX=yourprefix") -# message(STATUS " | ") -# message(STATUS "make uninstall | Removes files installed by make install") -# message(STATUS "----------------|--------------------------------------------------------") -# endif() -# message(STATUS "") diff --git a/cmake/helperFunctions.cmake b/cmake/helperFunctions.cmake deleted file mode 100644 index 394f43663..000000000 --- a/cmake/helperFunctions.cmake +++ /dev/null @@ -1,20 +0,0 @@ - - -# function(get_file_list_no_ext TARGDIR RESULT) - - # TO finish - - # file(GLOB ${TARGIDR}/all_files_here "*") - - # foreach(f ${all_files_here}) - # if(NOT f MATCHES "\\.txt" - # AND NOT f MATCHES ".DS_Store" - # AND NOT f MATCHES "${CMAKE_CURRENT_SOURCE_DIR}/[.].+") - - # strip file estension - # string(REGEX REPLACE "\\.[^.]*$" "" f2 ${f}) - - # endif() - # endforeach(f ${all_files_here}) - -# endfunction() diff --git a/cmake/macrosForCreatingUnitTests.cmake b/cmake/macrosForCreatingUnitTests.cmake deleted file mode 100644 index b2482c1be..000000000 --- a/cmake/macrosForCreatingUnitTests.cmake +++ /dev/null @@ -1,48 +0,0 @@ - -# this function creates and adds an individual SERIAL unit-test -macro(add_serial_utest TESTNAME) - # set name of the executable - set(testNameFinal ${TESTNAME}) - - add_executable(${testNameFinal} - ${ARGN} ${GTESTMAINSDIR}/gTestMain_serial.cc) - - target_link_libraries(${testNameFinal} - GTest::gtest GTest::Main) - - add_test(NAME ${testNameFinal} COMMAND ${testNameFinal}) -endmacro() -#===================================================================== - -macro(add_serial_utest_kokkos TESTNAME TESTSRCS) - # set name of the executable - set(testNameFinal ${TESTNAME}) - - add_executable(${testNameFinal} - ${TESTSRCS} ${GTESTMAINSDIR}/gTestMain_kokkos.cc) - - target_link_libraries(${testNameFinal} - GTest::GTest GTest::Main) - - add_test(NAME ${testNameFinal} COMMAND ${testNameFinal}) -endmacro() -#===================================================================== - - -macro(add_utest_mpi TESTNAME TESTSRCS gMAIN nRANKS) - set(testNameFinal ${TESTNAME}_np${nRANKS}) - - add_executable(${testNameFinal} - ${TESTSRCS} ${GTESTMAINSDIR}/${gMAIN}.cc) - - target_link_libraries(${testNameFinal} - ${MPI_CXX_LIBRARIES} - GTest::GTest GTest::Main) - - add_test( - NAME ${testNameFinal} - COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${nRANKS} - ${MPIEXEC_PREFLAGS} ${testNameFinal} ${MPIEXEC_POSTFLAGS} - ) -endmacro() -#===================================================================== diff --git a/cmake/options.cmake b/cmake/options.cmake new file mode 100644 index 000000000..72f46d19b --- /dev/null +++ b/cmake/options.cmake @@ -0,0 +1,30 @@ + +option(PRESSIO_ENABLE_TPL_EIGEN "Enable Eigen TPL" ON) +option(PRESSIO_ENABLE_TPL_TRILINOS "Enable Trilinos TPL" OFF) +option(PRESSIO_ENABLE_TPL_KOKKOS "Enable Kokkos TPL" OFF) +option(PRESSIO_ENABLE_TPL_MPI "Enable MPI" OFF) +option(PRESSIO_ENABLE_TPL_PYBIND11 "Enable Pybind11 TPL" OFF) + +if(PRESSIO_ENABLE_TPL_EIGEN) + message(">> Eigen is currently enabled by default via PRESSIO_ENABLE_TPL_EIGEN=ON") +endif() + +# if trilinos is on, then also set MPI, BLAS, LAPACK and KOKKOS ON +if(PRESSIO_ENABLE_TPL_TRILINOS) + message(">> PRESSIO_ENABLE_TPL_TRILINOS=ON ==> enabling also BLAS, LAPACK, MPI, KOKKOS") + + set(PRESSIO_ENABLE_TPL_KOKKOS ON) + set(PRESSIO_ENABLE_TPL_MPI ON) +endif() + +if(PRESSIO_ENABLE_TPL_KOKKOS) + message(">> Enabling Kokkos since PRESSIO_ENABLE_TPL_KOKKOS=ON") +endif() + +if(PRESSIO_ENABLE_TPL_MPI) + message(">> Enabling MPI since PRESSIO_ENABLE_TPL_MPI=ON") +endif() + +if(PRESSIO_ENABLE_TPL_Pybind11) + message(">> Enabling Pybind11 since PRESSIO_ENABLE_TPL_PYBIND11=ON") +endif() diff --git a/cmake/pressioConfig.cmake.in b/cmake/pressioConfig.cmake.in new file mode 100644 index 000000000..274ab5db6 --- /dev/null +++ b/cmake/pressioConfig.cmake.in @@ -0,0 +1,6 @@ + +@PACKAGE_INIT@ + +if (NOT TARGET pressio) + include ("${CMAKE_CURRENT_LIST_DIR}/pressioTargets.cmake") +endif () \ No newline at end of file diff --git a/cmake/pressioUninstall.cmake b/cmake/pressioUninstall.cmake deleted file mode 100644 index 54241b4a9..000000000 --- a/cmake/pressioUninstall.cmake +++ /dev/null @@ -1,38 +0,0 @@ - -################ CMake Uninstall Template ####################### -# CMake Template file for uninstallation -# of files in 'install_manifest.txt' -# -# Used by uinstall target -################################################################# - -set(MANIFEST "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt") - -if(EXISTS ${MANIFEST}) - message(STATUS "============== Uninstalling pressio ===================") - - file(STRINGS ${MANIFEST} files) - foreach(file ${files}) - if(EXISTS ${file}) - message(STATUS "Removing file: '${file}'") - - execute_process( - COMMAND ${CMAKE_COMMAND} -E remove ${file} - OUTPUT_VARIABLE rm_out - RESULT_VARIABLE rm_retval - ) - - if(NOT "${rm_retval}" STREQUAL 0) - message(FATAL_ERROR "Failed to remove file: '${file}'.") - endif() - else() - message(STATUS "File '${file}' does not exist.") - endif() - endforeach(file) - - message(STATUS "========== Finished Uninstalling pressio ==============") -else() - message(STATUS "Cannot find install manifest: '${MANIFEST}'") - message(STATUS "Probably make install has not been performed") - message(STATUS "or install_manifest.txt has been deleted.") -endif() diff --git a/cmake/tpls/tplBlas.cmake b/cmake/tpls/tplBlas.cmake deleted file mode 100644 index 3d8ffdeb6..000000000 --- a/cmake/tpls/tplBlas.cmake +++ /dev/null @@ -1,24 +0,0 @@ - -if(PRESSIO_ENABLE_TPL_BLAS) - message(">> Enabling BLAS since PRESSIO_ENABLE_TPL_BLAS=ON ==> enabling also LAPACK") - set(PRESSIO_ENABLE_TPL_LAPACK ON) -endif() - - -if(PRESSIO_ENABLE_TPL_BLAS OR PRESSIO_ENABLE_TPL_TRILINOS) - - if(PRESSIO_ENABLE_UNIT_TESTS OR PRESSIO_ENABLE_TESTS) - # check if BLAS_ROOT is specified - if (NOT ${BLAS_ROOT}) - message("") - message(FATAL_ERROR "BLAS_ROOT not speificed, terminating") - message("Make sure you set the BLAS_ROOT env var") - endif() - - cmake_policy(SET CMP0074 NEW) - find_package(BLAS REQUIRED) - link_libraries(${BLAS_LIBRARIES}) - message("") - endif() - -endif() diff --git a/cmake/tpls/tplEigen.cmake b/cmake/tpls/tplEigen.cmake deleted file mode 100644 index 2447fc12b..000000000 --- a/cmake/tpls/tplEigen.cmake +++ /dev/null @@ -1,27 +0,0 @@ - - -if(PRESSIO_ENABLE_TPL_EIGEN) - message(">> Eigen is currently enabled by default via PRESSIO_ENABLE_TPL_EIGEN=ON") -endif() - -if(PRESSIO_ENABLE_TPL_EIGEN) - - if(PRESSIO_ENABLE_UNIT_TESTS OR PRESSIO_ENABLE_TESTS) - - if(NOT EIGEN_INC_DIR AND NOT EIGEN_INCLUDE_DIR) - message(FATAL_ERROR - "I cannot find the Eigen headers. Please reconfigure with: - -DEIGEN_INC_DIR= - or - -DEIGEN_INCLUDE_DIR= - ") - endif() - - if(NOT EIGEN_INC_DIR AND EIGEN_INCLUDE_DIR) - set(EIGEN_INC_DIR ${EIGEN_INCLUDE_DIR}) - endif() - - include_directories(${EIGEN_INC_DIR}) - endif() - -endif() diff --git a/cmake/tpls/tplKokkos.cmake b/cmake/tpls/tplKokkos.cmake deleted file mode 100644 index 5abe50809..000000000 --- a/cmake/tpls/tplKokkos.cmake +++ /dev/null @@ -1,34 +0,0 @@ - -if(PRESSIO_ENABLE_TPL_KOKKOS) - message(">> Enabling Kokkos since PRESSIO_ENABLE_TPL_KOKKOS=ON") -endif() - - -if(PRESSIO_ENABLE_TPL_KOKKOS) - - if(PRESSIO_ENABLE_UNIT_TESTS OR PRESSIO_ENABLE_TESTS) - - # # when trilinos is also enabled it links kokkos too, see tplTrilinos.cmake - if(NOT PRESSIO_ENABLE_TPL_TRILINOS) - # if kokkos is used as standalone lib, then we are more specific - # user needs to defined: KOKKOS_ROOT_DIR and KOKKOS_KERNELS_ROOT_DIR - if (NOT KOKKOS_ROOT OR NOT KOKKOS_KERNELS_ROOT) - message(FATAL_ERROR "Missing KOKKOS_ROOT. KOKKOS needs: - -D KOKKOS_ROOT= - -D KOKKOS_KERNELS_ROOT= - ") - endif() - - set(KOKKOS_LIB_NAMES kokkoscontainers kokkoscore kokkoskernels) - - include_directories(${KOKKOS_ROOT}/include ${KOKKOS_KERNELS_ROOT}/include) - - link_directories(${KOKKOS_ROOT}/lib ${KOKKOS_ROOT}/lib64 - ${KOKKOS_KERNELS_ROOT}/lib ${KOKKOS_KERNELS_ROOT}/lib64) - - link_libraries(${KOKKOS_LIB_NAMES}) - endif() - - endif() - -endif() diff --git a/cmake/tpls/tplLapack.cmake b/cmake/tpls/tplLapack.cmake deleted file mode 100644 index 6e92951ce..000000000 --- a/cmake/tpls/tplLapack.cmake +++ /dev/null @@ -1,24 +0,0 @@ - - -if(PRESSIO_ENABLE_TPL_LAPACK) - message(">> Enabling LAPACK since PRESSIO_ENABLE_TPL_LAPACK=ON ==> enabling also BLAS") - set(PRESSIO_ENABLE_TPL_BLAS ON) -endif() - -if(PRESSIO_ENABLE_TPL_LAPACK) - - if(PRESSIO_ENABLE_UNIT_TESTS OR PRESSIO_ENABLE_TESTS) - # check if LAPACK_ROOT is specified - if (NOT ${LAPACK_ROOT}) - message("") - message(FATAL_ERROR "LAPACK_ROOT not speificed, terminating") - message("Make sure you set the LAPACK_ROOT env var") - endif() - - cmake_policy(SET CMP0074 NEW) - find_package( LAPACK REQUIRED ) - link_libraries(${LAPACK_LIBRARIES}) - message("LAPLIBS=${LAPACK_LIBRARIES}") - endif() - -endif() diff --git a/cmake/tpls/tplMPI.cmake b/cmake/tpls/tplMPI.cmake deleted file mode 100644 index f8f142950..000000000 --- a/cmake/tpls/tplMPI.cmake +++ /dev/null @@ -1,12 +0,0 @@ - -if(PRESSIO_ENABLE_TPL_MPI) - message(">> Enabling MPI since PRESSIO_ENABLE_TPL_MPI=ON") -endif() - - -if(PRESSIO_ENABLE_TPL_MPI) - if(PRESSIO_ENABLE_UNIT_TESTS OR PRESSIO_ENABLE_TESTS) - find_package(MPI REQUIRED) - include_directories(${MPI_CXX_INCLUDE_PATH}) - endif() -endif() diff --git a/cmake/tpls/tplPybind11.cmake b/cmake/tpls/tplPybind11.cmake deleted file mode 100644 index 5b74ecc1a..000000000 --- a/cmake/tpls/tplPybind11.cmake +++ /dev/null @@ -1,34 +0,0 @@ - - -if(PRESSIO_ENABLE_TPL_Pybind11) - message(">> Enabling Pybind11 since PRESSIO_ENABLE_TPL_PYBIND11=ON") -endif() - -function(pybind11_fatal) - message(FATAL_ERROR "I cannot find the Pybind11 library. -To use it, please reconfigure with: --D PYBIND11_ROOT=") -endfunction() - - -if(PRESSIO_ENABLE_TPL_PYBIND11) - message("Found PRESSIO_ENABLE_TPL_PYBIND11=${PRESSIO_ENABLE_TPL_PYBIND11}.") - - # if we need to build tests, then prep for it - if(PRESSIO_ENABLE_UNIT_TESTS OR PRESSIO_ENABLE_TESTS) - - # if PYBIND11_ROOT not found - if (NOT PYBIND11_ROOT) - pybind11_fatal() - endif() - - find_package(pybind11 REQUIRED PATHS ${PYBIND11_ROOT}/share/cmake) - find_package(Python3 COMPONENTS Interpreter NumPy) - - include_directories(${Python3_INCLUDE_DIRS} ${PYBIND11_ROOT}/include) - - if(NOT ${Python3_FOUND}) - message(FATAL_ERROR "Python > 3 not found") - endif() - endif() -endif() diff --git a/cmake/tpls/tplTrilinos.cmake b/cmake/tpls/tplTrilinos.cmake deleted file mode 100644 index 89f7ec930..000000000 --- a/cmake/tpls/tplTrilinos.cmake +++ /dev/null @@ -1,60 +0,0 @@ - - -# if trilinos is on, then also set MPI, BLAS, LAPACK and KOKKOS ON -if(PRESSIO_ENABLE_TPL_TRILINOS) - message(">> PRESSIO_ENABLE_TPL_TRILINOS=ON ==> enabling also BLAS, LAPACK, MPI, KOKKOS") - - set(PRESSIO_ENABLE_TPL_KOKKOS ON) - set(PRESSIO_ENABLE_TPL_MPI ON) - set(PRESSIO_ENABLE_TPL_BLAS ON) - set(PRESSIO_ENABLE_TPL_LAPACK ON) -endif() - -if(PRESSIO_ENABLE_TPL_TRILINOS) - #message("Enabling Trilinos since PRESSIO_ENABLE_TPL_TRILINOS=${PRESSIO_ENABLE_TPL_TRILINOS}") - - # if we need to build tests, then find trilinos - if(PRESSIO_ENABLE_UNIT_TESTS OR PRESSIO_ENABLE_TESTS) - - if (NOT TRILINOS_ROOT) - message(FATAL_ERROR - "You enabled PRESSIO_ENABLE_TPL_TRILINOS but did not set TRILINOS_ROOT. - Please reconfigure with: - -D TRILINOS_ROOT= - ") - endif() - - set(TRILINOS_LIB_NAMES kokkosalgorithms - kokkoscontainers - kokkoscore - teuchoskokkoscomm - teuchoskokkoscompat - teuchosremainder - teuchosnumerics - teuchoscomm - teuchosparameterlist - teuchosparser - teuchoscore - epetra - epetraext - ifpack - aztecoo - tpetraext - tpetrainout - tpetra - kokkostsqr - tpetraclassiclinalg - tpetraclassicnodeapi - tpetraclassic - kokkoskernels - ifpack2 - triutils - # repeat to solve issue we have on linux - kokkosalgorithms - teuchosparameterlist) - - include_directories(${TRILINOS_ROOT}/include) - link_directories(${TRILINOS_ROOT}/lib ${TRILINOS_ROOT}/lib64) - link_libraries(${TRILINOS_LIB_NAMES}) - endif() -endif() diff --git a/cmake/version_parse.cmake b/cmake/version_parse.cmake deleted file mode 100644 index d95f6bb28..000000000 --- a/cmake/version_parse.cmake +++ /dev/null @@ -1,17 +0,0 @@ -function(get_version_number PATH_TO_FILE OUT) - file(READ ${PATH_TO_FILE} tmpver) - - string(FIND ${OUT} MAJOR wantMajor) - string(FIND ${OUT} MINOR wantMinor) - string(FIND ${OUT} PATCH wantPatch) - if (wantMajor GREATER -1) - string(REGEX MATCH "VERSION_MAJOR ([0-9]*)" _ ${tmpver}) - endif() - if (wantMinor GREATER -1) - string(REGEX MATCH "VERSION_MINOR ([0-9]*)" _ ${tmpver}) - endif() - if (wantPatch GREATER -1) - string(REGEX MATCH "VERSION_PATCH ([0-9]*)" _ ${tmpver}) - endif() - set(${OUT} ${CMAKE_MATCH_1} PARENT_SCOPE) -endfunction() \ No newline at end of file diff --git a/include/pressio/macros.hpp b/include/pressio/macros.hpp new file mode 100644 index 000000000..68fe1ecbe --- /dev/null +++ b/include/pressio/macros.hpp @@ -0,0 +1,129 @@ +/* +//@HEADER +// ************************************************************************ +// +// pressio_cmake_config.h.in +// Pressio +// Copyright 2019 +// National Technology & Engineering Solutions of Sandia, LLC (NTESS) +// +// Under the terms of Contract DE-NA0003525 with NTESS, the +// U.S. Government retains certain rights in this software. +// +// Pressio is licensed under BSD-3-Clause terms of use: +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// Questions? Contact Francesco Rizzi (fnrizzi@sandia.gov) +// +// ************************************************************************ +//@HEADER +*/ + +#ifndef PRESSIO_MACROS_HPP_ +#define PRESSIO_MACROS_HPP_ + +#define PRESSIO_MAJOR_VERSION 0 +#define PRESSIO_MINOR_VERSION 14 +#define PRESSIO_PATCH_VERSION 0 + +// ---------------------------------------- +// compiler version +// ---------------------------------------- +#ifdef _MSVC_LANG +#define _PRESSIO_CPLUSPLUS _MSVC_LANG +#else +#define _PRESSIO_CPLUSPLUS __cplusplus +#endif + +#define PRESSIO_CXX_STD_11 201103L +#define PRESSIO_CXX_STD_14 201402L +#define PRESSIO_CXX_STD_17 201703L +#define PRESSIO_CXX_STD_20 202002L +static_assert(_PRESSIO_CPLUSPLUS >= PRESSIO_CXX_STD_14, "PRESSIO requires C++14 or greater."); + +// #if !defined PRESSIO_ENABLE_CXX11 +// #define PRESSIO_ENABLE_CXX11 (_PRESSIO_CPLUSPLUS >= PRESSIO_CXX_STD_11) +// #endif + +#if defined PRESSIO_ENABLE_CXX20 +#define PRESSIO_ENABLE_CXX17 +#endif +#if defined PRESSIO_ENABLE_CXX17 +#define PRESSIO_ENABLE_CXX14 +#endif +#if defined PRESSIO_ENABLE_CXX14 +#define PRESSIO_ENABLE_CXX11 +#endif + +// ---------------------------------------- +// logging macros +// ---------------------------------------- +#define PRESSIO_LOG_LEVEL_TRACE 0 +#define PRESSIO_LOG_LEVEL_DEBUG 1 +#define PRESSIO_LOG_LEVEL_INFO 2 +#define PRESSIO_LOG_LEVEL_WARN 3 +#define PRESSIO_LOG_LEVEL_ERROR 4 +#define PRESSIO_LOG_LEVEL_CRITICAL 5 +#define PRESSIO_LOG_LEVEL_OFF 6 + +// if we are in debug mode, enable debug prints by default +#if !defined NDEBUG +#define PRESSIO_ENABLE_DEBUG_PRINT +#endif + +#if defined(PRESSIO_ENABLE_DEBUG_PRINT) && !defined(PRESSIO_LOG_ACTIVE_MIN_LEVEL) +// if DEBUG_PRINT is on but MIN_LEVEL off, then set min level to trace +#define PRESSIO_LOG_ACTIVE_MIN_LEVEL PRESSIO_LOG_LEVEL_TRACE +#elif !defined(PRESSIO_ENABLE_DEBUG_PRINT) && !defined(PRESSIO_LOG_ACTIVE_MIN_LEVEL) +// if DEBUG_PRINT=off and MIN_LEVEL=off, then set logging off +#define PRESSIO_LOG_ACTIVE_MIN_LEVEL PRESSIO_LOG_LEVEL_OFF +#else +//DEBUG_PRINT is off and LOG_ACTIVE_MIN_LEVEL=on, nothing to do +#endif + +// ---------------------------------------- +// TPL macros +// ---------------------------------------- +#if defined PRESSIO_ENABLE_TPL_TRILINOS +// if trilinos enabled, kokkos and MPI should be too +#if !defined PRESSIO_ENABLE_TPL_KOKKOS +#define PRESSIO_ENABLE_TPL_KOKKOS +#endif +#if !defined PRESSIO_ENABLE_TPL_MPI +#define PRESSIO_ENABLE_TPL_MPI +#endif +#if !defined PRESSIO_ENABLE_TEUCHOS_TIMERS +#define PRESSIO_ENABLE_TEUCHOS_TIMERS +#endif +#endif + +// static_assert(PRESSIO_ENABLE_TPL_EIGEN, ...) // TBD + +#endif diff --git a/include/pressio/mpl.hpp b/include/pressio/mpl.hpp index 708002152..ffe0cdeda 100644 --- a/include/pressio/mpl.hpp +++ b/include/pressio/mpl.hpp @@ -49,7 +49,7 @@ #ifndef PRESSIO_MPL_HPP_ #define PRESSIO_MPL_HPP_ -#include "./pressio_cmake_config.h" +#include "macros.hpp" #include "./mpl/mpl_ConfigDefs.hpp" diff --git a/include/pressio/pressio_cmake_config.h.in b/include/pressio/pressio_cmake_config.h.in deleted file mode 100644 index c65e39140..000000000 --- a/include/pressio/pressio_cmake_config.h.in +++ /dev/null @@ -1,64 +0,0 @@ -/* -//@HEADER -// ************************************************************************ -// -// pressio_cmake_config.h.in -// Pressio -// Copyright 2019 -// National Technology & Engineering Solutions of Sandia, LLC (NTESS) -// -// Under the terms of Contract DE-NA0003525 with NTESS, the -// U.S. Government retains certain rights in this software. -// -// Pressio is licensed under BSD-3-Clause terms of use: -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Francesco Rizzi (fnrizzi@sandia.gov) -// -// ************************************************************************ -//@HEADER -*/ - -#ifndef PRESSIO_CMAKE_CONFIG_H_ -#define PRESSIO_CMAKE_CONFIG_H_ - -#cmakedefine PRESSIO_DEBUG_BUILD -#cmakedefine PRESSIO_ENABLE_DEBUG_PRINT -#cmakedefine PRESSIO_ENABLE_TPL_EIGEN -#cmakedefine PRESSIO_ENABLE_TPL_TRILINOS -#cmakedefine PRESSIO_ENABLE_TEUCHOS_TIMERS -#cmakedefine PRESSIO_ENABLE_TPL_PYBIND11 -#cmakedefine PRESSIO_ENABLE_TPL_KOKKOS -#cmakedefine PRESSIO_ENABLE_TPL_MPI -#cmakedefine PRESSIO_ENABLE_CXX14 -#cmakedefine PRESSIO_ENABLE_CXX17 -#cmakedefine PRESSIO_ENABLE_CXX20 - -#endif diff --git a/include/pressio/utils.hpp b/include/pressio/utils.hpp index 2eafc005f..7c7f20a21 100644 --- a/include/pressio/utils.hpp +++ b/include/pressio/utils.hpp @@ -65,36 +65,7 @@ #include "./utils/io/utils_colorize_print.hpp" #include "./utils/io/utils_print_helper.hpp" -/* headers needed for logging */ - -// fmt is needed #include "./utils/logger/fmt/fmt.hpp" - -#define PRESSIO_LOG_LEVEL_TRACE 0 -#define PRESSIO_LOG_LEVEL_DEBUG 1 -#define PRESSIO_LOG_LEVEL_INFO 2 -#define PRESSIO_LOG_LEVEL_WARN 3 -#define PRESSIO_LOG_LEVEL_ERROR 4 -#define PRESSIO_LOG_LEVEL_CRITICAL 5 -#define PRESSIO_LOG_LEVEL_OFF 6 - - -// if DEBUG_PRINT is on but MIN_LEVEL off, then set min level to trace -#if defined(PRESSIO_ENABLE_DEBUG_PRINT) && !defined(PRESSIO_LOG_ACTIVE_MIN_LEVEL) - -#define PRESSIO_LOG_ACTIVE_MIN_LEVEL PRESSIO_LOG_LEVEL_TRACE - -// if DEBUG_PRINT=off and MIN_LEVEL=off, then set logging off -#elif !defined(PRESSIO_ENABLE_DEBUG_PRINT) && !defined(PRESSIO_LOG_ACTIVE_MIN_LEVEL) - -#define PRESSIO_LOG_ACTIVE_MIN_LEVEL PRESSIO_LOG_LEVEL_OFF - -#else //DEBUG_PRINT=off, but LOG_ACTIVE_MIN_LEVEL=on - -// nothing to do - -#endif - #include "./utils/logger/utils_logger_enums.hpp" #include "./utils/logger/utils_logger.hpp" #include "./utils/utils_noop.hpp" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index caa230509..784b15fef 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,30 +1,164 @@ +option(PRESSIO_ENABLE_CXX11 "bla bla" OFF) +option(PRESSIO_ENABLE_CXX14 "bla bla" OFF) +option(PRESSIO_ENABLE_CXX17 "bla bla" OFF) +option(PRESSIO_ENABLE_CXX20 "bla bla" OFF) -include_directories(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/include) +option(PRESSIO_ENABLE_DEBUG_PRINT "bla bla" OFF) +option(PRESSIO_ENABLE_TPL_EIGEN "bla bla" OFF) +option(PRESSIO_ENABLE_TPL_TRILINOS "bla bla" OFF) +# option(PRESSIO_ENABLE_TEUCHOS_TIMERS "bla bla" OFF) +# option(PRESSIO_ENABLE_TPL_KOKKOS "bla bla" OFF) +# option(PRESSIO_ENABLE_TPL_MPI "bla bla" OFF) -# set where all the mains for google tests are -set(GTESTMAINSDIR "${CMAKE_CURRENT_SOURCE_DIR}/gtest_mains") -message(">> Google tests main files are in: " ${GTESTMAINSDIR}) - -# we need Gtest for unit tests -find_package(GTest REQUIRED) -if (NOT GTEST_FOUND) -message(FATAL_ERROR - "Trying to build unit_tests but I cannot find GTest. - Please reconfigure using -DGTEST_ROOT=. - The GTEST_ROOT should have a lib and include subdirs.") +if (CMAKE_CXX_STANDARD EQUAL 14) + add_definitions(-DPRESSIO_ENABLE_CXX14) + message(STATUS "cxx_std1 = ${CMAKE_CXX_STANDARD}") +elseif(CMAKE_CXX_STANDARD EQUAL 17) + add_definitions(-DPRESSIO_ENABLE_CXX17) + message(STATUS "cxx_std2 = ${CMAKE_CXX_STANDARD}") +elseif(CMAKE_CXX_STANDARD EQUAL 20) + add_definitions(-DPRESSIO_ENABLE_CXX20) + message(STATUS "cxx_std3 = ${CMAKE_CXX_STANDARD}") endif() -include(macrosForCreatingUnitTests) -include(macrosForCreatingTests) +if (PRESSIO_ENABLE_DEBUG_PRINT) + add_definitions(-DPRESSIO_ENABLE_DEBUG_PRINT) +endif() -if(PRESSIO_ENABLE_FUNCTIONAL_SMALL_TESTS OR PRESSIO_ENABLE_TESTS) - add_subdirectory(functional_small) +if(PRESSIO_ENABLE_TPL_EIGEN) + if(NOT EIGEN_INCLUDE_DIR) + message(FATAL_ERROR + "I cannot find the Eigen headers. " + "Please reconfigure with: -DEIGEN_INCLUDE_DIR=") + endif() + include_directories(${EIGEN_INCLUDE_DIR}) + add_definitions(-DPRESSIO_ENABLE_TPL_EIGEN) endif() -if(PRESSIO_ENABLE_FUNCTIONAL_MEDIUM_TESTS OR PRESSIO_ENABLE_TESTS) - add_subdirectory(functional_medium) +if(PRESSIO_ENABLE_TPL_TRILINOS) + find_package(trilinos REQUIRED) + add_definitions(-DPRESSIO_ENABLE_TPL_TRILINOS) + + # FINISH THIS +endif() + +# if(PRESSIO_ENABLE_TPL_MPI) +# find_package(MPI REQUIRED) +# include_directories(${MPI_CXX_INCLUDE_DIRS}) +# endif() + +# if(PRESSIO_ENABLE_TPL_KOKKOS AND NOT PRESSIO_ENABLE_TPL_TRILINOS) +# find_package(KokkosKernels REQUIRED) +# set(KOKKOS_LIBS Kokkos::kokkoskernels) +# #Kokkos::BLAS Kokkos::LAPACK Kokkos::kokkos Kokkos::kokkoskernels) +# endif() + +# --------------------------------- +# 1. find or get gtest +# --------------------------------- +# adapted from Kokkos +find_package(GTest QUIET) +if (GTEST_FOUND) + add_library(gtest_main ALIAS GTest::gtest_main) + message(STATUS "GTest found at ${GTEST_INCLUDE_DIRS}") +else() + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/googletest/CMakeLists.txt.in + googletest-download/CMakeLists.txt) + execute_process( + COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download + ) + if(result) + message(FATAL_ERROR "Configure step for googletest failed: ${result}") + endif() + + execute_process( + COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download + ) + if(result) + message(FATAL_ERROR "Build step for googletest failed: ${result}") + endif() + + # Add googletest directly to our build. This defines the gtest and gtest_main targets. + add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src + ${CMAKE_CURRENT_BINARY_DIR}/googletest-build EXCLUDE_FROM_ALL) endif() -if(PRESSIO_ENABLE_FUNCTIONAL_LARGE_TESTS OR PRESSIO_ENABLE_TESTS) - add_subdirectory(functional_large) +# --------------------------------- +# 2. where all mains are +# --------------------------------- +set(GTESTMAINSDIR "${CMAKE_CURRENT_SOURCE_DIR}/gtest_mains") +message("${Magenta}>> Google tests main files are in: ${GTESTMAINSDIR} ${ColourReset}") + +# --------------------------------- +# 3. macros for createing unit tests +# --------------------------------- +macro(add_serial_utest TESTNAME) + set(testNameFinal ${TESTNAME}) + add_executable(${testNameFinal} ${ARGN} ${GTESTMAINSDIR}/gTestMain_serial.cc) + target_link_libraries(${testNameFinal} pressio gtest_main) + add_test(NAME ${testNameFinal} COMMAND ${testNameFinal}) +endmacro() + +macro(add_serial_utest_kokkos TESTNAME TESTSRCS) + set(testNameFinal ${TESTNAME}) + add_executable(${testNameFinal} ${TESTSRCS} ${GTESTMAINSDIR}/gTestMain_kokkos.cc) + target_link_libraries(${testNameFinal} ${KOKKOS_LIBS} pressio gtest_main) + add_test(NAME ${testNameFinal} COMMAND ${testNameFinal}) +endmacro() + +# macro(add_utest_mpi TESTNAME TESTSRCS gMAIN nRANKS) +# set(testNameFinal ${TESTNAME}_np${nRANKS}) +# add_executable(${testNameFinal} ${TESTSRCS} ${GTESTMAINSDIR}/${gMAIN}.cc) +# target_link_libraries(${testNameFinal} ${MPI_CXX_LIBRARIES} gtest_main) +# add_test( +# NAME ${testNameFinal} +# COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${nRANKS} +# ${MPIEXEC_PREFLAGS} ${testNameFinal} ${MPIEXEC_POSTFLAGS} +# ) +# endmacro() +#===================================================================== + +# # macro to create and add an individual SERIAL test +# macro(add_serial_exe_and_test TESTNAME PKGNAME TESTSRCS REGEX) +# set(testNameFinal ${PKGNAME}_${TESTNAME}) +# add_executable(${testNameFinal} ${TESTSRCS}) +# add_test(NAME ${testNameFinal} COMMAND ${testNameFinal}) +# set_tests_properties( +# ${testNameFinal} +# PROPERTIES PASS_REGULAR_EXPRESSION ${REGEX} FAIL_REGULAR_EXPRESSION "FAILED" +# ) +# endmacro() +# #===================================================================== + +# macro(add_mpi_exe_and_test TESTNAME PKGNAME TESTSRCS nRANKS REGEXOK) +# set(testNameFinal ${PKGNAME}_${TESTNAME}_np${nRANKS}) +# add_executable(${testNameFinal} ${TESTSRCS}) +# target_link_libraries(${testNameFinal} ${MPI_CXX_LIBRARIES}) +# add_test( +# NAME ${testNameFinal} +# COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${nRANKS} +# ${MPIEXEC_PREFLAGS} ${testNameFinal} ${MPIEXEC_POSTFLAGS} +# ) +# set_tests_properties( +# ${testNameFinal} +# PROPERTIES PASS_REGULAR_EXPRESSION ${REGEXOK} FAIL_REGULAR_EXPRESSION "FAILED" +# ) +# endmacro() +# #===================================================================== + +if(PRESSIO_ENABLE_FUNCTIONAL_SMALL_TESTS OR PRESSIO_ENABLE_TESTS) + add_subdirectory(functional_small) endif() + +# if(PRESSIO_ENABLE_FUNCTIONAL_MEDIUM_TESTS OR PRESSIO_ENABLE_TESTS) +# add_subdirectory(functional_medium) +# endif() + +# if(PRESSIO_ENABLE_FUNCTIONAL_LARGE_TESTS OR PRESSIO_ENABLE_TESTS) +# add_subdirectory(functional_large) +# endif() diff --git a/tests/cmake/googletest/CMakeLists.txt.in b/tests/cmake/googletest/CMakeLists.txt.in new file mode 100644 index 000000000..5e808996a --- /dev/null +++ b/tests/cmake/googletest/CMakeLists.txt.in @@ -0,0 +1,16 @@ +# from https://github.com/google/googletest/blob/master/googletest/README.md +cmake_minimum_required(VERSION 3.0) + +project(googletest-download NONE) + +include(ExternalProject) +ExternalProject_Add(googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG main + SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" +) diff --git a/cmake/macrosForCreatingTests.cmake b/tests/cmake/macrosForCreatingTests.cmake similarity index 100% rename from cmake/macrosForCreatingTests.cmake rename to tests/cmake/macrosForCreatingTests.cmake diff --git a/tests/cmake/macrosForCreatingUnitTests.cmake b/tests/cmake/macrosForCreatingUnitTests.cmake new file mode 100644 index 000000000..26adda3c9 --- /dev/null +++ b/tests/cmake/macrosForCreatingUnitTests.cmake @@ -0,0 +1,15 @@ + +# this function creates and adds an individual SERIAL unit-test +macro(add_serial_utest TESTNAME) + # set name of the executable + set(testNameFinal ${TESTNAME}) + + add_executable(${testNameFinal} + ${ARGN} ${GTESTMAINSDIR}/gTestMain_serial.cc) + + target_link_libraries(${testNameFinal} + GTest::gtest GTest::Main) + + add_test(NAME ${testNameFinal} COMMAND ${testNameFinal}) +endmacro() +#===================================================================== diff --git a/tests/cmake/tpls.cmake b/tests/cmake/tpls.cmake new file mode 100644 index 000000000..d7a39644c --- /dev/null +++ b/tests/cmake/tpls.cmake @@ -0,0 +1,170 @@ +# if(PRESSIO_ENABLE_TPL_BLAS) +# message(">> Enabling BLAS since PRESSIO_ENABLE_TPL_BLAS=ON ==> enabling also LAPACK") +# set(PRESSIO_ENABLE_TPL_LAPACK ON) +# endif() +# if(PRESSIO_ENABLE_TPL_LAPACK) +# message(">> Enabling LAPACK since PRESSIO_ENABLE_TPL_LAPACK=ON ==> enabling also BLAS") +# set(PRESSIO_ENABLE_TPL_BLAS ON) +# endif() + +if(PRESSIO_ENABLE_TPL_MPI) + if(PRESSIO_ENABLE_UNIT_TESTS OR PRESSIO_ENABLE_TESTS) + find_package(MPI REQUIRED) + include_directories(${MPI_CXX_INCLUDE_PATH}) + endif() +endif() + + +if(PRESSIO_ENABLE_TPL_BLAS OR PRESSIO_ENABLE_TPL_TRILINOS) + # check if BLAS_ROOT is specified + if (NOT ${BLAS_ROOT}) + message("") + message(FATAL_ERROR "BLAS_ROOT not speificed, terminating") + message("Make sure you set the BLAS_ROOT env var") + endif() + + cmake_policy(SET CMP0074 NEW) + find_package(BLAS REQUIRED) + link_libraries(${BLAS_LIBRARIES}) + message("") +endif() + +if(PRESSIO_ENABLE_TPL_LAPACK) + if(PRESSIO_ENABLE_UNIT_TESTS OR PRESSIO_ENABLE_TESTS) + # check if LAPACK_ROOT is specified + if (NOT ${LAPACK_ROOT}) + message("") + message(FATAL_ERROR "LAPACK_ROOT not speificed, terminating") + message("Make sure you set the LAPACK_ROOT env var") + endif() + + cmake_policy(SET CMP0074 NEW) + find_package( LAPACK REQUIRED ) + link_libraries(${LAPACK_LIBRARIES}) + message("LAPLIBS=${LAPACK_LIBRARIES}") + endif() +endif() + + +if(PRESSIO_ENABLE_TPL_EIGEN) + if(PRESSIO_ENABLE_UNIT_TESTS OR PRESSIO_ENABLE_TESTS) + + if(NOT EIGEN_INC_DIR AND NOT EIGEN_INCLUDE_DIR) + message(FATAL_ERROR + "I cannot find the Eigen headers. Please reconfigure with: + -DEIGEN_INC_DIR= + or + -DEIGEN_INCLUDE_DIR= + ") + endif() + + if(NOT EIGEN_INC_DIR AND EIGEN_INCLUDE_DIR) + set(EIGEN_INC_DIR ${EIGEN_INCLUDE_DIR}) + endif() + + include_directories(${EIGEN_INC_DIR}) + endif() +endif() + + +if(PRESSIO_ENABLE_TPL_KOKKOS) + if(PRESSIO_ENABLE_UNIT_TESTS OR PRESSIO_ENABLE_TESTS) + + # # when trilinos is also enabled it links kokkos too, see tplTrilinos.cmake + if(NOT PRESSIO_ENABLE_TPL_TRILINOS) + # if kokkos is used as standalone lib, then we are more specific + # user needs to defined: KOKKOS_ROOT_DIR and KOKKOS_KERNELS_ROOT_DIR + if (NOT KOKKOS_ROOT OR NOT KOKKOS_KERNELS_ROOT) + message(FATAL_ERROR "Missing KOKKOS_ROOT. KOKKOS needs: + -D KOKKOS_ROOT= + -D KOKKOS_KERNELS_ROOT= + ") + endif() + + set(KOKKOS_LIB_NAMES kokkoscontainers kokkoscore kokkoskernels) + + include_directories(${KOKKOS_ROOT}/include ${KOKKOS_KERNELS_ROOT}/include) + + link_directories(${KOKKOS_ROOT}/lib ${KOKKOS_ROOT}/lib64 + ${KOKKOS_KERNELS_ROOT}/lib ${KOKKOS_KERNELS_ROOT}/lib64) + + link_libraries(${KOKKOS_LIB_NAMES}) + endif() + + endif() +endif() + + +if(PRESSIO_ENABLE_TPL_TRILINOS) + if(PRESSIO_ENABLE_UNIT_TESTS OR PRESSIO_ENABLE_TESTS) + if (NOT TRILINOS_ROOT) + message(FATAL_ERROR + "You enabled PRESSIO_ENABLE_TPL_TRILINOS but did not set TRILINOS_ROOT. + Please reconfigure with: + -D TRILINOS_ROOT= + ") + endif() + + set(TRILINOS_LIB_NAMES kokkosalgorithms + kokkoscontainers + kokkoscore + teuchoskokkoscomm + teuchoskokkoscompat + teuchosremainder + teuchosnumerics + teuchoscomm + teuchosparameterlist + teuchosparser + teuchoscore + epetra + epetraext + ifpack + aztecoo + tpetraext + tpetrainout + tpetra + kokkostsqr + tpetraclassiclinalg + tpetraclassicnodeapi + tpetraclassic + kokkoskernels + ifpack2 + triutils + # repeat to solve issue we have on linux + kokkosalgorithms + teuchosparameterlist) + + include_directories(${TRILINOS_ROOT}/include) + link_directories(${TRILINOS_ROOT}/lib ${TRILINOS_ROOT}/lib64) + link_libraries(${TRILINOS_LIB_NAMES}) + endif() +endif() + + +# function(pybind11_fatal) +# message(FATAL_ERROR "I cannot find the Pybind11 library. +# To use it, please reconfigure with: +# -D PYBIND11_ROOT=") +# endfunction() + +# if(PRESSIO_ENABLE_TPL_PYBIND11) +# message("Found PRESSIO_ENABLE_TPL_PYBIND11=${PRESSIO_ENABLE_TPL_PYBIND11}.") + +# # if we need to build tests, then prep for it +# if(PRESSIO_ENABLE_UNIT_TESTS OR PRESSIO_ENABLE_TESTS) + +# # if PYBIND11_ROOT not found +# if (NOT PYBIND11_ROOT) +# pybind11_fatal() +# endif() + +# find_package(pybind11 REQUIRED PATHS ${PYBIND11_ROOT}/share/cmake) +# find_package(Python3 COMPONENTS Interpreter NumPy) + +# include_directories(${Python3_INCLUDE_DIRS} ${PYBIND11_ROOT}/include) + +# if(NOT ${Python3_FOUND}) +# message(FATAL_ERROR "Python > 3 not found") +# endif() +# endif() +# endif() diff --git a/tests/functional_small/CMakeLists.txt b/tests/functional_small/CMakeLists.txt index c6c258a20..ad8285909 100644 --- a/tests/functional_small/CMakeLists.txt +++ b/tests/functional_small/CMakeLists.txt @@ -1,4 +1,3 @@ - set(TESTING_LEVEL functional_small) add_subdirectory(mpl) @@ -6,9 +5,9 @@ add_subdirectory(utils) add_subdirectory(type_traits) add_subdirectory(expressions) add_subdirectory(ops) -add_subdirectory(qr) -add_subdirectory(solvers_linear) -add_subdirectory(solvers_nonlinear) -add_subdirectory(ode_advancers) -add_subdirectory(ode_steppers) -add_subdirectory(rom) +# add_subdirectory(qr) +# add_subdirectory(solvers_linear) +# add_subdirectory(solvers_nonlinear) +# add_subdirectory(ode_advancers) +# add_subdirectory(ode_steppers) +# add_subdirectory(rom) diff --git a/version.txt b/version.txt index 4989a7ebf..9d6585c25 100644 --- a/version.txt +++ b/version.txt @@ -1,3 +1 @@ -VERSION_MAJOR 0 -VERSION_MINOR 14 -VERSION_PATCH 0 \ No newline at end of file +Version is defined in lines 52-54 of pressio/include/pressio/macros.hpp From 7c96e3edbd81994cf6714a140b11fc22f6b2b87b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 29 Aug 2023 12:28:46 +0200 Subject: [PATCH 04/56] Avoid macro redefinition --- include/pressio/macros.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pressio/macros.hpp b/include/pressio/macros.hpp index 68fe1ecbe..9c9eef94f 100644 --- a/include/pressio/macros.hpp +++ b/include/pressio/macros.hpp @@ -94,7 +94,7 @@ static_assert(_PRESSIO_CPLUSPLUS >= PRESSIO_CXX_STD_14, "PRESSIO requires C++14 #define PRESSIO_LOG_LEVEL_OFF 6 // if we are in debug mode, enable debug prints by default -#if !defined NDEBUG +#if !defined NDEBUG && !defined PRESSIO_ENABLE_DEBUG_PRINT #define PRESSIO_ENABLE_DEBUG_PRINT #endif From 0558a6c522606801591e817a6f4361c8dfb38a50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 29 Aug 2023 13:50:13 +0200 Subject: [PATCH 05/56] ci: remove redundant parameters --- .github/workflows/ci-baseline.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci-baseline.yml b/.github/workflows/ci-baseline.yml index c88f080e3..cb504c686 100644 --- a/.github/workflows/ci-baseline.yml +++ b/.github/workflows/ci-baseline.yml @@ -58,9 +58,6 @@ jobs: num_cpus: 2 eigen_inc_dir: /usr/local/eigen/install/include/eigen3 gtest_dir: /usr/local/gtest/install - small: small - medium: medium - large: large steps: - uses: actions/checkout@v3 @@ -81,22 +78,22 @@ jobs: -D CMAKE_CXX_FLAGS='' # In this stage small functional tests are built and run - - name: build-test-${{ env.small }} + - name: build-test-small run: | - cd builddir/tests/functional_${{ env.small }} + cd builddir/tests/functional_small make -j $num_cpus ctest -j $num_cpus --output-on-failure # In this stage medium functional tests are built and run - - name: build-test-${{ env.medium }} + - name: build-test-medium run: | - cd builddir/tests/functional_${{ env.medium }} + cd builddir/tests/functional_medium make -j $num_cpus ctest -j $num_cpus --output-on-failure # In this stage large functional tests are built and run - - name: build-test-${{ env.large }} + - name: build-test-large run: | - cd builddir/tests/functional_${{ env.large }} + cd builddir/tests/functional_large make -j $num_cpus ctest -j $num_cpus --output-on-failure From 16d88a6face2b6d3ba03cd5809bf6a8791c65e20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 29 Aug 2023 14:20:45 +0200 Subject: [PATCH 06/56] ci: simplify baseline workflow --- .github/workflows/ci-baseline.yml | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci-baseline.yml b/.github/workflows/ci-baseline.yml index cb504c686..ab3c861a8 100644 --- a/.github/workflows/ci-baseline.yml +++ b/.github/workflows/ci-baseline.yml @@ -77,23 +77,11 @@ jobs: -D CMAKE_INSTALL_PREFIX:PATH=../install \ -D CMAKE_CXX_FLAGS='' - # In this stage small functional tests are built and run - - name: build-test-small + - name: build run: | - cd builddir/tests/functional_small - make -j $num_cpus - ctest -j $num_cpus --output-on-failure - - # In this stage medium functional tests are built and run - - name: build-test-medium - run: | - cd builddir/tests/functional_medium - make -j $num_cpus - ctest -j $num_cpus --output-on-failure + cmake --build builddir - # In this stage large functional tests are built and run - - name: build-test-large + - name: test + working-directory: builddir run: | - cd builddir/tests/functional_large - make -j $num_cpus ctest -j $num_cpus --output-on-failure From 12b4cee2233a7b1a90fa09fa71bfb6868920adad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 29 Aug 2023 14:31:58 +0200 Subject: [PATCH 07/56] ci: simplify workflows and make them more consistent --- .github/workflows/ci-baseline.yml | 50 +++++++++++++------------------ .github/workflows/ci-cxx20.yml | 2 -- 2 files changed, 20 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci-baseline.yml b/.github/workflows/ci-baseline.yml index ab3c861a8..16b074aba 100644 --- a/.github/workflows/ci-baseline.yml +++ b/.github/workflows/ci-baseline.yml @@ -28,32 +28,22 @@ jobs: CI: name: baseline continue-on-error: false - strategy: max-parallel: 10 fail-fast: false matrix: - config: - # os: Stands for OS on GitHub Runner (Ubuntu / MacOS / Windows) - # image: Stands for used Docker Image - # mode: Stands for build mode inside Pressio (Debug / Release) - - { os: ubuntu-latest, image: ubuntu-20.04-gnu_9-eigen_3.3.7-gtest, mode: Release } - - { os: ubuntu-latest, image: ubuntu-20.04-gnu_9-eigen_3.3.7-gtest, mode: Debug } - - - { os: ubuntu-latest, image: ubuntu-20.04-clang_9-eigen_3.3.7-gtest, mode: Release } - - { os: ubuntu-latest, image: ubuntu-20.04-clang_9-eigen_3.3.7-gtest, mode: Debug } - - - { os: ubuntu-latest, image: fedora-34-gnu_11-eigen_3.3.7-gtest, mode: Release } - - { os: ubuntu-latest, image: fedora-34-gnu_11-eigen_3.3.7-gtest, mode: Debug } + image: + - ubuntu-20.04-gnu_9-eigen_3.3.7-gtest + - ubuntu-20.04-clang_9-eigen_3.3.7-gtest + - fedora-34-gnu_11-eigen_3.3.7-gtest + - fedora-34-clang_12-eigen_3.3.7-gtest + #- intel_oneapi-eigen_3.3.7-gtest + build_type: + - Release + - Debug - - { os: ubuntu-latest, image: fedora-34-clang_12-eigen_3.3.7-gtest, mode: Release } - - { os: ubuntu-latest, image: fedora-34-clang_12-eigen_3.3.7-gtest, mode: Debug } - - #- { os: ubuntu-latest, image: intel_oneapi-eigen_3.3.7-gtest, mode: Release } - #- { os: ubuntu-latest, image: intel_oneapi-eigen_3.3.7-gtest, mode: Debug } - - runs-on: ${{ matrix.config.os }} - container: pressiomodelreduction/${{ matrix.config.image }} + runs-on: ubuntu-latest + container: pressiomodelreduction/${{ matrix.image }} env: num_cpus: 2 eigen_inc_dir: /usr/local/eigen/install/include/eigen3 @@ -62,26 +52,26 @@ jobs: steps: - uses: actions/checkout@v3 - - name: configure + - name: Configure run: | cmake -B builddir \ - -D CMAKE_BUILD_TYPE:STRING=${{ matrix.config.mode }} \ - -D CMAKE_VERBOSE_MAKEFILE:BOOL=ON \ + -D CMAKE_BUILD_TYPE:STRING=${{ matrix.build_type }} \ -D CMAKE_C_COMPILER=$CC \ -D CMAKE_CXX_COMPILER=$CXX \ - -D PRESSIO_ENABLE_TPL_EIGEN:BOOL=ON \ - -D EIGEN_INCLUDE_DIR=$eigen_inc_dir \ + -D CMAKE_CXX_FLAGS='' \ + -D CMAKE_INSTALL_PREFIX:PATH=../install \ + -D CMAKE_VERBOSE_MAKEFILE:BOOL=ON \ -D GTEST_ROOT=$gtest_dir \ -D PRESSIO_ENABLE_DEBUG_PRINT=ON \ -D PRESSIO_ENABLE_TESTS:BOOL=ON \ - -D CMAKE_INSTALL_PREFIX:PATH=../install \ - -D CMAKE_CXX_FLAGS='' + -D PRESSIO_ENABLE_TPL_EIGEN:BOOL=ON \ + -D EIGEN_INCLUDE_DIR=$eigen_inc_dir - - name: build + - name: Build run: | cmake --build builddir - - name: test + - name: Test working-directory: builddir run: | ctest -j $num_cpus --output-on-failure diff --git a/.github/workflows/ci-cxx20.yml b/.github/workflows/ci-cxx20.yml index 5807a250b..21b013df7 100644 --- a/.github/workflows/ci-cxx20.yml +++ b/.github/workflows/ci-cxx20.yml @@ -40,9 +40,7 @@ jobs: # - Debug # disable to reduce number of jobs runs-on: ubuntu-latest - container: pressiomodelreduction/${{ matrix.image }} - env: num_cpus: 2 # $(cat /proc/cpuinfo | grep processor -c) eigen_inc_dir: /usr/local/eigen/install/include/eigen3 From 390362438e48153315429ced5bdbaee1839fb5dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 29 Aug 2023 14:40:58 +0200 Subject: [PATCH 08/56] ci: use single workflow for baseline and cxx20 --- .github/workflows/ci-baseline.yml | 19 ++++++++- .github/workflows/ci-cxx20.yml | 71 ------------------------------- 2 files changed, 17 insertions(+), 73 deletions(-) delete mode 100644 .github/workflows/ci-cxx20.yml diff --git a/.github/workflows/ci-baseline.yml b/.github/workflows/ci-baseline.yml index 16b074aba..06f8f8a43 100644 --- a/.github/workflows/ci-baseline.yml +++ b/.github/workflows/ci-baseline.yml @@ -29,7 +29,6 @@ jobs: name: baseline continue-on-error: false strategy: - max-parallel: 10 fail-fast: false matrix: image: @@ -41,11 +40,26 @@ jobs: build_type: - Release - Debug + cmake_extra_args: + - '' + include: + - image: ubuntu-20.04_gnu-11_eigen-3.3.7_gtest + build_type: Release + cmake_extra_args: '-D CMAKE_CXX_STANDARD=20 -D PRESSIO_ENABLE_CXX20=ON' + - image: ubuntu-20.04_clang-12_eigen-3.3.7_gtest + build_type: Release + cmake_extra_args: '-D CMAKE_CXX_STANDARD=20 -D PRESSIO_ENABLE_CXX20=ON' + - image: fedora-34-gnu_11-eigen_3.3.7-gtest + build_type: Release + cmake_extra_args: '-D CMAKE_CXX_STANDARD=20 -D PRESSIO_ENABLE_CXX20=ON' + - image: fedora-34-clang_12-eigen_3.3.7-gtest + build_type: Release + cmake_extra_args: '-D CMAKE_CXX_STANDARD=20 -D PRESSIO_ENABLE_CXX20=ON' runs-on: ubuntu-latest container: pressiomodelreduction/${{ matrix.image }} env: - num_cpus: 2 + num_cpus: 2 # $(cat /proc/cpuinfo | grep processor -c) eigen_inc_dir: /usr/local/eigen/install/include/eigen3 gtest_dir: /usr/local/gtest/install @@ -61,6 +75,7 @@ jobs: -D CMAKE_CXX_FLAGS='' \ -D CMAKE_INSTALL_PREFIX:PATH=../install \ -D CMAKE_VERBOSE_MAKEFILE:BOOL=ON \ + ${{ matrix.cmake_extra_args }} \ -D GTEST_ROOT=$gtest_dir \ -D PRESSIO_ENABLE_DEBUG_PRINT=ON \ -D PRESSIO_ENABLE_TESTS:BOOL=ON \ diff --git a/.github/workflows/ci-cxx20.yml b/.github/workflows/ci-cxx20.yml deleted file mode 100644 index 21b013df7..000000000 --- a/.github/workflows/ci-cxx20.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: github-Linux-cxx20 - -on: - pull_request: - types: [ opened, reopened, synchronize ] - paths-ignore: - - 'logos/**' - - 'helper_scripts/**' - - 'docker_scripts/**' - - 'docs/**' - - '**/*.md' - push: # for direct quick fixes - branches: - - 'main' - - 'develop' - paths-ignore: - - 'logos/**' - - 'helper_scripts/**' - - 'docker_scripts/**' - - 'docs/**' - - '**/*.md' - -concurrency: - group: ${ {github.event_name }}-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{github.event_name == 'pull_request'}} - -jobs: - CI-cxx20: - name: cxx20 - strategy: - matrix: - image: - - ubuntu-20.04_gnu-11_eigen-3.3.7_gtest - - ubuntu-20.04_clang-12_eigen-3.3.7_gtest - - fedora-34-gnu_11-eigen_3.3.7-gtest - - fedora-34-clang_12-eigen_3.3.7-gtest - #- intel-oneapi-2022.2.0_eigen-3.3.7_gtest - build_type: - - Release - # - Debug # disable to reduce number of jobs - - runs-on: ubuntu-latest - container: pressiomodelreduction/${{ matrix.image }} - env: - num_cpus: 2 # $(cat /proc/cpuinfo | grep processor -c) - eigen_inc_dir: /usr/local/eigen/install/include/eigen3 - gtest_dir: /usr/local/gtest/install/ - - steps: - - uses: actions/checkout@v3 - - - name: Configure - run: | - cmake -B builddir \ - -D CMAKE_BUILD_TYPE:STRING=${{ matrix.build_type }} \ - -D CMAKE_CXX_STANDARD=20 \ - -D CMAKE_VERBOSE_MAKEFILE:BOOL=ON \ - -D GTEST_ROOT=$gtest_dir \ - -D EIGEN_INCLUDE_DIR=$eigen_inc_dir \ - -D PRESSIO_ENABLE_TPL_EIGEN:BOOL=ON \ - -D PRESSIO_ENABLE_DEBUG_PRINT=ON \ - -D PRESSIO_ENABLE_TESTS:BOOL=ON \ - -D PRESSIO_ENABLE_CXX17:BOOL=OFF \ - -D PRESSIO_ENABLE_CXX20:BOOL=ON - - - name: Build - run: cmake --build builddir -j $num_cpus - - - name: Test - working-directory: builddir - run: ctest -j $num_cpus --output-on-failure From 371ae432a06bdb832b3f07281e7b380091081c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 29 Aug 2023 14:56:46 +0200 Subject: [PATCH 09/56] Remove C++11 support --- include/pressio/macros.hpp | 7 ------- tests/CMakeLists.txt | 1 - 2 files changed, 8 deletions(-) diff --git a/include/pressio/macros.hpp b/include/pressio/macros.hpp index 9c9eef94f..8639b43fb 100644 --- a/include/pressio/macros.hpp +++ b/include/pressio/macros.hpp @@ -68,19 +68,12 @@ #define PRESSIO_CXX_STD_20 202002L static_assert(_PRESSIO_CPLUSPLUS >= PRESSIO_CXX_STD_14, "PRESSIO requires C++14 or greater."); -// #if !defined PRESSIO_ENABLE_CXX11 -// #define PRESSIO_ENABLE_CXX11 (_PRESSIO_CPLUSPLUS >= PRESSIO_CXX_STD_11) -// #endif - #if defined PRESSIO_ENABLE_CXX20 #define PRESSIO_ENABLE_CXX17 #endif #if defined PRESSIO_ENABLE_CXX17 #define PRESSIO_ENABLE_CXX14 #endif -#if defined PRESSIO_ENABLE_CXX14 -#define PRESSIO_ENABLE_CXX11 -#endif // ---------------------------------------- // logging macros diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 784b15fef..f195b12c3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,3 @@ -option(PRESSIO_ENABLE_CXX11 "bla bla" OFF) option(PRESSIO_ENABLE_CXX14 "bla bla" OFF) option(PRESSIO_ENABLE_CXX17 "bla bla" OFF) option(PRESSIO_ENABLE_CXX20 "bla bla" OFF) From a7341ea728b4d0587ac5464c18aa11cde2935113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 29 Aug 2023 15:09:40 +0200 Subject: [PATCH 10/56] tests: improve CMake output --- tests/CMakeLists.txt | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f195b12c3..a40f9117b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,23 +1,22 @@ -option(PRESSIO_ENABLE_CXX14 "bla bla" OFF) -option(PRESSIO_ENABLE_CXX17 "bla bla" OFF) -option(PRESSIO_ENABLE_CXX20 "bla bla" OFF) +include(CMakePrintHelpers) -option(PRESSIO_ENABLE_DEBUG_PRINT "bla bla" OFF) -option(PRESSIO_ENABLE_TPL_EIGEN "bla bla" OFF) -option(PRESSIO_ENABLE_TPL_TRILINOS "bla bla" OFF) +option(PRESSIO_ENABLE_CXX14 "Enable C++14" OFF) +option(PRESSIO_ENABLE_CXX17 "Enable C++17" OFF) +option(PRESSIO_ENABLE_CXX20 "Enable C++20" OFF) + +option(PRESSIO_ENABLE_DEBUG_PRINT "Enable debug printing" OFF) +option(PRESSIO_ENABLE_TPL_EIGEN "Enable Eigen TPL" OFF) +option(PRESSIO_ENABLE_TPL_TRILINOS "Enable Trilinos TPL" OFF) # option(PRESSIO_ENABLE_TEUCHOS_TIMERS "bla bla" OFF) # option(PRESSIO_ENABLE_TPL_KOKKOS "bla bla" OFF) # option(PRESSIO_ENABLE_TPL_MPI "bla bla" OFF) if (CMAKE_CXX_STANDARD EQUAL 14) add_definitions(-DPRESSIO_ENABLE_CXX14) - message(STATUS "cxx_std1 = ${CMAKE_CXX_STANDARD}") elseif(CMAKE_CXX_STANDARD EQUAL 17) add_definitions(-DPRESSIO_ENABLE_CXX17) - message(STATUS "cxx_std2 = ${CMAKE_CXX_STANDARD}") elseif(CMAKE_CXX_STANDARD EQUAL 20) add_definitions(-DPRESSIO_ENABLE_CXX20) - message(STATUS "cxx_std3 = ${CMAKE_CXX_STANDARD}") endif() if (PRESSIO_ENABLE_DEBUG_PRINT) @@ -56,11 +55,13 @@ endif() # 1. find or get gtest # --------------------------------- # adapted from Kokkos -find_package(GTest QUIET) +find_package(GTest REQUIRED) if (GTEST_FOUND) add_library(gtest_main ALIAS GTest::gtest_main) - message(STATUS "GTest found at ${GTEST_INCLUDE_DIRS}") + cmake_print_variables(GTEST_INCLUDE_DIRS) else() + # FIXME: use FetchContent_MakeAvailable? + # don't forget to remove tests/cmake/googletest/CMakeLists.txt.in configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/googletest/CMakeLists.txt.in googletest-download/CMakeLists.txt) @@ -154,10 +155,10 @@ if(PRESSIO_ENABLE_FUNCTIONAL_SMALL_TESTS OR PRESSIO_ENABLE_TESTS) add_subdirectory(functional_small) endif() -# if(PRESSIO_ENABLE_FUNCTIONAL_MEDIUM_TESTS OR PRESSIO_ENABLE_TESTS) -# add_subdirectory(functional_medium) -# endif() +if(PRESSIO_ENABLE_FUNCTIONAL_MEDIUM_TESTS OR PRESSIO_ENABLE_TESTS) + add_subdirectory(functional_medium) +endif() -# if(PRESSIO_ENABLE_FUNCTIONAL_LARGE_TESTS OR PRESSIO_ENABLE_TESTS) -# add_subdirectory(functional_large) -# endif() +if(PRESSIO_ENABLE_FUNCTIONAL_LARGE_TESTS OR PRESSIO_ENABLE_TESTS) + add_subdirectory(functional_large) +endif() From df06cb138b2e91738fd19236ce37b014b1a227ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 29 Aug 2023 15:53:30 +0200 Subject: [PATCH 11/56] tests: use FetchContent to obtain GTest when it is not found --- tests/CMakeLists.txt | 39 ++++++++---------------- tests/cmake/googletest/CMakeLists.txt.in | 16 ---------- 2 files changed, 13 insertions(+), 42 deletions(-) delete mode 100644 tests/cmake/googletest/CMakeLists.txt.in diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a40f9117b..eaf4f0eb1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -55,37 +55,24 @@ endif() # 1. find or get gtest # --------------------------------- # adapted from Kokkos -find_package(GTest REQUIRED) +find_package(GTest) if (GTEST_FOUND) add_library(gtest_main ALIAS GTest::gtest_main) cmake_print_variables(GTEST_INCLUDE_DIRS) else() - # FIXME: use FetchContent_MakeAvailable? - # don't forget to remove tests/cmake/googletest/CMakeLists.txt.in - configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/googletest/CMakeLists.txt.in - googletest-download/CMakeLists.txt) - execute_process( - COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download + set(GTEST_VERSION "v1.14.0") + message(STATUS "GTest not found, fetching version ${GTEST_VERSION}") + + list(APPEND CMAKE_MESSAGE_INDENT "[GTest] ") + include(FetchContent) + FetchContent_Declare( + googletest + URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz + URL_HASH MD5=c8340a482851ef6a3fe618a082304cfc + DOWNLOAD_EXTRACT_TIMESTAMP TRUE ) - if(result) - message(FATAL_ERROR "Configure step for googletest failed: ${result}") - endif() - - execute_process( - COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download - ) - if(result) - message(FATAL_ERROR "Build step for googletest failed: ${result}") - endif() - - # Add googletest directly to our build. This defines the gtest and gtest_main targets. - add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src - ${CMAKE_CURRENT_BINARY_DIR}/googletest-build EXCLUDE_FROM_ALL) + FetchContent_MakeAvailable(googletest) + list(POP_BACK CMAKE_MESSAGE_INDENT) endif() # --------------------------------- diff --git a/tests/cmake/googletest/CMakeLists.txt.in b/tests/cmake/googletest/CMakeLists.txt.in deleted file mode 100644 index 5e808996a..000000000 --- a/tests/cmake/googletest/CMakeLists.txt.in +++ /dev/null @@ -1,16 +0,0 @@ -# from https://github.com/google/googletest/blob/master/googletest/README.md -cmake_minimum_required(VERSION 3.0) - -project(googletest-download NONE) - -include(ExternalProject) -ExternalProject_Add(googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG main - SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src" - BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" -) From 998150baec7976e3ad61041e49911e2ffa6775cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 29 Aug 2023 17:01:31 +0200 Subject: [PATCH 12/56] fix Trilinos configuration --- .github/workflows/ci-trilinos.yml | 2 +- tests/CMakeLists.txt | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci-trilinos.yml b/.github/workflows/ci-trilinos.yml index 6a5ae37e8..ad7434334 100644 --- a/.github/workflows/ci-trilinos.yml +++ b/.github/workflows/ci-trilinos.yml @@ -80,7 +80,7 @@ jobs: -D PRESSIO_ENABLE_DEBUG_PRINT=ON \ -D EIGEN_INCLUDE_DIR=$eigen_inc_dir \ -D GTEST_ROOT=$gtest_dir \ - -D TRILINOS_ROOT=$trilinos_dir \ + -D Trilinos_DIR=${{ env.trilinos_dir }}/lib/cmake/Trilinos \ -D CMAKE_INSTALL_PREFIX:PATH=../install \ -D CMAKE_CXX_FLAGS='' diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index eaf4f0eb1..72e5fc698 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -34,9 +34,14 @@ if(PRESSIO_ENABLE_TPL_EIGEN) endif() if(PRESSIO_ENABLE_TPL_TRILINOS) - find_package(trilinos REQUIRED) + find_package(Trilinos REQUIRED) + # Note: it is possible to use find_package() for each (sub)package + # https://trilinos.github.io/pdfs/Finding_Trilinos.txt add_definitions(-DPRESSIO_ENABLE_TPL_TRILINOS) + include_directories(${Trilinos_INCLUDE_DIRS}) + link_libraries(${Trilinos_LIBRARIES}) + # FINISH THIS endif() @@ -98,16 +103,16 @@ macro(add_serial_utest_kokkos TESTNAME TESTSRCS) add_test(NAME ${testNameFinal} COMMAND ${testNameFinal}) endmacro() -# macro(add_utest_mpi TESTNAME TESTSRCS gMAIN nRANKS) -# set(testNameFinal ${TESTNAME}_np${nRANKS}) -# add_executable(${testNameFinal} ${TESTSRCS} ${GTESTMAINSDIR}/${gMAIN}.cc) -# target_link_libraries(${testNameFinal} ${MPI_CXX_LIBRARIES} gtest_main) -# add_test( -# NAME ${testNameFinal} -# COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${nRANKS} -# ${MPIEXEC_PREFLAGS} ${testNameFinal} ${MPIEXEC_POSTFLAGS} -# ) -# endmacro() +macro(add_utest_mpi TESTNAME TESTSRCS gMAIN nRANKS) + set(testNameFinal ${TESTNAME}_np${nRANKS}) + add_executable(${testNameFinal} ${TESTSRCS} ${GTESTMAINSDIR}/${gMAIN}.cc) + target_link_libraries(${testNameFinal} ${MPI_CXX_LIBRARIES} gtest_main) + add_test( + NAME ${testNameFinal} + COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${nRANKS} + ${MPIEXEC_PREFLAGS} ${testNameFinal} ${MPIEXEC_POSTFLAGS} + ) +endmacro() #===================================================================== # # macro to create and add an individual SERIAL test From b65c124eb6ebc7d1e3398dfdda5e4e1b751911e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Wed, 30 Aug 2023 13:34:54 +0200 Subject: [PATCH 13/56] ci: simplify trilinos workflow --- .github/workflows/ci-trilinos.yml | 38 ++++++++++++------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci-trilinos.yml b/.github/workflows/ci-trilinos.yml index ad7434334..b74771bd4 100644 --- a/.github/workflows/ci-trilinos.yml +++ b/.github/workflows/ci-trilinos.yml @@ -29,27 +29,19 @@ jobs: name: Trilinos strategy: matrix: - config: - - { - os: ubuntu-latest, - image: ubuntu-20.04-gnu_10-eigen_3.3.7-gtest-trilinos_hash-ef73d14babf6e7556b0420add98cce257ccaa56b, - build_type: "Release", cc: "mpicc", cxx: "mpicxx", - requirements: "apt install -y openmpi-bin libopenmpi-dev;sed -i -e '$alocalhost slots=4' /etc/openmpi/openmpi-default-hostfile", - } + image: + - ubuntu-20.04-gnu_10-eigen_3.3.7-gtest-trilinos_hash-ef73d14babf6e7556b0420add98cce257ccaa56b + build_type: + - Release + - Debug + requirements: + - "apt install -y openmpi-bin libopenmpi-dev;sed -i -e '$alocalhost slots=4' /etc/openmpi/openmpi-default-hostfile" - - { - os: ubuntu-latest, - image: ubuntu-20.04-gnu_10-eigen_3.3.7-gtest-trilinos_hash-ef73d14babf6e7556b0420add98cce257ccaa56b, - build_type: "Debug", cc: "mpicc", cxx: "mpicxx", - requirements: "apt install -y openmpi-bin libopenmpi-dev;sed -i -e '$alocalhost slots=4' /etc/openmpi/openmpi-default-hostfile", - } - - runs-on: ${{ matrix.config.os }} - container: pressiomodelreduction/${{ matrix.config.image }} + runs-on: ubuntu-latest + container: pressiomodelreduction/${{ matrix.image }} env: num_cpus: 4 - pressio_build: /home/pressio_builds eigen_inc_dir: /home/pressio_builds/eigen/install/include/eigen3 gtest_dir: /home/pressio_builds/gtest/install trilinos_dir: /home/pressio_builds/trilinos/install @@ -60,12 +52,12 @@ jobs: - name: Creating environnement run: | apt-get update -y - ${{ matrix.config.requirements }} + ${{ matrix.requirements }} - name: Configure run: | - cmake -B $pressio_build \ - -D CMAKE_BUILD_TYPE:STRING=${{ matrix.config.build_type }} \ + cmake -B builddir \ + -D CMAKE_BUILD_TYPE:STRING=${{ matrix.build_type }} \ -D CMAKE_VERBOSE_MAKEFILE:BOOL=ON \ -D CMAKE_C_COMPILER:FILEPATH=/usr/bin/mpicc \ -D CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/mpic++ \ @@ -85,12 +77,12 @@ jobs: -D CMAKE_CXX_FLAGS='' - name: Build - run: cmake --build $pressio_build -j $num_cpus + run: cmake --build builddir -j $num_cpus - name: Test + working-directory: builddir run: | - cd ${{ env.pressio_build }} - export LD_LIBRARY_PATH=${{ env.pressio_build }}/trilinos/install/lib + export LD_LIBRARY_PATH=${{ env.trilinos_dir }}/lib export OMPI_ALLOW_RUN_AS_ROOT=1 export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 ctest -j $num_cpus --output-on-failure From 791412f5f71718d17fc71563b5a794aee65f2f8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Wed, 30 Aug 2023 14:32:58 +0200 Subject: [PATCH 14/56] tests: link pressio in mpi tests --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 72e5fc698..b325e5c64 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -106,7 +106,7 @@ endmacro() macro(add_utest_mpi TESTNAME TESTSRCS gMAIN nRANKS) set(testNameFinal ${TESTNAME}_np${nRANKS}) add_executable(${testNameFinal} ${TESTSRCS} ${GTESTMAINSDIR}/${gMAIN}.cc) - target_link_libraries(${testNameFinal} ${MPI_CXX_LIBRARIES} gtest_main) + target_link_libraries(${testNameFinal} ${MPI_CXX_LIBRARIES} pressio gtest_main) add_test( NAME ${testNameFinal} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${nRANKS} From f174f8269a0a7590aa023605d1c73ec2ff513e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Wed, 30 Aug 2023 22:15:19 +0200 Subject: [PATCH 15/56] tests: find MPI package when enabled --- tests/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b325e5c64..40e772e67 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -45,10 +45,10 @@ if(PRESSIO_ENABLE_TPL_TRILINOS) # FINISH THIS endif() -# if(PRESSIO_ENABLE_TPL_MPI) -# find_package(MPI REQUIRED) -# include_directories(${MPI_CXX_INCLUDE_DIRS}) -# endif() +if(PRESSIO_ENABLE_TPL_MPI) + find_package(MPI REQUIRED) + include_directories(${MPI_CXX_INCLUDE_DIRS}) +endif() # if(PRESSIO_ENABLE_TPL_KOKKOS AND NOT PRESSIO_ENABLE_TPL_TRILINOS) # find_package(KokkosKernels REQUIRED) From 6bb8896ae4286878d6ae95c26681837a4bd64b15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Thu, 31 Aug 2023 12:50:33 +0200 Subject: [PATCH 16/56] move CMake options to a separate file --- cmake/options.cmake | 18 ++++++++++++++++++ tests/CMakeLists.txt | 24 +----------------------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/cmake/options.cmake b/cmake/options.cmake index 72f46d19b..414dc2179 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -1,9 +1,27 @@ +option(PRESSIO_ENABLE_CXX14 "Enable C++14" OFF) +option(PRESSIO_ENABLE_CXX17 "Enable C++17" OFF) +option(PRESSIO_ENABLE_CXX20 "Enable C++20" OFF) + +if (CMAKE_CXX_STANDARD EQUAL 14) + add_definitions(-DPRESSIO_ENABLE_CXX14) +elseif(CMAKE_CXX_STANDARD EQUAL 17) + add_definitions(-DPRESSIO_ENABLE_CXX17) +elseif(CMAKE_CXX_STANDARD EQUAL 20) + add_definitions(-DPRESSIO_ENABLE_CXX20) +endif() + +option(PRESSIO_ENABLE_DEBUG_PRINT "Enable debug printing" OFF) +if (PRESSIO_ENABLE_DEBUG_PRINT) + add_definitions(-DPRESSIO_ENABLE_DEBUG_PRINT) +endif() option(PRESSIO_ENABLE_TPL_EIGEN "Enable Eigen TPL" ON) option(PRESSIO_ENABLE_TPL_TRILINOS "Enable Trilinos TPL" OFF) option(PRESSIO_ENABLE_TPL_KOKKOS "Enable Kokkos TPL" OFF) option(PRESSIO_ENABLE_TPL_MPI "Enable MPI" OFF) option(PRESSIO_ENABLE_TPL_PYBIND11 "Enable Pybind11 TPL" OFF) +# option(PRESSIO_ENABLE_TEUCHOS_TIMERS "bla bla" OFF) + if(PRESSIO_ENABLE_TPL_EIGEN) message(">> Eigen is currently enabled by default via PRESSIO_ENABLE_TPL_EIGEN=ON") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 40e772e67..3f9316116 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,27 +1,5 @@ include(CMakePrintHelpers) - -option(PRESSIO_ENABLE_CXX14 "Enable C++14" OFF) -option(PRESSIO_ENABLE_CXX17 "Enable C++17" OFF) -option(PRESSIO_ENABLE_CXX20 "Enable C++20" OFF) - -option(PRESSIO_ENABLE_DEBUG_PRINT "Enable debug printing" OFF) -option(PRESSIO_ENABLE_TPL_EIGEN "Enable Eigen TPL" OFF) -option(PRESSIO_ENABLE_TPL_TRILINOS "Enable Trilinos TPL" OFF) -# option(PRESSIO_ENABLE_TEUCHOS_TIMERS "bla bla" OFF) -# option(PRESSIO_ENABLE_TPL_KOKKOS "bla bla" OFF) -# option(PRESSIO_ENABLE_TPL_MPI "bla bla" OFF) - -if (CMAKE_CXX_STANDARD EQUAL 14) - add_definitions(-DPRESSIO_ENABLE_CXX14) -elseif(CMAKE_CXX_STANDARD EQUAL 17) - add_definitions(-DPRESSIO_ENABLE_CXX17) -elseif(CMAKE_CXX_STANDARD EQUAL 20) - add_definitions(-DPRESSIO_ENABLE_CXX20) -endif() - -if (PRESSIO_ENABLE_DEBUG_PRINT) - add_definitions(-DPRESSIO_ENABLE_DEBUG_PRINT) -endif() +include(options) if(PRESSIO_ENABLE_TPL_EIGEN) if(NOT EIGEN_INCLUDE_DIR) From f2423f0a1b0dbc88a84303c07fabf990513929b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Thu, 31 Aug 2023 16:38:33 +0200 Subject: [PATCH 17/56] move option handling to a separate file --- CMakeLists.txt | 26 +++++++++----------------- cmake/options.cmake | 28 ++++++++++++++++++++++++++++ tests/CMakeLists.txt | 34 ---------------------------------- 3 files changed, 37 insertions(+), 51 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c92226e77..6ce7c352c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ project(pressio C CXX) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(colors) +include(options) #===================================================================== # versioning @@ -21,30 +22,21 @@ message("${Magenta}>> PRESSIO: version = ${PRESSIO_VERSION_NUMBER} ${ColourReset #===================================================================== # c++ standard #===================================================================== -IF (NOT CMAKE_CXX_STANDARD) +if (NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -ENDIF() +endif() message("${Magenta}>> PRESSIO: CMAKE_CXX_STANDARD is set to ${CMAKE_CXX_STANDARD} ${ColourReset}") -IF(CMAKE_CXX_STANDARD STREQUAL "14") - if(NOT "cxx_std_14" IN_LIST CMAKE_CXX_COMPILE_FEATURES) - message(FATAL_ERROR "Compiler does not support C++14. This is required.") - endif() - -ELSEIF(CMAKE_CXX_STANDARD STREQUAL "17") - if(NOT "cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES) - message(FATAL_ERROR "Compiler does not support C++17. This is required.") +if(CMAKE_CXX_STANDARD STREQUAL "14" + OR CMAKE_CXX_STANDARD STREQUAL "17" + OR CMAKE_CXX_STANDARD STREQUAL "20") + if(NOT "cxx_std_${CMAKE_CXX_STANDARD}" IN_LIST CMAKE_CXX_COMPILE_FEATURES) + message(FATAL_ERROR "Compiler does not support C++${CMAKE_CXX_STANDARD}. This is required.") endif() - -ELSEIF(CMAKE_CXX_STANDARD STREQUAL "20") - message("${Magenta}>> PRESSIO: CMAKE_CXX_STANDARD = 20 ${ColourReset}") - if(NOT "cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES) - message(FATAL_ERROR "Compiler does not support C++20. This is required.") - endif() -ENDIF() +endif() ################################################################################ diff --git a/cmake/options.cmake b/cmake/options.cmake index 414dc2179..edecd76bb 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -25,6 +25,14 @@ option(PRESSIO_ENABLE_TPL_PYBIND11 "Enable Pybind11 TPL" OFF) if(PRESSIO_ENABLE_TPL_EIGEN) message(">> Eigen is currently enabled by default via PRESSIO_ENABLE_TPL_EIGEN=ON") + if(NOT EIGEN_INCLUDE_DIR) + message(FATAL_ERROR + "I cannot find the Eigen headers. " + "Please reconfigure with: -DEIGEN_INCLUDE_DIR=") + endif() + + include_directories(${EIGEN_INCLUDE_DIR}) + add_definitions(-DPRESSIO_ENABLE_TPL_EIGEN) endif() # if trilinos is on, then also set MPI, BLAS, LAPACK and KOKKOS ON @@ -33,6 +41,16 @@ if(PRESSIO_ENABLE_TPL_TRILINOS) set(PRESSIO_ENABLE_TPL_KOKKOS ON) set(PRESSIO_ENABLE_TPL_MPI ON) + + find_package(Trilinos REQUIRED) + # FIXME: it is possible to use find_package() for each (sub)package + # https://trilinos.github.io/pdfs/Finding_Trilinos.txt + add_definitions(-DPRESSIO_ENABLE_TPL_TRILINOS) + + include_directories(${Trilinos_INCLUDE_DIRS}) + link_libraries(${Trilinos_LIBRARIES}) + + # FINISH THIS endif() if(PRESSIO_ENABLE_TPL_KOKKOS) @@ -41,8 +59,18 @@ endif() if(PRESSIO_ENABLE_TPL_MPI) message(">> Enabling MPI since PRESSIO_ENABLE_TPL_MPI=ON") + + find_package(MPI REQUIRED) + include_directories(${MPI_CXX_INCLUDE_DIRS}) endif() if(PRESSIO_ENABLE_TPL_Pybind11) message(">> Enabling Pybind11 since PRESSIO_ENABLE_TPL_PYBIND11=ON") endif() + + +# if(PRESSIO_ENABLE_TPL_KOKKOS AND NOT PRESSIO_ENABLE_TPL_TRILINOS) +# find_package(KokkosKernels REQUIRED) +# set(KOKKOS_LIBS Kokkos::kokkoskernels) +# #Kokkos::BLAS Kokkos::LAPACK Kokkos::kokkos Kokkos::kokkoskernels) +# endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3f9316116..240f26358 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,38 +1,4 @@ include(CMakePrintHelpers) -include(options) - -if(PRESSIO_ENABLE_TPL_EIGEN) - if(NOT EIGEN_INCLUDE_DIR) - message(FATAL_ERROR - "I cannot find the Eigen headers. " - "Please reconfigure with: -DEIGEN_INCLUDE_DIR=") - endif() - include_directories(${EIGEN_INCLUDE_DIR}) - add_definitions(-DPRESSIO_ENABLE_TPL_EIGEN) -endif() - -if(PRESSIO_ENABLE_TPL_TRILINOS) - find_package(Trilinos REQUIRED) - # Note: it is possible to use find_package() for each (sub)package - # https://trilinos.github.io/pdfs/Finding_Trilinos.txt - add_definitions(-DPRESSIO_ENABLE_TPL_TRILINOS) - - include_directories(${Trilinos_INCLUDE_DIRS}) - link_libraries(${Trilinos_LIBRARIES}) - - # FINISH THIS -endif() - -if(PRESSIO_ENABLE_TPL_MPI) - find_package(MPI REQUIRED) - include_directories(${MPI_CXX_INCLUDE_DIRS}) -endif() - -# if(PRESSIO_ENABLE_TPL_KOKKOS AND NOT PRESSIO_ENABLE_TPL_TRILINOS) -# find_package(KokkosKernels REQUIRED) -# set(KOKKOS_LIBS Kokkos::kokkoskernels) -# #Kokkos::BLAS Kokkos::LAPACK Kokkos::kokkos Kokkos::kokkoskernels) -# endif() # --------------------------------- # 1. find or get gtest From f31d74b972c2e1540ae9d17d558709da213ec98f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 10 Oct 2023 18:38:05 +0200 Subject: [PATCH 18/56] Fix formatting --- cmake/options.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/options.cmake b/cmake/options.cmake index edecd76bb..6db5f256a 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -17,7 +17,7 @@ endif() option(PRESSIO_ENABLE_TPL_EIGEN "Enable Eigen TPL" ON) option(PRESSIO_ENABLE_TPL_TRILINOS "Enable Trilinos TPL" OFF) -option(PRESSIO_ENABLE_TPL_KOKKOS "Enable Kokkos TPL" OFF) +option(PRESSIO_ENABLE_TPL_KOKKOS "Enable Kokkos TPL" OFF) option(PRESSIO_ENABLE_TPL_MPI "Enable MPI" OFF) option(PRESSIO_ENABLE_TPL_PYBIND11 "Enable Pybind11 TPL" OFF) # option(PRESSIO_ENABLE_TEUCHOS_TIMERS "bla bla" OFF) From 38565408aa29c8a5c2bb31a57cf4fdea7d36860b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 10 Oct 2023 18:38:39 +0200 Subject: [PATCH 19/56] do not extract timestamps when fetching content --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 240f26358..38a85aeb1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -18,7 +18,7 @@ else() googletest URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz URL_HASH MD5=c8340a482851ef6a3fe618a082304cfc - DOWNLOAD_EXTRACT_TIMESTAMP TRUE + DOWNLOAD_EXTRACT_TIMESTAMP FALSE ) FetchContent_MakeAvailable(googletest) list(POP_BACK CMAKE_MESSAGE_INDENT) From 4f265c3955f500d9dae8d12c683ea1c6411ec545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 10 Oct 2023 18:45:43 +0200 Subject: [PATCH 20/56] remove commented out / duplicated code --- tests/CMakeLists.txt | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 38a85aeb1..917abf28e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -59,34 +59,6 @@ macro(add_utest_mpi TESTNAME TESTSRCS gMAIN nRANKS) endmacro() #===================================================================== -# # macro to create and add an individual SERIAL test -# macro(add_serial_exe_and_test TESTNAME PKGNAME TESTSRCS REGEX) -# set(testNameFinal ${PKGNAME}_${TESTNAME}) -# add_executable(${testNameFinal} ${TESTSRCS}) -# add_test(NAME ${testNameFinal} COMMAND ${testNameFinal}) -# set_tests_properties( -# ${testNameFinal} -# PROPERTIES PASS_REGULAR_EXPRESSION ${REGEX} FAIL_REGULAR_EXPRESSION "FAILED" -# ) -# endmacro() -# #===================================================================== - -# macro(add_mpi_exe_and_test TESTNAME PKGNAME TESTSRCS nRANKS REGEXOK) -# set(testNameFinal ${PKGNAME}_${TESTNAME}_np${nRANKS}) -# add_executable(${testNameFinal} ${TESTSRCS}) -# target_link_libraries(${testNameFinal} ${MPI_CXX_LIBRARIES}) -# add_test( -# NAME ${testNameFinal} -# COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${nRANKS} -# ${MPIEXEC_PREFLAGS} ${testNameFinal} ${MPIEXEC_POSTFLAGS} -# ) -# set_tests_properties( -# ${testNameFinal} -# PROPERTIES PASS_REGULAR_EXPRESSION ${REGEXOK} FAIL_REGULAR_EXPRESSION "FAILED" -# ) -# endmacro() -# #===================================================================== - if(PRESSIO_ENABLE_FUNCTIONAL_SMALL_TESTS OR PRESSIO_ENABLE_TESTS) add_subdirectory(functional_small) endif() From 30906e8fadb932aa9446796031faa65a3e061bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 10 Oct 2023 18:47:31 +0200 Subject: [PATCH 21/56] tests: remove empty directories --- CMakeLists.txt | 2 +- tests/CMakeLists.txt | 10 +--------- tests/functional_large/CMakeLists.txt | 4 ---- tests/functional_medium/CMakeLists.txt | 4 ---- 4 files changed, 2 insertions(+), 18 deletions(-) delete mode 100644 tests/functional_large/CMakeLists.txt delete mode 100644 tests/functional_medium/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ce7c352c..5fb2da273 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,7 +84,7 @@ install(FILES ################################################################################ -if(PRESSIO_ENABLE_FUNCTIONAL_TESTS OR PRESSIO_ENABLE_TESTS) +if(PRESSIO_ENABLE_TESTS) enable_testing() add_subdirectory(tests) endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 917abf28e..8eefca1dd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -59,14 +59,6 @@ macro(add_utest_mpi TESTNAME TESTSRCS gMAIN nRANKS) endmacro() #===================================================================== -if(PRESSIO_ENABLE_FUNCTIONAL_SMALL_TESTS OR PRESSIO_ENABLE_TESTS) +if(PRESSIO_ENABLE_TESTS) add_subdirectory(functional_small) endif() - -if(PRESSIO_ENABLE_FUNCTIONAL_MEDIUM_TESTS OR PRESSIO_ENABLE_TESTS) - add_subdirectory(functional_medium) -endif() - -if(PRESSIO_ENABLE_FUNCTIONAL_LARGE_TESTS OR PRESSIO_ENABLE_TESTS) - add_subdirectory(functional_large) -endif() diff --git a/tests/functional_large/CMakeLists.txt b/tests/functional_large/CMakeLists.txt deleted file mode 100644 index 13b61e600..000000000 --- a/tests/functional_large/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ - -set(TESTING_LEVEL functional_large) - -#add_subdirectory(...) diff --git a/tests/functional_medium/CMakeLists.txt b/tests/functional_medium/CMakeLists.txt deleted file mode 100644 index a33208788..000000000 --- a/tests/functional_medium/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ - -set(TESTING_LEVEL functional_medium) - -#add_subdirectory(...) \ No newline at end of file From 6730b1e408a5dded2fda47cf1fc9684007ff16f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 10 Oct 2023 18:50:17 +0200 Subject: [PATCH 22/56] add FIXME for missing libeigen --- cmake/options.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/options.cmake b/cmake/options.cmake index 6db5f256a..367a62721 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -26,6 +26,7 @@ option(PRESSIO_ENABLE_TPL_PYBIND11 "Enable Pybind11 TPL" OFF) if(PRESSIO_ENABLE_TPL_EIGEN) message(">> Eigen is currently enabled by default via PRESSIO_ENABLE_TPL_EIGEN=ON") if(NOT EIGEN_INCLUDE_DIR) + # FIXME: use FetchContent_Declare instead of failing? message(FATAL_ERROR "I cannot find the Eigen headers. " "Please reconfigure with: -DEIGEN_INCLUDE_DIR=") From 33b118f79a3bdd238ac4dde3fed92dbdd2d66c08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 10 Oct 2023 19:01:36 +0200 Subject: [PATCH 23/56] tests: use predefined gtest version when fetching from github --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8eefca1dd..2bb2bd4dd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,7 +16,7 @@ else() include(FetchContent) FetchContent_Declare( googletest - URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz + URL https://github.com/google/googletest/archive/refs/tags/${GTEST_VERSION}.tar.gz URL_HASH MD5=c8340a482851ef6a3fe618a082304cfc DOWNLOAD_EXTRACT_TIMESTAMP FALSE ) From 1792892248b72f45ca56e22d01e270a231c662bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 10 Oct 2023 19:10:20 +0200 Subject: [PATCH 24/56] tests: remove duplicated code --- tests/CMakeLists.txt | 37 ++++---------------- tests/cmake/macrosForCreatingTests.cmake | 2 -- tests/cmake/macrosForCreatingUnitTests.cmake | 29 ++++++++++----- 3 files changed, 27 insertions(+), 41 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2bb2bd4dd..ae42023e6 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,9 +1,12 @@ include(CMakePrintHelpers) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +include(macrosForCreatingTests) +include(macrosForCreatingUnitTests) + # --------------------------------- # 1. find or get gtest # --------------------------------- -# adapted from Kokkos find_package(GTest) if (GTEST_FOUND) add_library(gtest_main ALIAS GTest::gtest_main) @@ -31,34 +34,6 @@ set(GTESTMAINSDIR "${CMAKE_CURRENT_SOURCE_DIR}/gtest_mains") message("${Magenta}>> Google tests main files are in: ${GTESTMAINSDIR} ${ColourReset}") # --------------------------------- -# 3. macros for createing unit tests +# 3. add test subdirectories # --------------------------------- -macro(add_serial_utest TESTNAME) - set(testNameFinal ${TESTNAME}) - add_executable(${testNameFinal} ${ARGN} ${GTESTMAINSDIR}/gTestMain_serial.cc) - target_link_libraries(${testNameFinal} pressio gtest_main) - add_test(NAME ${testNameFinal} COMMAND ${testNameFinal}) -endmacro() - -macro(add_serial_utest_kokkos TESTNAME TESTSRCS) - set(testNameFinal ${TESTNAME}) - add_executable(${testNameFinal} ${TESTSRCS} ${GTESTMAINSDIR}/gTestMain_kokkos.cc) - target_link_libraries(${testNameFinal} ${KOKKOS_LIBS} pressio gtest_main) - add_test(NAME ${testNameFinal} COMMAND ${testNameFinal}) -endmacro() - -macro(add_utest_mpi TESTNAME TESTSRCS gMAIN nRANKS) - set(testNameFinal ${TESTNAME}_np${nRANKS}) - add_executable(${testNameFinal} ${TESTSRCS} ${GTESTMAINSDIR}/${gMAIN}.cc) - target_link_libraries(${testNameFinal} ${MPI_CXX_LIBRARIES} pressio gtest_main) - add_test( - NAME ${testNameFinal} - COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${nRANKS} - ${MPIEXEC_PREFLAGS} ${testNameFinal} ${MPIEXEC_POSTFLAGS} - ) -endmacro() -#===================================================================== - -if(PRESSIO_ENABLE_TESTS) - add_subdirectory(functional_small) -endif() +add_subdirectory(functional_small) diff --git a/tests/cmake/macrosForCreatingTests.cmake b/tests/cmake/macrosForCreatingTests.cmake index 1863f7153..480401f68 100644 --- a/tests/cmake/macrosForCreatingTests.cmake +++ b/tests/cmake/macrosForCreatingTests.cmake @@ -1,7 +1,5 @@ -# macro to create and add an individual SERIAL test macro(add_serial_exe_and_test TESTNAME PKGNAME TESTSRCS REGEX) - # set name of the executable set(testNameFinal ${PKGNAME}_${TESTNAME}) add_executable(${testNameFinal} ${TESTSRCS}) add_test(NAME ${testNameFinal} COMMAND ${testNameFinal}) diff --git a/tests/cmake/macrosForCreatingUnitTests.cmake b/tests/cmake/macrosForCreatingUnitTests.cmake index 26adda3c9..362a4b5ce 100644 --- a/tests/cmake/macrosForCreatingUnitTests.cmake +++ b/tests/cmake/macrosForCreatingUnitTests.cmake @@ -1,15 +1,28 @@ -# this function creates and adds an individual SERIAL unit-test macro(add_serial_utest TESTNAME) - # set name of the executable set(testNameFinal ${TESTNAME}) + add_executable(${testNameFinal} ${ARGN} ${GTESTMAINSDIR}/gTestMain_serial.cc) + target_link_libraries(${testNameFinal} pressio gtest_main) + add_test(NAME ${testNameFinal} COMMAND ${testNameFinal}) +endmacro() +#===================================================================== - add_executable(${testNameFinal} - ${ARGN} ${GTESTMAINSDIR}/gTestMain_serial.cc) - - target_link_libraries(${testNameFinal} - GTest::gtest GTest::Main) - +macro(add_serial_utest_kokkos TESTNAME TESTSRCS) + set(testNameFinal ${TESTNAME}) + add_executable(${testNameFinal} ${TESTSRCS} ${GTESTMAINSDIR}/gTestMain_kokkos.cc) + target_link_libraries(${testNameFinal} ${KOKKOS_LIBS} pressio gtest_main) add_test(NAME ${testNameFinal} COMMAND ${testNameFinal}) endmacro() #===================================================================== + +macro(add_utest_mpi TESTNAME TESTSRCS gMAIN nRANKS) + set(testNameFinal ${TESTNAME}_np${nRANKS}) + add_executable(${testNameFinal} ${TESTSRCS} ${GTESTMAINSDIR}/${gMAIN}.cc) + target_link_libraries(${testNameFinal} ${MPI_CXX_LIBRARIES} pressio gtest_main) + add_test( + NAME ${testNameFinal} + COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${nRANKS} + ${MPIEXEC_PREFLAGS} ${testNameFinal} ${MPIEXEC_POSTFLAGS} + ) +endmacro() +#===================================================================== From 99e202f11a8d96581876c5bdbd00413a5943d93f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 10 Oct 2023 19:35:04 +0200 Subject: [PATCH 25/56] tests: re-enable all unit tests --- tests/cmake/macrosForCreatingTests.cmake | 1 + tests/functional_small/CMakeLists.txt | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/cmake/macrosForCreatingTests.cmake b/tests/cmake/macrosForCreatingTests.cmake index 480401f68..24e3d12e1 100644 --- a/tests/cmake/macrosForCreatingTests.cmake +++ b/tests/cmake/macrosForCreatingTests.cmake @@ -2,6 +2,7 @@ macro(add_serial_exe_and_test TESTNAME PKGNAME TESTSRCS REGEX) set(testNameFinal ${PKGNAME}_${TESTNAME}) add_executable(${testNameFinal} ${TESTSRCS}) + target_link_libraries(${testNameFinal} pressio) add_test(NAME ${testNameFinal} COMMAND ${testNameFinal}) set_tests_properties( ${testNameFinal} diff --git a/tests/functional_small/CMakeLists.txt b/tests/functional_small/CMakeLists.txt index ad8285909..c6c258a20 100644 --- a/tests/functional_small/CMakeLists.txt +++ b/tests/functional_small/CMakeLists.txt @@ -1,3 +1,4 @@ + set(TESTING_LEVEL functional_small) add_subdirectory(mpl) @@ -5,9 +6,9 @@ add_subdirectory(utils) add_subdirectory(type_traits) add_subdirectory(expressions) add_subdirectory(ops) -# add_subdirectory(qr) -# add_subdirectory(solvers_linear) -# add_subdirectory(solvers_nonlinear) -# add_subdirectory(ode_advancers) -# add_subdirectory(ode_steppers) -# add_subdirectory(rom) +add_subdirectory(qr) +add_subdirectory(solvers_linear) +add_subdirectory(solvers_nonlinear) +add_subdirectory(ode_advancers) +add_subdirectory(ode_steppers) +add_subdirectory(rom) From d90eea4326162e60d0ae52c2bb3b38008116c3b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Mon, 16 Oct 2023 17:40:31 +0200 Subject: [PATCH 26/56] ensure Eigen is always enabled --- include/pressio/macros.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pressio/macros.hpp b/include/pressio/macros.hpp index 8639b43fb..fe8a5dac5 100644 --- a/include/pressio/macros.hpp +++ b/include/pressio/macros.hpp @@ -117,6 +117,6 @@ static_assert(_PRESSIO_CPLUSPLUS >= PRESSIO_CXX_STD_14, "PRESSIO requires C++14 #endif #endif -// static_assert(PRESSIO_ENABLE_TPL_EIGEN, ...) // TBD +static_assert(PRESSIO_ENABLE_TPL_EIGEN, "Eigen is not enabled."); #endif From 28cd0fffe0291cce0a403d404f8f78f572749fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 17 Oct 2023 13:00:53 +0200 Subject: [PATCH 27/56] examples: add cmake_installed example --- .github/workflows/ci-baseline.yml | 9 ++++++++- examples/cmake_installed/CMakeLists.txt | 7 +++++++ examples/cmake_installed/main.cpp | 11 +++++++++++ include/pressio/macros.hpp | 3 ++- 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 examples/cmake_installed/CMakeLists.txt create mode 100644 examples/cmake_installed/main.cpp diff --git a/.github/workflows/ci-baseline.yml b/.github/workflows/ci-baseline.yml index 06f8f8a43..52fee4ef2 100644 --- a/.github/workflows/ci-baseline.yml +++ b/.github/workflows/ci-baseline.yml @@ -84,9 +84,16 @@ jobs: - name: Build run: | - cmake --build builddir + cmake --build builddir --target install - name: Test working-directory: builddir run: | ctest -j $num_cpus --output-on-failure + + - name: Examples + working-directory: examples/cmake_installed + run: | + cmake -B builddir \ + -DCMAKE_PREFIX_PATH=../../install \ + && cmake --build builddir diff --git a/examples/cmake_installed/CMakeLists.txt b/examples/cmake_installed/CMakeLists.txt new file mode 100644 index 000000000..9692ae218 --- /dev/null +++ b/examples/cmake_installed/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.18.0) +project(pressio-cmake-example) + +find_package(pressio REQUIRED) + +add_executable(pressio-cmake-example main.cpp) +target_link_libraries(pressio-cmake-example PUBLIC pressio) diff --git a/examples/cmake_installed/main.cpp b/examples/cmake_installed/main.cpp new file mode 100644 index 000000000..47044237d --- /dev/null +++ b/examples/cmake_installed/main.cpp @@ -0,0 +1,11 @@ +#include + +int main() { + pressio::log::initialize(pressio::logto::terminal, "log.txt"); + pressio::log::setVerbosity({pressio::log::level::info}); + + double a = 1.; + PRESSIOLOG_INFO("pressio log message, {:3}", a); + + pressio::log::finalize(); +} diff --git a/include/pressio/macros.hpp b/include/pressio/macros.hpp index fe8a5dac5..7faeb68bc 100644 --- a/include/pressio/macros.hpp +++ b/include/pressio/macros.hpp @@ -117,6 +117,7 @@ static_assert(_PRESSIO_CPLUSPLUS >= PRESSIO_CXX_STD_14, "PRESSIO requires C++14 #endif #endif -static_assert(PRESSIO_ENABLE_TPL_EIGEN, "Eigen is not enabled."); +// FIXME: disabled for cmaked_installed example +// static_assert(PRESSIO_ENABLE_TPL_EIGEN, "Eigen is not enabled."); #endif From ebaab5fc434303b970250a90018466419f09e365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 17 Oct 2023 18:12:12 +0200 Subject: [PATCH 28/56] tests: avoid CMake error for FetchContent_Declare --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ae42023e6..093c208f3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -19,9 +19,9 @@ else() include(FetchContent) FetchContent_Declare( googletest + DOWNLOAD_EXTRACT_TIMESTAMP FALSE URL https://github.com/google/googletest/archive/refs/tags/${GTEST_VERSION}.tar.gz URL_HASH MD5=c8340a482851ef6a3fe618a082304cfc - DOWNLOAD_EXTRACT_TIMESTAMP FALSE ) FetchContent_MakeAvailable(googletest) list(POP_BACK CMAKE_MESSAGE_INDENT) From d3622ba8192f5e6f0742d178ffeadc1646b002ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 17 Oct 2023 18:21:15 +0200 Subject: [PATCH 29/56] search for Eigen package when EIGEN_INCLUDE_DIR is not provided --- cmake/options.cmake | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/cmake/options.cmake b/cmake/options.cmake index 367a62721..9c0251d14 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -25,15 +25,22 @@ option(PRESSIO_ENABLE_TPL_PYBIND11 "Enable Pybind11 TPL" OFF) if(PRESSIO_ENABLE_TPL_EIGEN) message(">> Eigen is currently enabled by default via PRESSIO_ENABLE_TPL_EIGEN=ON") - if(NOT EIGEN_INCLUDE_DIR) - # FIXME: use FetchContent_Declare instead of failing? - message(FATAL_ERROR + add_definitions(-DPRESSIO_ENABLE_TPL_EIGEN) + + if(EIGEN_INCLUDE_DIR) + include_directories(${EIGEN_INCLUDE_DIR}) + else() + find_package(Eigen3) + + if(NOT EIGEN3_FOUND) + # FIXME: use FetchContent_Declare instead of failing? + message(FATAL_ERROR "I cannot find the Eigen headers. " "Please reconfigure with: -DEIGEN_INCLUDE_DIR=") - endif() + endif() - include_directories(${EIGEN_INCLUDE_DIR}) - add_definitions(-DPRESSIO_ENABLE_TPL_EIGEN) + include_directories(SYSTEM ${EIGEN3_INCLUDE_DIR}) + endif() endif() # if trilinos is on, then also set MPI, BLAS, LAPACK and KOKKOS ON From 690494a6239ec82fe0ce4eba8f56356797ceaec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 17 Oct 2023 18:42:09 +0200 Subject: [PATCH 30/56] tests: configure gtest --- tests/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 093c208f3..dcf8f0c16 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -13,6 +13,8 @@ if (GTEST_FOUND) cmake_print_variables(GTEST_INCLUDE_DIRS) else() set(GTEST_VERSION "v1.14.0") + set(BUILD_GMOCK OFF) + set(INSTALL_GTEST OFF) message(STATUS "GTest not found, fetching version ${GTEST_VERSION}") list(APPEND CMAKE_MESSAGE_INDENT "[GTest] ") From befd65e1dd5cafcb21eaa2e89293b10956f37bc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 17 Oct 2023 18:45:35 +0200 Subject: [PATCH 31/56] examples: run the example after building --- .github/workflows/ci-baseline.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-baseline.yml b/.github/workflows/ci-baseline.yml index 52fee4ef2..335efe9ce 100644 --- a/.github/workflows/ci-baseline.yml +++ b/.github/workflows/ci-baseline.yml @@ -96,4 +96,5 @@ jobs: run: | cmake -B builddir \ -DCMAKE_PREFIX_PATH=../../install \ - && cmake --build builddir + && cmake --build builddir \ + && ./builddir/pressio-cmake-example From 86c93873e5ba665ecf06b5dd693e43e07737f039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 17 Oct 2023 19:06:48 +0200 Subject: [PATCH 32/56] examples: add in-tree example --- .github/workflows/ci-baseline.yml | 10 +++++++++- examples/cmake_subdir/CMakeLists.txt | 7 +++++++ examples/cmake_subdir/main.cpp | 11 +++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 examples/cmake_subdir/CMakeLists.txt create mode 100644 examples/cmake_subdir/main.cpp diff --git a/.github/workflows/ci-baseline.yml b/.github/workflows/ci-baseline.yml index 335efe9ce..448fceff0 100644 --- a/.github/workflows/ci-baseline.yml +++ b/.github/workflows/ci-baseline.yml @@ -91,10 +91,18 @@ jobs: run: | ctest -j $num_cpus --output-on-failure - - name: Examples + - name: Example - installed working-directory: examples/cmake_installed run: | cmake -B builddir \ -DCMAKE_PREFIX_PATH=../../install \ && cmake --build builddir \ && ./builddir/pressio-cmake-example + + - name: Example - add_subdirectory + working-directory: examples/cmake_subdir + run: | + cmake -B builddir \ + -D EIGEN_INCLUDE_DIR=$eigen_inc_dir \ + && cmake --build builddir \ + && ./builddir/pressio-cmake-example diff --git a/examples/cmake_subdir/CMakeLists.txt b/examples/cmake_subdir/CMakeLists.txt new file mode 100644 index 000000000..3c22b1797 --- /dev/null +++ b/examples/cmake_subdir/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.18.0) +project(Example) + +add_subdirectory(${Example_SOURCE_DIR}/../.. ${Example_BINARY_DIR}/pressio) + +add_executable(pressio-cmake-example main.cpp) +target_link_libraries(pressio-cmake-example PUBLIC pressio) diff --git a/examples/cmake_subdir/main.cpp b/examples/cmake_subdir/main.cpp new file mode 100644 index 000000000..47044237d --- /dev/null +++ b/examples/cmake_subdir/main.cpp @@ -0,0 +1,11 @@ +#include + +int main() { + pressio::log::initialize(pressio::logto::terminal, "log.txt"); + pressio::log::setVerbosity({pressio::log::level::info}); + + double a = 1.; + PRESSIOLOG_INFO("pressio log message, {:3}", a); + + pressio::log::finalize(); +} From b799852e534219432c244c234ba7d24f7f0d81cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Wed, 18 Oct 2023 14:13:27 +0200 Subject: [PATCH 33/56] enforce PRESSIO_ENABLE_TPL_EIGEN ON --- .github/workflows/ci-baseline.yml | 6 +++--- examples/cmake_installed/CMakeLists.txt | 1 + examples/cmake_subdir/CMakeLists.txt | 1 + include/pressio/macros.hpp | 3 +-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-baseline.yml b/.github/workflows/ci-baseline.yml index 448fceff0..3f5b85c83 100644 --- a/.github/workflows/ci-baseline.yml +++ b/.github/workflows/ci-baseline.yml @@ -96,13 +96,13 @@ jobs: run: | cmake -B builddir \ -DCMAKE_PREFIX_PATH=../../install \ - && cmake --build builddir \ + && cmake --build builddir \ && ./builddir/pressio-cmake-example - name: Example - add_subdirectory working-directory: examples/cmake_subdir run: | cmake -B builddir \ - -D EIGEN_INCLUDE_DIR=$eigen_inc_dir \ - && cmake --build builddir \ + -DEIGEN_INCLUDE_DIR=$eigen_inc_dir \ + && cmake --build builddir \ && ./builddir/pressio-cmake-example diff --git a/examples/cmake_installed/CMakeLists.txt b/examples/cmake_installed/CMakeLists.txt index 9692ae218..d71e28fe0 100644 --- a/examples/cmake_installed/CMakeLists.txt +++ b/examples/cmake_installed/CMakeLists.txt @@ -5,3 +5,4 @@ find_package(pressio REQUIRED) add_executable(pressio-cmake-example main.cpp) target_link_libraries(pressio-cmake-example PUBLIC pressio) +target_compile_definitions(pressio-cmake-example PUBLIC PRESSIO_ENABLE_TPL_EIGEN) diff --git a/examples/cmake_subdir/CMakeLists.txt b/examples/cmake_subdir/CMakeLists.txt index 3c22b1797..76ac88937 100644 --- a/examples/cmake_subdir/CMakeLists.txt +++ b/examples/cmake_subdir/CMakeLists.txt @@ -5,3 +5,4 @@ add_subdirectory(${Example_SOURCE_DIR}/../.. ${Example_BINARY_DIR}/pressio) add_executable(pressio-cmake-example main.cpp) target_link_libraries(pressio-cmake-example PUBLIC pressio) +target_compile_definitions(pressio-cmake-example PUBLIC PRESSIO_ENABLE_TPL_EIGEN) diff --git a/include/pressio/macros.hpp b/include/pressio/macros.hpp index 7faeb68bc..fe8a5dac5 100644 --- a/include/pressio/macros.hpp +++ b/include/pressio/macros.hpp @@ -117,7 +117,6 @@ static_assert(_PRESSIO_CPLUSPLUS >= PRESSIO_CXX_STD_14, "PRESSIO requires C++14 #endif #endif -// FIXME: disabled for cmaked_installed example -// static_assert(PRESSIO_ENABLE_TPL_EIGEN, "Eigen is not enabled."); +static_assert(PRESSIO_ENABLE_TPL_EIGEN, "Eigen is not enabled."); #endif From 8311d1ad1fcac3efeed121619edb66064ba7a8ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Wed, 18 Oct 2023 14:26:33 +0200 Subject: [PATCH 34/56] add missing newline --- cmake/pressioConfig.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/pressioConfig.cmake.in b/cmake/pressioConfig.cmake.in index 274ab5db6..ff7e27d4b 100644 --- a/cmake/pressioConfig.cmake.in +++ b/cmake/pressioConfig.cmake.in @@ -3,4 +3,4 @@ if (NOT TARGET pressio) include ("${CMAKE_CURRENT_LIST_DIR}/pressioTargets.cmake") -endif () \ No newline at end of file +endif () From 3ab69346b4bca1939ae15ee0c0a57f811b822f25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Wed, 18 Oct 2023 16:33:52 +0200 Subject: [PATCH 35/56] examples: add include only example --- .github/workflows/ci-baseline.yml | 15 +++++++++++++-- examples/include_only/main.cpp | 11 +++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 examples/include_only/main.cpp diff --git a/.github/workflows/ci-baseline.yml b/.github/workflows/ci-baseline.yml index 3f5b85c83..21f11613f 100644 --- a/.github/workflows/ci-baseline.yml +++ b/.github/workflows/ci-baseline.yml @@ -91,7 +91,7 @@ jobs: run: | ctest -j $num_cpus --output-on-failure - - name: Example - installed + - name: Example - CMake installed working-directory: examples/cmake_installed run: | cmake -B builddir \ @@ -99,10 +99,21 @@ jobs: && cmake --build builddir \ && ./builddir/pressio-cmake-example - - name: Example - add_subdirectory + - name: Example - CMake add_subdirectory working-directory: examples/cmake_subdir run: | cmake -B builddir \ -DEIGEN_INCLUDE_DIR=$eigen_inc_dir \ && cmake --build builddir \ && ./builddir/pressio-cmake-example + + - name: Example - include only + working-directory: examples/include_only + run: | + $CXX \ + -DPRESSIO_ENABLE_TPL_EIGEN \ + -I$eigen_inc_dir \ + -I../../include \ + -c main.cpp \ + && $CXX -o pressio-example main.o \ + && ./pressio-example diff --git a/examples/include_only/main.cpp b/examples/include_only/main.cpp new file mode 100644 index 000000000..47044237d --- /dev/null +++ b/examples/include_only/main.cpp @@ -0,0 +1,11 @@ +#include + +int main() { + pressio::log::initialize(pressio::logto::terminal, "log.txt"); + pressio::log::setVerbosity({pressio::log::level::info}); + + double a = 1.; + PRESSIOLOG_INFO("pressio log message, {:3}", a); + + pressio::log::finalize(); +} From 6df197379ce631ddb4ce4e30d696946810941757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Thu, 19 Oct 2023 21:28:10 +0200 Subject: [PATCH 36/56] ci: remove unused workflow --- .github/workflows/.ci-workflow-trilinos.txt | 138 -------------------- 1 file changed, 138 deletions(-) delete mode 100644 .github/workflows/.ci-workflow-trilinos.txt diff --git a/.github/workflows/.ci-workflow-trilinos.txt b/.github/workflows/.ci-workflow-trilinos.txt deleted file mode 100644 index 034d1951f..000000000 --- a/.github/workflows/.ci-workflow-trilinos.txt +++ /dev/null @@ -1,138 +0,0 @@ -name: - -on: [push] - -jobs: - CI-trilinos: - - runs-on: ubuntu-20.04 - - strategy: - matrix: - config: - # - { - # name: "ubuntu_20.04_gcc", - # build_type: "Debug", cc: "gcc", cxx: "g++", - # options: "-eigen-path=/home/runner/work/pressio/pressio_builds/eigen/install -gtest-path=/home/runner/work/pressio/pressio_builds/gtest/install", - # envscript: "", - # requirements: "", - # ctest_build: /home/runner/work/pressio/pressio_builds/pressio/build - # } - - - # - { - # name: "ubuntu_20.04_clang", - # build_type: "Debug", cc: "clang", cxx: "clang++", - # options: "-eigen-path=/home/runner/work/pressio/pressio_builds/eigen/install -gtest-path=/home/runner/work/pressio/pressio_builds/gtest/install", - # envscript: "", - # requirements: "", - # ctest_build: /home/runner/work/pressio/pressio_builds/pressio/build - # } - - - { - name: "ubuntu_20.04_gcc_openmpi_trilinos_release", - build_type: "Release", cc: "mpicc", cxx: "mpicxx", - options: "-cmake-generator-name=default_mpi_trilinos_with_tests -eigen-path=/home/runner/work/pressio/pressio_builds/eigen/install -gtest-path=/home/runner/work/pressio/pressio_builds/gtest/install -trilinos-path=/home/runner/work/pressio/pressio_builds/trilinos/install", - envscript: "-env-script=/home/runner/work/pressio/pressio_repos/pressio-builder/sample_env_scripts/setenv_mpi_ubuntu_ci.sh", - requirements: "sudo apt install -y openmpi-bin libopenmpi-dev;sudo sed -i -e '$alocalhost slots=4' /etc/openmpi/openmpi-default-hostfile", - ctest_build: /home/runner/work/pressio/pressio_builds/pressio/build - } - - - { - name: "ubuntu_20.04_gcc_openmpi_trilinos_debug", - build_type: "Debug", cc: "mpicc", cxx: "mpicxx", - options: "-cmake-generator-name=default_mpi_trilinos_with_tests -eigen-path=/home/runner/work/pressio/pressio_builds/eigen/install -gtest-path=/home/runner/work/pressio/pressio_builds/gtest/install -trilinos-path=/home/runner/work/pressio/pressio_builds/trilinos/install", - envscript: "-env-script=/home/runner/work/pressio/pressio_repos/pressio-builder/sample_env_scripts/setenv_mpi_ubuntu_ci.sh", - requirements: "sudo apt install -y openmpi-bin libopenmpi-dev;sudo sed -i -e '$alocalhost slots=4' /etc/openmpi/openmpi-default-hostfile", - ctest_build: /home/runner/work/pressio/pressio_builds/pressio/build - } - - # - { - # name: "ubuntu_20.04_gcc_coverage", - # build_type: "Debug", cc: "gcc", cxx: "g++", - # options: "-cmake-generator-name=default_with_tests_codecov -eigen-path=/home/runner/work/pressio/pressio_builds/eigen/install -gtest-path=/home/runner/work/pressio/pressio_builds/gtest/install", - # envscript: "", - # requirements: "sudo apt install gcovr", - # ctest_build: /home/runner/work/pressio/pressio_builds/pressio/build, - # coverage: true, - # coverage_filename: "pressio_tests_coverage.xml", - # coverage_uploadname: "codecoverage-pressio", - # flag: "pressio-packages" - # } - - # - { - # name: "Ubuntu 20.04 MPI - trilinos - coverage", - # build_type: "Debug", cc: "mpicc", cxx: "mpicxx", - # options: "-cmake-generator-name=default_mpi_trilinos_with_tests_codecov -eigen-path=/home/runner/work/pressio/pressio_builds/eigen/install -gtest-path=/home/runner/work/pressio/pressio_builds/gtest/install -trilinos-path=/home/runner/work/pressio/pressio_builds/trilinos/install", - # envscript: "--ncpu-for-make=1 -env-script=/home/runner/work/pressio/pressio_repos/pressio-builder/sample_env_scripts/setenv_mpi_ubuntu_ci.sh", - # requirements: "sudo apt install -y gcovr openmpi-bin libopenmpi-dev;sudo sed -i -e '$alocalhost slots=4' /etc/openmpi/openmpi-default-hostfile", - # ctest_build: /home/runner/work/pressio/pressio_builds/pressio/build, - # coverage: true, - # coverage_filename: "pressio_tests_mpi_coverage.xml", - # coverage_uploadname: "codecoverage-pressio-trilinos", - # flag: "pressio-trilinos-packages" - # } - - steps: - - uses: actions/checkout@v1 - - name: Creating environnement... - run: | - cd .. - mkdir pressio_repos - PARENT_DIR=$(pwd) - echo "WORKSPACE_PARENT_DIR=$PARENT_DIR" >> $GITHUB_ENV - echo "PRESSIO_REPOS=$PARENT_DIR/pressio_repos" >> $GITHUB_ENV - echo "PRESSIO_BUILDS=$PARENT_DIR/pressio_builds" >> $GITHUB_ENV - sudo apt-get update - ${{ matrix.config.requirements }} - - - name: Cloning Pressio Builder... - run: | - cd ${{ env.PRESSIO_REPOS }} - git clone git://github.com/Pressio/pressio-builder.git - cd pressio-builder - git checkout main - - - name: Get TPLs... - run: | - export TERM=xterm - docker run -di perrinel/ubuntu-pressio-tpl - TNAME=$(docker ps --format "{{.Names}}") - docker cp $TNAME:/home/pressio_builds ${{ env.WORKSPACE_PARENT_DIR }} - docker stop $TNAME - docker rm $TNAME - docker image rm perrinel/ubuntu-pressio-tpl - - - name: Build - env: - CC: ${{ matrix.config.cc }} - CXX: ${{ matrix.config.cxx }} - run: | - export TERM=xterm - cd ${{ env.PRESSIO_REPOS }}/pressio-builder - ./main_pressio.sh ${{ matrix.config.envscript }} -dryrun=no \ - -build-mode=${{ matrix.config.build_type }} \ - -pressio-src=${{ env.WORKSPACE_PARENT_DIR }}/pressio \ - -target-dir=${{ env.PRESSIO_BUILDS }} \ - -cmake-generator-name=default_with_tests ${{ matrix.config.options }} \ - -ncpu-for-make=4 - - - name: Test - run: | - cd ${{ matrix.config.ctest_build }} - export LD_LIBRARY_PATH=${{ env.PRESSIO_BUILDS }}/trilinos/install/lib - ctest -V - - # - if: ${{ matrix.config.coverage }} - # name: Generate code coverage - # run: | - # cd ${{ matrix.config.ctest_build }} - # gcovr -x -r ${{ env.WORKSPACE_PARENT_DIR }}/pressio/packages -e ${{ env.WORKSPACE_PARENT_DIR }}/pressio/packages/utils/src/logger/ . -o ${{ matrix.config.coverage_filename }} - - # - if: ${{ matrix.config.coverage }} - # name: Upload code coverage - # uses: codecov/codecov-action@v1 - # with: - # file: ${{ matrix.config.ctest_build }}/${{ matrix.config.coverage_filename }} - # name: ${{ matrix.config.coverage_uploadname }} - # flags: ${{ matrix.config.flag }} From 874845c1d0525c8c49d1d9bed04833bb60b57ab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Thu, 19 Oct 2023 21:30:10 +0200 Subject: [PATCH 37/56] examples: add examples to trilinos workflow --- .github/workflows/ci-baseline.yml | 2 +- .github/workflows/ci-trilinos.yml | 27 ++++++++++- examples/cmake_installed/CMakeLists.txt | 8 ++-- examples/cmake_installed/main.cpp | 11 ----- examples/cmake_subdir/CMakeLists.txt | 11 ++--- examples/cmake_subdir/main.cpp | 11 ----- examples/include_only/main.cpp | 11 ----- examples/main.cpp | 59 +++++++++++++++++++++++++ 8 files changed, 96 insertions(+), 44 deletions(-) delete mode 100644 examples/cmake_installed/main.cpp delete mode 100644 examples/cmake_subdir/main.cpp delete mode 100644 examples/include_only/main.cpp create mode 100644 examples/main.cpp diff --git a/.github/workflows/ci-baseline.yml b/.github/workflows/ci-baseline.yml index 21f11613f..79cbe5fd9 100644 --- a/.github/workflows/ci-baseline.yml +++ b/.github/workflows/ci-baseline.yml @@ -114,6 +114,6 @@ jobs: -DPRESSIO_ENABLE_TPL_EIGEN \ -I$eigen_inc_dir \ -I../../include \ - -c main.cpp \ + -c ../main.cpp \ && $CXX -o pressio-example main.o \ && ./pressio-example diff --git a/.github/workflows/ci-trilinos.yml b/.github/workflows/ci-trilinos.yml index b74771bd4..e377cbf19 100644 --- a/.github/workflows/ci-trilinos.yml +++ b/.github/workflows/ci-trilinos.yml @@ -77,7 +77,7 @@ jobs: -D CMAKE_CXX_FLAGS='' - name: Build - run: cmake --build builddir -j $num_cpus + run: cmake --build builddir -j $num_cpus --target install - name: Test working-directory: builddir @@ -87,4 +87,29 @@ jobs: export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 ctest -j $num_cpus --output-on-failure + - name: Example - CMake installed + working-directory: examples/cmake_installed + run: | + cmake -B builddir \ + -DCMAKE_PREFIX_PATH=../../install \ + && cmake --build builddir \ + && ./builddir/pressio-cmake-example + + - name: Example - CMake add_subdirectory + working-directory: examples/cmake_subdir + run: | + cmake -B builddir \ + -DEIGEN_INCLUDE_DIR=$eigen_inc_dir \ + && cmake --build builddir \ + && ./builddir/pressio-cmake-example + - name: Example - include only + working-directory: examples/include_only + run: | + $CXX \ + -DPRESSIO_ENABLE_TPL_EIGEN \ + -I$eigen_inc_dir \ + -I../../include \ + -c ../main.cpp \ + && $CXX -o pressio-example main.o \ + && ./pressio-example diff --git a/examples/cmake_installed/CMakeLists.txt b/examples/cmake_installed/CMakeLists.txt index d71e28fe0..d4f91f53e 100644 --- a/examples/cmake_installed/CMakeLists.txt +++ b/examples/cmake_installed/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.18.0) -project(pressio-cmake-example) +set(example pressio-example) find_package(pressio REQUIRED) -add_executable(pressio-cmake-example main.cpp) -target_link_libraries(pressio-cmake-example PUBLIC pressio) -target_compile_definitions(pressio-cmake-example PUBLIC PRESSIO_ENABLE_TPL_EIGEN) +add_executable(${example} ${CMAKE_CURRENT_SOURCE_DIR}/../main.cpp) +target_link_libraries(${example} PUBLIC pressio) +target_compile_definitions(${example} PUBLIC PRESSIO_ENABLE_TPL_EIGEN) diff --git a/examples/cmake_installed/main.cpp b/examples/cmake_installed/main.cpp deleted file mode 100644 index 47044237d..000000000 --- a/examples/cmake_installed/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include - -int main() { - pressio::log::initialize(pressio::logto::terminal, "log.txt"); - pressio::log::setVerbosity({pressio::log::level::info}); - - double a = 1.; - PRESSIOLOG_INFO("pressio log message, {:3}", a); - - pressio::log::finalize(); -} diff --git a/examples/cmake_subdir/CMakeLists.txt b/examples/cmake_subdir/CMakeLists.txt index 76ac88937..c4aa74f70 100644 --- a/examples/cmake_subdir/CMakeLists.txt +++ b/examples/cmake_subdir/CMakeLists.txt @@ -1,8 +1,9 @@ cmake_minimum_required(VERSION 3.18.0) -project(Example) +set(example pressio-example) +project(${example}) -add_subdirectory(${Example_SOURCE_DIR}/../.. ${Example_BINARY_DIR}/pressio) +add_subdirectory(${${example}_SOURCE_DIR}/../.. ${${example}_BINARY_DIR}/pressio) -add_executable(pressio-cmake-example main.cpp) -target_link_libraries(pressio-cmake-example PUBLIC pressio) -target_compile_definitions(pressio-cmake-example PUBLIC PRESSIO_ENABLE_TPL_EIGEN) +add_executable(${example} ${CMAKE_CURRENT_SOURCE_DIR}/../main.cpp) +target_link_libraries(${example} PUBLIC pressio) +target_compile_definitions(${example} PUBLIC PRESSIO_ENABLE_TPL_EIGEN) diff --git a/examples/cmake_subdir/main.cpp b/examples/cmake_subdir/main.cpp deleted file mode 100644 index 47044237d..000000000 --- a/examples/cmake_subdir/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include - -int main() { - pressio::log::initialize(pressio::logto::terminal, "log.txt"); - pressio::log::setVerbosity({pressio::log::level::info}); - - double a = 1.; - PRESSIOLOG_INFO("pressio log message, {:3}", a); - - pressio::log::finalize(); -} diff --git a/examples/include_only/main.cpp b/examples/include_only/main.cpp deleted file mode 100644 index 47044237d..000000000 --- a/examples/include_only/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include - -int main() { - pressio::log::initialize(pressio::logto::terminal, "log.txt"); - pressio::log::setVerbosity({pressio::log::level::info}); - - double a = 1.; - PRESSIOLOG_INFO("pressio log message, {:3}", a); - - pressio::log::finalize(); -} diff --git a/examples/main.cpp b/examples/main.cpp new file mode 100644 index 000000000..6e1bd47f6 --- /dev/null +++ b/examples/main.cpp @@ -0,0 +1,59 @@ +/* +//@HEADER +// ************************************************************************ +// +// main.cpp +// Pressio +// Copyright 2019 +// National Technology & Engineering Solutions of Sandia, LLC (NTESS) +// +// Under the terms of Contract DE-NA0003525 with NTESS, the +// U.S. Government retains certain rights in this software. +// +// Pressio is licensed under BSD-3-Clause terms of use: +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// Questions? Contact Francesco Rizzi (fnrizzi@sandia.gov) +// +// ************************************************************************ +//@HEADER +*/ + +#include + +int main() { + pressio::log::initialize(pressio::logto::terminal, "log.txt"); + pressio::log::setVerbosity({pressio::log::level::info}); + + double a = 1.; + PRESSIOLOG_INFO("pressio log message, {:3}", a); + + pressio::log::finalize(); +} From f9ba0c65c41a0b107fd61af2d4da3fca17efc64a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Fri, 20 Oct 2023 13:55:35 +0200 Subject: [PATCH 38/56] fix examples --- .github/workflows/ci-baseline.yml | 10 +++++----- .github/workflows/ci-trilinos.yml | 10 +++++----- examples/cmake_installed/CMakeLists.txt | 1 + 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci-baseline.yml b/.github/workflows/ci-baseline.yml index 79cbe5fd9..9fcc59665 100644 --- a/.github/workflows/ci-baseline.yml +++ b/.github/workflows/ci-baseline.yml @@ -97,7 +97,7 @@ jobs: cmake -B builddir \ -DCMAKE_PREFIX_PATH=../../install \ && cmake --build builddir \ - && ./builddir/pressio-cmake-example + && ./builddir/pressio-example - name: Example - CMake add_subdirectory working-directory: examples/cmake_subdir @@ -105,15 +105,15 @@ jobs: cmake -B builddir \ -DEIGEN_INCLUDE_DIR=$eigen_inc_dir \ && cmake --build builddir \ - && ./builddir/pressio-cmake-example + && ./builddir/pressio-example - name: Example - include only - working-directory: examples/include_only + working-directory: examples run: | $CXX \ -DPRESSIO_ENABLE_TPL_EIGEN \ -I$eigen_inc_dir \ - -I../../include \ - -c ../main.cpp \ + -I../include \ + -c main.cpp \ && $CXX -o pressio-example main.o \ && ./pressio-example diff --git a/.github/workflows/ci-trilinos.yml b/.github/workflows/ci-trilinos.yml index e377cbf19..05d876ee9 100644 --- a/.github/workflows/ci-trilinos.yml +++ b/.github/workflows/ci-trilinos.yml @@ -93,7 +93,7 @@ jobs: cmake -B builddir \ -DCMAKE_PREFIX_PATH=../../install \ && cmake --build builddir \ - && ./builddir/pressio-cmake-example + && ./builddir/pressio-example - name: Example - CMake add_subdirectory working-directory: examples/cmake_subdir @@ -101,15 +101,15 @@ jobs: cmake -B builddir \ -DEIGEN_INCLUDE_DIR=$eigen_inc_dir \ && cmake --build builddir \ - && ./builddir/pressio-cmake-example + && ./builddir/pressio-example - name: Example - include only - working-directory: examples/include_only + working-directory: examples run: | $CXX \ -DPRESSIO_ENABLE_TPL_EIGEN \ -I$eigen_inc_dir \ - -I../../include \ - -c ../main.cpp \ + -I../include \ + -c main.cpp \ && $CXX -o pressio-example main.o \ && ./pressio-example diff --git a/examples/cmake_installed/CMakeLists.txt b/examples/cmake_installed/CMakeLists.txt index d4f91f53e..48b2d5ccd 100644 --- a/examples/cmake_installed/CMakeLists.txt +++ b/examples/cmake_installed/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required(VERSION 3.18.0) set(example pressio-example) +project(${example}) find_package(pressio REQUIRED) From bd9eb3f076982c47e6f45f57e52167a7078b575b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Mon, 30 Oct 2023 22:21:51 +0100 Subject: [PATCH 39/56] ci: add another example --- .github/workflows/ci-baseline.yml | 21 +++++++++++ examples/main_with_defines.cpp | 62 +++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 examples/main_with_defines.cpp diff --git a/.github/workflows/ci-baseline.yml b/.github/workflows/ci-baseline.yml index 9fcc59665..c498e4f5f 100644 --- a/.github/workflows/ci-baseline.yml +++ b/.github/workflows/ci-baseline.yml @@ -117,3 +117,24 @@ jobs: -c main.cpp \ && $CXX -o pressio-example main.o \ && ./pressio-example + + - name: Example - include only + working-directory: examples + run: | + $CXX \ + -DPRESSIO_ENABLE_TPL_EIGEN \ + -I$eigen_inc_dir \ + -I../include \ + -c main.cpp \ + && $CXX -o pressio-example main.o \ + && ./pressio-example + + - name: Example - include only with embedded definitions + working-directory: examples + run: | + $CXX \ + -I$eigen_inc_dir \ + -I../include \ + -c main_with_defines.cpp \ + && $CXX -o pressio-example main.o \ + && ./pressio-example diff --git a/examples/main_with_defines.cpp b/examples/main_with_defines.cpp new file mode 100644 index 000000000..54bb8f80d --- /dev/null +++ b/examples/main_with_defines.cpp @@ -0,0 +1,62 @@ +/* +//@HEADER +// ************************************************************************ +// +// main_with_defines.cpp +// Pressio +// Copyright 2019 +// National Technology & Engineering Solutions of Sandia, LLC (NTESS) +// +// Under the terms of Contract DE-NA0003525 with NTESS, the +// U.S. Government retains certain rights in this software. +// +// Pressio is licensed under BSD-3-Clause terms of use: +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// Questions? Contact Francesco Rizzi (fnrizzi@sandia.gov) +// +// ************************************************************************ +//@HEADER +*/ + +#define PRESSIO_ENABLE_TPL_EIGEN +#define PRESSIO_LOG_LEVEL_INFO + +#include + +int main() { + pressio::log::initialize(pressio::logto::terminal, "log.txt"); + pressio::log::setVerbosity({pressio::log::level::info}); + + double a = 1.; + PRESSIOLOG_INFO("pressio log message, {:3}", a); + + pressio::log::finalize(); +} From 392307d0890196fc5940f8adc958b413e6576527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Mon, 30 Oct 2023 22:22:20 +0100 Subject: [PATCH 40/56] ci: run tests after examples --- .github/workflows/ci-baseline.yml | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci-baseline.yml b/.github/workflows/ci-baseline.yml index c498e4f5f..bacc921ec 100644 --- a/.github/workflows/ci-baseline.yml +++ b/.github/workflows/ci-baseline.yml @@ -86,11 +86,6 @@ jobs: run: | cmake --build builddir --target install - - name: Test - working-directory: builddir - run: | - ctest -j $num_cpus --output-on-failure - - name: Example - CMake installed working-directory: examples/cmake_installed run: | @@ -118,17 +113,6 @@ jobs: && $CXX -o pressio-example main.o \ && ./pressio-example - - name: Example - include only - working-directory: examples - run: | - $CXX \ - -DPRESSIO_ENABLE_TPL_EIGEN \ - -I$eigen_inc_dir \ - -I../include \ - -c main.cpp \ - && $CXX -o pressio-example main.o \ - && ./pressio-example - - name: Example - include only with embedded definitions working-directory: examples run: | @@ -138,3 +122,8 @@ jobs: -c main_with_defines.cpp \ && $CXX -o pressio-example main.o \ && ./pressio-example + + - name: Test + working-directory: builddir + run: | + ctest -j $num_cpus --output-on-failure From 1c4522842e391650f5b18f8b9d5d0a6c2d3caa43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Mon, 30 Oct 2023 22:27:24 +0100 Subject: [PATCH 41/56] ci: use separate repository for examples --- .github/workflows/ci-baseline.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci-baseline.yml b/.github/workflows/ci-baseline.yml index bacc921ec..a340c9e91 100644 --- a/.github/workflows/ci-baseline.yml +++ b/.github/workflows/ci-baseline.yml @@ -86,6 +86,12 @@ jobs: run: | cmake --build builddir --target install + - name: Checkout pressio examples + uses: actions/checkout@v4 + with: + repository: Pressio/pressio-templates-usage-as-library + path: pressio-templates-usage-as-library + - name: Example - CMake installed working-directory: examples/cmake_installed run: | From 2cad07da071d406ebdcabe58a5a866f2d6dae0bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Mon, 30 Oct 2023 22:38:08 +0100 Subject: [PATCH 42/56] use correct file name --- include/pressio/macros.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pressio/macros.hpp b/include/pressio/macros.hpp index fe8a5dac5..9f7e59395 100644 --- a/include/pressio/macros.hpp +++ b/include/pressio/macros.hpp @@ -2,7 +2,7 @@ //@HEADER // ************************************************************************ // -// pressio_cmake_config.h.in +// macros.hpp // Pressio // Copyright 2019 // National Technology & Engineering Solutions of Sandia, LLC (NTESS) From f3906007b2e681a15551cd0ecf9be28501602f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 31 Oct 2023 15:01:35 +0100 Subject: [PATCH 43/56] ci: use examples from a separate repo --- .github/workflows/ci-baseline.yml | 6 +-- examples/cmake_installed/CMakeLists.txt | 9 ---- examples/cmake_subdir/CMakeLists.txt | 9 ---- examples/main.cpp | 59 ----------------------- examples/main_with_defines.cpp | 62 ------------------------- 5 files changed, 3 insertions(+), 142 deletions(-) delete mode 100644 examples/cmake_installed/CMakeLists.txt delete mode 100644 examples/cmake_subdir/CMakeLists.txt delete mode 100644 examples/main.cpp delete mode 100644 examples/main_with_defines.cpp diff --git a/.github/workflows/ci-baseline.yml b/.github/workflows/ci-baseline.yml index a340c9e91..bee9a8032 100644 --- a/.github/workflows/ci-baseline.yml +++ b/.github/workflows/ci-baseline.yml @@ -90,10 +90,10 @@ jobs: uses: actions/checkout@v4 with: repository: Pressio/pressio-templates-usage-as-library - path: pressio-templates-usage-as-library + path: examples - name: Example - CMake installed - working-directory: examples/cmake_installed + working-directory: examples/cmake_find_package run: | cmake -B builddir \ -DCMAKE_PREFIX_PATH=../../install \ @@ -101,7 +101,7 @@ jobs: && ./builddir/pressio-example - name: Example - CMake add_subdirectory - working-directory: examples/cmake_subdir + working-directory: examples/cmake_add_subdirectory run: | cmake -B builddir \ -DEIGEN_INCLUDE_DIR=$eigen_inc_dir \ diff --git a/examples/cmake_installed/CMakeLists.txt b/examples/cmake_installed/CMakeLists.txt deleted file mode 100644 index 48b2d5ccd..000000000 --- a/examples/cmake_installed/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.18.0) -set(example pressio-example) -project(${example}) - -find_package(pressio REQUIRED) - -add_executable(${example} ${CMAKE_CURRENT_SOURCE_DIR}/../main.cpp) -target_link_libraries(${example} PUBLIC pressio) -target_compile_definitions(${example} PUBLIC PRESSIO_ENABLE_TPL_EIGEN) diff --git a/examples/cmake_subdir/CMakeLists.txt b/examples/cmake_subdir/CMakeLists.txt deleted file mode 100644 index c4aa74f70..000000000 --- a/examples/cmake_subdir/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.18.0) -set(example pressio-example) -project(${example}) - -add_subdirectory(${${example}_SOURCE_DIR}/../.. ${${example}_BINARY_DIR}/pressio) - -add_executable(${example} ${CMAKE_CURRENT_SOURCE_DIR}/../main.cpp) -target_link_libraries(${example} PUBLIC pressio) -target_compile_definitions(${example} PUBLIC PRESSIO_ENABLE_TPL_EIGEN) diff --git a/examples/main.cpp b/examples/main.cpp deleted file mode 100644 index 6e1bd47f6..000000000 --- a/examples/main.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* -//@HEADER -// ************************************************************************ -// -// main.cpp -// Pressio -// Copyright 2019 -// National Technology & Engineering Solutions of Sandia, LLC (NTESS) -// -// Under the terms of Contract DE-NA0003525 with NTESS, the -// U.S. Government retains certain rights in this software. -// -// Pressio is licensed under BSD-3-Clause terms of use: -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Francesco Rizzi (fnrizzi@sandia.gov) -// -// ************************************************************************ -//@HEADER -*/ - -#include - -int main() { - pressio::log::initialize(pressio::logto::terminal, "log.txt"); - pressio::log::setVerbosity({pressio::log::level::info}); - - double a = 1.; - PRESSIOLOG_INFO("pressio log message, {:3}", a); - - pressio::log::finalize(); -} diff --git a/examples/main_with_defines.cpp b/examples/main_with_defines.cpp deleted file mode 100644 index 54bb8f80d..000000000 --- a/examples/main_with_defines.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* -//@HEADER -// ************************************************************************ -// -// main_with_defines.cpp -// Pressio -// Copyright 2019 -// National Technology & Engineering Solutions of Sandia, LLC (NTESS) -// -// Under the terms of Contract DE-NA0003525 with NTESS, the -// U.S. Government retains certain rights in this software. -// -// Pressio is licensed under BSD-3-Clause terms of use: -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Francesco Rizzi (fnrizzi@sandia.gov) -// -// ************************************************************************ -//@HEADER -*/ - -#define PRESSIO_ENABLE_TPL_EIGEN -#define PRESSIO_LOG_LEVEL_INFO - -#include - -int main() { - pressio::log::initialize(pressio::logto::terminal, "log.txt"); - pressio::log::setVerbosity({pressio::log::level::info}); - - double a = 1.; - PRESSIOLOG_INFO("pressio log message, {:3}", a); - - pressio::log::finalize(); -} From 45cd9b8bc6bb1709dcc54252141fd4d311a2eba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 31 Oct 2023 16:44:05 +0100 Subject: [PATCH 44/56] ci: adjust trilinos build --- .github/workflows/ci-trilinos.yml | 36 +++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci-trilinos.yml b/.github/workflows/ci-trilinos.yml index 05d876ee9..eed3eee79 100644 --- a/.github/workflows/ci-trilinos.yml +++ b/.github/workflows/ci-trilinos.yml @@ -79,16 +79,15 @@ jobs: - name: Build run: cmake --build builddir -j $num_cpus --target install - - name: Test - working-directory: builddir - run: | - export LD_LIBRARY_PATH=${{ env.trilinos_dir }}/lib - export OMPI_ALLOW_RUN_AS_ROOT=1 - export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 - ctest -j $num_cpus --output-on-failure + - name: Checkout pressio examples + uses: actions/checkout@v4 + with: + repository: Pressio/pressio-templates-usage-as-library + path: examples + ref: ci - name: Example - CMake installed - working-directory: examples/cmake_installed + working-directory: examples/cmake_find_package run: | cmake -B builddir \ -DCMAKE_PREFIX_PATH=../../install \ @@ -96,7 +95,7 @@ jobs: && ./builddir/pressio-example - name: Example - CMake add_subdirectory - working-directory: examples/cmake_subdir + working-directory: examples/cmake_add_subdirectory run: | cmake -B builddir \ -DEIGEN_INCLUDE_DIR=$eigen_inc_dir \ @@ -113,3 +112,22 @@ jobs: -c main.cpp \ && $CXX -o pressio-example main.o \ && ./pressio-example + + + - name: Example - include only with embedded definitions + working-directory: examples + run: | + $CXX \ + -I$eigen_inc_dir \ + -I../include \ + -c main_with_defines.cpp \ + && $CXX -o pressio-example main.o \ + && ./pressio-example + + - name: Test + working-directory: builddir + run: | + export LD_LIBRARY_PATH=${{ env.trilinos_dir }}/lib + export OMPI_ALLOW_RUN_AS_ROOT=1 + export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 + ctest -j $num_cpus --output-on-failure From 8fff1f96525f66ee9b99ffec54a8dc3dd0a8a412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 31 Oct 2023 17:07:25 +0100 Subject: [PATCH 45/56] ci: add more examples --- .github/workflows/ci-baseline.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci-baseline.yml b/.github/workflows/ci-baseline.yml index bee9a8032..c334dc539 100644 --- a/.github/workflows/ci-baseline.yml +++ b/.github/workflows/ci-baseline.yml @@ -108,6 +108,14 @@ jobs: && cmake --build builddir \ && ./builddir/pressio-example + - name: Example - CMake include_directories + working-directory: examples/cmake_include_directories + run: | + cmake -B builddir \ + -DEIGEN_INCLUDE_DIR=$eigen_inc_dir \ + && cmake --build builddir \ + && ./builddir/pressio-example + - name: Example - include only working-directory: examples run: | From 8a0237e7eadcc0796f497e2252b52108d671b005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 31 Oct 2023 18:35:33 +0100 Subject: [PATCH 46/56] ci: use `main` branch for examples --- .github/workflows/ci-trilinos.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci-trilinos.yml b/.github/workflows/ci-trilinos.yml index eed3eee79..1fd561523 100644 --- a/.github/workflows/ci-trilinos.yml +++ b/.github/workflows/ci-trilinos.yml @@ -84,7 +84,6 @@ jobs: with: repository: Pressio/pressio-templates-usage-as-library path: examples - ref: ci - name: Example - CMake installed working-directory: examples/cmake_find_package From 6e117d08384e7074686a9ab52b72baad1486fbe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 31 Oct 2023 18:54:56 +0100 Subject: [PATCH 47/56] ci: restore test categorization --- .github/workflows/ci-baseline.yml | 14 ++++++++++++-- tests/CMakeLists.txt | 12 +++++++++++- tests/functional_large/CMakeLists.txt | 2 ++ tests/functional_medium/CMakeLists.txt | 2 ++ 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 tests/functional_large/CMakeLists.txt create mode 100644 tests/functional_medium/CMakeLists.txt diff --git a/.github/workflows/ci-baseline.yml b/.github/workflows/ci-baseline.yml index c334dc539..ac0ec71c6 100644 --- a/.github/workflows/ci-baseline.yml +++ b/.github/workflows/ci-baseline.yml @@ -137,7 +137,17 @@ jobs: && $CXX -o pressio-example main.o \ && ./pressio-example - - name: Test - working-directory: builddir + - name: Run small tests + working-directory: builddir/tests/functional_small + run: | + ctest -j $num_cpus --output-on-failure + + - name: Run medium tests + working-directory: builddir/tests/functional_medium + run: | + ctest -j $num_cpus --output-on-failure + + - name: Run large tests + working-directory: builddir/tests/functional_large run: | ctest -j $num_cpus --output-on-failure diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index dcf8f0c16..edc4a8667 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -38,4 +38,14 @@ message("${Magenta}>> Google tests main files are in: ${GTESTMAINSDIR} ${ColourR # --------------------------------- # 3. add test subdirectories # --------------------------------- -add_subdirectory(functional_small) +if(PRESSIO_ENABLE_FUNCTIONAL_SMALL_TESTS OR PRESSIO_ENABLE_TESTS) + add_subdirectory(functional_small) +endif() + +if(PRESSIO_ENABLE_FUNCTIONAL_MEDIUM_TESTS OR PRESSIO_ENABLE_TESTS) + add_subdirectory(functional_medium) +endif() + +if(PRESSIO_ENABLE_FUNCTIONAL_LARGE_TESTS OR PRESSIO_ENABLE_TESTS) + add_subdirectory(functional_large) +endif() diff --git a/tests/functional_large/CMakeLists.txt b/tests/functional_large/CMakeLists.txt new file mode 100644 index 000000000..1fea968d9 --- /dev/null +++ b/tests/functional_large/CMakeLists.txt @@ -0,0 +1,2 @@ +#add_subdirectory(...) + diff --git a/tests/functional_medium/CMakeLists.txt b/tests/functional_medium/CMakeLists.txt new file mode 100644 index 000000000..1fea968d9 --- /dev/null +++ b/tests/functional_medium/CMakeLists.txt @@ -0,0 +1,2 @@ +#add_subdirectory(...) + From d0de1e215cdad1ddf52f9d794aaa06ef4354b8d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 31 Oct 2023 20:07:26 +0100 Subject: [PATCH 48/56] disable static_assert --- include/pressio/macros.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pressio/macros.hpp b/include/pressio/macros.hpp index 9f7e59395..0c024d53e 100644 --- a/include/pressio/macros.hpp +++ b/include/pressio/macros.hpp @@ -117,6 +117,6 @@ static_assert(_PRESSIO_CPLUSPLUS >= PRESSIO_CXX_STD_14, "PRESSIO requires C++14 #endif #endif -static_assert(PRESSIO_ENABLE_TPL_EIGEN, "Eigen is not enabled."); +// static_assert(PRESSIO_ENABLE_TPL_EIGEN, "Eigen is not enabled."); #endif From fee2a3154a3109df27baa33c2085b8f7c6e6f117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 31 Oct 2023 20:09:02 +0100 Subject: [PATCH 49/56] ci: use upgrade checkout action --- .github/workflows/ci-trilinos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-trilinos.yml b/.github/workflows/ci-trilinos.yml index 1fd561523..2e8649958 100644 --- a/.github/workflows/ci-trilinos.yml +++ b/.github/workflows/ci-trilinos.yml @@ -47,7 +47,7 @@ jobs: trilinos_dir: /home/pressio_builds/trilinos/install steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Creating environnement run: | From 978e41fa5aa399c96fc58c2357fce53060770300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 31 Oct 2023 20:13:36 +0100 Subject: [PATCH 50/56] ci: update trinilons examples --- .github/workflows/ci-trilinos.yml | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci-trilinos.yml b/.github/workflows/ci-trilinos.yml index 2e8649958..7256f8ccf 100644 --- a/.github/workflows/ci-trilinos.yml +++ b/.github/workflows/ci-trilinos.yml @@ -93,6 +93,14 @@ jobs: && cmake --build builddir \ && ./builddir/pressio-example + - name: Example - CMake include_directories + working-directory: examples/cmake_include_directories + run: | + cmake -B builddir \ + -DEIGEN_INCLUDE_DIR=$eigen_inc_dir \ + && cmake --build builddir \ + && ./builddir/pressio-example + - name: Example - CMake add_subdirectory working-directory: examples/cmake_add_subdirectory run: | @@ -105,10 +113,11 @@ jobs: working-directory: examples run: | $CXX \ - -DPRESSIO_ENABLE_TPL_EIGEN \ - -I$eigen_inc_dir \ - -I../include \ - -c main.cpp \ + -DPRESSIO_ENABLE_TPL_EIGEN \ + -DPRESSIO_ENABLE_TPL_TRILINOS \ + -I$eigen_inc_dir \ + -I../include \ + -c main.cpp \ && $CXX -o pressio-example main.o \ && ./pressio-example @@ -117,9 +126,10 @@ jobs: working-directory: examples run: | $CXX \ - -I$eigen_inc_dir \ - -I../include \ - -c main_with_defines.cpp \ + -DPRESSIO_ENABLE_TPL_TRILINOS \ + -I$eigen_inc_dir \ + -I../include \ + -c main_with_defines.cpp \ && $CXX -o pressio-example main.o \ && ./pressio-example From 0dc3d12e2eab8fd31dd3fc07b0113f35c166966a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 31 Oct 2023 20:38:59 +0100 Subject: [PATCH 51/56] move test specific configuration to test dir --- CMakeLists.txt | 1 - tests/CMakeLists.txt | 2 ++ {cmake => tests/cmake}/options.cmake | 2 +- tests/cmake/tpls.cmake | 35 +--------------------------- 4 files changed, 4 insertions(+), 36 deletions(-) rename {cmake => tests/cmake}/options.cmake (96%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fb2da273..1b024a29b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,6 @@ project(pressio C CXX) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(colors) -include(options) #===================================================================== # versioning diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index edc4a8667..c2abfc4d5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -3,6 +3,8 @@ include(CMakePrintHelpers) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(macrosForCreatingTests) include(macrosForCreatingUnitTests) +include(options) +include(tpls) # --------------------------------- # 1. find or get gtest diff --git a/cmake/options.cmake b/tests/cmake/options.cmake similarity index 96% rename from cmake/options.cmake rename to tests/cmake/options.cmake index 9c0251d14..afd417bd3 100644 --- a/cmake/options.cmake +++ b/tests/cmake/options.cmake @@ -51,7 +51,7 @@ if(PRESSIO_ENABLE_TPL_TRILINOS) set(PRESSIO_ENABLE_TPL_MPI ON) find_package(Trilinos REQUIRED) - # FIXME: it is possible to use find_package() for each (sub)package + # TODO: it is possible to use find_package() for each (sub)package # https://trilinos.github.io/pdfs/Finding_Trilinos.txt add_definitions(-DPRESSIO_ENABLE_TPL_TRILINOS) diff --git a/tests/cmake/tpls.cmake b/tests/cmake/tpls.cmake index d7a39644c..aa9d70889 100644 --- a/tests/cmake/tpls.cmake +++ b/tests/cmake/tpls.cmake @@ -97,46 +97,13 @@ endif() if(PRESSIO_ENABLE_TPL_TRILINOS) if(PRESSIO_ENABLE_UNIT_TESTS OR PRESSIO_ENABLE_TESTS) - if (NOT TRILINOS_ROOT) + if (NOT Trilinos_FOUND AND NOT TRILINOS_ROOT) message(FATAL_ERROR "You enabled PRESSIO_ENABLE_TPL_TRILINOS but did not set TRILINOS_ROOT. Please reconfigure with: -D TRILINOS_ROOT= ") endif() - - set(TRILINOS_LIB_NAMES kokkosalgorithms - kokkoscontainers - kokkoscore - teuchoskokkoscomm - teuchoskokkoscompat - teuchosremainder - teuchosnumerics - teuchoscomm - teuchosparameterlist - teuchosparser - teuchoscore - epetra - epetraext - ifpack - aztecoo - tpetraext - tpetrainout - tpetra - kokkostsqr - tpetraclassiclinalg - tpetraclassicnodeapi - tpetraclassic - kokkoskernels - ifpack2 - triutils - # repeat to solve issue we have on linux - kokkosalgorithms - teuchosparameterlist) - - include_directories(${TRILINOS_ROOT}/include) - link_directories(${TRILINOS_ROOT}/lib ${TRILINOS_ROOT}/lib64) - link_libraries(${TRILINOS_LIB_NAMES}) endif() endif() From 1b74bb6522b6abf12e87cda7b02a31b69b869731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 31 Oct 2023 21:17:31 +0100 Subject: [PATCH 52/56] ci: reorganize examples --- .github/workflows/ci-baseline.yml | 56 +++++++++++++++--------------- .github/workflows/ci-trilinos.yml | 57 +++++++++++++++---------------- tests/cmake/options.cmake | 2 -- 3 files changed, 55 insertions(+), 60 deletions(-) diff --git a/.github/workflows/ci-baseline.yml b/.github/workflows/ci-baseline.yml index ac0ec71c6..29dc4d761 100644 --- a/.github/workflows/ci-baseline.yml +++ b/.github/workflows/ci-baseline.yml @@ -64,7 +64,34 @@ jobs: gtest_dir: /usr/local/gtest/install steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + + - name: Checkout pressio examples + uses: actions/checkout@v4 + with: + repository: Pressio/pressio-templates-usage-as-library + path: examples + + - name: Example - include only + working-directory: examples + run: | + $CXX \ + -DPRESSIO_ENABLE_TPL_EIGEN \ + -I$eigen_inc_dir \ + -I../include \ + -c main.cpp \ + && $CXX -o pressio-example main.o \ + && ./pressio-example + + - name: Example - include only with embedded definitions + working-directory: examples + run: | + $CXX \ + -I$eigen_inc_dir \ + -I../include \ + -c main_with_defines.cpp \ + && $CXX -o pressio-example main.o \ + && ./pressio-example - name: Configure run: | @@ -86,12 +113,6 @@ jobs: run: | cmake --build builddir --target install - - name: Checkout pressio examples - uses: actions/checkout@v4 - with: - repository: Pressio/pressio-templates-usage-as-library - path: examples - - name: Example - CMake installed working-directory: examples/cmake_find_package run: | @@ -116,27 +137,6 @@ jobs: && cmake --build builddir \ && ./builddir/pressio-example - - name: Example - include only - working-directory: examples - run: | - $CXX \ - -DPRESSIO_ENABLE_TPL_EIGEN \ - -I$eigen_inc_dir \ - -I../include \ - -c main.cpp \ - && $CXX -o pressio-example main.o \ - && ./pressio-example - - - name: Example - include only with embedded definitions - working-directory: examples - run: | - $CXX \ - -I$eigen_inc_dir \ - -I../include \ - -c main_with_defines.cpp \ - && $CXX -o pressio-example main.o \ - && ./pressio-example - - name: Run small tests working-directory: builddir/tests/functional_small run: | diff --git a/.github/workflows/ci-trilinos.yml b/.github/workflows/ci-trilinos.yml index 7256f8ccf..4db5bf93e 100644 --- a/.github/workflows/ci-trilinos.yml +++ b/.github/workflows/ci-trilinos.yml @@ -49,11 +49,38 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Checkout pressio examples + uses: actions/checkout@v4 + with: + repository: Pressio/pressio-templates-usage-as-library + path: examples + - name: Creating environnement run: | apt-get update -y ${{ matrix.requirements }} + - name: Example - include only + working-directory: examples + run: | + $CXX \ + -DPRESSIO_ENABLE_TPL_EIGEN \ + -DPRESSIO_ENABLE_TPL_TRILINOS \ + -I$eigen_inc_dir \ + -I$trilinos_dir/include \ + -I../include \ + -c main.cpp + + - name: Example - include only with embedded definitions + working-directory: examples + run: | + $CXX \ + -DPRESSIO_ENABLE_TPL_TRILINOS \ + -I$eigen_inc_dir \ + -I$trilinos_dir/include \ + -I../include \ + -c main_with_defines.cpp + - name: Configure run: | cmake -B builddir \ @@ -79,12 +106,6 @@ jobs: - name: Build run: cmake --build builddir -j $num_cpus --target install - - name: Checkout pressio examples - uses: actions/checkout@v4 - with: - repository: Pressio/pressio-templates-usage-as-library - path: examples - - name: Example - CMake installed working-directory: examples/cmake_find_package run: | @@ -109,30 +130,6 @@ jobs: && cmake --build builddir \ && ./builddir/pressio-example - - name: Example - include only - working-directory: examples - run: | - $CXX \ - -DPRESSIO_ENABLE_TPL_EIGEN \ - -DPRESSIO_ENABLE_TPL_TRILINOS \ - -I$eigen_inc_dir \ - -I../include \ - -c main.cpp \ - && $CXX -o pressio-example main.o \ - && ./pressio-example - - - - name: Example - include only with embedded definitions - working-directory: examples - run: | - $CXX \ - -DPRESSIO_ENABLE_TPL_TRILINOS \ - -I$eigen_inc_dir \ - -I../include \ - -c main_with_defines.cpp \ - && $CXX -o pressio-example main.o \ - && ./pressio-example - - name: Test working-directory: builddir run: | diff --git a/tests/cmake/options.cmake b/tests/cmake/options.cmake index afd417bd3..4459021b0 100644 --- a/tests/cmake/options.cmake +++ b/tests/cmake/options.cmake @@ -57,8 +57,6 @@ if(PRESSIO_ENABLE_TPL_TRILINOS) include_directories(${Trilinos_INCLUDE_DIRS}) link_libraries(${Trilinos_LIBRARIES}) - - # FINISH THIS endif() if(PRESSIO_ENABLE_TPL_KOKKOS) From aa6bc1616f28cd38dd819b099320eee6a454f5d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Thu, 2 Nov 2023 17:14:07 +0100 Subject: [PATCH 53/56] tests: add missing definitions --- tests/cmake/options.cmake | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tests/cmake/options.cmake b/tests/cmake/options.cmake index 4459021b0..a82686727 100644 --- a/tests/cmake/options.cmake +++ b/tests/cmake/options.cmake @@ -20,7 +20,6 @@ option(PRESSIO_ENABLE_TPL_TRILINOS "Enable Trilinos TPL" OFF) option(PRESSIO_ENABLE_TPL_KOKKOS "Enable Kokkos TPL" OFF) option(PRESSIO_ENABLE_TPL_MPI "Enable MPI" OFF) option(PRESSIO_ENABLE_TPL_PYBIND11 "Enable Pybind11 TPL" OFF) -# option(PRESSIO_ENABLE_TEUCHOS_TIMERS "bla bla" OFF) if(PRESSIO_ENABLE_TPL_EIGEN) @@ -46,6 +45,7 @@ endif() # if trilinos is on, then also set MPI, BLAS, LAPACK and KOKKOS ON if(PRESSIO_ENABLE_TPL_TRILINOS) message(">> PRESSIO_ENABLE_TPL_TRILINOS=ON ==> enabling also BLAS, LAPACK, MPI, KOKKOS") + add_definitions(-DPRESSIO_ENABLE_TPL_TRILINOS) set(PRESSIO_ENABLE_TPL_KOKKOS ON) set(PRESSIO_ENABLE_TPL_MPI ON) @@ -53,7 +53,6 @@ if(PRESSIO_ENABLE_TPL_TRILINOS) find_package(Trilinos REQUIRED) # TODO: it is possible to use find_package() for each (sub)package # https://trilinos.github.io/pdfs/Finding_Trilinos.txt - add_definitions(-DPRESSIO_ENABLE_TPL_TRILINOS) include_directories(${Trilinos_INCLUDE_DIRS}) link_libraries(${Trilinos_LIBRARIES}) @@ -61,10 +60,12 @@ endif() if(PRESSIO_ENABLE_TPL_KOKKOS) message(">> Enabling Kokkos since PRESSIO_ENABLE_TPL_KOKKOS=ON") + add_definitions(-DPRESSIO_ENABLE_TPL_KOKKOS) endif() if(PRESSIO_ENABLE_TPL_MPI) message(">> Enabling MPI since PRESSIO_ENABLE_TPL_MPI=ON") + add_definitions(-DPRESSIO_ENABLE_TPL_MPI) find_package(MPI REQUIRED) include_directories(${MPI_CXX_INCLUDE_DIRS}) @@ -72,11 +73,5 @@ endif() if(PRESSIO_ENABLE_TPL_Pybind11) message(">> Enabling Pybind11 since PRESSIO_ENABLE_TPL_PYBIND11=ON") + add_definitions(-DPRESSIO_ENABLE_TPL_Pybind11) endif() - - -# if(PRESSIO_ENABLE_TPL_KOKKOS AND NOT PRESSIO_ENABLE_TPL_TRILINOS) -# find_package(KokkosKernels REQUIRED) -# set(KOKKOS_LIBS Kokkos::kokkoskernels) -# #Kokkos::BLAS Kokkos::LAPACK Kokkos::kokkos Kokkos::kokkoskernels) -# endif() From 378d215bfbc178351327a4bf3f2eaf618ab24163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Thu, 2 Nov 2023 17:19:00 +0100 Subject: [PATCH 54/56] tests: skip redundant checks --- tests/cmake/options.cmake | 2 +- tests/cmake/tpls.cmake | 109 ++++++++++++++++---------------------- 2 files changed, 47 insertions(+), 64 deletions(-) diff --git a/tests/cmake/options.cmake b/tests/cmake/options.cmake index a82686727..92970bd98 100644 --- a/tests/cmake/options.cmake +++ b/tests/cmake/options.cmake @@ -32,7 +32,7 @@ if(PRESSIO_ENABLE_TPL_EIGEN) find_package(Eigen3) if(NOT EIGEN3_FOUND) - # FIXME: use FetchContent_Declare instead of failing? + # TODO: use FetchContent_Declare instead of failing? message(FATAL_ERROR "I cannot find the Eigen headers. " "Please reconfigure with: -DEIGEN_INCLUDE_DIR=") diff --git a/tests/cmake/tpls.cmake b/tests/cmake/tpls.cmake index aa9d70889..430a5d70b 100644 --- a/tests/cmake/tpls.cmake +++ b/tests/cmake/tpls.cmake @@ -8,10 +8,8 @@ # endif() if(PRESSIO_ENABLE_TPL_MPI) - if(PRESSIO_ENABLE_UNIT_TESTS OR PRESSIO_ENABLE_TESTS) - find_package(MPI REQUIRED) - include_directories(${MPI_CXX_INCLUDE_PATH}) - endif() + find_package(MPI REQUIRED) + include_directories(${MPI_CXX_INCLUDE_PATH}) endif() @@ -26,84 +24,73 @@ if(PRESSIO_ENABLE_TPL_BLAS OR PRESSIO_ENABLE_TPL_TRILINOS) cmake_policy(SET CMP0074 NEW) find_package(BLAS REQUIRED) link_libraries(${BLAS_LIBRARIES}) - message("") + message("BLASLIBS=${BLAS_LIBRARIES}") endif() if(PRESSIO_ENABLE_TPL_LAPACK) - if(PRESSIO_ENABLE_UNIT_TESTS OR PRESSIO_ENABLE_TESTS) - # check if LAPACK_ROOT is specified - if (NOT ${LAPACK_ROOT}) - message("") - message(FATAL_ERROR "LAPACK_ROOT not speificed, terminating") - message("Make sure you set the LAPACK_ROOT env var") - endif() - - cmake_policy(SET CMP0074 NEW) - find_package( LAPACK REQUIRED ) - link_libraries(${LAPACK_LIBRARIES}) - message("LAPLIBS=${LAPACK_LIBRARIES}") + # check if LAPACK_ROOT is specified + if (NOT ${LAPACK_ROOT}) + message("") + message(FATAL_ERROR "LAPACK_ROOT not speificed, terminating") + message("Make sure you set the LAPACK_ROOT env var") endif() + + cmake_policy(SET CMP0074 NEW) + find_package( LAPACK REQUIRED ) + link_libraries(${LAPACK_LIBRARIES}) + message("LAPLIBS=${LAPACK_LIBRARIES}") endif() if(PRESSIO_ENABLE_TPL_EIGEN) - if(PRESSIO_ENABLE_UNIT_TESTS OR PRESSIO_ENABLE_TESTS) - - if(NOT EIGEN_INC_DIR AND NOT EIGEN_INCLUDE_DIR) - message(FATAL_ERROR - "I cannot find the Eigen headers. Please reconfigure with: - -DEIGEN_INC_DIR= - or - -DEIGEN_INCLUDE_DIR= - ") - endif() - - if(NOT EIGEN_INC_DIR AND EIGEN_INCLUDE_DIR) - set(EIGEN_INC_DIR ${EIGEN_INCLUDE_DIR}) - endif() + if(NOT EIGEN_INC_DIR AND NOT EIGEN_INCLUDE_DIR) + message(FATAL_ERROR +"I cannot find the Eigen headers. Please reconfigure with: + -DEIGEN_INC_DIR= + or + -DEIGEN_INCLUDE_DIR= + ") + endif() - include_directories(${EIGEN_INC_DIR}) + if(NOT EIGEN_INC_DIR AND EIGEN_INCLUDE_DIR) + set(EIGEN_INC_DIR ${EIGEN_INCLUDE_DIR}) endif() + + include_directories(${EIGEN_INC_DIR}) endif() if(PRESSIO_ENABLE_TPL_KOKKOS) - if(PRESSIO_ENABLE_UNIT_TESTS OR PRESSIO_ENABLE_TESTS) - - # # when trilinos is also enabled it links kokkos too, see tplTrilinos.cmake - if(NOT PRESSIO_ENABLE_TPL_TRILINOS) - # if kokkos is used as standalone lib, then we are more specific - # user needs to defined: KOKKOS_ROOT_DIR and KOKKOS_KERNELS_ROOT_DIR - if (NOT KOKKOS_ROOT OR NOT KOKKOS_KERNELS_ROOT) - message(FATAL_ERROR "Missing KOKKOS_ROOT. KOKKOS needs: - -D KOKKOS_ROOT= - -D KOKKOS_KERNELS_ROOT= - ") - endif() - - set(KOKKOS_LIB_NAMES kokkoscontainers kokkoscore kokkoskernels) + # # when trilinos is also enabled it links kokkos too, see tplTrilinos.cmake + if(NOT PRESSIO_ENABLE_TPL_TRILINOS) + # if kokkos is used as standalone lib, then we are more specific + # user needs to defined: KOKKOS_ROOT_DIR and KOKKOS_KERNELS_ROOT_DIR + if (NOT KOKKOS_ROOT OR NOT KOKKOS_KERNELS_ROOT) +message(FATAL_ERROR "Missing KOKKOS_ROOT. KOKKOS needs: + -D KOKKOS_ROOT= + -D KOKKOS_KERNELS_ROOT= + ") + endif() - include_directories(${KOKKOS_ROOT}/include ${KOKKOS_KERNELS_ROOT}/include) + set(KOKKOS_LIB_NAMES kokkoscontainers kokkoscore kokkoskernels) - link_directories(${KOKKOS_ROOT}/lib ${KOKKOS_ROOT}/lib64 - ${KOKKOS_KERNELS_ROOT}/lib ${KOKKOS_KERNELS_ROOT}/lib64) + include_directories(${KOKKOS_ROOT}/include ${KOKKOS_KERNELS_ROOT}/include) - link_libraries(${KOKKOS_LIB_NAMES}) - endif() + link_directories(${KOKKOS_ROOT}/lib ${KOKKOS_ROOT}/lib64 +${KOKKOS_KERNELS_ROOT}/lib ${KOKKOS_KERNELS_ROOT}/lib64) + link_libraries(${KOKKOS_LIB_NAMES}) endif() endif() if(PRESSIO_ENABLE_TPL_TRILINOS) - if(PRESSIO_ENABLE_UNIT_TESTS OR PRESSIO_ENABLE_TESTS) - if (NOT Trilinos_FOUND AND NOT TRILINOS_ROOT) - message(FATAL_ERROR - "You enabled PRESSIO_ENABLE_TPL_TRILINOS but did not set TRILINOS_ROOT. - Please reconfigure with: - -D TRILINOS_ROOT= - ") - endif() + if (NOT Trilinos_FOUND AND NOT TRILINOS_ROOT) + message(FATAL_ERROR +"You enabled PRESSIO_ENABLE_TPL_TRILINOS but did not set TRILINOS_ROOT. + Please reconfigure with: + -D TRILINOS_ROOT= + ") endif() endif() @@ -117,9 +104,6 @@ endif() # if(PRESSIO_ENABLE_TPL_PYBIND11) # message("Found PRESSIO_ENABLE_TPL_PYBIND11=${PRESSIO_ENABLE_TPL_PYBIND11}.") -# # if we need to build tests, then prep for it -# if(PRESSIO_ENABLE_UNIT_TESTS OR PRESSIO_ENABLE_TESTS) - # # if PYBIND11_ROOT not found # if (NOT PYBIND11_ROOT) # pybind11_fatal() @@ -132,6 +116,5 @@ endif() # if(NOT ${Python3_FOUND}) # message(FATAL_ERROR "Python > 3 not found") -# endif() # endif() # endif() From 520ff06f933f6c98200114443274746c0f809233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Thu, 2 Nov 2023 17:24:53 +0100 Subject: [PATCH 55/56] assert that eigen is enabled --- include/pressio/macros.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/pressio/macros.hpp b/include/pressio/macros.hpp index 0c024d53e..533903cd6 100644 --- a/include/pressio/macros.hpp +++ b/include/pressio/macros.hpp @@ -117,6 +117,8 @@ static_assert(_PRESSIO_CPLUSPLUS >= PRESSIO_CXX_STD_14, "PRESSIO requires C++14 #endif #endif -// static_assert(PRESSIO_ENABLE_TPL_EIGEN, "Eigen is not enabled."); +#ifndef PRESSIO_ENABLE_TPL_EIGEN +static_assert(false, "Eigen is not enabled."); +#endif #endif From 8801fa00b5d7a1aba7e10bb3cf28d724a216d5af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Thu, 2 Nov 2023 17:55:08 +0100 Subject: [PATCH 56/56] tests: handle CMake options in a single file --- tests/CMakeLists.txt | 1 - tests/cmake/options.cmake | 49 +++++++++++++++- tests/cmake/tpls.cmake | 120 -------------------------------------- 3 files changed, 46 insertions(+), 124 deletions(-) delete mode 100644 tests/cmake/tpls.cmake diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c2abfc4d5..51c10ffb8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -4,7 +4,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(macrosForCreatingTests) include(macrosForCreatingUnitTests) include(options) -include(tpls) # --------------------------------- # 1. find or get gtest diff --git a/tests/cmake/options.cmake b/tests/cmake/options.cmake index 92970bd98..2db8b6708 100644 --- a/tests/cmake/options.cmake +++ b/tests/cmake/options.cmake @@ -15,10 +15,10 @@ if (PRESSIO_ENABLE_DEBUG_PRINT) add_definitions(-DPRESSIO_ENABLE_DEBUG_PRINT) endif() -option(PRESSIO_ENABLE_TPL_EIGEN "Enable Eigen TPL" ON) +option(PRESSIO_ENABLE_TPL_EIGEN "Enable Eigen TPL" ON) option(PRESSIO_ENABLE_TPL_TRILINOS "Enable Trilinos TPL" OFF) -option(PRESSIO_ENABLE_TPL_KOKKOS "Enable Kokkos TPL" OFF) -option(PRESSIO_ENABLE_TPL_MPI "Enable MPI" OFF) +option(PRESSIO_ENABLE_TPL_KOKKOS "Enable Kokkos TPL" OFF) +option(PRESSIO_ENABLE_TPL_MPI "Enable MPI" OFF) option(PRESSIO_ENABLE_TPL_PYBIND11 "Enable Pybind11 TPL" OFF) @@ -49,6 +49,8 @@ if(PRESSIO_ENABLE_TPL_TRILINOS) set(PRESSIO_ENABLE_TPL_KOKKOS ON) set(PRESSIO_ENABLE_TPL_MPI ON) + set(PRESSIO_ENABLE_TPL_BLAS ON) + set(PRESSIO_ENABLE_TPL_LAPACK ON) find_package(Trilinos REQUIRED) # TODO: it is possible to use find_package() for each (sub)package @@ -61,6 +63,27 @@ endif() if(PRESSIO_ENABLE_TPL_KOKKOS) message(">> Enabling Kokkos since PRESSIO_ENABLE_TPL_KOKKOS=ON") add_definitions(-DPRESSIO_ENABLE_TPL_KOKKOS) + + # when trilinos is enabled it links kokkos too + if(NOT PRESSIO_ENABLE_TPL_TRILINOS) + # if kokkos is used as standalone lib, then we are more specific + # user needs to define: KOKKOS_ROOT_DIR and KOKKOS_KERNELS_ROOT_DIR + if (NOT KOKKOS_ROOT OR NOT KOKKOS_KERNELS_ROOT) +message(FATAL_ERROR "Missing KOKKOS_ROOT. KOKKOS needs: + -D KOKKOS_ROOT= + -D KOKKOS_KERNELS_ROOT= + ") + endif() + + set(KOKKOS_LIB_NAMES kokkoscontainers kokkoscore kokkoskernels) + + include_directories(${KOKKOS_ROOT}/include ${KOKKOS_KERNELS_ROOT}/include) + + link_directories(${KOKKOS_ROOT}/lib ${KOKKOS_ROOT}/lib64 +${KOKKOS_KERNELS_ROOT}/lib ${KOKKOS_KERNELS_ROOT}/lib64) + + link_libraries(${KOKKOS_LIB_NAMES}) + endif() endif() if(PRESSIO_ENABLE_TPL_MPI) @@ -75,3 +98,23 @@ if(PRESSIO_ENABLE_TPL_Pybind11) message(">> Enabling Pybind11 since PRESSIO_ENABLE_TPL_PYBIND11=ON") add_definitions(-DPRESSIO_ENABLE_TPL_Pybind11) endif() + +if(PRESSIO_ENABLE_TPL_BLAS) + message(">> Enabling BLAS since PRESSIO_ENABLE_TPL_BLAS=ON") + add_definitions(-DPRESSIO_ENABLE_TPL_BLAS) + + cmake_policy(SET CMP0074 NEW) + find_package(BLAS REQUIRED) + link_libraries(${BLAS_LIBRARIES}) + message("BLASLIBS=${BLAS_LIBRARIES}") +endif() + +if(PRESSIO_ENABLE_TPL_LAPACK) + message(">> Enabling LAPACK since PRESSIO_ENABLE_TPL_LAPACK=ON") + add_definitions(-DPRESSIO_ENABLE_TPL_LAPACK) + + cmake_policy(SET CMP0074 NEW) + find_package(LAPACK REQUIRED) + link_libraries(${LAPACK_LIBRARIES}) + message("LAPLIBS=${LAPACK_LIBRARIES}") +endif() diff --git a/tests/cmake/tpls.cmake b/tests/cmake/tpls.cmake deleted file mode 100644 index 430a5d70b..000000000 --- a/tests/cmake/tpls.cmake +++ /dev/null @@ -1,120 +0,0 @@ -# if(PRESSIO_ENABLE_TPL_BLAS) -# message(">> Enabling BLAS since PRESSIO_ENABLE_TPL_BLAS=ON ==> enabling also LAPACK") -# set(PRESSIO_ENABLE_TPL_LAPACK ON) -# endif() -# if(PRESSIO_ENABLE_TPL_LAPACK) -# message(">> Enabling LAPACK since PRESSIO_ENABLE_TPL_LAPACK=ON ==> enabling also BLAS") -# set(PRESSIO_ENABLE_TPL_BLAS ON) -# endif() - -if(PRESSIO_ENABLE_TPL_MPI) - find_package(MPI REQUIRED) - include_directories(${MPI_CXX_INCLUDE_PATH}) -endif() - - -if(PRESSIO_ENABLE_TPL_BLAS OR PRESSIO_ENABLE_TPL_TRILINOS) - # check if BLAS_ROOT is specified - if (NOT ${BLAS_ROOT}) - message("") - message(FATAL_ERROR "BLAS_ROOT not speificed, terminating") - message("Make sure you set the BLAS_ROOT env var") - endif() - - cmake_policy(SET CMP0074 NEW) - find_package(BLAS REQUIRED) - link_libraries(${BLAS_LIBRARIES}) - message("BLASLIBS=${BLAS_LIBRARIES}") -endif() - -if(PRESSIO_ENABLE_TPL_LAPACK) - # check if LAPACK_ROOT is specified - if (NOT ${LAPACK_ROOT}) - message("") - message(FATAL_ERROR "LAPACK_ROOT not speificed, terminating") - message("Make sure you set the LAPACK_ROOT env var") - endif() - - cmake_policy(SET CMP0074 NEW) - find_package( LAPACK REQUIRED ) - link_libraries(${LAPACK_LIBRARIES}) - message("LAPLIBS=${LAPACK_LIBRARIES}") -endif() - - -if(PRESSIO_ENABLE_TPL_EIGEN) - if(NOT EIGEN_INC_DIR AND NOT EIGEN_INCLUDE_DIR) - message(FATAL_ERROR -"I cannot find the Eigen headers. Please reconfigure with: - -DEIGEN_INC_DIR= - or - -DEIGEN_INCLUDE_DIR= - ") - endif() - - if(NOT EIGEN_INC_DIR AND EIGEN_INCLUDE_DIR) - set(EIGEN_INC_DIR ${EIGEN_INCLUDE_DIR}) - endif() - - include_directories(${EIGEN_INC_DIR}) -endif() - - -if(PRESSIO_ENABLE_TPL_KOKKOS) - # # when trilinos is also enabled it links kokkos too, see tplTrilinos.cmake - if(NOT PRESSIO_ENABLE_TPL_TRILINOS) - # if kokkos is used as standalone lib, then we are more specific - # user needs to defined: KOKKOS_ROOT_DIR and KOKKOS_KERNELS_ROOT_DIR - if (NOT KOKKOS_ROOT OR NOT KOKKOS_KERNELS_ROOT) -message(FATAL_ERROR "Missing KOKKOS_ROOT. KOKKOS needs: - -D KOKKOS_ROOT= - -D KOKKOS_KERNELS_ROOT= - ") - endif() - - set(KOKKOS_LIB_NAMES kokkoscontainers kokkoscore kokkoskernels) - - include_directories(${KOKKOS_ROOT}/include ${KOKKOS_KERNELS_ROOT}/include) - - link_directories(${KOKKOS_ROOT}/lib ${KOKKOS_ROOT}/lib64 -${KOKKOS_KERNELS_ROOT}/lib ${KOKKOS_KERNELS_ROOT}/lib64) - - link_libraries(${KOKKOS_LIB_NAMES}) - endif() -endif() - - -if(PRESSIO_ENABLE_TPL_TRILINOS) - if (NOT Trilinos_FOUND AND NOT TRILINOS_ROOT) - message(FATAL_ERROR -"You enabled PRESSIO_ENABLE_TPL_TRILINOS but did not set TRILINOS_ROOT. - Please reconfigure with: - -D TRILINOS_ROOT= - ") - endif() -endif() - - -# function(pybind11_fatal) -# message(FATAL_ERROR "I cannot find the Pybind11 library. -# To use it, please reconfigure with: -# -D PYBIND11_ROOT=") -# endfunction() - -# if(PRESSIO_ENABLE_TPL_PYBIND11) -# message("Found PRESSIO_ENABLE_TPL_PYBIND11=${PRESSIO_ENABLE_TPL_PYBIND11}.") - -# # if PYBIND11_ROOT not found -# if (NOT PYBIND11_ROOT) -# pybind11_fatal() -# endif() - -# find_package(pybind11 REQUIRED PATHS ${PYBIND11_ROOT}/share/cmake) -# find_package(Python3 COMPONENTS Interpreter NumPy) - -# include_directories(${Python3_INCLUDE_DIRS} ${PYBIND11_ROOT}/include) - -# if(NOT ${Python3_FOUND}) -# message(FATAL_ERROR "Python > 3 not found") -# endif() -# endif()