Debian Codegraph @

libgomp/testsuite/libgomp.fortran/get-mapped-ptr-2.f90

raw
1 program main
2 use omp_lib
3 use iso_c_binding
4 implicit none (external, type)
5 integer :: d, id, i, j
6 integer, target :: a, b(1:2), c(1:2), e(0:127)
7 type(c_ptr) :: p1, p2, p3, q, devptrs(0:63)
8
9 a = 42;
10 q = c_loc (a);
11 e = [(i, i = 0, 127)]
12
13 d = omp_get_default_device ()
14 id = omp_get_initial_device ()
15
16 if (d < 0 .or. d >= omp_get_num_devices ()) &
17 d = id
18
19 if (d /= id) then
20 !$omp target data map(alloc: a, b, c(2), e(32:95)) device(d)
21 !$omp target map(from: p1, p2, p3, devptrs) map(alloc: a, b, c(2), e(32:95)) device(d)
22 p1 = c_loc (a);
23 p2 = c_loc (b);
24 p3 = c_loc (c(2))
25 devptrs = [(c_loc (e(i)), i = 32, 95)]
26 !$omp end target
27
28 if (.not. c_associated (omp_get_mapped_ptr (c_loc (a), d), p1) &
29 .or. .not. c_associated (omp_get_mapped_ptr (q, d), p1) &
30 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (b), d), p2) &
31 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (b(1)), d), p2) &
32 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (c(2)), d), p3) &
33 .or. c_associated (omp_get_mapped_ptr (c_loc (c(1)), d))) &
34 stop 0
35
36 do j = 0, 31
37 if (c_associated (omp_get_mapped_ptr (c_loc (e(j)), d))) &
38 stop 1
39 end do
40 do j = 32, 95
41 if (.not. c_associated (omp_get_mapped_ptr (c_loc (e(j)), d), devptrs(j-32))) &
42 stop 2
43 end do
44 do j = 96, 128
45 if (c_associated (omp_get_mapped_ptr (c_loc (e(j)), d))) &
46 stop 3
47 end do
48 !$omp end target data
49
50 if (c_associated (omp_get_mapped_ptr (c_loc (a), d)) &
51 .or. c_associated (omp_get_mapped_ptr (q, d)) &
52 .or. c_associated (omp_get_mapped_ptr (c_loc (b), d)) &
53 .or. c_associated (omp_get_mapped_ptr (c_loc (b(1)), d)) &
54 .or. c_associated (omp_get_mapped_ptr (c_loc (c(2)), d)) &
55 .or. c_associated (omp_get_mapped_ptr (c_loc (c(1)), d))) &
56 stop 4
57 do j = 0, 127
58 if (c_associated (omp_get_mapped_ptr (c_loc (e(j)), d))) &
59 stop 5
60 end do
61
62 !$omp target enter data map (alloc: a, b, c(2), e(32:95)) device (d)
63 !$omp target map(from: p1, p2, p3, devptrs) map(alloc: a, b, c(2), e(32:95)) device(d)
64 p1 = c_loc (a);
65 p2 = c_loc (b);
66 p3 = c_loc (c(2))
67 devptrs = [(c_loc (e(i)), i = 32, 95)]
68 !$omp end target
69
70 if (.not. c_associated (omp_get_mapped_ptr (c_loc (a), d), p1) &
71 .or. .not. c_associated (omp_get_mapped_ptr (q, d), p1) &
72 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (b), d), p2) &
73 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (c(2)), d), p3) &
74 .or. c_associated (omp_get_mapped_ptr (c_loc (c(1)), d))) &
75 stop 6
76
77 do j = 0, 31
78 if (c_associated (omp_get_mapped_ptr (c_loc (e(j)), d))) &
79 stop 7
80 end do
81 do j = 32, 95
82 if (.not. c_associated (omp_get_mapped_ptr (c_loc (e(j)), d), devptrs(j-32))) &
83 stop 8
84 end do
85 do j = 96, 128
86 if (c_associated (omp_get_mapped_ptr (c_loc (e(j)), d))) &
87 stop 9
88 end do
89 !$omp target exit data map (delete: a, b, c(2), e(32:95)) device (d)
90
91 if (c_associated (omp_get_mapped_ptr (c_loc (a), d)) &
92 .or. c_associated (omp_get_mapped_ptr (q, d)) &
93 .or. c_associated (omp_get_mapped_ptr (c_loc (b), d)) &
94 .or. c_associated (omp_get_mapped_ptr (c_loc (b(1)), d)) &
95 .or. c_associated (omp_get_mapped_ptr (c_loc (c(1)), d)) &
96 .or. c_associated (omp_get_mapped_ptr (c_loc (c(2)), d))) &
97 stop 10
98 do j = 0, 127
99 if (c_associated (omp_get_mapped_ptr (c_loc (e(j)), d))) &
100 stop 11
101 end do
102
103 else ! d == id
104
105 !$omp target data map(alloc: a, b, c(2), e(32:95)) device(d)
106 !$omp target map(from: p1, p2, p3, devptrs) map(alloc: a, b, c(2), e(32:95)) device(d)
107 p1 = c_loc (a);
108 p2 = c_loc (b);
109 p3 = c_loc (c(2))
110 devptrs = [(c_loc (e(i)), i = 32, 95)]
111 !$omp end target
112
113 if (.not. c_associated (omp_get_mapped_ptr (c_loc (a), d), c_loc (a)) &
114 .or. .not. c_associated (omp_get_mapped_ptr (q, d), q) &
115 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (b), d), c_loc (b)) &
116 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (b(1)), d), c_loc (b(1))) &
117 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (c(2)), d), c_loc (c(2))) &
118 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (c(1)), d), c_loc (c(1)))) &
119 stop 12
120
121 do j = 0, 127
122 if (.not. c_associated (omp_get_mapped_ptr (c_loc (e(j)), d), c_loc (e(j)))) &
123 stop 13
124 end do
125 !$omp end target data
126
127 if (.not. c_associated (omp_get_mapped_ptr (c_loc (a), d), c_loc (a)) &
128 .or. .not. c_associated (omp_get_mapped_ptr (q, d), q) &
129 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (b), d), c_loc (b)) &
130 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (b(1)), d), c_loc (b(1))) &
131 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (c(2)), d), c_loc (c(2))) &
132 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (c(1)), d), c_loc (c(1)))) &
133 stop 14
134 do j = 0, 127
135 if (.not. c_associated (omp_get_mapped_ptr (c_loc (e(j)), d))) &
136 stop 15
137 end do
138
139 !$omp target enter data map (alloc: a, b, c(2), e(32:95)) device (d)
140 !$omp target map(from: p1, p2, p3, devptrs) map(alloc: a, b, c(2), e(32:95)) device(d)
141 p1 = c_loc (a);
142 p2 = c_loc (b);
143 p3 = c_loc (c(2))
144 devptrs = [(c_loc (e(i)), i = 32, 95)]
145 !$omp end target
146
147 if (.not. c_associated (omp_get_mapped_ptr (c_loc (a), d), c_loc (a)) &
148 .or. .not. c_associated (omp_get_mapped_ptr (q, d), q) &
149 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (b), d), c_loc (b)) &
150 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (b(1)), d), c_loc (b(1))) &
151 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (c(2)), d), c_loc (c(2))) &
152 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (c(1)), d), c_loc (c(1)))) &
153 stop 16
154
155 do j = 0, 127
156 if (.not. c_associated (omp_get_mapped_ptr (c_loc (e(j)), d), c_loc (e(j)))) &
157 stop 17
158 end do
159 !$omp target exit data map (delete: a, b, c(2), e(32:95)) device (d)
160
161 if (.not. c_associated (omp_get_mapped_ptr (c_loc (a), d), c_loc (a)) &
162 .or. .not. c_associated (omp_get_mapped_ptr (q, d), q) &
163 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (b), d), c_loc (b)) &
164 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (b(1)), d), c_loc (b(1))) &
165 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (c(2)), d), c_loc (c(2))) &
166 .or. .not. c_associated (omp_get_mapped_ptr (c_loc (c(1)), d), c_loc (c(1)))) &
167 stop 18
168
169 do j = 0, 127
170 if (.not. c_associated (omp_get_mapped_ptr (c_loc (e(j)), d), c_loc (e(j)))) &
171 stop 19
172 end do
173 end if
174
175 end program main