]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgomp/testsuite/libgomp.fortran/target-allocatable-1-1.f90
[PR90743] Fortran 'allocatable' with OpenACC data/OpenMP 'target' 'map' clauses
[thirdparty/gcc.git] / libgomp / testsuite / libgomp.fortran / target-allocatable-1-1.f90
1 ! Test 'allocatable' with OpenMP 'target' 'map' clauses.
2
3 ! See also '../libgomp.oacc-fortran/allocatable-1-1.f90'.
4
5 ! { dg-do run }
6 ! { dg-additional-options "-cpp" }
7 ! { dg-additional-options "-DMEM_SHARED" { target offload_device_shared_as } }
8
9 program main
10 implicit none
11 integer, allocatable :: a, b, c, d, e
12
13 allocate (a)
14 a = 11
15
16 b = 25 ! Implicit allocation.
17
18 c = 52 ! Implicit allocation.
19
20 !No 'allocate (d)' here.
21
22 !No 'allocate (e)' here.
23
24 !$omp target map(to: a) map(tofrom: b, c, d) map(from: e)
25
26 if (.not. allocated (a)) stop 1
27 if (a .ne. 11) stop 2
28 a = 33
29
30 if (.not. allocated (b)) stop 3
31 if (b .ne. 25) stop 4
32
33 if (.not. allocated (c)) stop 5
34 if (c .ne. 52) stop 6
35 c = 10
36
37 if (allocated (d)) stop 7
38 d = 42 ! Implicit allocation, but on device only.
39 if (.not. allocated (d)) stop 8
40 deallocate (d) ! OpenMP requires must be "unallocated upon exit from the region".
41
42 if (allocated (e)) stop 9
43 e = 24 ! Implicit allocation, but on device only.
44 if (.not. allocated (e)) stop 10
45 deallocate (e) ! OpenMP requires must be "unallocated upon exit from the region".
46
47 !$omp end target
48
49 if (.not. allocated (a)) stop 20
50 #ifdef MEM_SHARED
51 if (a .ne. 33) stop 21
52 #else
53 if (a .ne. 11) stop 22
54 #endif
55 deallocate (a)
56
57 if (.not. allocated (b)) stop 23
58 if (b .ne. 25) stop 24
59 deallocate (b)
60
61 if (.not. allocated (c)) stop 25
62 if (c .ne. 10) stop 26
63 deallocate (c)
64
65 if (allocated (d)) stop 27
66
67 if (allocated (e)) stop 28
68
69 end program main