xref: /llvm-project/offload/test/offloading/fortran/target-map-enter-exit-array-bounds.f90 (revision 372344995568cae076477a8b0e98fcdec7c49379)
1! Offloading test checking interaction of an enter and exit map of an array of
2! scalars with specified bounds
3! REQUIRES: flang, amdgpu
4
5! RUN: %libomptarget-compile-fortran-run-and-check-generic
6
7program main
8    integer :: array(10)
9
10    do I = 1, 10
11      array(I) = I + I
12    end do
13
14    !$omp target enter data map(to: array(3:6))
15    ! Shouldn't overwrite data already locked in
16    ! on target via enter, which will then be
17    ! overwritten by our exit
18    do I = 1, 10
19      array(I) = 10
20    end do
21
22  ! The compiler/runtime is less lenient about read/write out of
23  ! bounds when using enter and exit, we have to specifically loop
24  ! over the correctly mapped range
25   !$omp target
26    do i=3,6
27      array(i) = array(i) + i
28    end do
29  !$omp end target
30
31  !$omp target exit data map(from: array(3:6))
32  print *, array
33end program
34
35!CHECK: 10 10 9 12 15 18 10 10 10 10
36