Skip to content

Conversation

@SeanBryan51
Copy link
Collaborator

@SeanBryan51 SeanBryan51 commented Jan 22, 2024

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:

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.

Edit: 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/

@SeanBryan51 SeanBryan51 linked an issue Jan 22, 2024 that may be closed by this pull request
4 tasks
@SeanBryan51 SeanBryan51 force-pushed the 188-cmake-based-build-system branch from 6476b8c to 9496936 Compare January 22, 2024 05:50
Copy link
Collaborator Author

@SeanBryan51 SeanBryan51 Jan 23, 2024

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 specifying mpif90 when invoking cmake 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.

@SeanBryan51 SeanBryan51 force-pushed the 188-cmake-based-build-system branch from 5d34dbf to ec3e56a Compare January 23, 2024 05:07
@SeanBryan51 SeanBryan51 force-pushed the 188-cmake-based-build-system branch from ec3e56a to a5f70cd Compare January 24, 2024 23:56
@SeanBryan51 SeanBryan51 marked this pull request as ready for review January 25, 2024 01:03
@SeanBryan51 SeanBryan51 force-pushed the 188-cmake-based-build-system branch 4 times, most recently from ecba2bb to b54a2a1 Compare January 29, 2024 02:37
@SeanBryan51
Copy link
Collaborator Author

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 main with 188-cmake-based-build-system in the url.

@SeanBryan51
Copy link
Collaborator Author

@ccarouge is it worth supporting both Makefile and CMake based build systems? Or should we deprecate the Makefile build system in this pull request?

@ccarouge
Copy link
Member

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

@SeanBryan51 SeanBryan51 force-pushed the 188-cmake-based-build-system branch 3 times, most recently from 22896d4 to b7aec13 Compare February 28, 2024 01:29
@SeanBryan51 SeanBryan51 force-pushed the 188-cmake-based-build-system branch from b7aec13 to 8caa102 Compare February 28, 2024 03:01
Copy link
Member

@ccarouge ccarouge left a 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.

@SeanBryan51 SeanBryan51 force-pushed the 188-cmake-based-build-system branch from c2084b1 to 26d0136 Compare February 28, 2024 05:28
@SeanBryan51 SeanBryan51 force-pushed the 188-cmake-based-build-system branch from 65b39ba to 2bc0c31 Compare February 28, 2024 05:33
@SeanBryan51 SeanBryan51 force-pushed the 188-cmake-based-build-system branch from 2bc0c31 to 3d98226 Compare February 29, 2024 00:43
SeanBryan51 and others added 2 commits February 29, 2024 11:50
Co-authored-by: Claire Carouge <ccarouge@users.noreply.github.com>
@SeanBryan51 SeanBryan51 force-pushed the 188-cmake-based-build-system branch from 3d98226 to 956304f Compare February 29, 2024 00:50
Copy link

@harshula harshula left a 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 was referenced Mar 1, 2024
@SeanBryan51 SeanBryan51 merged commit 045dfe2 into main Mar 1, 2024
@SeanBryan51 SeanBryan51 deleted the 188-cmake-based-build-system branch March 1, 2024 04:55
SeanBryan51 added a commit that referenced this pull request Mar 15, 2024
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 -->
SeanBryan51 added a commit to CABLE-LSM/benchcab that referenced this pull request Apr 4, 2024
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
SeanBryan51 added a commit to CABLE-LSM/benchcab that referenced this pull request Apr 4, 2024
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
SeanBryan51 added a commit to CABLE-LSM/benchcab that referenced this pull request Apr 5, 2024
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
SeanBryan51 added a commit to CABLE-LSM/benchcab that referenced this pull request Apr 5, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants