diff --git a/src/ZSOLVER/tensorproductmultigrid_Source/mode_openacc_set_device.f90 b/src/MNH/mode_openacc_set_device.f90 similarity index 100% rename from src/ZSOLVER/tensorproductmultigrid_Source/mode_openacc_set_device.f90 rename to src/MNH/mode_openacc_set_device.f90 diff --git a/src/MNH/tools.f90 b/src/MNH/tools.f90 index 3db90c5a7c81080cad9a155384dc5526e595a055..41929a0c19623f4969a6fdef10de336db2affd08 100644 --- a/src/MNH/tools.f90 +++ b/src/MNH/tools.f90 @@ -21,6 +21,7 @@ module mode_tools ! P. Wautelet 28/05/2019: move COUNTJV function to tools.f90 ! P. Wautelet 05/06/2019: add Countjv_device ! P. Wautelet 20/06/2019: add Countjv1d, Countjv1d_device and Countjv2d_device subroutines +! J. Escobar 25/08/2021: nvhpc21.X bug on 'atomic' in host -> switch to version without atomic on HOST implicit none @@ -108,6 +109,7 @@ end function Countjv3d #ifdef MNH_OPENACC subroutine Countjv1d_device(ltab, i1,ic) use mode_mppdb, only: mppdb_initialized + use MODE_OPENACC_SET_DEVICE, only : mnh_idevice_type_current, acc_device_nvidia logical, dimension(:), intent(in) :: ltab ! Mask integer, dimension(:), intent(out) :: i1 ! Positions of elements with 'true' value @@ -118,7 +120,7 @@ subroutine Countjv1d_device(ltab, i1,ic) !$acc data present( ltab, i1 ) -if ( .not. mppdb_initialized ) then +if ( (.not. mppdb_initialized ) .and. (mnh_idevice_type_current .eq. acc_device_nvidia ) ) then ic = 0 @@ -151,7 +153,7 @@ ic = 0 !$acc kernels !To allow comparisons... (i1 is not fully used) - i1(:) = -999 +!!$ i1(:) = -999 do ji = 1, size( ltab, 1 ) if ( ltab(ji ) ) then @@ -171,6 +173,7 @@ end subroutine Countjv1d_device subroutine Countjv2d_device(ltab, i1, i2, ic) use mode_mppdb, only: mppdb_initialized + use MODE_OPENACC_SET_DEVICE, only : mnh_idevice_type_current, acc_device_nvidia logical, dimension(:,:), intent(in) :: ltab ! Mask integer, dimension(:), intent(out) :: i1, i2 ! Positions of elements with 'true' value @@ -181,7 +184,7 @@ subroutine Countjv2d_device(ltab, i1, i2, ic) !$acc data present( ltab, i1, i2 ) -if ( .not. mppdb_initialized ) then +if ( (.not. mppdb_initialized ) .and. (mnh_idevice_type_current .eq. acc_device_nvidia ) ) then ic = 0 @@ -192,8 +195,6 @@ ic = 0 ! i1(:) = -999 ! i2(:) = -999 - - !Warning: if "independent" is set, content of i1, i2 and i3 can vary between 2 ! different runs of this subroutine BUT final result should be the same !Comment the following line + atomic directives to have consistent values for debugging @@ -244,6 +245,7 @@ end subroutine Countjv2d_device subroutine Countjv3d_device(ltab, i1, i2, i3, ic) use mode_mppdb, only: mppdb_initialized + use MODE_OPENACC_SET_DEVICE, only : mnh_idevice_type_current, acc_device_nvidia logical, dimension(:,:,:), intent(in) :: ltab ! Mask integer, dimension(:), intent(out) :: i1, i2, i3 ! Positions of elements with 'true' value @@ -254,7 +256,7 @@ subroutine Countjv3d_device(ltab, i1, i2, i3, ic) !$acc data present( ltab, i1, i2, i3 ) -if ( .not. mppdb_initialized ) then +if ( (.not. mppdb_initialized ) .and. (mnh_idevice_type_current .eq. acc_device_nvidia ) ) then ic = 0 @@ -266,8 +268,6 @@ ic = 0 ! i2(:) = -999 ! i3(:) = -999 - - !Warning: if "independent" is set, content of i1, i2 and i3 can vary between 2 ! different runs of this subroutine BUT final result should be the same !Comment the following line + atomic directives to have consistent values for debugging @@ -297,9 +297,9 @@ ic = 0 !$acc kernels !To allow comparisons... (i1/i2/i3 are not fully used) - i1(:) = -999 - i2(:) = -999 - i3(:) = -999 +!!$ i1(:) = -999 +!!$ i2(:) = -999 +!!$ i3(:) = -999 do jk = 1, size( ltab, 3 ) do jj = 1, size( ltab, 2 )