Replies: 5 comments 11 replies
-
|
The issue is a very large, doubly-nested loop over tracer species (?) and vertical levels. This loop contains many, separate doubly nested ! 'dia_ptr_hst' is not available on the 'default' accelerator device, and therefore it cannot be called from within an OMP
!& Target region. Use the 'device_string' option to specify a different device.
do jn = 1, kjpt, 1
! 'dia_ptr_hst' is not available on the 'default' accelerator device, and therefore it cannot be called from within an OMP
!& Target region. Use the 'device_string' option to specify a different device.
do jk = 1, jpkm1, 1
!$omp target
!$omp teams loop collapse(2) default(shared) private(ji,jj)
do jj = loop_start_5, loop_stop_5, 1
do ji = loop_start_6, loop_stop_6, 1
zdxt(ji,jj) = (pt(ji + 1,jj,jk,jn,kbb) - pt(ji,jj,jk,jn,kbb)) * umask(ji,jj,jk)
zdyt(ji,jj) = (pt(ji,jj + 1,jk,jn,kbb) - pt(ji,jj,jk,jn,kbb)) * vmask(ji,jj,jk)
enddo
enddo
...
enddo
enddo
!$omp end teams loop
!$omp end target
if (l_ptr) then
call dia_ptr_hst(jn, 'adv', zwy(:,:))
end if
if (l_hst) then
call dia_ar5_hst(jn, 'adv', zwx(:,:), zwy(:,:), ldfin=jk == jpkm1)
end if
enddo
!$omp target
!$omp teams loop collapse(2) default(shared) private(idx_5,idx_6)
do idx_5 = loop_start_13, loop_stop_13, 1
...
subroutine dia_ptr_hst_2d(ktra, cptr, pvflx)
integer, intent(in) :: ktra
CHARACTER(LEN = 3), INTENT(IN) :: cptr
real(kind=wp), dimension(:,:), intent(in) :: pvflx
call dia_ptr_hst_t(ktra, cptr, pvflx2d=pvflx(:,:), ktvflx=lbnd_ij(pvflx))
end subroutine dia_ptr_hst_2dand subroutine dia_ptr_hst_t(ktra, cptr, pvflx2d, pvflx3d, ktvflx)
integer, dimension(2), intent(in) :: ktvflx
integer, intent(in) :: ktra
CHARACTER(LEN = 3), INTENT(IN) :: cptr
REAL(KIND = wp), DIMENSION(ktvflx(1) :, ktvflx(2) :), INTENT(IN), OPTIONAL :: pvflx2d
REAL(KIND = wp), DIMENSION(ktvflx(1) :, ktvflx(2) :, :), INTENT(IN), OPTIONAL :: pvflx3d
real(kind=wp), dimension(ntsj - 0:ntej + 0,nbasin) :: zsj
integer :: jn
if (PRESENT(pvflx2d)) then
do jn = 1, nbasin, 1
zsj(:,jn) = ptr_sj(pvflx2d(:,:), btmsk(:,:,jn))
enddo
else
if (PRESENT(pvflx3d)) then
do jn = 1, nbasin, 1
zsj(:,jn) = ptr_sj(pvflx3d(:,:,:), btmsk(:,:,jn))
enddo
end if
end if
if (cptr == 'adv') then
if (ktra == jp_tem) then
call ptr_sum(hstr_all(:,:,jp_tem,1), zsj(:,:))
end if
if (ktra == jp_sal) then
call ptr_sum(hstr_all(:,:,jp_sal,1), zsj(:,:))
end if
...and subroutine ptr_sum_2d(phstr, pva)
real(kind=wp), dimension(njs0 - 0:nje0 + 0,nbasin), intent(inout) :: phstr
real(kind=wp), dimension(ntsj - 0:ntej + 0,nbasin), intent(in) :: pva
...
loop_stop = ntej + 0
loop_start = ntsj - 0
!$omp target
!$omp teams loop collapse(2) default(shared) private(jj,jn)
do jn = 1, nbasin, 1
do jj = loop_start, loop_stop, 1
phstr(jj,jn) = phstr(jj,jn) + pva(jj,jn)
enddo
enddo
!$omp end teams loop
!$omp end target
end subroutine ptr_sum_2d
function ptr_sj_2d(pvflx, pmsk) result(p_fval)
real(kind=wp), dimension(:,:), intent(in) :: pvflx
real(kind=wp), dimension(nis0 - nn_hls:nie0 + nn_hls,njs0 - nn_hls:nje0 + nn_hls), intent(in) :: pmsk
real(kind=wp), dimension(ntsj - 0:ntej + 0) :: p_fval
call ptr_sj_2d_t(pvflx(:,:), lbnd_ij(pvflx), pmsk(:,:), p_fval(:))
end function ptr_sj_2d
subroutine ptr_sj_2d_t(pvflx, ktvflx, pmsk, p_fval)
integer, dimension(2), intent(in) :: ktvflx
real(kind=wp), dimension(ktvflx(1):,ktvflx(2):), intent(in) :: pvflx
real(kind=wp), dimension(nis0 - nn_hls:nie0 + nn_hls,njs0 - nn_hls:nje0 + nn_hls), intent(in) :: pmsk
real(kind=wp), dimension(ntsj - 0:ntej + 0), intent(out) :: p_fval
...
loop_stop = UBOUND(p_fval, dim=1)
loop_start = LBOUND(p_fval, dim=1)
!$omp target
!$omp teams loop collapse(1) default(shared) private(idx)
do idx = loop_start, loop_stop, 1
p_fval(idx) = 0._wp
enddo
!$omp end teams loop
!$omp end target
loop_stop_1 = ntej + 0
loop_start_1 = ntsj - 0
loop_stop_2 = ntei + 0
loop_start_2 = ntsi - 0
!$omp target
!$omp teams loop collapse(1) default(shared) private(ji,jj)
do jj = loop_start_1, loop_stop_1, 1
! Error: The write access to 'p_fval(jj)' in 'p_fval(jj) = p_fval(jj) + pvflx(ji,jj) * pmsk(ji,jj) * tmask_i(ji,jj)' and the
!& read access to 'p_fval(jj)' in 'p_fval(jj) = p_fval(jj) + pvflx(ji,jj) * pmsk(ji,jj) * tmask_i(ji,jj)' are dependent and cannot
!& be parallelised. Variable: 'p_fval'. Consider using the "ignore_dependencies_for" transformation option if this is a false
!& dependency.
do ji = loop_start_2, loop_stop_2, 1
p_fval(jj) = p_fval(jj) + pvflx(ji,jj) * pmsk(ji,jj) * tmask_i(ji,jj)
enddo
enddo
!$omp end teams loop
!$omp end target
end subroutine ptr_sj_2d_t |
Beta Was this translation helpful? Give feedback.
-
|
Inlining does look feasible but the problem is that it needs to be done recursively as the routines in |
Beta Was this translation helpful? Give feedback.
-
|
Regarding |
Beta Was this translation helpful? Give feedback.
-
|
@francescamele I've made a branch with an example of how to remove subroutine calls: !$omp target
!$omp teams loop collapse(1) default(shared) private(idx_5,idx_6,idx_7,idx_8,ik,ji,jj,jk,jn,loop_start_19,loop_start_20,loop_start_21,loop_start_22,loop_start_23,loop_start_24,loop_start_25,loop_start_26,loop_stop_19,loop_stop_20,loop_stop_21,loop_stop_22,loop_stop_23,loop_stop_24,loop_stop_25,loop_stop_26,z0u,z0v,z0w,zalpha,zdxt,zdyt,zdzt_kp2,zfw_kp1,zslpx,zslpy,zslpz_kp1,zu,zv,zw,zwx,zwy,zzslpx,zzslpy,zzwx,zzwy)
do jn = 1, kjpt, 1
! Loop cannot be collapsed because it has siblings
do jk = 1, jpkm1, 1
do jj = loop_start_5, loop_stop_5, 1
do ji = loop_start_6, loop_stop_6, 1which is better than before but still not good because it has parallelised only the outer loop over |
Beta Was this translation helpful? Give feedback.
-
|
@francescamele I think what would be really helpful for us is if you could do some manual experiments with this particular subroutine to see what works best. Some ideas:
I'm not sure what we can do about the last k loop with the loop-carried dependence. Can we alter it so that the k loop is innermost and have that run by just a single thread? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The MUSCL scheme is used in the MED24 configuration and is currently a massive performance bottleneck. This discussion is to analyse the code and see what can be done.
Beta Was this translation helpful? Give feedback.
All reactions