Debian Codegraph @

gcc/testsuite/gcc.target/aarch64/sve/gomp/target-device.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-msve-vector-bits=256 -fopenmp -O2" } */
3
4 #include <arm_sve.h>
5
6 #define N __ARM_FEATURE_SVE_BITS
7
8 int64_t __attribute__ ((noipa))
9 target_device_ptr_vla (svbool_t vp, svint32_t *vptr)
10 {
11
12 int a[N], b[N], c[N];
13 svint32_t va, vb, vc;
14 int64_t res;
15 int i;
16
17 #pragma omp parallel for
18 for (i = 0; i < N; i++)
19 {
20 b[i] = i;
21 c[i] = i + 1;
22 }
23 /* { dg-error {SVE type 'svint32_t \*' not allowed in 'target' device clauses} "" { target *-*-* } .+1 } */
24 #pragma omp target data use_device_ptr (vptr) map (to: b, c)
25 /* { dg-error {SVE type 'svint32_t \*' not allowed in 'target' device clauses} "" { target *-*-* } .+1 } */
26 #pragma omp target is_device_ptr (vptr) map (to: b, c) map (from: res)
27 for (i = 0; i < 8; i++)
28 {
29 /* { dg-error "cannot reference 'svint32_t' object types in 'target' region" "" { target *-*-* } .+1 } */
30 vb = *vptr;
31 /* { dg-error "cannot reference 'svint32_t' object types in 'target' region" "" { target *-*-* } .+2 } */
32 /* { dg-error "cannot reference 'svbool_t' object types in 'target' region" "" { target *-*-* } .+1 } */
33 vc = svld1_s32 (vp, c);
34 /* { dg-error "cannot reference 'svint32_t' object types in 'target' region" "" { target *-*-* } .+1 } */
35 va = svadd_s32_z (vp, vb, vc);
36 res = svaddv_s32 (svptrue_b32 (), va);
37 }
38
39 return res;
40 }
41
42 int64_t __attribute__ ((noipa))
43 target_device_addr_vla (svbool_t vp, svint32_t *vptr)
44 {
45
46 int a[N], b[N], c[N];
47 svint32_t va, vb, vc;
48 int64_t res;
49 int i;
50
51 #pragma omp parallel for
52 for (i = 0; i < N; i++)
53 {
54 b[i] = i;
55 c[i] = i + 1;
56 }
57
58 /* { dg-error "SVE type 'svint32_t' not allowed in 'target' device clauses" "" { target *-*-* } .+1 } */
59 #pragma omp target data use_device_addr (vb) map (to: b, c)
60 /* { dg-error {SVE type 'svint32_t \*' not allowed in 'target' device clauses} "" { target *-*-* } .+1 } */
61 #pragma omp target is_device_ptr (vptr) map (to: b, c) map (from: res)
62 for (i = 0; i < 8; i++)
63 {
64 /* { dg-error "cannot reference 'svint32_t' object types in 'target' region" "" { target *-*-* } .+1 } */
65 vb = *vptr;
66 /* { dg-error "cannot reference 'svint32_t' object types in 'target' region" "" { target *-*-* } .+2 } */
67 /* { dg-error "cannot reference 'svbool_t' object types in 'target' region" "" { target *-*-* } .+1 } */
68 vc = svld1_s32 (vp, c);
69 /* { dg-error "cannot reference 'svint32_t' object types in 'target' region" "" { target *-*-* } .+1 } */
70 va = svadd_s32_z (vp, vb, vc);
71 res = svaddv_s32 (svptrue_b32 (), va);
72 }
73
74 return res;
75 }
76
77 int64_t __attribute__ ((noipa))
78 target_has_device_addr_vla (svbool_t vp, svint32_t *vptr)
79 {
80
81 int a[N], b[N], c[N];
82 svint32_t va, vb, vc;
83 int64_t res;
84 int i;
85
86 #pragma omp parallel for
87 for (i = 0; i < N; i++)
88 {
89 b[i] = i;
90 c[i] = i + 1;
91 }
92
93 /* { dg-error "SVE type 'svint32_t' not allowed in 'target' device clauses" "" { target *-*-* } .+1 } */
94 #pragma omp target data use_device_addr (vb) map (to: b, c)
95 /* { dg-error "SVE type 'svint32_t' not allowed in 'target' device clauses" "" { target *-*-* } .+1 } */
96 #pragma omp target has_device_addr (vb) map (to: b, c) map (from: res)
97 for (i = 0; i < 8; i++)
98 {
99 /* { dg-error "cannot reference 'svbool_t' object types in 'target' region" "" { target *-*-* } .+1 } */
100 vb = svld1_s32 (vp, b);
101 /* { dg-error "cannot reference 'svint32_t' object types in 'target' region" "" { target *-*-* } .+1 } */
102 vc = svld1_s32 (vp, c);
103 /* { dg-error "cannot reference 'svint32_t' object types in 'target' region" "" { target *-*-* } .+1 } */
104 va = svadd_s32_z (vp, vb, vc);
105 res = svaddv_s32 (svptrue_b32 (), va);
106 }
107
108 return res;
109 }
110
111 #define FIXED_ATTR __attribute__ ((arm_sve_vector_bits (N)))
112
113 typedef __SVInt32_t v8si FIXED_ATTR;
114 typedef svbool_t v8bi FIXED_ATTR;
115
116 int64_t __attribute__ ((noipa))
117 target_device_ptr_vls (v8bi vp, v8si *vptr)
118 {
119
120 int a[N], b[N], c[N];
121 v8si va, vb, vc;
122 int64_t res;
123 int i;
124
125 #pragma omp parallel for
126 for (i = 0; i < N; i++)
127 {
128 b[i] = i;
129 c[i] = i + 1;
130 }
131
132 #pragma omp target data use_device_ptr (vptr) map (to: b, c)
133 #pragma omp target is_device_ptr (vptr) map (to: b, c) map (from: res)
134 for (i = 0; i < 8; i++)
135 {
136 vb = *vptr;
137 vc = svld1_s32 (vp, c);
138 va = svadd_s32_z (vp, vb, vc);
139 res = svaddv_s32 (svptrue_b32 (), va);
140 }
141
142 return res;
143 }
144
145 int64_t __attribute__ ((noipa))
146 target_device_addr_vls (v8bi vp, v8si *vptr)
147 {
148
149 int a[N], b[N], c[N];
150 v8si va, vb, vc;
151 int64_t res;
152 int i;
153
154 #pragma omp parallel for
155 for (i = 0; i < N; i++)
156 {
157 b[i] = i;
158 c[i] = i + 1;
159 }
160
161 #pragma omp target data use_device_addr (vb) map (to: b, c)
162 #pragma omp target is_device_ptr (vptr) map (to: b, c) map (from: res)
163 for (i = 0; i < 8; i++)
164 {
165 vb = *vptr;
166 vc = svld1_s32 (vp, c);
167 va = svadd_s32_z (vp, vb, vc);
168 res = svaddv_s32 (svptrue_b32 (), va);
169 }
170
171 return res;
172 }
173
174 int64_t __attribute__ ((noipa))
175 target_has_device_addr_vls (v8bi vp, v8si *vptr)
176 {
177
178 int a[N], b[N], c[N];
179 v8si va, vb, vc;
180 int64_t res;
181 int i;
182
183 #pragma omp parallel for
184 for (i = 0; i < N; i++)
185 {
186 b[i] = i;
187 c[i] = i + 1;
188 }
189
190 #pragma omp target data use_device_addr (vb) map (to: b, c)
191 #pragma omp target has_device_addr (vb) map (to: b, c) map (from: res)
192 for (i = 0; i < 8; i++)
193 {
194 vb = svld1_s32 (vp, b);
195 vc = svld1_s32 (vp, c);
196 va = svadd_s32_z (vp, vb, vc);
197 res = svaddv_s32 (svptrue_b32 (), va);
198 }
199
200 return res;
201 }