Skip to content

Commit

Permalink
Merge pull request #2514 from boutproject/ci-cmake-only
Browse files Browse the repository at this point in the history
Switch to CMake in CI and docs
  • Loading branch information
ZedThree authored Jun 14, 2023
2 parents 3c06094 + 23f8939 commit f695441
Show file tree
Hide file tree
Showing 20 changed files with 244 additions and 303 deletions.
2 changes: 1 addition & 1 deletion .ci_fedora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ else
cd
cd BOUT-dev
echo "starting configure"
time cmake -DBOUT_USE_PETSC=ON -S . -B build
time cmake -S . -B build -DBOUT_USE_PETSC=ON
time make -C build build-check -j 2
time make -C build check
fi
13 changes: 12 additions & 1 deletion .ci_with_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@
set -ex

cmake --version
cmake . -B build $@ -DCMAKE_INSTALL_PREFIX=$(pwd)/installed
cmake -S . -B build $@ -DCMAKE_INSTALL_PREFIX=$(pwd)/installed

if test ".$UNIT_ONLY" = ".YES" ; then
make -C build build-check-unit-tests
make -C build check-unit-tests
exit 0
fi

cmake --build build --target build-check -j 2
cd build
ctest --output-on-failure --timeout 300

export LD_LIBRARY_PATH=/home/runner/local/lib:$LD_LIBRARY_PATH

# Test bout-config basic functionallity
cd ../examples/make-script
PATH=../../build/bin:$PATH bout-config --all
PATH=../../build/bin:$PATH make
./test --help
cd -
Expand All @@ -25,6 +35,7 @@ rm -rf build
# Test installation with plain `make`
cd ../examples/make-script
rm test
PATH=../../installed/bin:$PATH bout-config --all
PATH=../../installed/bin:$PATH make
./test --help
cd -
Expand Down
89 changes: 39 additions & 50 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,45 +25,42 @@ jobs:
OMPI_MCA_rmaps_base_oversubscribe: yes
MPIRUN: mpiexec -np
strategy:
fail-fast: false
fail-fast: true
matrix:
# Need this to be able to exclude the coverage job
is_master_or_next:
- ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next' || github.base_ref == 'master' || github.base_ref == 'next' }}
config:
- name: "Default options, Ubuntu 20.04"
os: ubuntu-20.04
configure_options: ""
script_flags: "-uim"
cmake_options: ""

- name: "Optimised, shared, Python"
- name: "Optimised, static"
os: ubuntu-20.04
configure_options: "--enable-shared
--enable-checks=no
--enable-optimize=3
--disable-signal
--disable-track
--disable-backtrace
--with-petsc
--with-slepc
--with-sundials=/home/runner/local"
script_flags: "-uim -t shared -t python"
omp_num_threads: 1
cmake_options: "-DBOUT_ENABLE_CHECKS=OFF
-DBUILD_SHARED_LIBS=OFF
-DCXXFLAGS=-Ofast
-DBOUT_ENABLE_SIGNAL=OFF
-DBOUT_ENABLE_TRACK=OFF
-DBOUT_ENABLE_BACKTRACE=OFF
-DBOUT_USE_PETSC=ON
-DBOUT_USE_SLEPC=ON
-DBOUT_USE_SUNDIALS=ON
-DSUNDIALS_ROOT=/home/runner/local"

- name: "Debug, shared"
os: ubuntu-20.04
configure_options: "--enable-shared
--enable-sigfpe
--enable-debug
--enable-track
--with-petsc
--with-slepc
--with-sundials=/home/runner/local"
script_flags: "-uim"
omp_num_threads: 1

- name: "CMake, shared, release"
os: ubuntu-latest
cmake_options: "-DBOUT_ENABLE_CHECKS=3
-DCMAKE_BUILD_TYPE=Debug
-DBOUT_ENABLE_SIGNAL=ON
-DBOUT_ENABLE_TRACK=ON
-DBOUT_USE_PETSC=ON
-DBOUT_USE_SLEPC=ON
-DBOUT_USE_SUNDIALS=ON
-DSUNDIALS_ROOT=/home/runner/local"

