61 lines · plain
1! Offloading test checking interaction of allocatables with target in different2! scopes3! REQUIRES: flang, amdgpu4 5! RUN: %libomptarget-compile-fortran-run-and-check-generic6module test7 contains8 subroutine func_arg(arg_alloc)9 integer, allocatable, intent (inout) :: arg_alloc(:)10 11 !$omp target map(tofrom: arg_alloc)12 do index = 1, 1013 arg_alloc(index) = arg_alloc(index) + index14 end do15 !$omp end target16 17 print *, arg_alloc18 end subroutine func_arg19end module20 21subroutine func22 integer, allocatable :: local_alloc(:)23 allocate(local_alloc(10))24 25 !$omp target map(tofrom: local_alloc)26 do index = 1, 1027 local_alloc(index) = index28 end do29 !$omp end target30 31 print *, local_alloc32 33 deallocate(local_alloc)34end subroutine func35 36 37program main38 use test39 integer, allocatable :: map_ptr(:)40 41 allocate(map_ptr(10))42 43 !$omp target map(tofrom: map_ptr)44 do index = 1, 1045 map_ptr(index) = index46 end do47 !$omp end target48 49 call func50 51 print *, map_ptr52 53 call func_arg(map_ptr)54 55 deallocate(map_ptr)56end program57 58! CHECK: 1 2 3 4 5 6 7 8 9 1059! CHECK: 1 2 3 4 5 6 7 8 9 1060! CHECK: 2 4 6 8 10 12 14 16 18 2061