Skip to content

Commit 2887494

Browse files
committed
GPU workarounds for OLCF Frontier
1 parent 54fcd74 commit 2887494

File tree

12 files changed

+89
-60
lines changed

12 files changed

+89
-60
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
133133
-fimplicit-none
134134
#-ffpe-trap=invalid,zero,denormal,overflow
135135
-fsignaling-nans
136+
-finit-real=snan
137+
-finit-integer=-99999999
136138
)
137139
endif()
138140

src/common/m_mpi_common.fpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ contains
236236
real(kind(0d0)), intent(out) :: ccfl_max_glb
237237
real(kind(0d0)), intent(out) :: Rc_min_glb
238238
239-
#ifdef MFC_MPI
240239
#ifdef MFC_SIMULATION
240+
#ifdef MFC_MPI
241241
242242
! Reducing local extrema of ICFL, VCFL, CCFL and Rc numbers to their
243243
! global extrema and bookkeeping the results on the rank 0 processor
@@ -254,6 +254,15 @@ contains
254254
MPI_COMM_WORLD, ierr)
255255
end if
256256
257+
#else
258+
259+
icfl_max_glb = icfl_max_loc
260+
261+
if (any(Re_size > 0)) then
262+
vcfl_max_glb = vcfl_max_loc
263+
Rc_min_glb = Rc_min_loc
264+
end if
265+
257266
#endif
258267
#endif
259268

src/common/m_phase_change.fpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,11 @@ contains
298298
!! @param rhoe mixture energy
299299
!! @param TS equilibrium temperature at the interface
300300
subroutine s_infinite_pt_relaxation_k(j, k, l, MFL, pS, p_infpT, rM, q_cons_vf, rhoe, TS)
301+
#ifdef CRAY_ACC_WAR
302+
!DIR$ INLINEALWAYS s_compute_speed_of_sound
303+
#else
301304
!$acc routine seq
305+
#endif
302306

303307
! initializing variables
304308
integer, intent(in) :: j, k, l, MFL
@@ -402,7 +406,11 @@ contains
402406
!! @param TS equilibrium temperature at the interface
403407
subroutine s_infinite_ptg_relaxation_k(j, k, l, pS, p_infpT, rhoe, q_cons_vf, TS)
404408

409+
#ifdef CRAY_ACC_WAR
410+
!DIR$ INLINEALWAYS s_infinite_ptg_relaxation_k
411+
#else
405412
!$acc routine seq
413+
#endif
406414