- name: "Shared, release, Ubuntu 20.04"
os: ubuntu-20.04
cmake_options: "-DBUILD_SHARED_LIBS=ON
-DBOUT_ENABLE_OPENMP=ON
-DCMAKE_BUILD_TYPE=Release
Expand All @@ -74,7 +71,7 @@ jobs:
-DSUNDIALS_ROOT=/home/runner/local"
omp_num_threads: 2

- name: "CMake, shared, OpenMP, 3D metrics"
- name: "Shared, OpenMP, 3D metrics"
os: ubuntu-latest
cmake_options: "-DBUILD_SHARED_LIBS=ON
-DBOUT_ENABLE_METRIC_3D=ON
Expand All @@ -88,16 +85,17 @@ jobs:

- name: "Coverage"
os: ubuntu-20.04
configure_options: "--enable-shared
--enable-code-coverage
--enable-debug
--enable-track
--with-lapack
--with-petsc
--with-slepc
--with-sundials=/home/runner/local"
omp_num_threads: 1
script_flags: "-u"
cmake_options: "-DBUILD_SHARED_LIBS=ON
-DCMAKE_BUILD_TYPE=Debug
-DCHECK=3
-DENABLE_COVERAGE=ON
-DBOUT_USE_PETSC=ON
-DBOUT_USE_SLEPC=ON
-DBOUT_USE_HDF5=ON
-DBOUT_USE_SUNDIALS=ON
-DBOUT_ENABLE_PYTHON=ON
-DSUNDIALS_ROOT=/home/runner/local"
unit_only: YES
exclude:
# Don't run the coverage tests if the branch isn't master or next
- is_master_or_next: false
Expand All @@ -108,7 +106,6 @@ jobs:
- name: Job information
run: |
echo Build: ${{ matrix.config.name }}, ${{ matrix.config.os }}
echo Configure options: ${{ matrix.config.configure_options }}
echo CMake options: ${{ matrix.config.cmake_options }}
- name: Install dependencies
Expand Down Expand Up @@ -137,7 +134,7 @@ jobs:

- name: Install pip packages
run: |
./.pip_install_for_ci.sh 'cython~=0.29' 'netcdf4~=1.5' 'sympy~=1.5' 'gcovr' 'cmake' 'h5py' zoidberg
./.pip_install_for_ci.sh 'cython~=0.29' 'netcdf4~=1.5' 'sympy~=1.5' 'gcovr' 'cmake' 'h5py' zoidberg fastcov
# Add the pip install location to the runner's PATH
echo ~/.local/bin >> $GITHUB_PATH
Expand All @@ -150,16 +147,8 @@ jobs:
- name: Build SUNDIALS
run: ./.build_sundials_for_ci.sh

- name: Build (configure)
if: ${{ ! contains(matrix.config.name, 'CMake') }}
run: ./.ci_script.sh ${{ matrix.config.script_flags }}
env:
LD_LIBRARY_PATH: /home/runner/local/lib:$LD_LIBRARY_PATH
CONFIGURE_OPTIONS: ${{ matrix.config.configure_options }}

- name: Build (CMake)
if: ${{ contains(matrix.config.name, 'CMake') }}
run: ./.ci_with_cmake.sh ${{ matrix.config.cmake_options }}
run: UNIT_ONLY=${{ matrix.config.unit_only }} ./.ci_with_cmake.sh ${{ matrix.config.cmake_options }}

- name: Capture coverage
if: ${{ matrix.config.name == 'Coverage' }}
Expand All @@ -171,7 +160,7 @@ jobs:
# This is to try and make the coverage report slightly more accurate
# It still won't include, e.g. any solvers we don't build with though
find . -name "*.gcno" -exec sh -c 'touch -a "${1%.gcno}.gcda"' _ {} \;
make code-coverage-capture
make -C build code-coverage-capture
- name: Upload coverage
if: ${{ matrix.config.name == 'Coverage' }}
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ src/fmt/format.cxx
/tests/integrated/test-options-netcdf/time.nc
/tests/integrated/test-yupdown-weights/test_yupdown_weights

