Skip to content

Commit 41a73ae

Browse files
committed
Size host callers of fixed-bound routines with BOUND
In GPU simulation builds BOUND('num_fluids') is 3, but three host paths still passed num_fluids-sized arrays to routines with BOUND dummies: s_convert_species_to_mixture_variables (its alpha_K/alpha_rho_K locals and the forwarded G), s_report_icfl_violation, and s_write_probe_files. With one or two fluids and mpp_lim, the kernel's whole-array normalization of alpha_K wrote past the end of the host local. Declare those with BOUND (every G caller passes fluid_pp(:)%G, sized num_fluids_max), and normalize only alpha_K(1:num_fluids). Also: fix the generated-file count in contributing.md (21, not 18), and tell users to rebuild with --case-optimization when sys_size exceeds the GPU maximum.
1 parent fa18783 commit 41a73ae

4 files changed

Lines changed: 51 additions & 51 deletions

File tree

‎docs/documentation/contributing.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ mode, debug, chemistry, MPI. Staging and install trees are namespaced by slug u
101101
`add_custom_command` per `.fpp` file to run Fypp at build time. `cmake/ParamsCodegen.cmake`
102102
registers a single ninja-tracked `add_custom_command` (DEPENDS all `params/*.py`) that
103103
invokes `cmake_gen.py` and writes the 21 generated includes under
104-
`build/include/<target>/`. There is no configure-time generation: all 18 files are build
104+
`build/include/<target>/`. There is no configure-time generation: all 21 files are build
105105
outputs, so changing any `params/*.py` triggers only a targeted rebuild, not a full
106106
reconfigure.
107107

‎src/common/m_variables_conversion.fpp‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ contains
5353
!! procedure pointer.
5454
subroutine s_convert_to_mixture_variables(q_vf, i, j, k, rho, gamma, pi_inf, qv, Re_K, G_K, G)
5555

56-
type(scalar_field), dimension(sys_size), intent(in) :: q_vf
57-
integer, intent(in) :: i, j, k
58-
real(wp), intent(out), target :: rho, gamma, pi_inf, qv
59-
real(wp), optional, dimension(2), intent(out) :: Re_K
60-
real(wp), optional, intent(out) :: G_K
61-
real(wp), optional, dimension(num_fluids), intent(in) :: G
56+
type(scalar_field), dimension(sys_size), intent(in) :: q_vf
57+
integer, intent(in) :: i, j, k
58+
real(wp), intent(out), target :: rho, gamma, pi_inf, qv
59+
real(wp), optional, dimension(2), intent(out) :: Re_K
60+
real(wp), optional, intent(out) :: G_K
61+
real(wp), optional, dimension(${BOUND('num_fluids')}$), intent(in) :: G
6262

6363
if (model_eqns == model_eqns_gamma_law) then ! Gamma/pi_inf model
6464
call s_convert_mixture_to_mixture_variables(q_vf, i, j, k, rho, gamma, pi_inf, qv)
@@ -153,17 +153,17 @@ contains
153153
!! stores the results into rho, gamma and pi_inf.
154154
subroutine s_convert_species_to_mixture_variables(q_vf, k, l, r, rho, gamma, pi_inf, qv, Re_K, G_K, G)
155155

156-
type(scalar_field), dimension(sys_size), intent(in) :: q_vf
157-
integer, intent(in) :: k, l, r
158-
real(wp), intent(out), target :: rho
159-
real(wp), intent(out), target :: gamma
160-
real(wp), intent(out), target :: pi_inf
161-
real(wp), intent(out), target :: qv
162-
real(wp), optional, dimension(2), intent(out) :: Re_K
163-
real(wp), optional, intent(out) :: G_K
164-
real(wp), dimension(num_fluids) :: alpha_rho_K, alpha_K
165-
real(wp), optional, dimension(num_fluids), intent(in) :: G
166-
integer :: i, j !< Generic loop iterator
156+
type(scalar_field), dimension(sys_size), intent(in) :: q_vf
157+
integer, intent(in) :: k, l, r
158+
real(wp), intent(out), target :: rho
159+
real(wp), intent(out), target :: gamma
160+
real(wp), intent(out), target :: pi_inf
161+
real(wp), intent(out), target :: qv
162+
real(wp), optional, dimension(2), intent(out) :: Re_K
163+
real(wp), optional, intent(out) :: G_K
164+
real(wp), dimension(${BOUND('num_fluids')}$) :: alpha_rho_K, alpha_K
165+
real(wp), optional, dimension(${BOUND('num_fluids')}$), intent(in) :: G
166+
integer :: i, j !< Generic loop iterator
167167
! Computing the density, the specific heat ratio function and the liquid stiffness function, respectively
168168

169169
call s_compute_species_fraction(q_vf, k, l, r, alpha_rho_K, alpha_K)
@@ -209,7 +209,7 @@ contains
209209
alpha_K(i) = min(max(0._wp, alpha_K(i)), 1._wp)
210210
alpha_K_sum = alpha_K_sum + alpha_K(i)
211211
end do
212-
alpha_K = alpha_K/max(alpha_K_sum, sgm_eps)
212+
alpha_K(1:num_fluids) = alpha_K(1:num_fluids)/max(alpha_K_sum, sgm_eps)
213213
end if
214214
call s_compute_mixture_coefficients(alpha_rho_K, alpha_K, rho_K, gamma_K, pi_inf_K, qv_K)
215215

