Skip to content

Commit 91e3a9b

Browse files
julianlitzmknaranjajulianlitz
authored
Join all tests into one executable, reintroduce coverage basics and rework cmake (#73)
- CMake structure reworked - Unit test joint in one executable - Code coverage basics reintroduced Co-authored-by: Martin J. Kühn <62713180+mknaranja@users.noreply.github.com> Co-authored-by: julianlitz <julian.liz@icloud.com>
1 parent ce61090 commit 91e3a9b

36 files changed

Lines changed: 1315 additions & 327 deletions

.github/actions/build/action.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ runs:
66
shell: bash
77
run: |
88
sudo apt-get -qq update
9-
sudo apt-get -qq install gcc-11
10-
sudo apt-get -qq -y install g++-11
11-
sudo apt-get -qq -y install lcov
9+
sudo apt-get -qq install gcc-13
10+
sudo apt-get -qq -y install g++-13
11+
sudo apt-get -qq -y install lcov
1212
- name: Build
1313
shell:
1414
# ensure that the installed compiler version is used
1515
run: |
16-
export CC=/usr/bin/gcc-11
17-
export CXX=/usr/bin/g++-11
16+
export CC=/usr/bin/gcc-13
17+
export CXX=/usr/bin/g++-13
1818
mkdir build && cd build
1919
cmake -DCMAKE_BUILD_TYPE=Debug -DGMGPOLAR_TEST_COVERAGE=ON ..
2020
make -j4

.github/actions/test/action.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,25 @@ runs:
3030
cd build/tests
3131
sudo chmod a+x gmgpolar_tests
3232
./gmgpolar_tests --gtest_output="xml:testreport.xml"
33-
- name: Compute code coverage
34-
shell: bash
35-
# compute code coverage
36-
run: |
37-
cd build
38-
cmake --build . --target coverage/fast
39-
- name: Upload test report
40-
uses: actions/upload-artifact@v4
41-
with:
42-
name: test-report
43-
path: build/tests/testreport.xml
44-
if-no-files-found: error
45-
retention-days: 3
46-
- name: Upload coverage reports
47-
uses: actions/upload-artifact@v4
48-
with:
49-
name: test-coverage-reports
50-
path: |
51-
build/coverage.info
52-
build/coverage
53-
if-no-files-found: error
54-
retention-days: 1
33+
# - name: Compute code coverage
34+
# shell: bash
35+
# # compute code coverage
36+
# run: |
37+
# cd build
38+
# cmake --build . --target coverage/fast
39+
# - name: Upload test report
40+
# uses: actions/upload-artifact@v4
41+
# with:
42+
# name: test-report
43+
# path: build/tests/testreport.xml
44+
# if-no-files-found: error
45+
# retention-days: 3
46+
# - name: Upload coverage reports
47+
# uses: actions/upload-artifact@v4
48+
# with:
49+
# name: test-coverage-reports
50+
# path: |
51+
# build/coverage.info
52+
# build/coverage
53+
# if-no-files-found: error
54+
# retention-days: 1

.github/workflows/main.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,35 @@ jobs:
1414
if: github.event.pull_request.draft == false
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v4
1818
- uses: ./.github/actions/build
1919

2020
run-unit-test:
2121
needs: install-and-build
2222
runs-on: ubuntu-latest
2323
steps:
24-
- uses: actions/checkout@v3
24+
- uses: actions/checkout@v4
2525
- uses: ./.github/actions/test
2626
with:
2727
build-artifact: build-cpp-linux-gmgpolar
2828

29-
codecov:
30-
if: github.event.pull_request.draft == false
31-
needs: [run-unit-test]
32-
runs-on: ubuntu-latest
33-
steps:
34-
- uses: actions/checkout@v3
35-
- name: Install dependencies
36-
run: |
37-
sudo apt-get -qq update
38-
sudo apt-get -qq -y install git curl
39-
- name: Download cpp coverage report
40-
uses: actions/download-artifact@v3
41-
with:
42-
name: test-coverage-reports
43-
- name: Deploy to codecov.io
44-
uses: codecov/codecov-action@v3
45-
with:
46-
token: ${{ secrets.CODECOV_TOKEN }}
47-
files: ./coverage.info
48-
verbose: true
29+
# codecov:
30+
# if: github.event.pull_request.draft == false
31+
# needs: [run-unit-test]
32+
# runs-on: ubuntu-latest
33+
# steps:
34+
# - uses: actions/checkout@v4
35+
# - name: Install dependencies
36+
# run: |
37+
# sudo apt-get -qq update
38+
# sudo apt-get -qq -y install git curl
39+
# - name: Download cpp coverage report
40+
# uses: actions/download-artifact@v4
41+
# with:
42+
# name: test-coverage-reports
43+
# - name: Deploy to codecov.io
44+
# uses: codecov/codecov-action@v3
45+
# with:
46+
# token: ${{ secrets.CODECOV_TOKEN }}
47+
# files: ./coverage.info
48+
# verbose: true

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
.vscode/
44

5-
.github/
6-
75
Output/
86

97
*.vtu

CMakeLists.txt

Lines changed: 30 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -8,123 +8,50 @@ option(GMGPOLAR_USE_MUMPS "Use MUMPS to solve linear systems." OFF)
88
set(CMAKE_CXX_STANDARD 20)
99
set(CMAKE_CXX_STANDARD_REQUIRED True)
1010

11+
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
12+
1113
if(NOT CMAKE_BUILD_TYPE)
1214
set(CMAKE_BUILD_TYPE Release)
1315
endif()
1416

15-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -pedantic -Wno-unused")
16-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -mtune=generic")
17-
18-
# # Mumps: Sparse Matrix Solver
19-
# set(MUMPS_PREFIX_PATH "~/spack/opt/spack/linux-ubuntu20.04-icelake/gcc-9.4.0/mumps-5.6.2-m4xrhc4mshzrxmgptzbpult3nbf6qrzk")
20-
# include_directories(${MUMPS_PREFIX_PATH}/include)
21-
# link_directories(${MUMPS_PREFIX_PATH}/lib)
22-
23-
# # Metis: Matrix reordering for Mumps
24-
# set(METIS_PREFIX_PATH "~/spack/opt/spack/linux-ubuntu20.04-icelake/gcc-9.4.0/metis-5.1.0-bgoncx22w55soviybggl5ydjakvkm34v")
25-
# include_directories(${METIS_PREFIX_PATH}/include)
26-
# link_directories(${METIS_PREFIX_PATH}/lib)
27-
28-
# # Likwid: Performance monitoring
29-
# set(LIKWID_PREFIX_PATH "~/spack/opt/spack/linux-ubuntu20.04-icelake/gcc-9.4.0/likwid-5.3.0-6mvx2snsqnamuyhaqspd6gxkfuaso36g")
30-
# include_directories(${LIKWID_PREFIX_PATH}/include)
31-
# link_directories(${LIKWID_PREFIX_PATH}/lib)
32-
33-
# Include directories for the project
34-
include_directories(include)
35-
36-
# 1. Create a library target for the PolarGrid module
37-
file(GLOB_RECURSE POLAR_GRID_SOURCES "src/PolarGrid/*.cpp")
38-
add_library(PolarGrid STATIC ${POLAR_GRID_SOURCES})
39-
target_include_directories(PolarGrid PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src/PolarGrid)
40-
41-
# 2. Create a library target for the InputFunctions module
42-
file(GLOB_RECURSE INPUT_FUNCTIONS_SOURCES
43-
"src/InputFunctions/DensityProfileCoefficients/*.cpp"
44-
"src/InputFunctions/DomainGeometry/*.cpp"
45-
"src/InputFunctions/ExactSolution/*.cpp"
46-
"src/InputFunctions/BoundaryConditions/*.cpp"
47-
"src/InputFunctions/SourceTerms/*.cpp"
48-
)
49-
add_library(InputFunctions STATIC ${INPUT_FUNCTIONS_SOURCES})
50-
target_include_directories(InputFunctions PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src/InputFunctions)
51-
52-
# 3. Collect all the common source files for GMGPolar into a library
53-
file(GLOB_RECURSE GMG_POLAR_SOURCES "src/GMGPolar/*.cpp")
54-
file(GLOB_RECURSE MULTIGRID_METHODS_SOURCES "src/GMGPolar/MultigridMethods/*.cpp")
55-
file(GLOB_RECURSE LEVEL_SOURCES "src/Level/*.cpp")
56-
file(GLOB_RECURSE STENCIL_SOURCES "src/Stencil/*.cpp")
57-
file(GLOB_RECURSE INTERPOLATION_SOURCES "src/Interpolation/*.cpp")
58-
file(GLOB_RECURSE DIRECT_SOLVER_SOURCES "src/DirectSolver/*.cpp" "src/DirectSolverGive/*.cpp" "src/DirectSolverTake/*.cpp" "src/DirectSolverGiveCustomLU/*.cpp" "src/DirectSolverTakeCustomLU/*.cpp")
59-
file(GLOB_RECURSE RESIDUAL_SOURCES "src/Residual/*.cpp" "src/Residual/ResidualGive/*.cpp" "src/Residual/ResidualTake/*.cpp")
60-
file(GLOB_RECURSE SMOOTHER_SOURCES "src/Smoother/*.cpp" "src/SmootherGive/*.cpp" "src/SmootherTake/*.cpp")
61-
file(GLOB_RECURSE EXTRAPOLATED_SMOOTHER_SOURCES "src/ExtrapolatedSmoother/*.cpp" "src/ExtrapolatedSmoother/ExtrapolatedSmootherGive/*.cpp" "src/ExtrapolatedSmoother/ExtrapolatedSmootherTake/*.cpp")
62-
63-
# 4. Create the GMGPolarLib library and link PolarGrid and InputFunctions
64-
add_library(GMGPolarLib STATIC
65-
${GMG_POLAR_SOURCES}
66-
${MULTIGRID_METHODS_SOURCES}
67-
${LEVEL_SOURCES}
68-
${STENCIL_SOURCES}
69-
${INTERPOLATION_SOURCES}
70-
${DIRECT_SOLVER_SOURCES}
71-
${RESIDUAL_SOURCES}
72-
${SMOOTHER_SOURCES}
73-
${EXTRAPOLATED_SMOOTHER_SOURCES}
74-
)
75-
# Link PolarGrid and InputFunctions to GMGPolarLib
76-
target_link_libraries(GMGPolarLib PUBLIC PolarGrid InputFunctions)
77-
78-
# Link Likwid to GMGPolarLib
79-
if(GMGPOLAR_USE_LIKWID)
80-
target_link_libraries(GMGPolarLib PUBLIC likwid)
81-
target_compile_definitions(GMGPolarLib PUBLIC "-DLIKWID_PERFMON")
82-
add_compile_definitions(GMGPOLAR_USE_LIKWID)
83-
endif()
84-
85-
# Link Mumps to GMGPolarLib
86-
if(GMGPOLAR_USE_MUMPS)
87-
set(MUMPS_LIBRARIES
88-
mumps_common
89-
smumps
90-
dmumps
91-
mpiseq
92-
metis
93-
)
94-
target_link_libraries(GMGPolarLib PUBLIC ${MUMPS_LIBRARIES})
95-
add_compile_definitions(GMGPOLAR_USE_MUMPS)
96-
endif()
97-
98-
# Add OpenMP flags if available and link to GMGPolarLib
99-
find_package(OpenMP REQUIRED)
100-
if(OpenMP_CXX_FOUND)
101-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
102-
target_link_libraries(GMGPolarLib PUBLIC OpenMP::OpenMP_CXX)
17+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -pedantic -Wno-unused -Wno-psabi")
18+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -mtune=generic -Wno-psabi")
19+
20+
# code coverage analysis
21+
# Note: this only works under linux and with make
22+
# Ninja creates different directory names which do not work together with this scrupt
23+
# as STREQUAL is case-sensitive https://github.com/TriBITSPub/TriBITS/issues/131, also allow DEBUG as accepted input
24+
option(GMGPOLAR_TEST_COVERAGE "Enable GCov coverage analysis (adds a 'coverage' target)" OFF)
25+
26+
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "DEBUG")
27+
if(GMGPOLAR_TEST_COVERAGE)
28+
message(STATUS "Coverage enabled")
29+
include(CodeCoverage)
30+
append_coverage_compiler_flags()
31+
setup_target_for_coverage_lcov(
32+
NAME coverage
33+
EXECUTABLE tests/gmgpolar_tests
34+
LCOV_ARGS --ignore-errors gcov,mismatch
35+
EXCLUDE "${CMAKE_SOURCE_DIR}/tests*" "${CMAKE_SOURCE_DIR}/src/InputFunctions*" "${CMAKE_BINARY_DIR}/*" "/usr*"
36+
)
37+
endif()
10338
endif()
10439

