-
Notifications
You must be signed in to change notification settings - Fork 6
Follow standard CMake layout #214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 20 commits
7eb9e54
ed53411
ec909eb
1351a29
18a3cbe
4e46726
08d6ffb
ed80423
bdd3cd2
7d43a70
a01d03e
7392ea6
7a1850f
6e94e02
2106436
edaf7d4
adaca6d
4ee7dbb
c2da216
3678f5c
0bacedc
063b52c
f33f81d
b101c71
e1ca3ba
0ba4a9e
6971888
924e13f
626bd01
6a9c5da
3c70848
b55dc96
53168fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| cmake_minimum_required(VERSION 3.12) | ||
|
|
||
| # Ensure custom cmake modules can be found | ||
| list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") | ||
|
|
||
| # Options should be defined before they're used | ||
| option(GMGPOLAR_BUILD_TESTS "Build GMGPolar unit tests." ON) | ||
| option(GMGPOLAR_USE_LIKWID "Use LIKWID to measure code (regions)." OFF) | ||
|
|
@@ -27,6 +30,14 @@ endif() | |
| set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -pedantic -Wno-unused -Wno-psabi -Wfloat-conversion") | ||
| set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -mtune=generic -Wno-psabi") | ||
|
|
||
| set(CMAKE_CXX_STANDARD 20 CACHE INTERNAL "The C++ standard whose features are requested to build this project.") | ||
|
|
||
| if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE STREQUAL "Release") | ||
| # If using GNU increase maximum number of instructions considered for inlining | ||
| # in Release mode in this folder and sub-folders | ||
| add_compile_options(--param max-inline-insns-single=1500) | ||
| endif() | ||
|
|
||
| # Set coverage compiler flags - must come before any targets are defined | ||
| if(GMGPOLAR_ENABLE_COVERAGE) | ||
| if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") | ||
|
|
@@ -44,23 +55,70 @@ if(GMGPOLAR_ENABLE_COVERAGE) | |
| endif() | ||
| endif() | ||
|
|
||
| find_package(OpenMP REQUIRED COMPONENTS CXX) | ||
| find_package(Kokkos 4.4.1...<5.1 QUIET REQUIRED) | ||
|
EmilyBourne marked this conversation as resolved.
Outdated
|
||
| include_directories(include) | ||
|
|
||
| if(GMGPOLAR_USE_MUMPS) | ||
| find_package(MUMPS REQUIRED COMPONENTS OpenMP METIS) | ||
| endif() | ||
|
|
||
| if(GMGPOLAR_USE_LIKWID) | ||
| find_package(LIKWID REQUIRED) | ||
| endif() | ||
|
|
||
| set(GMGPOLAR_INCLUDE_DIRS | ||
| $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> | ||
| $<INSTALL_INTERFACE:include> | ||
| ) | ||
|
|
||
| install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include) | ||
|
|
||
| include(CMakePackageConfigHelpers) | ||
|
|
||
| configure_package_config_file( | ||
| cmake/GMGPolarConfig.cmake.in | ||
| ${CMAKE_CURRENT_BINARY_DIR}/GMGPolarConfig.cmake | ||
| INSTALL_DESTINATION lib/cmake/GMGPolar | ||
| ) | ||
|
|
||
| write_basic_package_version_file( | ||
| ${CMAKE_CURRENT_BINARY_DIR}/GMGPolarConfigVersion.cmake | ||
| VERSION ${PROJECT_VERSION} | ||
| COMPATIBILITY SameMajorVersion | ||
| ) | ||
|
|
||
| install(FILES | ||
| ${CMAKE_CURRENT_BINARY_DIR}/GMGPolarConfig.cmake | ||
| ${CMAKE_CURRENT_BINARY_DIR}/GMGPolarConfigVersion.cmake | ||
| cmake/FindMUMPS.cmake | ||
| cmake/FindLIKWID.cmake | ||
| cmake/FindMetis.cmake | ||
| DESTINATION lib/cmake/GMGPolar | ||
| ) | ||
|
|
||
| install(EXPORT GMGPolarTargets | ||
| NAMESPACE GMGPolar:: | ||
| DESTINATION lib/cmake/GMGPolar | ||
| ) | ||
|
|
||
| add_subdirectory(src) | ||
|
|
||
| add_executable(gmgpolar src/main.cpp) | ||
| add_executable(convergence_order src/convergence_order.cpp) | ||
| add_executable(weak_scaling src/weak_scaling.cpp) | ||
| add_executable(strong_scaling src/strong_scaling.cpp) | ||
|
|
||
| target_link_libraries(gmgpolar PRIVATE GMGPolarLib) | ||
| target_link_libraries(convergence_order PRIVATE GMGPolarLib) | ||
| target_link_libraries(weak_scaling PRIVATE GMGPolarLib) | ||
| target_link_libraries(strong_scaling PRIVATE GMGPolarLib) | ||
| target_link_libraries(gmgpolar PRIVATE GMGPolarLib GMGPolarInterface) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. im not really familiar with the structure. But these executables are built but not installed. Is this intentional? If yes, maybe add a comment :)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is where we need feedback from the GMGPolar team. It is related to the comment above : #214 (comment) It depends on how you see GMGPolar. My impression was that it is more of a library so I have implemented it like this for now. But that also raises the question of whether
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think if you would export it as a library than you might need the sourceTerm.h concept definitions, but not all source term specific test case examples. And the main.cpp etc are just for testing purposes and are probably also not part of a library.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current setup is:
As an example of end users:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @HenrZu What is your opinion? |
||
| target_link_libraries(convergence_order PRIVATE GMGPolarLib GMGPolarInterface) | ||
| target_link_libraries(weak_scaling PRIVATE GMGPolarLib GMGPolarInterface) | ||
| target_link_libraries(strong_scaling PRIVATE GMGPolarLib GMGPolarInterface) | ||
|
|
||
| if(GMGPOLAR_BUILD_TESTS) | ||
| enable_testing() | ||
| add_subdirectory(third-party) | ||
| find_package(GTest 1.17) | ||
|
EmilyBourne marked this conversation as resolved.
Outdated
|
||
| if (NOT GTest_FOUND) | ||
| add_subdirectory(third-party) | ||
| endif() | ||
| add_subdirectory(tests) | ||
|
|
||
| # Add coverage target - moved after test configuration | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
|
|
||
| if(DEFINED ENV{LIKWID_DIR} AND NOT LIKWID_DIR) | ||
| set(LIKWID_DIR "$ENV{LIKWID_DIR}" CACHE PATH "LIKWID installation directory") | ||
| endif() | ||
|
|
||
| find_package(PkgConfig QUIET) | ||
| if(PKG_CONFIG_FOUND) | ||
| pkg_check_modules(LIKWID_PC QUIET likwid) | ||
| endif() | ||
|
|
||
| find_path(LIKWID_INCLUDE_DIR | ||
| NAMES likwid.h | ||
| HINTS ${LIKWID_DIR}/include ${LIKWID_PC_INCLUDE_DIRS} | ||
| ) | ||
|
|
||
| find_library(LIKWID_LIBRARY | ||
| NAMES likwid | ||
| HINTS ${LIKWID_DIR}/lib ${LIKWID_DIR}/lib64 ${LIKWID_PC_LIBRARY_DIRS} | ||
| ) | ||
|
|
||
| include(FindPackageHandleStandardArgs) | ||
| find_package_handle_standard_args(LIKWID | ||
| REQUIRED_VARS LIKWID_INCLUDE_DIR LIKWID_LIBRARY | ||
| ) | ||
|
|
||
| if(LIKWID_FOUND AND NOT TARGET LIKWID::LIKWID) | ||
| add_library(LIKWID::LIKWID INTERFACE IMPORTED) | ||
| set_target_properties(LIKWID::LIKWID PROPERTIES | ||
| INTERFACE_INCLUDE_DIRECTORIES "${LIKWID_INCLUDE_DIR}" | ||
| INTERFACE_LINK_LIBRARIES "${LIKWID_LIBRARY}" | ||
| INTERFACE_COMPILE_DEFINITIONS "LIKWID_PERFMON" | ||
| ) | ||
| endif() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
|
|
||
| # Stage 1: prefer an installed MUMPS CMake config (supports COMPONENTS properly) | ||
| find_package(MUMPS CONFIG QUIET COMPONENTS ${MUMPS_FIND_COMPONENTS}) | ||
| if(MUMPS_FOUND) | ||
| return() | ||
| endif() | ||
|
|
||
| # Stage 2: manual discovery via MUMPS_DIR hint | ||
| if(DEFINED ENV{MUMPS_DIR} AND NOT MUMPS_DIR) | ||
| set(MUMPS_DIR "$ENV{MUMPS_DIR}" CACHE PATH "MUMPS installation directory") | ||
| endif() | ||
|
|
||
| find_path(MUMPS_INCLUDE_DIR | ||
| NAMES dmumps_c.h | ||
| HINTS ${MUMPS_DIR}/include | ||
| ) | ||
|
|
||
| foreach(_lib dmumps smumps mumps_common) | ||
| find_library(MUMPS_${_lib}_LIBRARY | ||
| NAMES ${_lib} | ||
| HINTS ${MUMPS_DIR}/lib ${MUMPS_DIR}/lib64 | ||
| ) | ||
| list(APPEND _MUMPS_REQUIRED_VARS MUMPS_${_lib}_LIBRARY) | ||
| endforeach() | ||
|
|
||
| # mpiseq is the sequential MPI stub — only present in sequential builds | ||
| find_library(MUMPS_mpiseq_LIBRARY | ||
| NAMES mpiseq | ||
| HINTS ${MUMPS_DIR}/lib ${MUMPS_DIR}/lib64 | ||
| ${MUMPS_DIR}/libseq ${MUMPS_DIR}/lib/SEQ | ||
| ) | ||
|
|
||
| include(FindPackageHandleStandardArgs) | ||
| find_package_handle_standard_args(MUMPS | ||
| REQUIRED_VARS MUMPS_INCLUDE_DIR ${_MUMPS_REQUIRED_VARS} | ||
| ) | ||
|
|
||
| if(MUMPS_FOUND AND NOT TARGET MUMPS::MUMPS) | ||
| find_package(Metis REQUIRED) | ||
|
|
||
| set(_mumps_libs | ||
| ${MUMPS_dmumps_LIBRARY} | ||
| ${MUMPS_smumps_LIBRARY} | ||
| ${MUMPS_mumps_common_LIBRARY} | ||
| metis::metis | ||
| ) | ||
| if(MUMPS_mpiseq_LIBRARY) | ||
| list(APPEND _mumps_libs ${MUMPS_mpiseq_LIBRARY}) | ||
| endif() | ||
|
|
||
| add_library(MUMPS::MUMPS INTERFACE IMPORTED) | ||
| set_target_properties(MUMPS::MUMPS PROPERTIES | ||
| INTERFACE_INCLUDE_DIRECTORIES "${MUMPS_INCLUDE_DIR}" | ||
| INTERFACE_LINK_LIBRARIES "${_mumps_libs}" | ||
| ) | ||
| endif() |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this METIS from https://github.com/KarypisLab/METIS ? I see it is based on CMake, it does not generate its own Config files ? Does not need to be handled in the PR.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't check, I just reorganised what was already in the existing CMake files. Probably a question for @mknaranja
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. more a comment than a full answer: Yes, this is METIS from Karypis, it is used for mesh / graph partitioning which is used in direct solvers such as MUMPS. But: I couldn't tell you anything about the technical config file question, I never looked at it at that level.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I never tested Mumps without Metis, but Mumps could be used without it by setting ICNTL(7)=7. https://github.com/SciCompMod/GMGPolar/blob/main/src/LinearAlgebra/Solvers/coo_mumps_solver.cpp#L107
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think MUMPS can also use other graph partitioners such as p4est but I think that does only yield other problems. Graph partitioning is used to reduce fill-in. I would suggest to keep METIS if MUMPS is used. From my point of view, METIS is a minimal dependency as it is used in millions of numerical linear algebra (+ HPC) applications. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
|
|
||
| if(DEFINED ENV{METIS_DIR} AND NOT METIS_DIR) | ||
| set(METIS_DIR "$ENV{METIS_DIR}" CACHE PATH "METIS installation directory") | ||
| endif() | ||
|
|
||
| find_path(METIS_INCLUDE_DIR | ||
| NAMES metis.h | ||
| HINTS ${METIS_DIR}/include | ||
| ) | ||
|
|
||
| find_library(METIS_LIBRARY | ||
| NAMES metis | ||
| HINTS ${METIS_DIR}/lib ${METIS_DIR}/lib64 | ||
| ) | ||
|
|
||
| include(FindPackageHandleStandardArgs) | ||
| find_package_handle_standard_args(Metis | ||
| REQUIRED_VARS METIS_INCLUDE_DIR METIS_LIBRARY | ||
| ) | ||
|
|
||
| if(Metis_FOUND AND NOT TARGET metis::metis) | ||
| add_library(metis::metis INTERFACE IMPORTED) | ||
| set_target_properties(metis::metis PROPERTIES | ||
| INTERFACE_INCLUDE_DIRECTORIES "${METIS_INCLUDE_DIR}" | ||
| INTERFACE_LINK_LIBRARIES "${METIS_LIBRARY}" | ||
| ) | ||
| endif() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| @PACKAGE_INIT@ | ||
|
|
||
| list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") | ||
|
|
||
| include(CMakeFindDependencyMacro) | ||
|
|
||
| find_dependency(OpenMP REQUIRED) | ||
| find_dependency(Kokkos REQUIRED) | ||
|
EmilyBourne marked this conversation as resolved.
Outdated
|
||
|
|
||
| if(@GMGPOLAR_USE_MUMPS@) | ||
| find_dependency(MUMPS REQUIRED) | ||
|
EmilyBourne marked this conversation as resolved.
Outdated
|
||
| endif() | ||
|
|
||
| if(@GMGPOLAR_USE_LIKWID@) | ||
| find_dependency(LIKWID REQUIRED) | ||
|
EmilyBourne marked this conversation as resolved.
Outdated
|
||
| endif() | ||
|
|
||
| include("${CMAKE_CURRENT_LIST_DIR}/GMGPolarTargets.cmake") | ||
Uh oh!
There was an error while loading. Please reload this page.