Skip to content

Commit efa6579

Browse files
authored
start of support for C++20 (#1876)
1 parent e210832 commit efa6579

File tree

24 files changed

+297
-356
lines changed

24 files changed

+297
-356
lines changed

.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Checks: >
2121
-misc-use-internal-linkage,
2222
modernize-*,
2323
-modernize-avoid-c-arrays,
24+
-modernize-use-designated-initializers,
2425
-modernize-use-trailing-return-type,
2526
performance-*,
2627
-performance-avoid-endl,

.github/workflows/castro-development.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
export MICROPHYSICS_HOME=${PWD}
4848
4949
cd Castro/Exec/science/flame_wave/
50-
make -j 4 CCACHE=ccache USE_MPI=FALSE
50+
make -j 4 CXXSTD=c++20 CCACHE=ccache USE_MPI=FALSE
5151
5252
ccache -s
5353
du -hs ~/.cache/ccache
@@ -64,7 +64,7 @@ jobs:
6464
export MICROPHYSICS_HOME=${PWD}
6565
6666
cd Castro/Exec/science/subchandra/
67-
make -j 4 CCACHE=ccache USE_MPI=FALSE NETWORK_DIR=he-burn/he-burn-19am
67+
make -j 4 CXXSTD=c++20 CCACHE=ccache USE_MPI=FALSE NETWORK_DIR=he-burn/he-burn-19am
6868
6969
ccache -s
7070
du -hs ~/.cache/ccache

.github/workflows/castro.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
export MICROPHYSICS_HOME=${PWD}
5252
5353
cd Castro/Exec/science/flame_wave/
54-
make -j 4 CCACHE=ccache USE_MPI=FALSE
54+
make -j 4 CXXSTD=c++20 CCACHE=ccache USE_MPI=FALSE
5555
5656
ccache -s
5757
du -hs ~/.cache/ccache
@@ -68,7 +68,7 @@ jobs:
6868
export MICROPHYSICS_HOME=${PWD}
6969
7070
cd Castro/Exec/science/subchandra/
71-
make -j 4 CCACHE=ccache USE_MPI=FALSE NETWORK_DIR=he-burn/he-burn-19am
71+
make -j 4 CXXSTD=c++20 CCACHE=ccache USE_MPI=FALSE NETWORK_DIR=he-burn/he-burn-19am
7272
7373
ccache -s
7474
du -hs ~/.cache/ccache

.github/workflows/cuda.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ concurrency:
88

99
jobs:
1010
cuda-compile:
11-
name: CUDA@11.7 GCC
11+
name: CUDA@12.9 GCC
1212
runs-on: ubuntu-22.04
1313
steps:
1414
- uses: actions/checkout@v6
@@ -26,7 +26,7 @@ jobs:
2626
cd ../..
2727
2828
- name: Dependencies
29-
run: .github/workflows/dependencies/dependencies_nvcc.sh 11.7
29+
run: .github/workflows/dependencies/dependencies_nvcc.sh 12.9
3030

3131
- name: compile test_react (aprox13)
3232
run: |

Docs/source/getting_started.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Microphysics requires
1414

1515
optional dependencies are:
1616

17-
* CUDA (≥ 11)
17+
* CUDA (≥ 12)
1818
* ROCm (≥ 6.3.1 --- earlier versions have register allocation bugs)
1919

2020
Usage Modes

EOS/breakout/actual_eos.H

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ void actual_eos (I input, T& state)
6767
// dens, temp and xmass are inputs
6868
amrex::Real cv = R / (state.mu * (gamma_const - 1.0_rt));
6969
amrex::Real e = cv * state.T;
70-
if constexpr (has_energy<T>::value) {
70+
if constexpr (has_energy<T>) {
7171
state.cv = cv;
7272
state.e = e;
7373
}
74-
if constexpr (has_pressure<T>::value) {
74+
if constexpr (has_pressure<T>) {
7575
state.p = (gamma_const - 1.0_rt) * state.rho * e;
7676
}
77-
if constexpr (has_pressure<T>::value && has_energy<T>::value) {
77+
if constexpr (has_pressure<T> && has_energy<T>) {
7878
state.gam1 = gamma_const;
7979
}
8080

@@ -102,10 +102,10 @@ void actual_eos (I input, T& state)
102102
{
103103
// dens, pres, and xmass are inputs
104104

105-
if constexpr (has_pressure<T>::value) {
105+
if constexpr (has_pressure<T>) {
106106
amrex::Real poverrho = state.p / state.rho;
107107
state.T = poverrho * state.mu * (1.0_rt / R);
108-
if constexpr (has_energy<T>::value) {
108+
if constexpr (has_energy<T>) {
109109
state.e = poverrho * (1.0_rt / (gamma_const - 1.0_rt));
110110
state.gam1 = gamma_const;
111111
}
@@ -117,11 +117,11 @@ void actual_eos (I input, T& state)
117117
{
118118
// dens, energy, and xmass are inputs
119119

120-
if constexpr (has_energy<T>::value) {
120+
if constexpr (has_energy<T>) {
121121
amrex::Real poverrho = (gamma_const - 1.0_rt) * state.e;
122122
state.T = poverrho * state.mu * (1.0_rt / R);
123123

124-
if constexpr (has_pressure<T>::value) {
124+
if constexpr (has_pressure<T>) {
125125
state.p = poverrho * state.rho;
126126
state.gam1 = gamma_const;
127127

@@ -135,7 +135,7 @@ void actual_eos (I input, T& state)
135135

136136
// Try to avoid the expensive log function. Since we don't need entropy
137137
// in hydro solver, set it to an invalid but "nice" value for the plotfile.
138-
if constexpr (has_entropy<T>::value) {
138+
if constexpr (has_entropy<T>) {
139139
state.s = 1.0_rt;
140140
}
141141

EOS/eos_composition.H

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ eos_xderivs_t composition_derivatives (const T& state)
8585
eos_xderivs_t state_xderivs;
8686

8787
for (int n = 0; n < NumSpec; n++) {
88-
if constexpr (has_dpdA<T>::value && has_dpdZ<T>::value) {
88+
if constexpr (has_dpdA<T> && has_dpdZ<T>) {
8989
state_xderivs.dpdX[n] =
9090
state.dpdA * (state.abar * aion_inv[n]) * (aion[n] - state.abar) +
9191
state.dpdZ * (state.abar * aion_inv[n]) * (zion[n] - state.zbar);
@@ -94,7 +94,7 @@ eos_xderivs_t composition_derivatives (const T& state)
9494
state_xderivs.dpdX[n] = 0.0_rt;
9595
}
9696

97-
if constexpr (has_dedA<T>::value && has_dedZ<T>::value) {
97+
if constexpr (has_dedA<T> && has_dedZ<T>) {
9898
state_xderivs.dedX[n] =
9999
state.dedA * (state.abar * aion_inv[n]) * (aion[n] - state.abar) +
100100
state.dedZ * (state.abar * aion_inv[n]) * (zion[n] - state.zbar);
@@ -103,7 +103,7 @@ eos_xderivs_t composition_derivatives (const T& state)
103103
state_xderivs.dedX[n] = 0.0_rt;
104104
}
105105

106-
if constexpr (has_pressure<T>::value) {
106+
if constexpr (has_pressure<T>) {
107107
if (state.dpdr != 0.0) {
108108

109109
state_xderivs.dhdX[n] = state_xderivs.dedX[n]

EOS/gamma_law/actual_eos.H

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void actual_eos (I input, T& state)
5454
// Get the mass of a nucleon from m_u.
5555
const amrex::Real m_nucleon = C::m_u;
5656

57-
if constexpr (has_xn<T>::value) {
57+
if constexpr (has_xn<T>) {
5858
if (eos_rp::eos_assume_neutral) {
5959
state.mu = state.abar;
6060
} else {
@@ -86,7 +86,7 @@ void actual_eos (I input, T& state)
8686
// Solve for the temperature:
8787
// h = e + p/rho = (p/rho)*[1 + 1/(gamma-1)] = (p/rho)*gamma/(gamma-1)
8888

89-
if constexpr (has_enthalpy<T>::value) {
89+
if constexpr (has_enthalpy<T>) {
9090
state.T = (state.h * state.mu * m_nucleon / C::k_B)*(eos_rp::eos_gamma - 1.0)/eos_rp::eos_gamma;
9191
}
9292

@@ -99,7 +99,7 @@ void actual_eos (I input, T& state)
9999
// Solve for the density:
100100
// p = rho k T / (mu m_nucleon)
101101

102-
if constexpr (has_pressure<T>::value) {
102+
if constexpr (has_pressure<T>) {
103103
state.rho = state.p * state.mu * m_nucleon / (C::k_B * state.T);
104104
}
105105

@@ -112,7 +112,7 @@ void actual_eos (I input, T& state)
112112
// Solve for the temperature:
113113
// p = rho k T / (mu m_nucleon)
114114

115-
if constexpr (has_pressure<T>::value) {
115+
if constexpr (has_pressure<T>) {
116116
state.T = state.p * state.mu * m_nucleon / (C::k_B * state.rho);
117117
}
118118

@@ -125,7 +125,7 @@ void actual_eos (I input, T& state)
125125
// Solve for the temperature
126126
// e = k T / [(mu m_nucleon)*(gamma-1)]
127127

128-
if constexpr (has_energy<T>::value) {
128+
if constexpr (has_energy<T>) {
129129
state.T = state.e * state.mu * m_nucleon * (eos_rp::eos_gamma - 1.0) / C::k_B;
130130
}
131131

@@ -139,7 +139,7 @@ void actual_eos (I input, T& state)
139139
// Invert Sackur-Tetrode eqn (below) using
140140
// rho = p mu m_nucleon / (k T)
141141

142-
if constexpr (has_pressure<T>::value && has_entropy<T>::value) {
142+
if constexpr (has_pressure<T> && has_entropy<T>) {
143143
state.T = std::pow(state.p, 2.0/5.0) *
144144
std::pow(2.0 * M_PI * C::hbar * C::hbar / (state.mu * m_nucleon), 3.0/5.0) *
145145
std::exp(2.0 * state.mu * m_nucleon * state.s / (5.0 * C::k_B) - 1.0) / C::k_B;
@@ -148,7 +148,7 @@ void actual_eos (I input, T& state)
148148
// Solve for the density
149149
// rho = p mu m_nucleon / (k T)
150150

151-
if constexpr (has_pressure<T>::value) {
151+
if constexpr (has_pressure<T>) {
152152
state.rho = state.p * state.mu * m_nucleon / (C::k_B * state.T);
153153
}
154154

@@ -160,7 +160,7 @@ void actual_eos (I input, T& state)
160160

161161
// Solve for temperature and density
162162

163-
if constexpr (has_pressure<T>::value && has_enthalpy<T>::value) {
163+
if constexpr (has_pressure<T> && has_enthalpy<T>) {
164164
state.rho = state.p / state.h * eos_rp::eos_gamma / (eos_rp::eos_gamma - 1.0);
165165
state.T = state.p * state.mu * m_nucleon / (C::k_B * state.rho);
166166
}
@@ -199,21 +199,21 @@ void actual_eos (I input, T& state)
199199
// specific internal energy using the gamma-law EOS relation.
200200
amrex::Real pressure = state.rho * state.T * C::k_B / (state.mu * m_nucleon);
201201
amrex::Real energy = pressure / (eos_rp::eos_gamma - 1.0) * rhoinv;
202-
if constexpr (has_pressure<T>::value) {
202+
if constexpr (has_pressure<T>) {
203203
state.p = pressure;
204204
}
205-
if constexpr (has_energy<T>::value) {
205+
if constexpr (has_energy<T>) {
206206
state.e = energy;
207207
}
208208

209209
// enthalpy is h = e + p/rho
210-
if constexpr (has_enthalpy<T>::value) {
210+
if constexpr (has_enthalpy<T>) {
211211
state.h = energy + pressure * rhoinv;
212212
}
213213

214214
// entropy (per gram) of an ideal monoatomic gas (the Sackur-Tetrode equation)
215215
// NOTE: this expression is only valid for gamma = 5/3.
216-
if constexpr (has_entropy<T>::value) {
216+
if constexpr (has_entropy<T>) {
217217
const amrex::Real fac = 1.0 / std::pow(2.0 * M_PI * C::hbar * C::hbar, 1.5);
218218

219219
state.s = (C::k_B / (state.mu * m_nucleon)) *
@@ -222,39 +222,39 @@ void actual_eos (I input, T& state)
222222
}
223223

224224
// Compute the thermodynamic derivatives and specific heats
225-
if constexpr (has_pressure<T>::value) {
225+
if constexpr (has_pressure<T>) {
226226
state.dpdT = state.p * Tinv;
227227
state.dpdr = state.p * rhoinv;
228228
}
229-
if constexpr (has_energy<T>::value) {
229+
if constexpr (has_energy<T>) {
230230
state.dedT = state.e * Tinv;
231231
state.dedr = 0.0;
232232
}
233-
if constexpr (has_entropy<T>::value) {
233+
if constexpr (has_entropy<T>) {
234234
state.dsdT = 1.5 * (C::k_B / (state.mu * m_nucleon)) * Tinv;
235235
state.dsdr = - (C::k_B / (state.mu * m_nucleon)) * rhoinv;
236236
}
237-
if constexpr (has_enthalpy<T>::value) {
237+
if constexpr (has_enthalpy<T>) {
238238
state.dhdT = state.dedT + state.dpdT * rhoinv;
239239
state.dhdr = 0.0;
240240
}
241241

242-
if constexpr (has_xne_xnp<T>::value) {
242+
if constexpr (has_xne_xnp<T>) {
243243
state.xne = 0.0;
244244
state.xnp = 0.0;
245245
}
246-
if constexpr (has_eta<T>::value) {
246+
if constexpr (has_eta<T>) {
247247
state.eta = 0.0;
248248
}
249-
if constexpr (has_pele_ppos<T>::value) {
249+
if constexpr (has_pele_ppos<T>) {
250250
state.pele = 0.0;
251251
state.ppos = 0.0;
252252
}
253253

254-
if constexpr (has_energy<T>::value) {
254+
if constexpr (has_energy<T>) {
255255
state.cv = state.dedT;
256256

257-
if constexpr (has_pressure<T>::value) {
257+
if constexpr (has_pressure<T>) {
258258
state.cp = eos_rp::eos_gamma * state.cv;
259259

260260
state.gam1 = eos_rp::eos_gamma;
@@ -264,31 +264,31 @@ void actual_eos (I input, T& state)
264264

265265
// sound speed
266266
state.cs = std::sqrt(eos_rp::eos_gamma * state.p * rhoinv);
267-
if constexpr (has_G<T>::value) {
267+
if constexpr (has_G<T>) {
268268
state.G = 0.5 * (1.0 + eos_rp::eos_gamma);
269269
}
270270
}
271271
}
272272

273-
if constexpr (has_dpdA<T>::value) {
273+
if constexpr (has_dpdA<T>) {
274274
state.dpdA = - state.p * (1.0 / state.abar);
275275
}
276-
if constexpr (has_dedA<T>::value) {
276+
if constexpr (has_dedA<T>) {
277277
state.dedA = - state.e * (1.0 / state.abar);
278278
}
279279

280280
if (eos_rp::eos_assume_neutral) {
281-
if constexpr (has_dpdZ<T>::value) {
281+
if constexpr (has_dpdZ<T>) {
282282
state.dpdZ = 0.0;
283283
}
284-
if constexpr (has_dedZ<T>::value) {
284+
if constexpr (has_dedZ<T>) {
285285
state.dedZ = 0.0;
286286
}
287287
} else {
288-
if constexpr (has_dpdZ<T>::value) {
288+
if constexpr (has_dpdZ<T>) {
289289
state.dpdZ = state.p * (1.0 / (1.0 + state.zbar));
290290
}
291-
if constexpr (has_dedZ<T>::value) {
291+
if constexpr (has_dedZ<T>) {
292292
state.dedZ = state.e * (1.0/(1.0 + state.zbar));
293293
}
294294
}

0 commit comments

Comments
 (0)