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