105-
# 5. Add the main executable target (gmgpolar)
106-
set(MAIN_SOURCE "src/main.cpp")
107-
add_executable(gmgpolar ${MAIN_SOURCE})
108-
109-
# 6. Add another executable target (convergence_order)
110-
set(CONVERGENCE_ORDER_SOURCE "src/convergence_order.cpp")
111-
add_executable(convergence_order ${CONVERGENCE_ORDER_SOURCE})
112-
113-
set(WEAK_SCALING_SOURCE "src/weak_scaling.cpp")
114-
add_executable(weak_scaling ${WEAK_SCALING_SOURCE})
40+
include_directories(include)
41+
add_subdirectory(src)
11542

116-
set(STRONG_SCALING_SOURCE "src/strong_scaling.cpp")
117-
add_executable(strong_scaling ${STRONG_SCALING_SOURCE})
43+
add_executable(gmgpolar src/main.cpp)
44+
add_executable(convergence_order src/convergence_order.cpp)
45+
add_executable(weak_scaling src/weak_scaling.cpp)
46+
add_executable(strong_scaling src/strong_scaling.cpp)
11847

119-
# 7. Link GMGPolarLib (which now includes PolarGrid and InputFunctions) to both executables
12048
target_link_libraries(gmgpolar PRIVATE GMGPolarLib)
12149
target_link_libraries(convergence_order PRIVATE GMGPolarLib)
12250
target_link_libraries(weak_scaling PRIVATE GMGPolarLib)
12351
target_link_libraries(strong_scaling PRIVATE GMGPolarLib)
12452

125-
# 9. Enable testing and include other directories
12653
if(GMGPOLAR_BUILD_TESTS)
12754
enable_testing()
12855
add_subdirectory(third-party)
12956
add_subdirectory(tests)
130-
endif()
57+
endif()

0 commit comments

Comments
 (0)