brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · f5f284c Raw
78 lines · plain
1! Offloading test checking interaction of pointers with target in different 2! scopes3! REQUIRES: flang, amdgpu4 5! RUN: %libomptarget-compile-fortran-run-and-check-generic6module test7    contains8  subroutine func_arg(arg_alloc)9    integer,  pointer, intent (inout) :: arg_alloc(:)10 11  !$omp target enter data map(alloc: arg_alloc)12 13  !$omp target14    do index = 1, 1015      arg_alloc(index) = arg_alloc(index) + index16    end do17  !$omp end target18 19  !$omp target exit data map(from: arg_alloc)20 21  !$omp target exit data map(delete: arg_alloc)22 23    print *, arg_alloc24  end subroutine func_arg25end module26 27subroutine func28  integer,  pointer :: local_alloc(:)29  allocate(local_alloc(10))30 31  !$omp target enter data map(alloc: local_alloc)32 33  !$omp target34    do index = 1, 1035      local_alloc(index) = index36    end do37  !$omp end target38 39  !$omp target exit data map(from: local_alloc)40 41  !$omp target exit data map(delete: local_alloc)42 43  print *, local_alloc44 45  deallocate(local_alloc)46end subroutine func47 48 49program main50  use test51  integer,  pointer :: map_ptr(:)52  allocate(map_ptr(10))53 54  !$omp target enter data map(alloc: map_ptr)55 56  !$omp target57    do index = 1, 1058      map_ptr(index) = index59    end do60  !$omp end target61 62  !$omp target exit data map(from: map_ptr)63 64  !$omp target exit data map(delete: map_ptr)65 66  call func67 68  print *, map_ptr69 70  call func_arg(map_ptr)71 72  deallocate(map_ptr)73end program74 75! CHECK: 1 2 3 4 5 6 7 8 9 1076! CHECK: 1 2 3 4 5 6 7 8 9 1077! CHECK: 2 4 6 8 10 12 14 16 18 2078