coverage.info
coverage/

# Potential user build directories
/build/
/build*/
Expand All @@ -78,4 +81,5 @@ src/fmt/format.cxx
# Python stuff
/_wheel*/
/dist/
/manual/sphinx/_build
/_version.txt
4 changes: 0 additions & 4 deletions cmake/FindSUNDIALS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@

include(FindPackageHandleStandardArgs)

find_package(SUNDIALS CONFIG QUIET)
if (SUNDIALS_FOUND)
return()
endif()

find_path(SUNDIALS_INCLUDE_DIR
sundials_config.h
Expand Down
20 changes: 9 additions & 11 deletions cmake/Sanitizers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,22 @@ function(enable_sanitizers target_name)

if(ENABLE_COVERAGE)
target_compile_options(${target_name} PUBLIC --coverage -O0 -g)
target_link_libraries(${target_name} PUBLIC --coverage)
target_link_libraries(${target_name} PUBLIC --coverage -lgcov)

find_program(fastcov_FOUND fastcov)
message(STATUS "Looking for fastcov: ${fastcov_FOUND}")
find_program(lcov_FOUND lcov)
message(STATUS "Looking for lcov: ${lcov_FOUND}")
find_program(genhtml_FOUND genhtml)
message(STATUS "Looking for genhtml: ${fastcov_FOUND}")
message(STATUS "Looking for genhtml: ${genhtml_FOUND}")

if (fastcov_FOUND AND genhtml_FOUND)
if (lcov_FOUND AND genhtml_FOUND)
set(COVERAGE_NAME coverage CACHE STRING "Name of coverage output file")
set(COVERAGE_FILE "${COVERAGE_NAME}.info")
set(COVERAGE_MSG "Open file://${PROJECT_SOURCE_DIR}/${COVERAGE_NAME}/index.html in your browser to view coverage HTML output")

add_custom_target(code-coverage-capture
COMMAND
fastcov --include "${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_CURRENT_SOURCE_DIR}/include"
--exclude "${CMAKE_CURRENT_SOURCE_DIR}/externalpackages"
--lcov --process-gcno
--output "${COVERAGE_FILE}"
lcov -c --directory "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/bout++.dir/src"
--output-file "${COVERAGE_FILE}"
COMMAND
genhtml --output-directory "${COVERAGE_NAME}" --demangle-cpp --legend --show-details "${COVERAGE_FILE}"
COMMAND
Expand All @@ -41,11 +39,11 @@ function(enable_sanitizers target_name)

add_custom_target(code-coverage-clean
COMMAND
fastcov --zerocounters
lcov --zerocounters
COMMENT "Cleaning coverage information"
)
else()
message(STATUS "Coverage enabled, but coverage-capture not available. Please install fastcov and lcov")
message(FATAL_ERROR "Coverage enabled, but coverage-capture not available. Please install lcov")
endif()

endif()
Expand Down
9 changes: 7 additions & 2 deletions cmake/SetupBOUTThirdParty.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ if (BOUT_USE_PETSC)
find_package(PETSc REQUIRED)
target_link_libraries(bout++ PUBLIC PETSc::PETSc)
string(JOIN " " CONFIG_PETSC_LIBRARIES ${PETSC_LIBRARIES})
set(CONFIG_LDFLAGS "${CONFIG_PETSC_LIBRARIES} ${CONFIG_LDFLAGS}")
set(CONFIG_LDFLAGS "${CONFIG_LDFLAGS} ${CONFIG_PETSC_LIBRARIES}")
foreach(PETSC_INCLUDE ${PETSC_INCLUDES})
set(CONFIG_CFLAGS "${CONFIG_CFLAGS} -I${PETSC_INCLUDE}")
endforeach()
Expand Down Expand Up @@ -169,7 +169,12 @@ if (BOUT_USE_NETCDF)
FetchContent_MakeAvailable(netcdf-cxx4)
else()
find_package(netCDFCxx REQUIRED)
set(CONFIG_LDFLAGS "${CONFIG_LDFLAGS} ${netCDF_CXX_LIBRARY} ${netCDF_LIBRARIES}")
foreach(FLAG ${netCDF_CXX_LIBRARY} ${netCDF_LIBRARIES})
if("${FLAG}" STREQUAL "netcdf")
set(FLAG -lnetcdf)
endif()
set(CONFIG_LDFLAGS "${CONFIG_LDFLAGS} ${FLAG}")
endforeach()
endif()
target_link_libraries(bout++ PUBLIC netCDF::netcdf-cxx4)
endif()
Expand Down
2 changes: 1 addition & 1 deletion manual/RELEASE_HOWTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ Before merging PR:

After PR is merged:

- [ ] Make tarball: `./configure && make dist`
- [ ] Try to summarise the changes!
- [ ] Make [GitHub Release][gh_release], include change summary **NB:** tag should have
leading `v`
Expand All @@ -73,6 +72,7 @@ After PR is merged:
- [ ] [`manual/doxygen/Doxyfile`][Doxyfile]: `PROJECT_NUMBER`
- [ ] [`CMakeLists.txt`][CMakeLists]: `_bout_previous_version`, `_bout_next_version`
- [ ] [`tools/pylib/_boutpp_build/backend.py`][backend.py]: `_bout_previous_version`, `_bout_next_version`
- [ ] Make tarball: `cmake -S . -B build && make dist -C build`

[Doxyfile]: ../manual/doxygen/Doxyfile
[Doxyfile_readthedocs]: ../manual/doxygen/Doxyfile_readthedocs
Expand Down
2 changes: 1 addition & 1 deletion manual/sphinx/developer_docs/data_types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ offsets there is a function ``offset(x,y,z)`` so that
Note that by default no bounds checking is performed. If the checking
level is increased to 3 or above then bounds checks will be
performed. This will have a significant (bad) impact on performance, so is
just for debugging purposes. Configure with ``--enable-checks=3``
just for debugging purposes. Configure with ``-DCHECK=3``
option to do this.


Expand Down
2 changes: 1 addition & 1 deletion manual/sphinx/developer_docs/mesh.rst
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ The mesh spacing is given by the public members `Coordinates::dx`,
Field2D zlength(); // Computed from dz

`Coordinates::FieldMetric` can be either `Field2D` or if BOUT++ has
been configured with ``--enable-metric-3d`` then a `Field3D`.
been configured with ``-DBOUT_ENABLE_METRIC_3D`` then a `Field3D`.

Metrics
-------
Expand Down
10 changes: 5 additions & 5 deletions manual/sphinx/developer_docs/performance_profiling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,10 @@ percent of runtime.
Configure and build
~~~~~~~~~~~~~~~~~~~

Configure with ``--with-scorep`` to enable Scorep instrumentation, then build
as normal. This option can be combined with other options, but it is usually
desirable to profile the optimized code, configuring with the flags
``--enable-optimize=3 --enable-checks=0``. Build the code with ``make`` as
normal.
Configure with ``-BOUT_USE_SCOREP`` to enable Scorep instrumentation,
then build as normal. This option can be combined with other options,
but it is usually desirable to profile the optimized code, configuring
with the flags ````. Build the code with ``make`` as normal.

With CMake:

Expand All @@ -95,6 +94,7 @@ With CMake:
$ SCOREP_WRAPPER=off cmake \
-DCMAKE_C_COMPILER=scorep-mpicc \
-DCMAKE_CXX_COMPILER=scorep-mpicxx \
-DCMAKE_CXX_FLAGS=-O3 -DCHECK=0 \
<other CMake options>
This will turn off the instrumentation during the configure
Expand Down
Loading

0 comments on commit f695441

Please sign in to comment.