xref: /llvm-project/offload/test/offloading/fortran/target-map-two-nested-dtype-member-array-map.f90 (revision 372344995568cae076477a8b0e98fcdec7c49379)
1! Offloading test checking interaction of an explicit member map utilising
2! array bounds
3! REQUIRES: flang, amdgpu
4
5! RUN: %libomptarget-compile-fortran-run-and-check-generic
6program main
7    type :: array
8     real(4) :: array_z(10)
9     real(4) :: break_4
10     real(4) :: array_ix(10)
11    end type array
12
13    type :: scalar_array
14    real(4) :: break_0
15    real(4) :: array_x(10)
16    real(4) :: break_1
17    real(4) :: array_y(10)
18    real(4) :: break_3
19    type(array) :: nested
20    end type scalar_array
21
22    type(scalar_array) :: scalar_arr1
23    type(scalar_array) :: scalar_arr2
24
25  do i = 1, 10
26    scalar_arr1%nested%array_z(i) = i
27    scalar_arr2%nested%array_z(i) = i
28  end do
29
30  !$omp target map(tofrom:scalar_arr1%nested%array_z(3:6), scalar_arr1%nested%array_ix(3:6), scalar_arr2%nested%array_z(3:6), scalar_arr2%nested%array_ix(3:6))
31    do i = 3, 6
32      scalar_arr2%nested%array_ix(i) = scalar_arr1%nested%array_z(i)
33    end do
34
35    do i = 3, 6
36      scalar_arr1%nested%array_ix(i) = scalar_arr2%nested%array_z(i)
37    end do
38  !$omp end target
39
40  print*, scalar_arr1%nested%array_ix
41  print*, scalar_arr2%nested%array_z
42
43  print*, scalar_arr2%nested%array_ix
44  print*, scalar_arr1%nested%array_z
45end program main
46
47!CHECK: 0. 0. 3. 4. 5. 6. 0. 0. 0. 0.
48!CHECK: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.
49!CHECK: 0. 0. 3. 4. 5. 6. 0. 0. 0. 0.
50!CHECK: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.
51