‎src/simulation/m_data_output.fpp‎

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ contains
347347
impure subroutine s_report_icfl_violation(q_prim_vf)
348348

349349
type(scalar_field), dimension(sys_size), intent(in) :: q_prim_vf
350-
real(wp), dimension(num_fluids) :: alpha, alpha_rho
350+
real(wp), dimension(${BOUND('num_fluids')}$) :: alpha, alpha_rho
351351
real(wp), dimension(num_vels) :: vel, vel_hit
352352
real(wp), dimension(2) :: Re
353353
real(wp) :: rho, vel_sum, pres, gamma, pi_inf, qv, c
@@ -1435,36 +1435,36 @@ contains
14351435
14361436
! The cell-averaged partial densities, density, velocity, pressure, volume fractions, specific heat ratio function, liquid
14371437
! stiffness function, and sound speed.
1438-
real(wp) :: lit_gamma, nbub
1439-
real(wp) :: rho
1440-
real(wp), dimension(num_vels) :: vel
1441-
real(wp) :: pres
1442-
real(wp) :: ptilde
1443-
real(wp) :: ptot
1444-
real(wp) :: alf
1445-
real(wp) :: alfgr
1446-
real(wp), dimension(num_fluids) :: alpha, alpha_rho
1447-
real(wp) :: gamma
1448-
real(wp) :: pi_inf
1449-
real(wp) :: qv
1450-
real(wp) :: c
1451-
real(wp) :: M00, M10, M01, M20, M02
1452-
real(wp) :: varR, varV
1453-
real(wp), dimension(Nb) :: nR, R, nRdot, Rdot
1454-
real(wp) :: nR3
1455-
real(wp) :: accel
1456-
real(wp) :: int_pres
1457-
real(wp) :: max_pres
1458-
real(wp), dimension(2) :: Re
1459-
real(wp), dimension(6) :: tau_e
1460-
real(wp) :: G_undamaged, G_damaged
1461-
real(wp) :: dyn_p, T
1462-
real(wp) :: damage_state
1463-
real(wp) :: solid_partial_density !< damageable-solid partial density at the probe cell
1464-
integer :: i, j, k, l, s, d !< Generic loop iterator
1465-
real(wp) :: nondim_time !< Non-dimensional time
1466-
real(wp) :: tmp !< Temporary variable to store quantity for mpi_allreduce
1467-
real(wp) :: rhoYks(1:num_species)
1438+
real(wp) :: lit_gamma, nbub
1439+
real(wp) :: rho
1440+
real(wp), dimension(num_vels) :: vel
1441+
real(wp) :: pres
1442+
real(wp) :: ptilde
1443+
real(wp) :: ptot
1444+
real(wp) :: alf
1445+
real(wp) :: alfgr
1446+
real(wp), dimension(${BOUND('num_fluids')}$) :: alpha, alpha_rho
1447+
real(wp) :: gamma
1448+
real(wp) :: pi_inf
1449+
real(wp) :: qv
1450+
real(wp) :: c
1451+
real(wp) :: M00, M10, M01, M20, M02
1452+
real(wp) :: varR, varV
1453+
real(wp), dimension(Nb) :: nR, R, nRdot, Rdot
1454+
real(wp) :: nR3
1455+
real(wp) :: accel
1456+
real(wp) :: int_pres
1457+
real(wp) :: max_pres
1458+
real(wp), dimension(2) :: Re
1459+
real(wp), dimension(6) :: tau_e
1460+
real(wp) :: G_undamaged, G_damaged
1461+
real(wp) :: dyn_p, T
1462+
real(wp) :: damage_state
1463+
real(wp) :: solid_partial_density !< damageable-solid partial density at the probe cell
1464+
integer :: i, j, k, l, s, d !< Generic loop iterator
1465+
real(wp) :: nondim_time !< Non-dimensional time
1466+
real(wp) :: tmp !< Temporary variable to store quantity for mpi_allreduce
1467+
real(wp) :: rhoYks(1:num_species)
14681468
14691469
T = dflt_T_guess
14701470

‎src/simulation/m_start_up.fpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ contains
832832
@:PROHIBIT(hypoelasticity .and. eqn_idx%stress%end - eqn_idx%stress%beg + 1 /= ${CASE_OPT_SIZES['n_stress']}$, &
833833
& "stress count differs from the case-optimized build; rebuild it")
834834
#:elif MFC_FIXED_BOUNDS
835-
@:PROHIBIT(sys_size > ${SYS_SIZE_MAX}$, "sys_size <= ${SYS_SIZE_MAX}$ in GPU builds")
835+
@:PROHIBIT(sys_size > ${SYS_SIZE_MAX}$, "sys_size <= ${SYS_SIZE_MAX}$ in GPU builds; rebuild with --case-optimization")
836836
#:endif
837837
if (bubbles_euler .or. bubbles_lagrange) then
838838
call s_initialize_bubbles_model()

0 commit comments

Comments
 (0)