-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add CMake based build system for CABLE offline #200
Conversation
6476b8c
to
9496936
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO after this pull request:
- We should list the source files in alphabetical order (the current order is so that we preserve binary equivalence with the Makefile build).
- Use
find_package(MPI REQUIRED)
instead of specifyingmpif90
when invokingcmake
for MPI case. - Add simultaneous compilation of MPI and serial executables by creating a separate target for each executable.
- Remove MPI option from build script as the same can be achieved by specifying
--target cable-mpi
when invoking CMake.
5d34dbf
to
ec3e56a
Compare
ec3e56a
to
a5f70cd
Compare
ecba2bb
to
b54a2a1
Compare
e1475bd
to
b95462c
Compare
Note, some links in the documentation are currently broken as they point to source files that were added in this pull request. To see the source files, replace |
@ccarouge is it worth supporting both Makefile and CMake based build systems? Or should we deprecate the Makefile build system in this pull request? |
For the record: we only want to support one build system. So this PR should deprecate the Makefile build system. |
22896d4
to
b7aec13
Compare
b7aec13
to
8caa102
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor stuff. I don't think I need to review again but I'd like the -j
option for cmake to be an option for build.bash
.
documentation/docs/developer_guide/other_resources/build_system.md
Outdated
Show resolved
Hide resolved
c2084b1
to
26d0136
Compare
65b39ba
to
2bc0c31
Compare
2bc0c31
to
3d98226
Compare
Co-authored-by: Claire Carouge <[email protected]>
3d98226
to
956304f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done! Potentially a few things we can look at later.
This pull request should follow after the CMake implementation (see #200). This change adds the following build system changes: - List source files in alphabetical order in CMakeLists.txt. The order of source files was previously chosen so that we could demonstrate binary equivalence in executables between the CMake build and the Makefile build. - Use [`find_package(MPI REQUIRED)`](https://cmake.org/cmake/help/latest/module/FindMPI.html) instead of specifying `mpif90` when invoking `cmake` for MPI case. This is done so that 1. We can create separate targets for the serial and MPI executable and only link against the MPI libraries when needed without relying on the MPI compiler wrapper. This lets us compile all executables (serial and parallel) with a single invocation of CMake. 2. We can use object libraries to compile the object files common to both serial and MPI builds. This saves compiling these object files for each executable (serial and MPI), reducing compilation time. - Portability fixes and improvements to build.bash. - Add `--compiler` flag to build.bash and GNU compiler support. - Add Matthias's configuration for example. Regression tests using [benchcab](https://github.com/CABLE-LSM/benchcab)* (bitwise comparison of model output via nccmp) show that model output is bitwise identical between the current branch and the main branch for serial and MPI model runs. *executables were built manually as benchcab does not yet support the recent build system changes (see related issue: CABLE-LSM/benchcab#258). Fixes #215 <!-- readthedocs-preview cable start --> ---- 📚 Documentation preview 📚: https://cable--216.org.readthedocs.build/en/216/ <!-- readthedocs-preview cable end -->
The CABLE build system was transitioned from Makefile to CMake: see CABLE-LSM/CABLE#216, CABLE-LSM/CABLE#200. This change adds support for building CABLE via CMake in benchcab so that CABLE versions which branch from the HEAD of main can be tested. Closes #258
The CABLE build system was transitioned from Makefile to CMake: see CABLE-LSM/CABLE#216, CABLE-LSM/CABLE#200. This change adds support for building CABLE via CMake in benchcab so that CABLE versions which branch from the HEAD of main can be tested. Closes #258
The CABLE build system was transitioned from Makefile to CMake: see CABLE-LSM/CABLE#216, CABLE-LSM/CABLE#200. This change adds support for building CABLE via CMake in benchcab so that CABLE versions which branch from the HEAD of main can be tested. Closes #258
The CABLE build system was transitioned from Makefile to CMake: see CABLE-LSM/CABLE#216, CABLE-LSM/CABLE#200. This change adds support for building CABLE via CMake in benchcab so that CABLE versions which branch from the HEAD of main can be tested. Closes #258
In preparation for building CABLE with spack, @harshula, @ccarouge and I have found areas where the current build system for CABLE offline can be improved (see #188 for more details). This change adds a CMake based build system to address these issues:
Although this problem can be solved in the Makefile by specifying the relative paths to each source file, it requires updating all the Makefile Fortran module dependency rules which is a pain. CMake automatically handles Fortran module dependencies out of the box so doing this with CMake is much easier.
When invoking
cmake
, custom options, compilers and compiler flags can be configurable by setting the appropriate variables via the-D
flag, for example:cmake -DCMAKE_Fortran_COMPILER="mpif90" -DCMAKE_Fortran_FLAGS="-O2 -fp-model precise" -S . -B build
. These can be used for doing MPI only builds and enabling specific debug flags.As mentioned above, CMake automatically handles Fortran module dependencies out of the box. Parallelised builds can be done by specifying the
-j
flag tocmake
.The following pull requests should be merged before this pull request so that we can demonstrate binary equivalence between the executables compiled by both Makefile and CMake builds. This ensures no unwanted changes are introduced by the transition.
-O0
flag fromLDFLAGS
#197Edit: the above PR's have been merged - the serial and MPI binaries built by CMake (in release mode) are equivalent to the binaries built by the Makefile based build system in the main branch.
Fixes #188, #190, #191, #192
📚 Documentation preview 📚: https://cable--200.org.readthedocs.build/en/200/