Skip to content

Commit 49ea40c

Browse files
authored
Add support for C++26 (#5397)
Description of changes: - remove array comparison deprecated in C++20 and removed in C++26 (P2865R6) - support C++26's new `std::to_string` implementation - bump Caliper version - update CI runner images and C++ compiler toolchains and simplify CI/CD workflows
1 parent d8a9164 commit 49ea40c

10 files changed

Lines changed: 47 additions & 43 deletions

File tree

.github/actions/build_and_check/action.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ permissions:
99

1010
jobs:
1111
deploy_docs:
12-
runs-on: ubuntu-24.04
12+
runs-on: ubuntu-26.04
1313
if: ${{ github.repository == 'espressomd/espresso' }}
1414
environment: deploy_documentation
1515
steps:

.github/workflows/push_pull.yml

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,42 @@ jobs:
2424
- name: Install dependencies
2525
run: |
2626
echo '' > Brewfile
27-
for dep in boost boost-mpi libomp fftw gsl ccache ninja; do echo "brew \"${dep}\"" >> Brewfile; done
27+
for dep in boost boost-mpi libomp fftw gsl ccache ninja hdf5-mpi; do echo "brew \"${dep}\"" >> Brewfile; done
2828
brew bundle check >/dev/null 2>&1 || brew bundle --verbose --no-upgrade
2929
# set up Xcode compiler
3030
echo "::group::List available Xcode compilers"
3131
ls /Applications | grep Xcode
3232
echo "::endgroup::"
33-
sudo xcode-select -switch /Applications/Xcode_26.2.0.app
33+
sudo xcode-select -switch /Applications/Xcode_26.6.0.app
3434
# Python dependencies
3535
python -m venv venv
3636
. venv/bin/activate
3737
python -m pip install -c requirements.txt cython numpy scipy packaging
3838
deactivate
3939
shell: bash
4040
- name: Build and check
41-
uses: ./.github/actions/build_and_check
41+
run: |
42+
if test -d venv; then . venv/bin/activate; fi
43+
bash maintainer/CI/build_cmake.sh
4244
env:
4345
build_procs: 3
4446
check_procs: 3
4547
cmake_params: '-D ESPRESSO_TEST_NP=3'
48+
myconfig: 'maxset'
4649
with_ccache: 'true'
50+
with_cuda: 'false'
51+
with_hdf5: 'true'
4752
with_fftw: 'true'
4853
with_gsl: 'true'
4954
with_walberla: 'true'
5055
with_walberla_avx: 'false'
56+
check_skip_long: 'true'
57+
test_timeout: 800
5158

5259
debian:
53-
runs-on: ubuntu-latest
60+
runs-on: ubuntu-26.04
5461
container:
55-
image: ghcr.io/espressomd/docker/debian:ab5bc64f5c3cc7330952f8b3bf321270ca53960c-base-layer
62+
image: ghcr.io/espressomd/docker/debian:c6ad9809eed1d0e9f26f4968559b234ea3b8bf82-base-layer
5663
credentials:
5764
username: ${{ github.actor }}
5865
password: ${{ secrets.github_token }}
@@ -70,7 +77,9 @@ jobs:
7077
- name: Get runner specifications
7178
run: lscpu | egrep 'Model name|Socket|Thread|NUMA|CPU\(s\)'
7279
- name: Build and check
73-
uses: ./.github/actions/build_and_check
80+
run: |
81+
if test -d venv; then . venv/bin/activate; fi
82+
bash maintainer/CI/build_cmake.sh
7483
env:
7584
build_procs: 4
7685
check_procs: 4
@@ -90,10 +99,10 @@ jobs:
9099
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1
91100

92101
ubuntu:
93-
runs-on: ubuntu-latest
102+
runs-on: ubuntu-26.04
94103
if: ${{ github.repository == 'espressomd/espresso' }}
95104
container:
96-
image: ghcr.io/espressomd/docker/ubuntu-wo-dependencies:ab5bc64f5c3cc7330952f8b3bf321270ca53960c-base-layer
105+
image: ghcr.io/espressomd/docker/ubuntu-wo-dependencies:c6ad9809eed1d0e9f26f4968559b234ea3b8bf82-base-layer
97106
credentials:
98107
username: ${{ github.actor }}
99108
password: ${{ secrets.github_token }}
@@ -111,12 +120,14 @@ jobs:
111120
- name: Get runner specifications
112121
run: lscpu | egrep 'Model name|Socket|Thread|NUMA|CPU\(s\)'
113122
- name: Build and check
114-
uses: ./.github/actions/build_and_check
123+
run: |
124+
if test -d venv; then . venv/bin/activate; fi
125+
bash maintainer/CI/build_cmake.sh
115126
env:
116127
build_procs: 4
117128
check_procs: 4
118-
CC: 'gcc-13'
119-
CXX: 'g++-13'
129+
CC: 'gcc-16'
130+
CXX: 'g++-16'
120131
myconfig: 'maxset'
121132
with_ccache: 'true'
122133
with_cuda: 'false'
@@ -132,10 +143,10 @@ jobs:
132143
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1
133144

134145
fedora:
135-
runs-on: ubuntu-latest
146+
runs-on: ubuntu-26.04
136147
if: ${{ github.repository == 'espressomd/espresso' }}
137148
container:
138-
image: ghcr.io/espressomd/docker/fedora:ab5bc64f5c3cc7330952f8b3bf321270ca53960c-base-layer
149+
image: ghcr.io/espressomd/docker/fedora:c6ad9809eed1d0e9f26f4968559b234ea3b8bf82-base-layer
139150
credentials:
140151
username: ${{ github.actor }}
141152
password: ${{ secrets.github_token }}
@@ -153,7 +164,9 @@ jobs:
153164
- name: Get runner specifications
154165
run: lscpu | egrep 'Model name|Socket|Thread|NUMA|CPU\(s\)'
155166
- name: Build and check
156-
uses: ./.github/actions/build_and_check
167+
run: |
168+
if test -d venv; then . venv/bin/activate; fi
169+
bash maintainer/CI/build_cmake.sh
157170
env:
158171
build_procs: 4
159172
check_procs: 4
@@ -170,4 +183,6 @@ jobs:
170183
with_walberla: 'true'
171184
with_walberla_avx: 'false'
172185
with_stokesian_dynamics: 'true'
173-
cmake_params: '-D CMAKE_CXX_STANDARD=23 -D CMAKE_INCLUDE_PATH=/usr/include/mpich-x86_64 -D CMAKE_PREFIX_PATH=/usr/lib64/mpich/lib/ -D ESPRESSO_TEST_NT=1'
186+
check_skip_long: 'true'
187+
test_timeout: 800
188+
cmake_params: '-D CMAKE_CXX_STANDARD=26 -D CMAKE_INCLUDE_PATH=/usr/include/mpich-x86_64 -D CMAKE_PREFIX_PATH=/usr/lib64/mpich/lib/ -D ESPRESSO_TEST_NT=1'

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
image: ghcr.io/espressomd/docker/ubuntu:ab5bc64f5c3cc7330952f8b3bf321270ca53960c
1+
image: ghcr.io/espressomd/docker/ubuntu:c6ad9809eed1d0e9f26f4968559b234ea3b8bf82
22

33
stages:
44
- prepare
@@ -16,7 +16,7 @@ stages:
1616

1717
.notification_job_template: &notification_job_definition
1818
<<: *global_job_definition
19-
image: ghcr.io/espressomd/docker/alpine:ab5bc64f5c3cc7330952f8b3bf321270ca53960c
19+
image: ghcr.io/espressomd/docker/alpine:c6ad9809eed1d0e9f26f4968559b234ea3b8bf82
2020
variables:
2121
GET_SOURCES_ATTEMPTS: 3
2222
dependencies: []

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ if(ESPRESSO_BUILD_WITH_WALBERLA)
10351035
# cmake-format: off
10361036
FetchContent_Declare(
10371037
walberla
1038-
GIT_REPOSITORY https://i10git.cs.fau.de/walberla/walberla.git
1038+
GIT_REPOSITORY https://github.com/lssfau/walberla.git
10391039
GIT_TAG 3247aa73 # v7.2 with patches
10401040
)
10411041
# cmake-format: on
@@ -1108,7 +1108,7 @@ if(ESPRESSO_BUILD_WITH_CALIPER)
11081108
FetchContent_Declare(
11091109
caliper
11101110
GIT_REPOSITORY https://github.com/LLNL/Caliper.git
1111-
GIT_TAG v2.14.0
1111+
GIT_TAG v2.15.0
11121112
)
11131113
# cmake-format: on
11141114
set(CALIPER_OPTION_PREFIX on CACHE BOOL "")

src/script_interface/tests/AutoParameters_test.cpp

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

2323
#include "script_interface/auto_parameters/AutoParameters.hpp"
2424

25+
#include <algorithm>
26+
#include <string_view>
2527
#include <variant>
2628

2729
using ScriptInterface::AutoParameters;
@@ -34,13 +36,14 @@ struct A : AutoParameters<A> {
3436
};
3537

3638
BOOST_AUTO_TEST_CASE(basic) {
39+
using namespace std::literals;
3740
A a{0, 42};
3841

3942
auto const &parameters = a.valid_parameters();
4043

4144
BOOST_CHECK(parameters.size() == 2u);
42-
BOOST_CHECK(std::ranges::find(parameters, "i") != parameters.end());
43-
BOOST_CHECK(std::ranges::find(parameters, "j") != parameters.end());
45+
BOOST_CHECK(std::ranges::find(parameters, "i"sv) != parameters.end());
46+
BOOST_CHECK(std::ranges::find(parameters, "j"sv) != parameters.end());
4447

4548
BOOST_CHECK(0 == std::get<int>(a.get_parameter("i")));
4649
BOOST_CHECK(42 == std::get<int>(a.get_parameter("j")));

testsuite/python/caliper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_runtime_report(self):
7373
if not line.startswith("WARNING:"):
7474
lines = lines[i:]
7575
break
76-
header = "Path\tMin time/rank\tMax time/rank\tAvg time/rank\tTime %"
76+
header = "Path\tMin time/rank\tAvg time/rank\tMax time/rank\tTime %"
7777
self.assertEqual(lines[0].split(), header.split(),
7878
msg=f"Caliper summary should start with '{header}'")
7979
labels = [line[:36].rstrip() for line in lines[1:]]

testsuite/python/integrator_exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def test_temperature_change(self):
273273
self.system.thermostat.set_langevin(kT=1., gamma=1., seed=42)
274274
self.system.thermostat.set_langevin(kT=2., gamma=1., seed=42)
275275
self.system.thermostat.set_brownian(kT=2., gamma=1., seed=42)
276-
with self.assertRaisesRegex(RuntimeError, "Cannot set parameter 'kT' to 1.0*: there are currently active thermostats with kT=2.0*"):
276+
with self.assertRaisesRegex(RuntimeError, "Cannot set parameter 'kT' to 1[.0]*: there are currently active thermostats with kT=2[.0]*"):
277277
self.system.thermostat.set_brownian(kT=1., gamma=1., seed=42)
278278
with self.assertRaisesRegex(RuntimeError, f"Parameter 'kT' is read-only"):
279279
self.system.thermostat.kT = 2.

testsuite/python/lb.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def test_temperature_mismatch(self):
508508
self.system.thermostat.set_langevin(kT=2., seed=23, gamma=2.)
509509
lbf = self.lb_class(kT=1., seed=42, **self.params, **self.lb_params)
510510
self.system.lb = lbf
511-
with self.assertRaisesRegex(RuntimeError, "Cannot set parameter 'kT' to 1.0*: there are currently active thermostats with kT=2.0*"):
511+
with self.assertRaisesRegex(RuntimeError, r"Cannot set parameter 'kT' to (1[.0]*|0\.99[0-9]+): there are currently active thermostats with kT=(2[.0]*|1\.99[0-9]+)"):
512512
self.system.thermostat.set_lb(LB_fluid=lbf, seed=23, gamma=2.)
513513
self.assertFalse(self.system.thermostat.lb.is_active)
514514
self.assertTrue(self.system.thermostat.langevin.is_active)
@@ -869,9 +869,9 @@ def params_with_tau(tau):
869869
self.lb_class(**params_with_tau(self.system.time_step),
870870
**self.lb_params)
871871

872-
with self.assertRaisesRegex(ValueError, r"LB tau \(0\.0100[0-9]+\) must be >= MD time_step \(0\.0200[0-9]+\)"):
872+
with self.assertRaisesRegex(ValueError, r"LB tau \(0\.01(?:0*|00[0-9]+)\) must be >= MD time_step \(0\.02(?:0*|00[0-9]+)\)"):
873873
self.system.time_step = 2.0 * lbf.get_params()["tau"]
874-
with self.assertRaisesRegex(ValueError, r"LB tau \(0\.0100[0-9]+\) must be an integer multiple of the MD time_step \(0\.0080[0-9]+\)"):
874+
with self.assertRaisesRegex(ValueError, r"LB tau \(0\.01(?:0*|00[0-9]+)\) must be an integer multiple of the MD time_step \(0\.008(?:0*|0[0-9]+)\)"):
875875
self.system.time_step = 0.8 * lbf.get_params()["tau"]
876876

877877
self.system.lb = None

testsuite/python/reaction_methods_interface.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,15 +349,15 @@ def test_exceptions(self):
349349
with self.assertRaisesRegex(ValueError, "Invalid value for 'exclusion_range'"):
350350
espressomd.reaction_methods.ReactionEnsemble(
351351
kT=1., seed=12, exclusion_range=-1.)
352-
with self.assertRaisesRegex(ValueError, "Invalid excluded_radius value for type 1: radius -0.10"):
352+
with self.assertRaisesRegex(ValueError, r"Invalid excluded_radius value for type 1: radius -0\.1[0]*"):
353353
espressomd.reaction_methods.ReactionEnsemble(
354354
kT=1., seed=12, exclusion_range=1., exclusion_radius_per_type={1: -0.1})
355355
with self.assertRaisesRegex(ValueError, "Unknown search algorithm 'unknown'"):
356356
espressomd.reaction_methods.ReactionEnsemble(
357357
kT=1., seed=12, exclusion_range=1., search_algorithm="unknown")
358358
method = espressomd.reaction_methods.ReactionEnsemble(
359359
kT=1., exclusion_range=1., seed=12, exclusion_radius_per_type={1: 0.1})
360-
with self.assertRaisesRegex(ValueError, "Invalid excluded_radius value for type 2: radius -0.10"):
360+
with self.assertRaisesRegex(ValueError, r"Invalid excluded_radius value for type 2: radius -0\.1[0]*"):
361361
method.exclusion_radius_per_type = {2: -0.1}
362362
self.assertEqual(list(method.exclusion_radius_per_type.keys()), [1])
363363

0 commit comments

Comments
 (0)