Skip to content

Commit 3d69634

Browse files
mknaranjaLitzLitzjulianlitz
authored
Refactoring GMGPolar (#65)
Full refactoring of CPU-based GMGPolar to object oriented code design. - Improved code design - Improved cache efficiency - Improved scalability Co-authored-by: Litz <litz_ju@ubuntu-server.intra.dlr.de> Co-authored-by: Litz <litz_ju@fe-store02.maas> Co-authored-by: Julian Litz <91479202+julianlitz@users.noreply.github.com>
1 parent bba9d5b commit 3d69634

573 files changed

Lines changed: 71635 additions & 46795 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
BasedOnStyle: LLVM
22
IndentWidth: 4
3-
SortIncludes: false
4-
ColumnLimit: 120
3+
SortIncludes: false
4+
ColumnLimit: 120
55
AlignTrailingComments: false
66
AccessModifierOffset: -4
77
AlignConsecutiveAssignments: true
8-
ReflowComments: false
8+
ReflowComments: false
99
BraceWrapping:
10-
AfterClass: true
10+
AfterClass: true
1111
AfterFunction: true
1212
BeforeElse: true
1313
BeforeCatch: true

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
22

3+
.vscode/
4+
5+
.github/
6+
7+
Output/
8+
9+
*.vtu
10+
311
# dependencies
412
/.pnp
513
.pnp.js

CITATION.cff

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
title: GMGPolar
2-
version: 1.0.0
2+
version: 2.0.0
33
date-released: "2023-04-14"
44
repository-code: "https://github.com/mknaranja/GMGPolar"
55
url: "https://github.com/mknaranja/GMGPolar"
@@ -29,9 +29,12 @@ authors:
2929
orcid: "https://orcid.org/0000-0001-8796-8599"
3030
- given-names: Allan
3131
family-names: Kuhn
32-
affiliation: "German Aerospace Center (DLR)"
32+
affiliation: "German Aerospace Center (DLR)"
33+
- given-names: Julian
34+
family-names: Litz
35+
affiliation: "German Aerospace Center (DLR)"
3336
#Contributors
34-
cff-version: 1.0.0
37+
cff-version: 2.0.0
3538
message: >-
3639
If you use this software, please cite it using the
3740
metadata from this file.

CMakeLists.txt

100644100755
Lines changed: 108 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,130 @@
1-
cmake_minimum_required(VERSION 3.16.3)
2-
3-
project(GMGPolar VERSION 1.0.0)
1+
cmake_minimum_required(VERSION 3.12)
2+
project(GMGPolar VERSION 2.0.0 LANGUAGES CXX)
43

54
option(GMGPOLAR_BUILD_TESTS "Build GMGPolar unit tests." ON)
6-
option(GMGPOLAR_USE_MUMPS "Use MUMPS to compute matrix factorizations." OFF)
75
option(GMGPOLAR_USE_LIKWID "Use LIKWID to measure code (regions)." OFF)
6+
option(GMGPOLAR_USE_MUMPS "Use MUMPS to solve linear systems." OFF)
87

8+
set(CMAKE_CXX_STANDARD 20)
9+
set(CMAKE_CXX_STANDARD_REQUIRED True)
910

10-
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
11-
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
12-
13-
set(CMAKE_CXX_FLAGS "")
14-
set(CMAKE_LINKER_FLAGS "")
15-
16-
add_subdirectory(src)
17-
18-
# code coverage analysis
19-
# Note: this only works under linux and with make
20-
# Ninja creates different directory names which do not work together with this scrupt
21-
# as STREQUAL is case-sensitive https://github.com/TriBITSPub/TriBITS/issues/131, also allow DEBUG as accepted input
22-
option(GMGPOLAR_TEST_COVERAGE "Enable GCov coverage analysis (adds a 'coverage' target)" OFF)
23-
24-
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "DEBUG")
25-
if(GMGPOLAR_TEST_COVERAGE)
26-
message(STATUS "Coverage enabled")
27-
include(CodeCoverage)
28-
append_coverage_compiler_flags()
29-
setup_target_for_coverage_lcov(
30-
NAME coverage
31-
EXECUTABLE tests/gmgpolar_tests
32-
EXCLUDE "${CMAKE_SOURCE_DIR}/tests*" "${CMAKE_SOURCE_DIR}/src/test_cases*" "${CMAKE_BINARY_DIR}/*" "/usr*"
33-
)
34-
endif()
11+
if(NOT CMAKE_BUILD_TYPE)
12+
set(CMAKE_BUILD_TYPE Release)
3513
endif()
3614

