102 lines · plain
1! This test doesn't expect any results, the pass condition is running to completion2! without any memory access errors on device or mapping issues from descriptor3! collisions due to local descriptors being placed on device and not being unampped4! before a subsequent local descriptor residing at the same address is mapped to5! device.6! REQUIRES: flang, amdgpu7 8! RUN: %libomptarget-compile-fortran-run-and-check-generic9module test10contains11 subroutine kernel_1d(array)12 implicit none13 real, dimension(:) :: array14 integer :: i15 16 !$omp target enter data map(alloc:array)17 !$omp target teams distribute parallel do18 do i=1, ubound(array, 1)19 array(i) = 42.020 end do21 !$omp target update from(array)22 end subroutine23 24 subroutine kernel_2d(array)25 implicit none26 real, dimension(:,:) :: array27 integer :: i, j28 29 !$omp target enter data map(alloc:array)30 !$omp target teams distribute parallel do collapse(2)31 do j=1, ubound(array, 2)32 do i=1, ubound(array, 1)33 array(i,j) = 42.034 end do35 end do36 !$omp target update from(array)37 end subroutine38 39 subroutine kernel_3d(array)40 implicit none41 real, dimension(:,:,:) :: array42 integer :: i, j, k43 44 !$omp target enter data map(alloc:array)45 !$omp target teams distribute parallel do collapse(3)46 do k=1, ubound(array, 3)47 do j=1, ubound(array, 2)48 do i=1, ubound(array, 1)49 array(i,j,k) = 42.050 end do51 end do52 end do53 !$omp target update from(array)54 end subroutine55 56 subroutine kernel_4d(array)57 implicit none58 real, dimension(:,:,:,:) :: array59 integer :: i, j, k, l60 61 !$omp target enter data map(alloc:array)62 !$omp target teams distribute parallel do collapse(4)63 do l=1, ubound(array, 4)64 do k=1, ubound(array, 3)65 do j=1, ubound(array, 2)66 do i=1, ubound(array, 1)67 array(i,j,k,l) = 42.068 end do69 end do70 end do71 enddo72 !$omp target update from(array)73 end subroutine74end module75 76program main77 use test78 implicit none79 integer, parameter :: n = 280 real :: array1(n)81 real :: array2(n,n)82 real :: array3(n,n,n)83 real :: array4(n,n,n,n)84 85 call kernel_1d(array1)86 call kernel_2d(array2)87 call kernel_3d(array3)88 call kernel_4d(array4)89 90 print *, array191 print *, array292 print *, array393 print *, array494 print *, "PASS"95end program96 97! CHECK: 42. 42.98! CHECK: 42. 42. 42. 42.99! CHECK: 42. 42. 42. 42. 42. 42. 42. 42.100! CHECK: 42. 42. 42. 42. 42. 42. 42. 42. 42. 42. 42. 42. 42. 42. 42. 42.101! CHECK: PASS102