Debian Codegraph @

libgomp/testsuite/libgomp.fortran/target-present-3.f90

raw
1 program main
2 implicit none
3 integer, parameter :: N = 100
4 integer :: a(N), b(N), c(N), i
5
6 do i = 1, N
7 a(i) = i * 2
8 b(i) = i * 3 + 1
9 end do
10
11 !$omp target enter data map (alloc: a, c)
12
13 ! This should work as a has already been allocated.
14 !$omp target update to (present: a)
15
16 !$omp target map(present, alloc: a, c)
17 do i = 1, N
18 if (a(i) /= i * 2) stop 1
19 c(i) = 23 * i
20 end do
21 !$omp end target
22
23 !$omp target update from (present: c)
24 do i = 1, N
25 if (c(i) /= 23 * i) stop 1
26 end do
27
28 print *, "CheCKpOInT"
29 ! { dg-output "CheCKpOInT(\n|\r\n|\r).*" }
30
31 ! This should fail as b has not been allocated.
32 ! { dg-output "libgomp: present clause: not present on the device \\(addr: 0x\[0-9a-f\]+, size: \[0-9\]+ \\(0x\[0-9a-f\]+\\), dev: \[0-9\]+\\\)" { target offload_device_nonshared_as } }
33 ! { dg-shouldfail "present error triggered" { offload_device_nonshared_as } }
34 !$omp target update to (present: b)
35 !$omp target exit data map (from: c)
36 end program