Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 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
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
7 changes: 3 additions & 4 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ runs:
run: |
apt-get -qq update
apt-get -qq -y install lcov
- name: Install MUMPS Dependencies
shell: bash
run: |
apt-get -qq -y install gfortran
- name: Install additional dependencies to use MUMPS
if: inputs.use-mumps == 'true'
uses: ./.github/actions/install-dependencies
- name: Download build test directory
uses: actions/download-artifact@v4
with:
Expand Down
77 changes: 66 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
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)
option(GMGPOLAR_USE_MUMPS "Use MUMPS to solve linear systems." OFF)
option(GMGPOLAR_ENABLE_COVERAGE "Enable code coverage reporting (requires GCC/Clang)" OFF)

project(GMGPolar VERSION 2.1.0 LANGUAGES CXX)
# MUMPS does not automatically provide Fortran libraries
if (${GMGPOLAR_USE_MUMPS})
# MUMPS does not automatically provide Fortran libraries
project(GMGPolar VERSION 2.0.0 LANGUAGES CXX Fortran)
else()
project(GMGPolar VERSION 2.0.0 LANGUAGES CXX)
enable_language(Fortran)
endif()

set(CMAKE_CXX_STANDARD 20)
Expand All @@ -23,6 +25,12 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

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 @@ -40,23 +48,70 @@ if(GMGPOLAR_ENABLE_COVERAGE)
endif()
endif()

find_package(Kokkos 4.4.1...<5.1 QUIET REQUIRED)
include_directories(include)
find_package(OpenMP REQUIRED COMPONENTS CXX)
find_package(Kokkos 4.4.1...<6 QUIET REQUIRED)

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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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 :)

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.

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.
Is it a library? I.e. something designed to provide tools to other bigger tools (e.g. simulations, gyselalib++, etc)
Or is it a tool in its own right? I.e. does it make sense to have access to the executables but not the code?

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 GMGPolarInterface should be included in that library or not?
In any case I suspect that it does not make sense to install convergence_order, weak_scaling and strong_scaling as I'm not sure these are particularly useful if you can't modify the code to try different test cases?

Copy link
Copy Markdown
Collaborator

@julianlitz julianlitz Apr 24, 2026

Choose a reason for hiding this comment

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

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.

The current setup is:

  • All include files are installed
  • Everything except src/ConfigParser/* and src/InputFunctions/* is compiled into the GMGPolarLib target
  • src/ConfigParser/* and src/InputFunctions/* are compiled into a GMGPolarInterface library

As an example of end users:

  • gyselalib++ would use GMGPolarLib to provide a solver for the equation and would be happy to not have to compile GMGPolarInterface
  • gysela-mini-app_poisson (a mini-app designed to compare different solvers) would do the same but could also use GMGPolarInterface to avoid having to write our own test cases.

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.

@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 QUIET)
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 COMPONENTS CXX)
find_dependency(Kokkos)

if(@GMGPOLAR_USE_MUMPS@)
find_dependency(MUMPS COMPONENTS OpenMP METIS)
endif()

if(@GMGPOLAR_USE_LIKWID@)
find_dependency(LIKWID)
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"

namespace gmgpolar
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>

namespace gmgpolar
{
Expand Down
Loading
Loading