37-
38-
add_library(GMGPolar ${SOURCES_SRC})
39-
40-
add_executable(gmgpolar_simulation ./src/main.cpp)
41-
42-
configure_file(${CMAKE_SOURCE_DIR}/include/config_internal.h.in ${CMAKE_SOURCE_DIR}/include/config_internal.h)
43-
44-
target_include_directories(gmgpolar_simulation PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/include/test_cases )
45-
target_include_directories(GMGPolar PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/include/test_cases )
46-
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
4779
if(GMGPOLAR_USE_LIKWID)
48-
49-
find_package(LIKWID REQUIRED)
50-
51-
target_include_directories(GMGPolar PUBLIC ${LIKWID_INCLUDE_DIRS})
52-
target_link_libraries(GMGPolar PUBLIC ${LIKWID_LIBRARIES})
53-
target_compile_definitions(GMGPolar PUBLIC "-DLIKWID_PERFMON")
54-
80+
target_link_libraries(GMGPolarLib PUBLIC likwid)
81+
target_compile_definitions(GMGPolarLib PUBLIC "-DLIKWID_PERFMON")
82+
add_compile_definitions(GMGPOLAR_USE_LIKWID)
5583
endif()
5684

57-
58-
85+
# Link Mumps to GMGPolarLib
5986
if(GMGPOLAR_USE_MUMPS)
60-
61-
set(INC_DIRS
62-
/home/kueh_mj/.spack/rev.23.05/install/linux-rocky8-zen2/gcc-10.4.0/mumps-5.4.1-fftqkl/include
63-
/sw/rev/23.05/linux-rocky8-zen2/gcc-10.4.0/metis-5.1.0-akhgsf/include
64-
)
65-
66-
set(LIB_DIRS
67-
/home/kueh_mj/.spack/rev.23.05/install/linux-rocky8-zen2/gcc-10.4.0/mumps-5.4.1-fftqkl/lib
68-
/sw/rev/23.05/linux-rocky8-zen2/gcc-10.4.0/metis-5.1.0-akhgsf/lib
69-
)
70-
71-
include_directories(
72-
${INC_DIRS}
73-
)
74-
75-
target_link_directories(
76-
GMGPolar
77-
PUBLIC
78-
${LIB_DIRS}
79-
)
80-
81-
set(LIBS
82-
mpiseq
83-
dmumps
87+
set(MUMPS_LIBRARIES
8488
mumps_common
89+
smumps
90+
dmumps
91+
mpiseq
8592
metis
8693
)
87-
88-
target_link_libraries(
89-
GMGPolar
90-
PUBLIC
91-
${LIBS}
92-
)
94+
target_link_libraries(GMGPolarLib PUBLIC ${MUMPS_LIBRARIES})
95+
add_compile_definitions(GMGPOLAR_USE_MUMPS)
9396
endif()
9497

95-
96-
find_package(OpenMP)
97-
98-
#currently works on GNU compiler
99-
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7))
100-
101-
string(APPEND CMAKE_CXX_FLAGS " -O2 -Wall -MMD -MP -Wwrite-strings")
102-
string(APPEND CMAKE_LINKER_FLAGS " -O2 -Wall -MMD -MP -Wwrite-strings")
103-
104-
if(OPENMP_FOUND)
105-
string(APPEND CMAKE_CXX_FLAGS " -fopenmp")
106-
string(APPEND CMAKE_LINKER_FLAGS " -fopenmp")
107-
108-
else()
109-
message(FATAL_ERROR "OpenMP needed")
110-
endif()
111-
else()
112-
message(FATAL_ERROR "Please use GNU compiler or change CMakeLists manually")
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)
113103
endif()
114104

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})
115112

116-
target_link_libraries(gmgpolar_simulation PRIVATE GMGPolar)
113+
set(WEAK_SCALING_SOURCE "src/weak_scaling.cpp")
114+
add_executable(weak_scaling ${WEAK_SCALING_SOURCE})
117115

116+
set(STRONG_SCALING_SOURCE "src/strong_scaling.cpp")
117+
add_executable(strong_scaling ${STRONG_SCALING_SOURCE})
118118

119-
include(thirdparty/CMakeLists.txt)
120-
add_subdirectory(tests)
119+
# 7. Link GMGPolarLib (which now includes PolarGrid and InputFunctions) to both executables
120+
target_link_libraries(gmgpolar PRIVATE GMGPolarLib)
121+
target_link_libraries(convergence_order PRIVATE GMGPolarLib)
122+
target_link_libraries(weak_scaling PRIVATE GMGPolarLib)
123+
target_link_libraries(strong_scaling PRIVATE GMGPolarLib)
121124

125+
# 9. Enable testing and include other directories
126+
if(GMGPOLAR_BUILD_TESTS)
127+
enable_testing()
128+
add_subdirectory(third-party)
129+
add_subdirectory(tests)
130+
endif()

0 commit comments

Comments
 (0)