Debian Codegraph @

libgomp/testsuite/libgomp.fortran/map-alloc-comp-3.f90

raw
1 type t2
2 integer x, y, z
3 end type t2
4 type t
5 integer, allocatable :: A
6 integer, allocatable :: B(:)
7 type(t2), allocatable :: C
8 type(t2), allocatable :: D(:,:)
9 end type t
10
11 type t3
12 type(t) :: Q
13 type(t) :: R(5)
14 end type
15
16 type(t) :: var, var2
17 type(t3) :: var3, var4
18
19 ! --------------------------------------
20 ! Assign + allocate
21 var%A = 45
22 var%B = [1,2,3]
23 var%C = t2(6,5,4)
24 var%D = reshape([t2(1,2,3), t2(4,5,6), t2(11,12,13), t2(14,15,16)], [2,2])
25
26 ! Assign + allocate
27 var2%A = 145
28 var2%B = [991,992,993]
29 var2%C = t2(996,995,994)
30 var2%D = reshape([t2(199,299,399), t2(499,599,699), t2(1199,1299,1399), t2(1499,1599,1699)], [2,2])
31
32
33 !$omp target map(to: var) map(tofrom: var2)
34 call foo(var, var2)
35 !$omp end target
36
37 if (var2%A /= 45) stop 9
38 if (any (var2%B /= [1,2,3])) stop 10
39 if (var2%C%x /= 6) stop 11
40 if (var2%C%y /= 5) stop 11
41 if (var2%C%z /= 4) stop 11
42 if (any (var2%D(:,:)%x /= reshape([1, 4, 11, 14], [2,2]))) stop 12
43 if (any (var2%D(:,:)%y /= reshape([2, 5, 12, 15], [2,2]))) stop 12
44 if (any (var2%D(:,:)%z /= reshape([3, 6, 13, 16], [2,2]))) stop 12
45
46 ! --------------------------------------
47 ! Assign + allocate
48 var3%Q%A = 45
49 var3%Q%B = [1,2,3]
50 var3%Q%C = t2(6,5,4)
51 var3%Q%D = reshape([t2(1,2,3), t2(4,5,6), t2(11,12,13), t2(14,15,16)], [2,2])
52
53 var3%R(2)%A = 45
54 var3%R(2)%B = [1,2,3]
55 var3%R(2)%C = t2(6,5,4)
56 var3%R(2)%D = reshape([t2(1,2,3), t2(4,5,6), t2(11,12,13), t2(14,15,16)], [2,2])
57
58 ! Assign + allocate
59 var4%Q%A = 145
60 var4%Q%B = [991,992,993]
61 var4%Q%C = t2(996,995,994)
62 var4%Q%D = reshape([t2(199,299,399), t2(499,599,699), t2(1199,1299,1399), t2(1499,1599,1699)], [2,2])
63
64 var4%R(3)%A = 145
65 var4%R(3)%B = [991,992,993]
66 var4%R(3)%C = t2(996,995,994)
67 var4%R(3)%D = reshape([t2(199,299,399), t2(499,599,699), t2(1199,1299,1399), t2(1499,1599,1699)], [2,2])
68
69 !$omp target map(to: var3%Q) map(tofrom: var4%Q)
70 call foo(var3%Q, var4%Q)
71 !$omp end target
72
73 !$omp target map(to: var3%R(2)) map(tofrom: var4%R(3))
74 call foo(var3%R(2), var4%R(3))
75 !$omp end target
76
77 if (var4%Q%A /= 45) stop 13
78 if (any (var4%Q%B /= [1,2,3])) stop 14
79 if (var4%Q%C%x /= 6) stop 15
80 if (var4%Q%C%y /= 5) stop 15
81 if (var4%Q%C%z /= 4) stop 15
82 if (any (var4%Q%D(:,:)%x /= reshape([1, 4, 11, 14], [2,2]))) stop 16
83 if (any (var4%Q%D(:,:)%y /= reshape([2, 5, 12, 15], [2,2]))) stop 16
84 if (any (var4%Q%D(:,:)%z /= reshape([3, 6, 13, 16], [2,2]))) stop 16
85
86 if (var4%R(3)%A /= 45) stop 17
87 if (any (var4%R(3)%B /= [1,2,3])) stop 18
88 if (var4%R(3)%C%x /= 6) stop 19
89 if (var4%R(3)%C%y /= 5) stop 19
90 if (var4%R(3)%C%z /= 4) stop 19
91 if (any (var4%R(3)%D(:,:)%x /= reshape([1, 4, 11, 14], [2,2]))) stop 20
92 if (any (var4%R(3)%D(:,:)%y /= reshape([2, 5, 12, 15], [2,2]))) stop 20
93 if (any (var4%R(3)%D(:,:)%z /= reshape([3, 6, 13, 16], [2,2]))) stop 20
94
95 contains
96 subroutine foo(x, y)
97 type(t) :: x, y
98 if (x%A /= 45) stop 1
99 if (any (x%B /= [1,2,3])) stop 2
100 if (x%C%x /= 6) stop 3
101 if (x%C%y /= 5) stop 3
102 if (x%C%z /= 4) stop 3
103 if (any (x%D(:,:)%x /= reshape([1, 4, 11, 14], [2,2]))) stop 4
104 if (any (x%D(:,:)%y /= reshape([2, 5, 12, 15], [2,2]))) stop 4
105 if (any (x%D(:,:)%z /= reshape([3, 6, 13, 16], [2,2]))) stop 4
106
107 if (y%A /= 145) stop 5
108 if (any (y%B /= [991,992,993])) stop 6
109 if (y%C%x /= 996) stop 7
110 if (y%C%y /= 995) stop 7
111 if (y%C%z /= 994) stop 7
112 if (any (y%D(:,:)%x /= reshape([199, 499, 1199, 1499], [2,2]))) stop 8
113 if (any (y%D(:,:)%y /= reshape([299, 599, 1299, 1599], [2,2]))) stop 8
114 if (any (y%D(:,:)%z /= reshape([399, 699, 1399, 1699], [2,2]))) stop 8
115
116 y%A = x%A
117 y%B(:) = x%B
118 y%C = x%C
119 y%D(:,:) = x%D(:,:)
120 end
121 end