Skip to content

Commit

Permalink
GPU workarounds for OLCF Frontier
Browse files Browse the repository at this point in the history
  • Loading branch information
henryleberre committed Nov 2, 2024
1 parent 907bf65 commit d58ff09
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 6 deletions.
26 changes: 26 additions & 0 deletions src/common/m_phase_change.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,11 @@ contains
!! @param rhoe mixture energy
!! @param TS equilibrium temperature at the interface
subroutine s_infinite_pt_relaxation_k(j, k, l, MFL, pS, p_infpT, rM, q_cons_vf, rhoe, TS)
#ifdef CRAY_ACC_WAR
!DIR$ INLINEALWAYS s_compute_speed_of_sound
#else
!$acc routine seq
#endif

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

#ifdef CRAY_ACC_WAR
!DIR$ INLINEALWAYS s_infinite_ptg_relaxation_k
#else
!$acc routine seq
#endif

integer, intent(in) :: j, k, l
real(kind(0.0d0)), intent(inout) :: pS
Expand Down Expand Up @@ -522,7 +530,11 @@ contains
!! @param k generic loop iterator for y direction
!! @param l generic loop iterator for z direction
subroutine s_correct_partial_densities(MCT, q_cons_vf, rM, j, k, l)
#ifdef CRAY_ACC_WAR
!DIR$ INLINEALWAYS s_correct_partial_densities
#else
!$acc routine seq
#endif
!> @name variables for the correction of the reacting partial densities
!> @{
Expand Down Expand Up @@ -580,7 +592,12 @@ contains
!! @param q_cons_vf Cell-average conservative variables
!! @param TJac Transpose of the Jacobian Matrix
subroutine s_compute_jacobian_matrix(InvJac, j, Jac, k, l, mCPD, mCVGP, mCVGP2, pS, q_cons_vf, TJac)
#ifdef CRAY_ACC_WAR
!DIR$ INLINEALWAYS s_compute_jacobian_matrix
#else
!$acc routine seq
#endif
real(kind(0.0d0)), dimension(2, 2), intent(out) :: InvJac
integer, intent(in) :: j
Expand Down Expand Up @@ -682,7 +699,12 @@ contains
!! @param rhoe mixture energy
!! @param R2D (2D) residue array
subroutine s_compute_pTg_residue(j, k, l, mCPD, mCVGP, mQD, q_cons_vf, pS, rhoe, R2D)
#ifdef CRAY_ACC_WAR
!DIR$ INLINEALWAYS s_compute_pTg_residue
#else
!$acc routine seq
#endif
integer, intent(in) :: j, k, l
real(kind(0.0d0)), intent(in) :: mCPD, mCVGP, mQD
Expand Down Expand Up @@ -728,7 +750,11 @@ contains
!! @param TSat Saturation Temperature
!! @param TSIn equilibrium Temperature
subroutine s_TSat(pSat, TSat, TSIn)
#ifdef CRAY_ACC_WAR
!DIR$ INLINEALWAYS s_compute_speed_of_sound
#else
!$acc routine seq
#endif
real(kind(0.0d0)), intent(in) :: pSat
real(kind(0.0d0)), intent(out) :: TSat
Expand Down
7 changes: 5 additions & 2 deletions src/simulation/m_chemistry.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,19 @@ contains

#:if chemistry

!$acc parallel loop collapse(3) private(Ys)
!$acc parallel loop collapse(3) gang vector default(present) &
!$acc private(Ys, omega, enthalpies)
do x = 0, m
do y = 0, n
do z = 0, p

rho = 0d0
!$acc loop seq
do eqn = chemxb, chemxe
rho = rho + q_cons_qp(eqn)%sf(x, y, z)
end do

!$acc loop seq
do eqn = chemxb, chemxe
Ys(eqn - chemxb + 1) = q_prim_qp(eqn)%sf(x, y, z)
end do
Expand All @@ -96,7 +99,7 @@ contains

call get_net_production_rates(rho, T, Ys, omega)

!$acc routine seq
!$acc loop seq
do eqn = chemxb, chemxe

omega_m = mol_weights(eqn - chemxb + 1)*omega(eqn - chemxb + 1)
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/m_rhs.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ contains
call s_compute_chemistry_reaction_flux(rhs_vf, q_cons_qp%vf, q_prim_qp%vf)
call nvtxEndRange
else
!$acc parallel loop default(present)
!$acc parallel loop gang vector default(present)
do i = chemxb, chemxe
rhs_vf(i)%sf(:, :, :) = 0d0
end do
Expand Down
7 changes: 5 additions & 2 deletions src/simulation/m_riemann_solvers.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,11 @@ contains
#:for NORM_DIR, XYZ in [(1, 'x'), (2, 'y'), (3, 'z')]

if (norm_dir == ${NORM_DIR}$) then
!$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, &
!$acc rho_avg, h_avg, gamma_avg, s_L, s_R, s_S, Y_L, Ys_L, Y_R, Ys_R)
!$acc parallel loop collapse(3) gang vector default(present) &
!$acc private(alpha_rho_L, alpha_rho_R, vel_L, vel_R, alpha_L, &
!$acc alpha_R, vel_avg, tau_e_L, tau_e_R, G_L, G_R, Re_L, Re_R, &
!$acc rho_avg, h_avg, gamma_avg, s_L, s_R, s_S, Y_L, Ys_L, Y_R, &
!$acc Ys_R)
do l = is3%beg, is3%end
do k = is2%beg, is2%end
do j = is1%beg, is1%end
Expand Down
5 changes: 5 additions & 0 deletions src/simulation/m_sim_helpers.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ module m_sim_helpers
!! @param k y index
!! @param l z index
subroutine s_compute_enthalpy(q_prim_vf, pres, rho, gamma, pi_inf, Re, H, alpha, vel, vel_sum, j, k, l)
#ifdef CRAY_ACC_WAR
!DIR$ INLINEALWAYS s_compute_enthalpy
#else
!$acc routine seq
#endif

type(scalar_field), dimension(sys_size) :: q_prim_vf
real(kind(0d0)), dimension(num_fluids) :: alpha_rho
real(kind(0d0)), dimension(num_fluids) :: alpha
Expand Down
2 changes: 1 addition & 1 deletion toolchain/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ dependencies = [
]

[tool.hatch.metadata]
allow-direct-references = true
allow-direct-references = true

0 comments on commit d58ff09

Please sign in to comment.