xref: /llvm-project/offload/test/offloading/fortran/double-target-call-with-declare-target.f90 (revision 372344995568cae076477a8b0e98fcdec7c49379)
1! Offloading test with two target regions mapping the same declare target
2! Fortran array and writing some values to it before checking the host
3! correctly receives the correct updates made on the device.
4! REQUIRES: flang, amdgpu
5
6! RUN: %libomptarget-compile-fortran-run-and-check-generic
7module test_0
8    implicit none
9    integer :: sp(10) = (/0,0,0,0,0,0,0,0,0,0/)
10    !$omp declare target link(sp)
11end module test_0
12
13program main
14    use test_0
15    integer :: i = 1
16    integer :: j = 11
17
18!$omp target map(tofrom:sp) map(to: i, j)
19    do while (i <= j)
20        sp(i) = i;
21        i = i + 1
22    end do
23!$omp end target
24
25!$omp target map(tofrom:sp) map(to: i, j)
26    do while (i <= j)
27        sp(i) = sp(i) + i;
28        i = i + 1
29    end do
30!$omp end target
31
32print *, sp(:)
33
34end program
35
36! CHECK: 2 4 6 8 10 12 14 16 18 20
37