Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7eb9e54
Use directory agnostic imports
EmilyBourne Apr 20, 2026
ed53411
Move package searches to root. InputFunctions only needs to be linked…
EmilyBourne Apr 20, 2026
ec909eb
Link includes cleanly
EmilyBourne Apr 20, 2026
1351a29
All tests use input
EmilyBourne Apr 20, 2026
18a3cbe
Set C++ standard globally
EmilyBourne Apr 20, 2026
4e46726
Move LIKWID and MUMPS target definition to cmake/FindX.cmake files
EmilyBourne Apr 20, 2026
08d6ffb
Try for a local version of GTest
EmilyBourne Apr 20, 2026
ed80423
Prefer project paths
EmilyBourne Apr 20, 2026
bdd3cd2
Add an install target
EmilyBourne Apr 20, 2026
7d43a70
Add GMGPolarTargets to ensure we can do find_package(GMGPolar)
EmilyBourne Apr 20, 2026
a01d03e
Use different include paths for local build vs installed library
EmilyBourne Apr 20, 2026
7392ea6
Clang format
EmilyBourne Apr 21, 2026
7a1850f
Merge remote-tracking branch 'GMGPolar/main' into ebourne_cleanup_cmake
EmilyBourne Apr 21, 2026
6e94e02
Fix merge
EmilyBourne Apr 21, 2026
2106436
Merge remote-tracking branch 'GMGPolar/main' into ebourne_cleanup_cmake
EmilyBourne Apr 21, 2026
edaf7d4
Create GMGPolarInterface to hold all CLI/testing interface objects
EmilyBourne Apr 21, 2026
adaca6d
MUMPS dependencies
EmilyBourne Apr 21, 2026
4ee7dbb
Add target aliases
EmilyBourne Apr 22, 2026
c2da216
Can't export aliases
EmilyBourne Apr 22, 2026
3678f5c
Only C++ component required
EmilyBourne Apr 23, 2026
0bacedc
Tests should not be its own project
EmilyBourne Apr 24, 2026
063b52c
Add QUIET to find_package(GTest)
EmilyBourne Apr 24, 2026
f33f81d
Version already set
EmilyBourne Apr 24, 2026
b101c71
Duplicate C++ version specification
EmilyBourne Apr 24, 2026
e1ca3ba
Enable Fortran instead of choosing project languages based on USE_MUMPS
EmilyBourne Apr 27, 2026
0ba4a9e
Clear duplicate project declaration
EmilyBourne Apr 27, 2026
6971888
Review ebourne cleanup cmake (#234)
tpadioleau Apr 30, 2026
924e13f
Merge branch 'main' into ebourne_cleanup_cmake
EmilyBourne May 1, 2026
626bd01
Merge branch 'main' into ebourne_cleanup_cmake
EmilyBourne May 1, 2026
6a9c5da
Fix merge
EmilyBourne May 1, 2026
3c70848
Merge remote-tracking branch 'GMGPolar/main' into ebourne_cleanup_cmake
EmilyBourne May 21, 2026
b55dc96
Use cmake path
EmilyBourne May 21, 2026
53168fe
Fix merge
EmilyBourne May 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 64 additions & 6 deletions CMakeLists.txt
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)
Expand Down Expand Up @@ -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.")
Comment thread
EmilyBourne marked this conversation as resolved.
Outdated

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")
Expand All @@ -44,23 +55,70 @@ if(GMGPOLAR_ENABLE_COVERAGE)
endif()
endif()

find_package(OpenMP REQUIRED)
Comment thread
EmilyBourne marked this conversation as resolved.
Outdated
find_package(Kokkos 4.4.1...<5.1 QUIET REQUIRED)
Comment thread
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 InputFunctions)
target_link_libraries(convergence_order PRIVATE GMGPolarLib InputFunctions)
target_link_libraries(weak_scaling PRIVATE GMGPolarLib InputFunctions)
target_link_libraries(strong_scaling PRIVATE GMGPolarLib InputFunctions)

if(GMGPOLAR_BUILD_TESTS)
enable_testing()
add_subdirectory(third-party)
find_package(GTest 1.17)
Comment thread
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
Expand Down
33 changes: 33 additions & 0 deletions cmake/FindLIKWID.cmake
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()
56 changes: 56 additions & 0 deletions cmake/FindMUMPS.cmake
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()
27 changes: 27 additions & 0 deletions cmake/FindMetis.cmake
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Collaborator

@julianlitz julianlitz Apr 25, 2026

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Member

@mknaranja mknaranja Apr 29, 2026

Choose a reason for hiding this comment

The 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()
18 changes: 18 additions & 0 deletions cmake/GMGPolarConfig.cmake.in
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)
Comment thread
EmilyBourne marked this conversation as resolved.
Outdated

if(@GMGPOLAR_USE_MUMPS@)
find_dependency(MUMPS REQUIRED)
Comment thread
EmilyBourne marked this conversation as resolved.
Outdated
endif()

if(@GMGPOLAR_USE_LIKWID@)
find_dependency(LIKWID REQUIRED)
Comment thread
EmilyBourne marked this conversation as resolved.
Outdated
endif()

include("${CMAKE_CURRENT_LIST_DIR}/GMGPolarTargets.cmake")
12 changes: 6 additions & 6 deletions include/ConfigParser/config_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
#include <stdexcept>
#include <memory>

#include "../../include/ConfigParser/cmdline.h"
#include "../../include/Definitions/global_definitions.h"
#include "../../include/PolarGrid/polargrid.h"
#include "../../include/GMGPolar/test_cases.h"
#include "../../include/GMGPolar/igmgpolar.h"
#include "../../include/GMGPolar/gmgpolar.h"
#include <ConfigParser/cmdline.h>
#include <Definitions/global_definitions.h>
#include <PolarGrid/polargrid.h>
#include <GMGPolar/test_cases.h>
#include <GMGPolar/igmgpolar.h>
#include <GMGPolar/gmgpolar.h>
#include "test_selection.h"

class ConfigParser
Expand Down
2 changes: 1 addition & 1 deletion include/ConfigParser/test_selection.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <variant>

#include "../../include/GMGPolar/test_cases.h"
#include <GMGPolar/test_cases.h>

using DomainGeometryVariant = std::variant<CircularGeometry, ShafranovGeometry, CzarnyGeometry, CulhamGeometry>;

Expand Down
Loading
Loading