Skip to content

Commit

Permalink
make u/qpassmap constexpr (#2681)
Browse files Browse the repository at this point in the history
this will allow for some unrolling in the future
  • Loading branch information
zingale authored Dec 22, 2023
1 parent daa8721 commit 3095255
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions Source/driver/Castro_util.H
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ constexpr int dg2 = 1;
#endif

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
int upassmap (int ipassive)
constexpr int upassmap (int ipassive)
{
if (ipassive < NumAdv) {
// passive is one of the advected quantities
Expand All @@ -40,7 +40,7 @@ int upassmap (int ipassive)
}

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
int qpassmap (int ipassive)
constexpr int qpassmap (int ipassive)
{
if (ipassive < NumAdv) {
// passive is one of the advected quantities
Expand Down
4 changes: 2 additions & 2 deletions Source/hydro/advection_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,8 @@ Castro::do_enforce_minimum_density(const Box& bx,
#endif

for (int ipassive = 0; ipassive < npassive; ipassive++) {
int n = upassmap(ipassive);
state_arr(i,j,k,n) *= (small_dens / state_arr(i,j,k,URHO));
const int n = upassmap(ipassive);
state_arr(i,j,k,n) *= (small_dens / state_arr(i,j,k,URHO));
}

eos_re_t eos_state;
Expand Down
22 changes: 11 additions & 11 deletions Source/hydro/riemann.H
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,11 @@ cons_state(const Real* qstate, Real* U) {
U[UMUP] = 0.0;
U[UMUN] = 0.0;
#endif

for (int ipassive = 0; ipassive < npassive; ipassive++) {
int n = upassmap(ipassive);
int nqs = qpassmap(ipassive);
U[n] = qstate[QRHO]*qstate[nqs];
const int n = upassmap(ipassive);
const int nqs = qpassmap(ipassive);
U[n] = qstate[QRHO]*qstate[nqs];
}
}

Expand Down Expand Up @@ -459,11 +459,11 @@ HLLC_state(const int idir, const Real S_k, const Real S_c,
U[UMUP] = 0.0;
U[UMUN] = 0.0;
#endif

for (int ipassive = 0; ipassive < npassive; ipassive++) {
int n = upassmap(ipassive);
int nqs = qpassmap(ipassive);
U[n] = hllc_factor*qstate[nqs];
const int n = upassmap(ipassive);
const int nqs = qpassmap(ipassive);
U[n] = hllc_factor*qstate[nqs];
}
}

Expand Down Expand Up @@ -508,10 +508,10 @@ compute_flux(const int idir, const Real bnd_fac, const int coord,
F[UMUP] = 0.0;
F[UMUN] = 0.0;
#endif

for (int ipassive=0; ipassive < npassive; ipassive++) {
int n = upassmap(ipassive);
F[n] = U[n]*u_flx;
const int n = upassmap(ipassive);
F[n] = U[n]*u_flx;
}
}

Expand Down
10 changes: 5 additions & 5 deletions Source/hydro/riemann_solvers.H
Original file line number Diff line number Diff line change
Expand Up @@ -969,13 +969,13 @@ HLL(const Real* ql, const Real* qr,

// passively-advected scalar fluxes
for (int ipassive = 0; ipassive < npassive; ipassive++) {
int n = upassmap(ipassive);
int nqs = qpassmap(ipassive);
const int n = upassmap(ipassive);
const int nqs = qpassmap(ipassive);

fl_tmp = ql[QRHO]*ql[nqs]*ql[ivel];
fr_tmp = qr[QRHO]*qr[nqs]*qr[ivel];
fl_tmp = ql[QRHO]*ql[nqs]*ql[ivel];
fr_tmp = qr[QRHO]*qr[nqs]*qr[ivel];

flux_hll[n] = (bp*fl_tmp - bm*fr_tmp)*bd + bp*bm*bd*(qr[QRHO]*qr[nqs] - ql[QRHO]*ql[nqs]);
flux_hll[n] = (bp*fl_tmp - bm*fr_tmp)*bd + bp*bm*bd*(qr[QRHO]*qr[nqs] - ql[QRHO]*ql[nqs]);
}
}

Expand Down
4 changes: 2 additions & 2 deletions Source/hydro/trace_plm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ Castro::trace_plm(const Box& bx, const int idir,
#endif

for (int ipassive = 0; ipassive < npassive; ipassive++) {
int nc = upassmap(ipassive);
int n = qpassmap(ipassive);
const int nc = upassmap(ipassive);
const int n = qpassmap(ipassive);

// get the slope

Expand Down
4 changes: 2 additions & 2 deletions Source/hydro/trace_ppm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,8 @@ Castro::trace_ppm(const Box& bx,

for (int ipassive = 0; ipassive < npassive; ipassive++) {

int nc = upassmap(ipassive);
int n = qpassmap(ipassive);
const int nc = upassmap(ipassive);
const int n = qpassmap(ipassive);

load_passive_stencil(U_arr, rho_inv_arr, idir, i, j, k, nc, s);
ppm_reconstruct(s, flat, sm, sp);
Expand Down
8 changes: 4 additions & 4 deletions Source/hydro/trans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ Castro::actual_trans_single(const Box& bx,
const Real volinv = 1.0_rt / vol(il,jl,kl);
#endif
for (int ipassive = 0; ipassive < npassive; ipassive++) {
int n = upassmap(ipassive);
int nqp = qpassmap(ipassive);
const int n = upassmap(ipassive);
const int nqp = qpassmap(ipassive);

#if AMREX_SPACEDIM == 2
Real rrnew = q_arr(i,j,k,QRHO) - hdt * (area_t(ir,jr,kr) * flux_t(ir,jr,kr,URHO) -
Expand Down Expand Up @@ -629,8 +629,8 @@ Castro::actual_trans_final(const Box& bx,
// transverse terms and convert back to the primitive quantity.

for (int ipassive = 0; ipassive < npassive; ++ipassive) {
int n = upassmap(ipassive);
int nqp = qpassmap(ipassive);
const int n = upassmap(ipassive);
const int nqp = qpassmap(ipassive);

Real rrn = q_arr(i,j,k,QRHO);
Real compn = rrn * q_arr(i,j,k,nqp);
Expand Down
4 changes: 2 additions & 2 deletions Source/radiation/trace_ppm_rad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ Castro::trace_ppm_rad(const Box& bx,

for (int ipassive = 0; ipassive < npassive; ++ipassive) {

int n = qpassmap(ipassive);
int nc = upassmap(ipassive);
const int n = qpassmap(ipassive);
const int nc = upassmap(ipassive);

load_passive_stencil(U_arr, rho_inv_arr, idir, i, j, k, nc, s);
ppm_reconstruct(s, flat, sm, sp);
Expand Down

0 comments on commit 3095255

Please sign in to comment.