blob: c970d0def661f886abe69846709b50c39cbc191c [file] [log] [blame]
Jonas Hahnfeld87d44262017-11-18 21:00:46 +00001// PowerPC supports VLAs.
2// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-unknown-unknown -emit-llvm-bc %s -o %t-ppc-host-ppc.bc
3// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host-ppc.bc -o %t-ppc-device.ll
4
5// Nvidia GPUs don't support VLAs.
6// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host-nvptx.bc
7// RUN: %clang_cc1 -verify -DNO_VLA -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host-nvptx.bc -o %t-nvptx-device.ll
8
9#ifndef NO_VLA
10// expected-no-diagnostics
11#endif
12
13#pragma omp declare target
14void declare(int arg) {
15 int a[2];
16#ifdef NO_VLA
17 // expected-error@+2 {{variable length arrays are not supported for the current target}}
18#endif
19 int vla[arg];
20}
21
22void declare_parallel_reduction(int arg) {
23 int a[2];
24
25#pragma omp parallel reduction(+: a)
26 { }
27
28#pragma omp parallel reduction(+: a[0:2])
29 { }
30
31#ifdef NO_VLA
32 // expected-error@+3 {{cannot generate code for reduction on array section, which requires a variable length array}}
33 // expected-note@+2 {{variable length arrays are not supported for the current target}}
34#endif
35#pragma omp parallel reduction(+: a[0:arg])
36 { }
37}
38#pragma omp end declare target
39
40template <typename T>
41void target_template(int arg) {
42#pragma omp target
43 {
44#ifdef NO_VLA
45 // expected-error@+2 {{variable length arrays are not supported for the current target}}
46#endif
47 T vla[arg];
48 }
49}
50
51void target(int arg) {
52#pragma omp target
53 {
54#ifdef NO_VLA
55 // expected-error@+2 {{variable length arrays are not supported for the current target}}
56#endif
57 int vla[arg];
58 }
59
60#pragma omp target
61 {
62#pragma omp parallel
63 {
64#ifdef NO_VLA
65 // expected-error@+2 {{variable length arrays are not supported for the current target}}
66#endif
67 int vla[arg];
68 }
69 }
70
71 target_template<long>(arg);
72}
73
74void teams_reduction(int arg) {
75 int a[2];
76 int vla[arg];
77
78#pragma omp target map(a)
79#pragma omp teams reduction(+: a)
80 { }
81
82#ifdef NO_VLA
83 // expected-error@+4 {{cannot generate code for reduction on variable length array}}
84 // expected-note@+3 {{variable length arrays are not supported for the current target}}
85#endif
86#pragma omp target map(vla)
87#pragma omp teams reduction(+: vla)
88 { }
89
90#pragma omp target map(a[0:2])
91#pragma omp teams reduction(+: a[0:2])
92 { }
93
94#pragma omp target map(vla[0:2])
95#pragma omp teams reduction(+: vla[0:2])
96 { }
97
98#ifdef NO_VLA
99 // expected-error@+4 {{cannot generate code for reduction on array section, which requires a variable length array}}
100 // expected-note@+3 {{variable length arrays are not supported for the current target}}
101#endif
102#pragma omp target map(a[0:arg])
103#pragma omp teams reduction(+: a[0:arg])
104 { }
105
106#ifdef NO_VLA
107 // expected-error@+4 {{cannot generate code for reduction on array section, which requires a variable length array}}
108 // expected-note@+3 {{variable length arrays are not supported for the current target}}
109#endif
110#pragma omp target map(vla[0:arg])
111#pragma omp teams reduction(+: vla[0:arg])
112 { }
113}
114
115void parallel_reduction(int arg) {
116 int a[2];
117 int vla[arg];
118
119#pragma omp target map(a)
120#pragma omp parallel reduction(+: a)
121 { }
122
123#ifdef NO_VLA
124 // expected-error@+4 {{cannot generate code for reduction on variable length array}}
125 // expected-note@+3 {{variable length arrays are not supported for the current target}}
126#endif
127#pragma omp target map(vla)
128#pragma omp parallel reduction(+: vla)
129 { }
130
131#pragma omp target map(a[0:2])
132#pragma omp parallel reduction(+: a[0:2])
133 { }
134
135#pragma omp target map(vla[0:2])
136#pragma omp parallel reduction(+: vla[0:2])
137 { }
138
139#ifdef NO_VLA
140 // expected-error@+4 {{cannot generate code for reduction on array section, which requires a variable length array}}
141 // expected-note@+3 {{variable length arrays are not supported for the current target}}
142#endif
143#pragma omp target map(a[0:arg])
144#pragma omp parallel reduction(+: a[0:arg])
145 { }
146
147#ifdef NO_VLA
148 // expected-error@+4 {{cannot generate code for reduction on array section, which requires a variable length array}}
149 // expected-note@+3 {{variable length arrays are not supported for the current target}}
150#endif
151#pragma omp target map(vla[0:arg])
152#pragma omp parallel reduction(+: vla[0:arg])
153 { }
154}
155
156void for_reduction(int arg) {
157 int a[2];
158 int vla[arg];
159
160#pragma omp target map(a)
161#pragma omp parallel
162#pragma omp for reduction(+: a)
163 for (int i = 0; i < arg; i++) ;
164
165#ifdef NO_VLA
166 // expected-error@+5 {{cannot generate code for reduction on variable length array}}
167 // expected-note@+4 {{variable length arrays are not supported for the current target}}
168#endif
169#pragma omp target map(vla)
170#pragma omp parallel
171#pragma omp for reduction(+: vla)
172 for (int i = 0; i < arg; i++) ;
173
174#pragma omp target map(a[0:2])
175#pragma omp parallel
176#pragma omp for reduction(+: a[0:2])
177 for (int i = 0; i < arg; i++) ;
178
179#pragma omp target map(vla[0:2])
180#pragma omp parallel
181#pragma omp for reduction(+: vla[0:2])
182 for (int i = 0; i < arg; i++) ;
183
184#ifdef NO_VLA
185 // expected-error@+5 {{cannot generate code for reduction on array section, which requires a variable length array}}
186 // expected-note@+4 {{variable length arrays are not supported for the current target}}
187#endif
188#pragma omp target map(a[0:arg])
189#pragma omp parallel
190#pragma omp for reduction(+: a[0:arg])
191 for (int i = 0; i < arg; i++) ;
192
193#ifdef NO_VLA
194 // expected-error@+5 {{cannot generate code for reduction on array section, which requires a variable length array}}
195 // expected-note@+4 {{variable length arrays are not supported for the current target}}
196#endif
197#pragma omp target map(vla[0:arg])
198#pragma omp parallel
199#pragma omp for reduction(+: vla[0:arg])
200 for (int i = 0; i < arg; i++) ;
201}