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 executing mpas_atm_get_bdy_tend on GPUs #1277

Open
wants to merge 1 commit 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
42 changes: 37 additions & 5 deletions src/core_atmosphere/dynamics/mpas_atm_boundaries.F
Original file line number Diff line number Diff line change
Expand Up @@ -300,25 +300,57 @@ function mpas_atm_get_bdy_tend(clock, block, vertDim, horizDim, field, delta_t)
real (kind=RKIND), dimension(vertDim,horizDim+1) :: return_tend

type (mpas_pool_type), pointer :: lbc
integer, pointer :: idx
integer, pointer :: idx_ptr
real (kind=RKIND), dimension(:,:), pointer :: tend
real (kind=RKIND), dimension(:,:,:), pointer :: tend_scalars
integer :: ierr
integer :: idx, i, j


call mpas_pool_get_subpool(block % structs, 'lbc', lbc)

nullify(tend)
call mpas_pool_get_array(lbc, 'lbc_'//trim(field), tend, 1)

MPAS_ACC_TIMER_START('mpas_atm_get_bdy_tend [ACC_data_xfer]')
!$acc enter data create(return_tend)
if (associated(tend)) then
return_tend(:,:) = tend(:,:)
!$acc enter data copyin(tend)
else
call mpas_pool_get_array(lbc, 'lbc_scalars', tend_scalars, 1)
call mpas_pool_get_dimension(lbc, 'index_'//trim(field), idx)
!$acc enter data copyin(tend_scalars)

! Ensure the integer pointed to by idx_ptr is copied to the gpu device
call mpas_pool_get_dimension(lbc, 'index_'//trim(field), idx_ptr)
idx = idx_ptr
end if
MPAS_ACC_TIMER_STOP('mpas_atm_get_bdy_tend [ACC_data_xfer]')

return_tend(:,:) = tend_scalars(idx,:,:)
!$acc parallel default(present)
if (associated(tend)) then
!$acc loop gang vector collapse(2)
do j=1,horizDim+1
do i=1,vertDim
return_tend(i,j) = tend(i,j)
end do
end do
else
!$acc loop gang vector collapse(2)
do j=1,horizDim+1
do i=1,vertDim
return_tend(i,j) = tend_scalars(idx,i,j)
end do
end do
end if
!$acc end parallel

MPAS_ACC_TIMER_START('mpas_atm_get_bdy_tend [ACC_data_xfer]')
!$acc exit data copyout(return_tend)
if (associated(tend)) then
!$acc exit data delete(tend)
else
!$acc exit data delete(tend_scalars)
end if
MPAS_ACC_TIMER_STOP('mpas_atm_get_bdy_tend [ACC_data_xfer]')

end function mpas_atm_get_bdy_tend

Expand Down