Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable GPU execution of atm_compute_vert_imp_coefs via OpenACC #1241

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/core_atmosphere/dynamics/mpas_atm_time_integration.F
Original file line number Diff line number Diff line change
Expand Up @@ -1894,32 +1894,46 @@ subroutine atm_compute_vert_imp_coefs_work(nCells, moist_start, moist_end, dts,
real (kind=RKIND) :: dtseps, c2, qtotal, rcv
real (kind=RKIND), dimension( nVertLevels ) :: b_tri, c_tri

MPAS_ACC_TIMER_START('atm_compute_vert_imp_coefs_work [ACC_data_xfer]')
!$acc enter data copyin(rdzw, zz, fzm, fzp, rdzu, cqw, p, t, qtot, rb, &
!$acc rtb, rt, pb)
!$acc enter data create(cofrz, cofwr, cofwz, coftz, cofwt, a_tri, b_tri, &
!$acc c_tri, alpha_tri, gamma_tri)
MPAS_ACC_TIMER_STOP('atm_compute_vert_imp_coefs_work [ACC_data_xfer]')

! set coefficients
dtseps = .5*dts*(1.+epssm)
rcv = rgas/(cp-rgas)
c2 = cp*rcv

!$acc parallel
!$acc loop
! MGD bad to have all threads setting this variable?
do k=1,nVertLevels
cofrz(k) = dtseps*rdzw(k)
end do

!$acc end parallel

!$acc parallel
!$acc loop gang worker private(b_tri,c_tri)
do iCell = cellSolveStart,cellSolveEnd ! we only need to do cells we are solving for, not halo cells

!DIR$ IVDEP
!$acc loop
do k=2,nVertLevels
cofwr(k,iCell) =.5*dtseps*gravity*(fzm(k)*zz(k,iCell)+fzp(k)*zz(k-1,iCell))
end do
coftz(1,iCell) = 0.0
!DIR$ IVDEP
!$acc loop
do k=2,nVertLevels
cofwz(k,iCell) = dtseps*c2*(fzm(k)*zz(k,iCell)+fzp(k)*zz(k-1,iCell)) &
*rdzu(k)*cqw(k,iCell)*(fzm(k)*p (k,iCell)+fzp(k)*p (k-1,iCell))
coftz(k,iCell) = dtseps* (fzm(k)*t (k,iCell)+fzp(k)*t (k-1,iCell))
end do
coftz(nVertLevels+1,iCell) = 0.0
!DIR$ IVDEP
!$acc loop
do k=1,nVertLevels

! qtotal = 0.
Expand All @@ -1940,6 +1954,7 @@ subroutine atm_compute_vert_imp_coefs_work(nCells, moist_start, moist_end, dts,
alpha_tri(1,iCell) = 0. ! note, this value is never used

!DIR$ IVDEP
!$acc loop vector
do k=2,nVertLevels
a_tri(k,iCell) = -cofwz(k ,iCell)* coftz(k-1,iCell)*rdzw(k-1)*zz(k-1,iCell) &
+cofwr(k ,iCell)* cofrz(k-1 ) &
Expand All @@ -1955,12 +1970,18 @@ subroutine atm_compute_vert_imp_coefs_work(nCells, moist_start, moist_end, dts,
+cofwt(k ,iCell)* coftz(k+1,iCell)*rdzw(k )
end do
!MGD VECTOR DEPENDENCE
!$acc loop seq
do k=2,nVertLevels
alpha_tri(k,iCell) = 1./(b_tri(k)-a_tri(k,iCell)*gamma_tri(k-1,iCell))
gamma_tri(k,iCell) = c_tri(k)*alpha_tri(k,iCell)
end do

end do ! loop over cells
!$acc end parallel

!$acc exit data copyout(cofrz, cofwr, cofwz, coftz, cofwt, a_tri, b_tri, &
!$acc c_tri, alpha_tri, gamma_tri)
!$acc exit data delete(rdzw, zz, fzm, fzp, rdzu, cqw, p, t, qtot, rb, rtb, rt, pb)

end subroutine atm_compute_vert_imp_coefs_work

Expand Down