diff --git a/src/tests/field/fctest_field_wrap_gpu.F90 b/src/tests/field/fctest_field_wrap_gpu.F90 index 4d4669366..cae7006be 100644 --- a/src/tests/field/fctest_field_wrap_gpu.F90 +++ b/src/tests/field/fctest_field_wrap_gpu.F90 @@ -37,6 +37,51 @@ module fcta_Field_wrap_device_fixture ! ----------------------------------------------------------------------------- +subroutine kernel_1(view, N) + real(c_double) :: view(:,:,:) + integer, intent(in) :: N + !$acc data present(view) + !$acc parallel loop + do j=1,N + view(1,1,j) = real(j, c_double) + view(2,1,j) = -3_c_double + enddo + !$acc end data +end subroutine kernel_1 + + +subroutine kernel_2(view, Ni, Nj, Nl) + real(c_double) :: view(:,:,:) + integer, intent(in) :: Ni, Nj, Nl + !$acc data deviceptr(view) + !$acc parallel loop + do i = 1, Ni + do j = 1, Nj + do l = 1, Nl + view(i,j,l) = -view(i,j,l) + enddo + enddo + enddo + !$acc end data +end subroutine kernel_2 + + +subroutine kernel_3(view, Ni, Nj, Nk) + logical :: view(:,:,:) + integer, intent(in) :: Ni, Nj, Nk + !$acc data present(view) + !$acc parallel loop + do i=1,Ni + do j=1,Nj + do k=1,Nk + view(i,j,k) = (mod(k,3) == 0 ) + enddo + enddo + enddo + !$acc end data +end subroutine kernel_3 + + TEST( test_field_wrapdata ) implicit none @@ -60,13 +105,7 @@ module fcta_Field_wrap_device_fixture call field%allocate_device() call field%update_device() - !$acc data present(fview) - !$acc parallel loop - do j=1,N - fview(1,1,j) = real(j, c_double) - fview(2,1,j) = -3_c_double - enddo - !$acc end data + call kernel_1(fview, N) j = N/2 FCTEST_CHECK_EQUAL( existing_data(1,1,j), -2._c_double ) @@ -112,16 +151,7 @@ module fcta_Field_wrap_device_fixture call field%update_device() call field%device_data(fview) - !$acc data deviceptr(fview) - !$acc parallel loop - do i = 1, Ni - do j = 1, Nj - do l = 1, Nl - fview(i,j,l) = -fview(i,j,l) - enddo - enddo - enddo - !$acc end data + call kernel_2(fview, Ni, Nj, Nl) call field%update_host() call field%deallocate_device() @@ -171,16 +201,7 @@ module fcta_Field_wrap_device_fixture call field%allocate_device() call field%update_device() - !$acc data present(fview) - !$acc parallel loop - do i=1,Ni - do j=1,Nj - do k=1,Nk - fview(i,j,k) = (mod(k,3) == 0 ) - enddo - enddo - enddo - !$acc end data + call kernel_3(fview, Ni, Nj, Nk) FCTEST_CHECK_EQUAL( fview(1,1,1), .false. ) FCTEST_CHECK_EQUAL( fview(1,1,2), .true. )