407415
integer, intent(in) :: j, k, l
408416
real(kind(0.0d0)), intent(inout) :: pS
@@ -522,7 +530,11 @@ contains
522530
!! @param k generic loop iterator for y direction
523531
!! @param l generic loop iterator for z direction
524532
subroutine s_correct_partial_densities(MCT, q_cons_vf, rM, j, k, l)
533+
#ifdef CRAY_ACC_WAR
534+
!DIR$ INLINEALWAYS s_correct_partial_densities
535+
#else
525536
!$acc routine seq
537+
#endif
526538
527539
!> @name variables for the correction of the reacting partial densities
528540
!> @{
@@ -580,7 +592,12 @@ contains
580592
!! @param q_cons_vf Cell-average conservative variables
581593
!! @param TJac Transpose of the Jacobian Matrix
582594
subroutine s_compute_jacobian_matrix(InvJac, j, Jac, k, l, mCPD, mCVGP, mCVGP2, pS, q_cons_vf, TJac)
595+
596+
#ifdef CRAY_ACC_WAR
597+
!DIR$ INLINEALWAYS s_compute_jacobian_matrix
598+
#else
583599
!$acc routine seq
600+
#endif
584601
585602
real(kind(0.0d0)), dimension(2, 2), intent(out) :: InvJac
586603
integer, intent(in) :: j
@@ -682,7 +699,12 @@ contains
682699
!! @param rhoe mixture energy
683700
!! @param R2D (2D) residue array
684701
subroutine s_compute_pTg_residue(j, k, l, mCPD, mCVGP, mQD, q_cons_vf, pS, rhoe, R2D)
702+
703+
#ifdef CRAY_ACC_WAR
704+
!DIR$ INLINEALWAYS s_compute_pTg_residue
705+
#else
685706
!$acc routine seq
707+
#endif
686708
687709
integer, intent(in) :: j, k, l
688710
real(kind(0.0d0)), intent(in) :: mCPD, mCVGP, mQD
@@ -728,7 +750,11 @@ contains
728750
!! @param TSat Saturation Temperature
729751
!! @param TSIn equilibrium Temperature
730752
subroutine s_TSat(pSat, TSat, TSIn)
753+
#ifdef CRAY_ACC_WAR
754+
!DIR$ INLINEALWAYS s_compute_speed_of_sound
755+
#else
731756
!$acc routine seq
757+
#endif
732758
733759
real(kind(0.0d0)), intent(in) :: pSat
734760
real(kind(0.0d0)), intent(out) :: TSat

src/common/m_variables_conversion.fpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ contains
126126
!! @param mom Momentum
127127
subroutine s_compute_pressure(energy, alf, dyn_p, pi_inf, gamma, rho, qv, rhoYks, pres, T, stress, mom, G)
128128

129+
#ifdef CRAY_ACC_WAR
130+
!DIR$ INLINEALWAYS s_compute_pressure
131+
#else
129132
!$acc routine seq
133+
#endif
130134

131135
real(kind(0d0)), intent(in) :: energy, alf
132136
real(kind(0d0)), intent(in) :: dyn_p
@@ -135,7 +139,6 @@ contains
135139
real(kind(0d0)), intent(in), optional :: stress, mom, G
136140

137141
! Chemistry
138-
integer :: i
139142
real(kind(0d0)), dimension(1:num_species), intent(in) :: rhoYks
140143
real(kind(0d0)) :: E_e
141144
real(kind(0d0)) :: e_Per_Kg, Pdyn_Per_Kg
@@ -182,11 +185,8 @@ contains
182185
end if
183186

184187
#:else
185-
!$acc loop seq
186-
do i = 1, num_species
187-
Y_rs(i) = rhoYks(i)/rho
188-
end do
189188

189+
Y_rs(:) = rhoYks(:)/rho
190190
e_Per_Kg = energy/rho
191191
Pdyn_Per_Kg = dyn_p/rho
192192

@@ -886,7 +886,9 @@ contains
886886
end if
887887
#:endif
888888

889-
!$acc parallel loop collapse(3) gang vector default(present) private(alpha_K, alpha_rho_K, Re_K, nRtmp, rho_K, gamma_K, pi_inf_K, qv_K, dyn_pres_K, R3tmp, rhoyks)
889+
!$acc parallel loop collapse(3) gang vector default(present) &
890+
!$acc private(alpha_K, alpha_rho_K, Re_K, nRtmp, rho_K, gamma_K, &
891+
!$acc pi_inf_K, qv_K, dyn_pres_K, R3tmp, rhoYks)
890892
do l = ibounds(3)%beg, ibounds(3)%end
891893
do k = ibounds(2)%beg, ibounds(2)%end
892894
do j = ibounds(1)%beg, ibounds(1)%end
@@ -927,7 +929,6 @@ contains
927929
rho_K = 0d0
928930
!$acc loop seq
929931
do i = chemxb, chemxe
930-
!print*, j,k,l, qK_cons_vf(i)%sf(j, k, l)
931932
rho_K = rho_K + max(0d0, qK_cons_vf(i)%sf(j, k, l))
932933
end do
933934

@@ -936,16 +937,9 @@ contains
936937
qK_prim_vf(i)%sf(j, k, l) = rho_K
937938
end do
938939

939-
Yksum = 0d0
940940
!$acc loop seq
941941
do i = chemxb, chemxe
942942
qK_prim_vf(i)%sf(j, k, l) = max(0d0, qK_cons_vf(i)%sf(j, k, l)/rho_K)
943-
Yksum = Yksum + qK_prim_vf(i)%sf(j, k, l)
944-
end do
945-
946-
!$acc loop seq
947-
do i = chemxb, chemxe
948-
qK_prim_vf(i)%sf(j, k, l) = qK_prim_vf(i)%sf(j, k, l)/Yksum
949943
end do
950944

951945
qK_prim_vf(tempxb)%sf(j, k, l) = qK_cons_vf(tempxb)%sf(j, k, l)

src/simulation/m_chemistry.fpp

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,16 @@ contains
6363
if (num_dims == ${num_dims}$) then
6464
!$acc parallel loop collapse(4) gang vector default(present) &
6565
!$acc private(flux_x, flux_y, flux_z)
66-
do x = 0, m
67-
do y = 0, n
68-
do z = 0, p
66+
do z = idwint(3)%beg, idwint(3)%end
67+
do y = idwint(2)%beg, idwint(2)%end
68+
do x = idwint(1)%beg, idwint(1)%end
6969
do eqn = chemxb, chemxe
7070
! \nabla \cdot (F)
7171
flux_x = (flux_n(1)%vf(eqn)%sf(x - 1, y, z) - &
7272
flux_n(1)%vf(eqn)%sf(x, y, z))/dx(x)
7373

7474
#:if num_dims >= 2
75-
flux_x = (flux_n(2)%vf(eqn)%sf(x, y - 1, z) - &
75+
flux_y = (flux_n(2)%vf(eqn)%sf(x, y - 1, z) - &
7676
flux_n(2)%vf(eqn)%sf(x, y, z))/dy(y)
7777
#:else
7878
flux_y = 0d0
@@ -87,6 +87,8 @@ contains
8787

8888
rhs_vf(eqn)%sf(x, y, z) = flux_x + flux_y + flux_z
8989
end do
90+
91+
rhs_vf(tempxb)%sf(x, y, z) = 0d0
9092
end do
9193
end do
9294
end do
@@ -112,38 +114,27 @@ contains
112114
real(kind(0d0)) :: rho, omega_m
113115
real(kind(0d0)), dimension(num_species) :: Ys
114116
real(kind(0d0)), dimension(num_species) :: omega
115-
real(kind(0d0)), dimension(num_species) :: enthalpies
116117
real(kind(0d0)) :: cp_mix
117118

118119
#:if chemistry
119120

120-
!$acc parallel loop collapse(3) private(Ys)
121-
do x = 0, m
122-
do y = 0, n
123-
do z = 0, p
124-
125-
rho = 0d0
126-
do eqn = chemxb, chemxe
127-
rho = rho + q_cons_qp(eqn)%sf(x, y, z)
128-
end do
121+
!$acc parallel loop collapse(3) gang vector default(present) &
122+
!$acc private(Ys, omega)
123+
do z = idwint(3)%beg, idwint(3)%end
124+
do y = idwint(2)%beg, idwint(2)%end
125+
do x = idwint(1)%beg, idwint(1)%end
129126

127+
!$acc loop seq
130128
do eqn = chemxb, chemxe
131129
Ys(eqn - chemxb + 1) = q_prim_qp(eqn)%sf(x, y, z)
132130
end do
133131

134-
dyn_pres = 0d0
135-
!$acc loop seq
136-
do i = momxb, momxe
137-
dyn_pres = dyn_pres + q_cons_qp(i)%sf(x, y, z)* &
138-
q_prim_qp(i)%sf(x, y, z)/2d0
139-
end do
140-
141-
call get_temperature(q_cons_qp(E_idx)%sf(x, y, z)/rho - dyn_pres/rho, &
142-
& 1200d0, Ys, .true., T)
132+
rho = q_cons_qp(contxe)%sf(x, y, z)
133+
T = q_prim_qp(tempxb)%sf(x, y, z)
143134

144135
call get_net_production_rates(rho, T, Ys, omega)
145136

146-
!$acc routine seq
137+
!$acc loop seq
147138
do eqn = chemxb, chemxe
148139

149140
omega_m = mol_weights(eqn - chemxb + 1)*omega(eqn - chemxb + 1)

src/simulation/m_data_output.fpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -348,16 +348,13 @@ contains
348348
call s_mpi_abort('ICFL is greater than 1.0. Exiting ...')
349349
end if
350350

351-
do i = chemxb, chemxe
352-
!@:ASSERT(all(q_prim_vf(i)%sf(:,:,:) >= -1d0), "bad conc")
353-
!@:ASSERT(all(q_prim_vf(i)%sf(:,:,:) <= 2d0), "bad conc")
354-
end do
355-
356-
if (vcfl_max_glb /= vcfl_max_glb) then
357-
call s_mpi_abort('VCFL is NaN. Exiting ...')
358-
elseif (vcfl_max_glb > 1d0) then
359-
print *, 'vcfl', vcfl_max_glb
360-
call s_mpi_abort('VCFL is greater than 1.0. Exiting ...')
351+
if (any(Re_size > 0)) then
352+
if (vcfl_max_glb /= vcfl_max_glb) then
353+
call s_mpi_abort('VCFL is NaN. Exiting ...')
354+
elseif (vcfl_max_glb > 1d0) then
355+
print *, 'vcfl', vcfl_max_glb
356+
call s_mpi_abort('VCFL is greater than 1.0. Exiting ...')
357+
end if
361358
end if
362359
end if
363360

@@ -510,7 +507,7 @@ contains
510507
if (.not. file_exist) call s_create_directory(trim(t_step_dir))
511508

512509
if (prim_vars_wrt .or. (n == 0 .and. p == 0)) then
513-
call s_convert_conservative_to_primitive_variables(q_cons_vf, q_prim_vf, idwbuff)
510+
call s_convert_conservative_to_primitive_variables(q_cons_vf, q_prim_vf, idwint)
514511
do i = 1, sys_size
515512
!$acc update host(q_prim_vf(i)%sf(:,:,:))
516513
end do

src/simulation/m_global_parameters.fpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ module m_global_parameters
164164
logical, parameter :: chemistry = .${chemistry}$. !< Chemistry modeling
165165
logical :: cu_tensor
166166

167+
!$acc declare create(chemistry)
168+
167169
logical :: bodyForces
168170
logical :: bf_x, bf_y, bf_z !< body force toggle in three directions
169171
!< amplitude, frequency, and phase shift sinusoid in each direction

src/simulation/m_rhs.fpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -958,15 +958,15 @@ contains
958958
call nvtxEndRange
959959
! END: Additional physics and source terms =========================
960960

961-
#:if chemistry
962-
call nvtxStartRange("RHS_Chem_Advection")
963-
call s_compute_chemistry_advection_flux(flux_n, rhs_vf)
964-
call nvtxEndRange
965-
#:endif
966-
967961
end do
968962
! END: Dimensional Splitting Loop =================================
969963

964+
#:if chemistry
965+
call nvtxStartRange("RHS_Chem_Advection")
966+
call s_compute_chemistry_advection_flux(flux_n, rhs_vf)
967+
call nvtxEndRange
968+
#:endif
969+
970970
if (ib) then
971971
!$acc parallel loop collapse(3) gang vector default(present)
972972
do l = 0, p

src/simulation/m_riemann_solvers.fpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,11 @@ contains
363363
#:for NORM_DIR, XYZ in [(1, 'x'), (2, 'y'), (3, 'z')]
364364

365365
if (norm_dir == ${NORM_DIR}$) then
366-
!$acc parallel loop collapse(3) gang vector default(present) private(alpha_rho_L, alpha_rho_R, vel_L, vel_R, alpha_L, alpha_R, vel_avg, tau_e_L, tau_e_R, G_L, G_R, Re_L, Re_R, &
367-
!$acc rho_avg, h_avg, gamma_avg, s_L, s_R, s_S, Y_L, Ys_L, Y_R, Ys_R)
366+
!$acc parallel loop collapse(3) gang vector default(present) &
367+
!$acc private(alpha_rho_L, alpha_rho_R, vel_L, vel_R, alpha_L, &
368+
!$acc alpha_R, vel_avg, tau_e_L, tau_e_R, G_L, G_R, Re_L, Re_R, &
369+
!$acc rho_avg, h_avg, gamma_avg, s_L, s_R, s_S, Y_L, Ys_L, Y_R, &
370+
!$acc Ys_R)
368371
do l = is3%beg, is3%end
369372
do k = is2%beg, is2%end
370373
do j = is1%beg, is1%end

src/simulation/m_sim_helpers.f90

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ module m_sim_helpers
3131
!! @param k y index
3232
!! @param l z index
3333
subroutine s_compute_enthalpy(q_prim_vf, pres, rho, gamma, pi_inf, Re, H, alpha, vel, vel_sum, j, k, l)
34+
#ifdef CRAY_ACC_WAR
35+
!DIR$ INLINEALWAYS s_compute_enthalpy
36+
#else
3437
!$acc routine seq
38+
#endif
39+
3540
type(scalar_field), dimension(sys_size) :: q_prim_vf
3641
real(kind(0d0)), dimension(num_fluids) :: alpha_rho
3742
real(kind(0d0)), dimension(num_fluids) :: alpha

0 commit comments

Comments
 (0)