Debian Codegraph @

libgomp/testsuite/libgomp.fortran/reverse-offload-4.f90

raw
1 ! { dg-additional-options "-foffload-options=nvptx-none=-misa=sm_35" { target { offload_target_nvptx } } }
2
3 implicit none
4 !$omp requires reverse_offload
5
6 type t2
7 integer :: a, b, c
8 end type t2
9
10 type t
11 integer :: A(5), B(5), C(5)
12 integer, pointer :: P(:), P2 !Just some padding
13 type(t2) :: tt !Just some padding
14 end type t
15
16 type(t) :: S1, S2
17 logical :: shared_mem
18
19 shared_mem = .false.
20
21 !$omp target map(to: shared_mem)
22 shared_mem = .true.
23 !$omp end target
24
25 s1%A = [1,2,3,4,5]
26 s1%B = [10,20,30,40,50]
27 s1%C = [11,22,33,44,55]
28 s2%A = 2*s1%A
29 s2%B = 2*s1%B
30 s2%C = 2*s1%C
31
32 !$omp target &
33 !$omp& map(to: s1%b, s1%c) &
34 !$omp& map(to: s2%b, s2%c)
35 block
36 type(t) :: si1, si2, si3, si4
37
38 s1%B = -10 * s1%B
39 s1%C = -10 * s1%C
40 s2%B = -15 * s2%B
41 s2%C = -15 * s2%C
42
43 si1%A = -1 * [1,2,3,4,5]
44 si1%B = -1 * [10,20,30,40,50]
45 si1%C = -1 * [11,22,33,44,55]
46 si2%A = -23 * [1,2,3,4,5]
47 si2%B = -23 * [10,20,30,40,50]
48 si2%C = -23 * [11,22,33,44,55]
49
50 !$omp target device (ancestor:1) &
51 !$omp& map(to: si1%C, si1%B) &
52 !$omp& map(tofrom: si2%C, si2%B) &
53 !$omp& map(always, to: s1%B) &
54 !$omp& map( to: s2%B)
55 if (any (s1%A /= [1,2,3,4,5])) stop 1
56 if (any (s1%B /= -10 * [10,20,30,40,50])) stop 2
57 if (shared_mem) then
58 if (any (s1%C /= -10 * [11,22,33,44,55])) stop 4
59 else
60 if (any (s1%C /= [11,22,33,44,55])) stop 3
61 endif
62 if (any (s2%A /= 2 * [1,2,3,4,5])) stop 4
63 if (shared_mem) then
64 if (any (s2%B /= -15 * 2 * [10,20,30,40,50])) stop 5
65 if (any (s2%C /= -15 * 2 * [11,22,33,44,55])) stop 6
66 else
67 if (any (s2%B /= 2 * [10,20,30,40,50])) stop 7
68 if (any (s2%C /= 2 * [11,22,33,44,55])) stop 8
69 endif
70 if (any (si1%B /= -1 * [10,20,30,40,50])) stop 9
71 if (any (si1%C /= -1 * [11,22,33,44,55])) stop 10
72 if (any (si2%B /= -23 * [10,20,30,40,50])) stop 10
73 if (any (si2%C /= -23 * [11,22,33,44,55])) stop 11
74
75 s1%A = 5 * s1%A
76 s1%B = 7 * s1%B
77 s1%C = 13 * s1%C
78 s2%A = 9 * s2%A
79 s2%B = 21 * s2%B
80 s2%C = 31 * s2%C
81 si1%B = -11 * si1%B
82 si1%C = -13 * si1%C
83 si2%B = -27 * si2%B
84 si2%C = -29 * si2%C
85 !$omp end target
86
87 if (shared_mem) then
88 if (any (s1%B /= -10 * 7 * [10,20,30,40,50])) stop 20
89 if (any (s1%C /= -10 * 13 * [11,22,33,44,55])) stop 21
90 else
91 if (any (s1%B /= -10 * [10,20,30,40,50])) stop 22
92 if (any (s1%C /= -10 * [11,22,33,44,55])) stop 23
93 endif
94 if (shared_mem) then
95 if (any (s2%B /= -15 * 2 * 21 * [10,20,30,40,50])) stop 24
96 if (any (s2%C /= -15 * 2 * 31 * [11,22,33,44,55])) stop 25
97 else
98 if (any (s2%B /= -15 * 2 * [10,20,30,40,50])) stop 26
99 if (any (s2%C /= -15 * 2 * [11,22,33,44,55])) stop 27
100 endif
101 if (any (si1%A /= -1 * [1,2,3,4,5])) stop 28
102 if (shared_mem) then
103 if (any (si1%B /= -1 * (-11) * [10,20,30,40,50])) stop 29
104 if (any (si1%C /= -1 * (-13) * [11,22,33,44,55])) stop 30
105 else
106 if (any (si1%B /= -1 * [10,20,30,40,50])) stop 31
107 if (any (si1%C /= -1 * [11,22,33,44,55])) stop 32
108 endif
109 if (any (si2%A /= -23 * [1,2,3,4,5])) stop 33
110 if (any (si2%B /= -23 * (-27) * [10,20,30,40,50])) stop 34
111 if (any (si2%C /= -23 * (-29) * [11,22,33,44,55])) stop 35
112 end block
113
114 if (any (s1%A /= 5 * [1,2,3,4,5])) stop 40
115 if (any (s1%B /= -10 * 7 * [10,20,30,40,50])) stop 41
116 if (shared_mem) then
117 if (any (s1%C /= -10 * 13 * [11,22,33,44,55])) stop 42
118 else
119 if (any (s1%C /= 13 * [11,22,33,44,55])) stop 43
120 endif
121 if (any (s2%A /= 2 * 9 * [1,2,3,4,5])) stop 44
122 if (shared_mem) then
123 if (any (s2%B /= -15 * 2 * 21 * [10,20,30,40,50])) stop 45
124 if (any (s2%C /= -15 * 2 * 31 * [11,22,33,44,55])) stop 46
125 else
126 if (any (s2%B /= 2 * 21 * [10,20,30,40,50])) stop 47
127 if (any (s2%C /= 2 * 31 * [11,22,33,44,55])) stop 48
128 endif
129 end