Skip to content

Commit

Permalink
Coriolis: Split KE and KE[xy] loop kernels
Browse files Browse the repository at this point in the history
Previously the loops for KE and KE[xy] were in a single kernel.  This
seemed to work fine in double_gyre but crashed in benchmark.

Splitting the kernel seems to resolve this problem, although it also
seems slower.  This may need some extra work in the future.
  • Loading branch information
marshallward committed Feb 4, 2025
1 parent 0967476 commit b21dfb9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/core/MOM_CoriolisAdv.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,14 @@ subroutine gradKE(u, v, h, KE, KEx, KEy, k, OBC, G, GV, US, CS)
KE(i,j) = ( max(um2a,up2a) + max(vm2a,vp2a) )*0.5*G%IareaT(i,j)
enddo ; enddo
endif
!$omp end target
!
! This kernel needs to be split due to a dependency between KE and KE[xy].
! The compiler or the GPU does not appear to completing KE before starting
! the KE[xy] calculations. Maybe there's a better way to do this than
! splitting the kernel, but I don't know how.
!
!$omp target

! Term - d(KE)/dx.
!$omp parallel loop collapse(2)
Expand All @@ -1183,6 +1191,7 @@ subroutine gradKE(u, v, h, KE, KEx, KEy, k, OBC, G, GV, US, CS)
!$omp end target

if (associated(OBC)) then
!$omp target update from(KEx, KEy)
do n=1,OBC%number_of_segments
if (OBC%segment(n)%is_N_or_S) then
do i=OBC%segment(n)%HI%isd,OBC%segment(n)%HI%ied
Expand All @@ -1194,6 +1203,7 @@ subroutine gradKE(u, v, h, KE, KEx, KEy, k, OBC, G, GV, US, CS)
enddo
endif
enddo
!$omp target update to(KEx, KEy)
endif
end subroutine gradKE

Expand Down

0 comments on commit b21dfb9

Please sign in to comment.