summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCUDA/amdgpu-attrs.cu
blob: e04b32d121bc8cd959ded0abfaf061238762c742 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
#include "Inputs/cuda.h"


__attribute__((amdgpu_flat_work_group_size(32, 64)))
__global__ void flat_work_group_size_32_64() {}

__attribute__((amdgpu_waves_per_eu(2)))
__global__ void waves_per_eu_2() {}

__attribute__((amdgpu_waves_per_eu(2, 4)))
__global__ void waves_per_eu_2_4() {}

__attribute__((amdgpu_num_sgpr(32)))
__global__ void num_sgpr_32() {}

__attribute__((amdgpu_num_vgpr(64)))
__global__ void num_vgpr_64() {}


__attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2)))
__global__ void flat_work_group_size_32_64_waves_per_eu_2() {}

__attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2, 4)))
__global__ void flat_work_group_size_32_64_waves_per_eu_2_4() {}

__attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_num_sgpr(32)))
__global__ void flat_work_group_size_32_64_num_sgpr_32() {}

__attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_num_vgpr(64)))
__global__ void flat_work_group_size_32_64_num_vgpr_64() {}

__attribute__((amdgpu_waves_per_eu(2), amdgpu_num_sgpr(32)))
__global__ void waves_per_eu_2_num_sgpr_32() {}

__attribute__((amdgpu_waves_per_eu(2), amdgpu_num_vgpr(64)))
__global__ void waves_per_eu_2_num_vgpr_64() {}

__attribute__((amdgpu_waves_per_eu(2, 4), amdgpu_num_sgpr(32)))
__global__ void waves_per_eu_2_4_num_sgpr_32() {}

__attribute__((amdgpu_waves_per_eu(2, 4), amdgpu_num_vgpr(64)))
__global__ void waves_per_eu_2_4_num_vgpr_64() {}

__attribute__((amdgpu_num_sgpr(32), amdgpu_num_vgpr(64)))
__global__ void num_sgpr_32_num_vgpr_64() {}

__attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2), amdgpu_num_sgpr(32)))
__global__ void flat_work_group_size_32_64_waves_per_eu_2_num_sgpr_32() {}

__attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2), amdgpu_num_vgpr(64)))
__global__ void flat_work_group_size_32_64_waves_per_eu_2_num_vgpr_64() {}

__attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2, 4), amdgpu_num_sgpr(32)))
__global__ void flat_work_group_size_32_64_waves_per_eu_2_4_num_sgpr_32() {}

__attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2, 4), amdgpu_num_vgpr(64)))
__global__ void flat_work_group_size_32_64_waves_per_eu_2_4_num_vgpr_64() {}

__attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2), amdgpu_num_sgpr(32), amdgpu_num_vgpr(64)))
__global__ void flat_work_group_size_32_64_waves_per_eu_2_num_sgpr_32_num_vgpr_64() {}

__attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2, 4), amdgpu_num_sgpr(32), amdgpu_num_vgpr(64)))
__global__ void flat_work_group_size_32_64_waves_per_eu_2_4_num_sgpr_32_num_vgpr_64() {}

__attribute__((amdgpu_max_num_work_groups(32, 1, 1)))
__global__ void max_num_work_groups_32_1_1() {}

__attribute__((amdgpu_max_num_work_groups(32, 1, 1), amdgpu_flat_work_group_size(32, 64)))
__global__ void max_num_work_groups_32_1_1_flat_work_group_size_32_64() {}

__attribute__((amdgpu_max_num_work_groups(32, 1, 1), amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2, 4), amdgpu_num_sgpr(32), amdgpu_num_vgpr(64)))
__global__ void max_num_work_groups_32_1_1_flat_work_group_size_32_64_waves_per_eu_2_4_num_sgpr_32_num_vgpr_64() {}


// expected-error@+2{{attribute 'reqd_work_group_size' can only be applied to an OpenCL kernel function}}
__attribute__((reqd_work_group_size(32, 64, 64)))
__global__ void reqd_work_group_size_32_64_64() {}

// expected-error@+2{{attribute 'work_group_size_hint' can only be applied to an OpenCL kernel function}}
__attribute__((work_group_size_hint(2, 2, 2)))
__global__ void work_group_size_hint_2_2_2() {}

// expected-error@+2{{attribute 'vec_type_hint' can only be applied to an OpenCL kernel function}}
__attribute__((vec_type_hint(int)))
__global__ void vec_type_hint_int() {}

// expected-error@+2{{attribute 'intel_reqd_sub_group_size' can only be applied to an OpenCL kernel function}}
__attribute__((intel_reqd_sub_group_size(64)))
__global__ void intel_reqd_sub_group_size_64() {}

// expected-error@+1{{'amdgpu_flat_work_group_size' attribute requires parameter 0 to be an integer constant}}
__attribute__((amdgpu_flat_work_group_size("32", 64)))
__global__ void non_int_min_flat_work_group_size_32_64() {}
// expected-error@+1{{'amdgpu_flat_work_group_size' attribute requires parameter 1 to be an integer constant}}
__attribute__((amdgpu_flat_work_group_size(32, "64")))
__global__ void non_int_max_flat_work_group_size_32_64() {}

int nc_min = 32, nc_max = 64;
// expected-error@+1{{'amdgpu_flat_work_group_size' attribute requires parameter 0 to be an integer constant}}
__attribute__((amdgpu_flat_work_group_size(nc_min, 64)))
__global__ void non_cint_min_flat_work_group_size_32_64() {}
// expected-error@+1{{'amdgpu_flat_work_group_size' attribute requires parameter 1 to be an integer constant}}
__attribute__((amdgpu_flat_work_group_size(32, nc_max)))
__global__ void non_cint_max_flat_work_group_size_32_64() {}

const int c_min = 16, c_max = 32;
__attribute__((amdgpu_flat_work_group_size(c_min * 2, 64)))
__global__ void cint_min_flat_work_group_size_32_64() {}
__attribute__((amdgpu_flat_work_group_size(32, c_max * 2)))
__global__ void cint_max_flat_work_group_size_32_64() {}

// expected-error@+3{{'T' does not refer to a value}}
// expected-note@+1{{declared here}}
template<typename T>
__attribute__((amdgpu_flat_work_group_size(T, 64)))
__global__ void template_class_min_flat_work_group_size_32_64() {}
// expected-error@+3{{'T' does not refer to a value}}
// expected-note@+1{{declared here}}
template<typename T>
__attribute__((amdgpu_flat_work_group_size(32, T)))
__global__ void template_class_max_flat_work_group_size_32_64() {}

template<unsigned a, unsigned b>
__attribute__((amdgpu_flat_work_group_size(a, b)))
__global__ void template_flat_work_group_size_32_64() {}
template __global__ void template_flat_work_group_size_32_64<32, 64>();

template<unsigned a, unsigned b, unsigned c>
__attribute__((amdgpu_flat_work_group_size(a + b, b + c)))
__global__ void template_complex_flat_work_group_size_32_64() {}
template __global__ void template_complex_flat_work_group_size_32_64<16, 16, 48>();

unsigned ipow2(unsigned n) { return n == 0 ? 1 : 2 * ipow2(n - 1); }
constexpr unsigned ce_ipow2(unsigned n) { return n == 0 ? 1 : 2 * ce_ipow2(n - 1); }

__attribute__((amdgpu_flat_work_group_size(ce_ipow2(5), ce_ipow2(6))))
__global__ void cexpr_flat_work_group_size_32_64() {}
// expected-error@+1{{'amdgpu_flat_work_group_size' attribute requires parameter 0 to be an integer constant}}
__attribute__((amdgpu_flat_work_group_size(ipow2(5), 64)))
__global__ void non_cexpr_min_flat_work_group_size_32_64() {}
// expected-error@+1{{'amdgpu_flat_work_group_size' attribute requires parameter 1 to be an integer constant}}
__attribute__((amdgpu_flat_work_group_size(32, ipow2(6))))
__global__ void non_cexpr_max_flat_work_group_size_32_64() {}

// expected-error@+1{{'amdgpu_waves_per_eu' attribute requires parameter 0 to be an integer constant}}
__attribute__((amdgpu_waves_per_eu("2")))
__global__ void non_int_min_waves_per_eu_2() {}
// expected-error@+1{{'amdgpu_waves_per_eu' attribute requires parameter 1 to be an integer constant}}
__attribute__((amdgpu_waves_per_eu(2, "4")))
__global__ void non_int_max_waves_per_eu_2_4() {}

// expected-error@+1{{'amdgpu_waves_per_eu' attribute requires parameter 0 to be an integer constant}}
__attribute__((amdgpu_waves_per_eu(nc_min)))
__global__ void non_cint_min_waves_per_eu_2() {}
// expected-error@+1{{'amdgpu_waves_per_eu' attribute requires parameter 1 to be an integer constant}}
__attribute__((amdgpu_waves_per_eu(2, nc_max)))
__global__ void non_cint_min_waves_per_eu_2_4() {}

__attribute__((amdgpu_waves_per_eu(c_min / 8)))
__global__ void cint_min_waves_per_eu_2() {}
__attribute__((amdgpu_waves_per_eu(c_min / 8, c_max / 8)))
__global__ void cint_min_waves_per_eu_2_4() {}

// expected-error@+3{{'T' does not refer to a value}}
// expected-note@+1{{declared here}}
template<typename T>
__attribute__((amdgpu_waves_per_eu(T)))
__global__ void cint_min_waves_per_eu_2() {}
// expected-error@+3{{'T' does not refer to a value}}
// expected-note@+1{{declared here}}
template<typename T>
__attribute__((amdgpu_waves_per_eu(2, T)))
__global__ void cint_min_waves_per_eu_2_4() {}

template<unsigned a>
__attribute__((amdgpu_waves_per_eu(a)))
__global__ void template_waves_per_eu_2() {}
template __global__ void template_waves_per_eu_2<2>();

template<unsigned a, unsigned b>
__attribute__((amdgpu_waves_per_eu(a, b)))
__global__ void template_waves_per_eu_2_4() {}
template __global__ void template_waves_per_eu_2_4<2, 4>();

template<unsigned a, unsigned b, unsigned c>
__attribute__((amdgpu_waves_per_eu(a + b, c - b)))
__global__ void template_complex_waves_per_eu_2_4() {}
template __global__ void template_complex_waves_per_eu_2_4<1, 1, 5>();

// expected-error@+2{{expression contains unexpanded parameter pack 'Args'}}
template<unsigned... Args>
__attribute__((amdgpu_waves_per_eu(Args)))
__global__ void template_waves_per_eu_2() {}
template __global__ void template_waves_per_eu_2<2, 4>();

__attribute__((amdgpu_waves_per_eu(ce_ipow2(1))))
__global__ void cexpr_waves_per_eu_2() {}
__attribute__((amdgpu_waves_per_eu(ce_ipow2(1), ce_ipow2(2))))
__global__ void cexpr_waves_per_eu_2_4() {}
// expected-error@+1{{'amdgpu_waves_per_eu' attribute requires parameter 0 to be an integer constant}}
__attribute__((amdgpu_waves_per_eu(ipow2(1))))
__global__ void non_cexpr_waves_per_eu_2() {}
// expected-error@+1{{'amdgpu_waves_per_eu' attribute requires parameter 1 to be an integer constant}}
__attribute__((amdgpu_waves_per_eu(2, ipow2(2))))
__global__ void non_cexpr_waves_per_eu_2_4() {}

__attribute__((amdgpu_max_num_work_groups(32)))
__global__ void max_num_work_groups_32() {}

__attribute__((amdgpu_max_num_work_groups(32, 1)))
__global__ void max_num_work_groups_32_1() {}

// expected-error@+1{{'amdgpu_max_num_work_groups' attribute takes no more than 3 arguments}}
__attribute__((amdgpu_max_num_work_groups(32, 1, 1, 1)))
__global__ void max_num_work_groups_32_1_1_1() {}

// expected-error@+1{{'amdgpu_max_num_work_groups' attribute takes at least 1 argument}}
__attribute__((amdgpu_max_num_work_groups()))
__global__ void max_num_work_groups_no_arg() {}

// expected-error@+1{{expected expression}}
__attribute__((amdgpu_max_num_work_groups(,1,1)))
__global__ void max_num_work_groups_empty_1_1() {}

// expected-error@+1{{expected expression}}
__attribute__((amdgpu_max_num_work_groups(32,,1)))
__global__ void max_num_work_groups_32_empty_1() {}

// expected-error@+1{{'amdgpu_max_num_work_groups' attribute requires parameter 0 to be an integer constant}}
__attribute__((amdgpu_max_num_work_groups(ipow2(5), 1, 1)))
__global__ void max_num_work_groups_32_1_1_non_int_arg0() {}

// expected-error@+1{{'amdgpu_max_num_work_groups' attribute requires parameter 1 to be an integer constant}}
__attribute__((amdgpu_max_num_work_groups(32, "1", 1)))
__global__ void max_num_work_groups_32_1_1_non_int_arg1() {}

// expected-error@+1{{'amdgpu_max_num_work_groups' attribute requires a non-negative integral compile time constant expression}}
__attribute__((amdgpu_max_num_work_groups(-32, 1, 1)))
__global__ void max_num_work_groups_32_1_1_neg_int_arg0() {}

// expected-error@+1{{'amdgpu_max_num_work_groups' attribute requires a non-negative integral compile time constant expression}}
__attribute__((amdgpu_max_num_work_groups(32, -1, 1)))
__global__ void max_num_work_groups_32_1_1_neg_int_arg1() {}

// expected-error@+1{{'amdgpu_max_num_work_groups' attribute requires a non-negative integral compile time constant expression}}
__attribute__((amdgpu_max_num_work_groups(32, 1, -1)))
__global__ void max_num_work_groups_32_1_1_neg_int_arg2() {}

// expected-error@+1{{'amdgpu_max_num_work_groups' attribute must be greater than 0}}
__attribute__((amdgpu_max_num_work_groups(0, 1, 1)))
__global__ void max_num_work_groups_0_1_1() {}

// expected-error@+1{{'amdgpu_max_num_work_groups' attribute must be greater than 0}}
__attribute__((amdgpu_max_num_work_groups(32, 0, 1)))
__global__ void max_num_work_groups_32_0_1() {}

// expected-error@+1{{'amdgpu_max_num_work_groups' attribute must be greater than 0}}
__attribute__((amdgpu_max_num_work_groups(32, 1, 0)))
__global__ void max_num_work_groups_32_1_0() {}

__attribute__((amdgpu_max_num_work_groups(4294967295)))
__global__ void max_num_work_groups_max_unsigned_int() {}

// expected-error@+1{{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
__attribute__((amdgpu_max_num_work_groups(4294967296)))
__global__ void max_num_work_groups_max_unsigned_int_plus1() {}

// expected-error@+1{{integer constant expression evaluates to value 10000000000 that cannot be represented in a 32-bit unsigned integer type}}
__attribute__((amdgpu_max_num_work_groups(10000000000)))
__global__ void max_num_work_groups_too_large() {}

int num_wg_x = 32;
int num_wg_y = 1;
int num_wg_z = 1;
// expected-error@+1{{'amdgpu_max_num_work_groups' attribute requires parameter 0 to be an integer constant}}
__attribute__((amdgpu_max_num_work_groups(num_wg_x, 1, 1)))
__global__ void max_num_work_groups_32_1_1_non_const_arg0() {}

// expected-error@+1{{'amdgpu_max_num_work_groups' attribute requires parameter 1 to be an integer constant}}
__attribute__((amdgpu_max_num_work_groups(32, num_wg_y, 1)))
__global__ void max_num_work_groups_32_1_1_non_const_arg1() {}

// expected-error@+1{{'amdgpu_max_num_work_groups' attribute requires parameter 2 to be an integer constant}}
__attribute__((amdgpu_max_num_work_groups(32, 1, num_wg_z)))
__global__ void max_num_work_groups_32_1_1_non_const_arg2() {}

const int c_num_wg_x = 32;
__attribute__((amdgpu_max_num_work_groups(c_num_wg_x, 1, 1)))
__global__ void max_num_work_groups_32_1_1_const_arg0() {}

template<unsigned a>
__attribute__((amdgpu_max_num_work_groups(a, 1, 1)))
__global__ void template_a_1_1_max_num_work_groups() {}
template __global__ void template_a_1_1_max_num_work_groups<32>();

template<unsigned a>
__attribute__((amdgpu_max_num_work_groups(32, a, 1)))
__global__ void template_32_a_1_max_num_work_groups() {}
template __global__ void template_32_a_1_max_num_work_groups<1>();

template<unsigned a>
__attribute__((amdgpu_max_num_work_groups(32, 1, a)))
__global__ void template_32_1_a_max_num_work_groups() {}
template __global__ void template_32_1_a_max_num_work_groups<1>();

// expected-error@+3{{'amdgpu_max_num_work_groups' attribute must be greater than 0}}
// expected-note@+4{{in instantiation of}}
template<unsigned b>
__attribute__((amdgpu_max_num_work_groups(b, 1, 1)))
__global__ void template_b_1_1_max_num_work_groups() {}
template __global__ void template_b_1_1_max_num_work_groups<0>();

// expected-error@+3{{'amdgpu_max_num_work_groups' attribute must be greater than 0}}
// expected-note@+4{{in instantiation of}}
template<unsigned b>
__attribute__((amdgpu_max_num_work_groups(32, b, 1)))
__global__ void template_32_b_1_max_num_work_groups() {}
template __global__ void template_32_b_1_max_num_work_groups<0>();

// expected-error@+3{{'amdgpu_max_num_work_groups' attribute must be greater than 0}}
// expected-note@+4{{in instantiation of}}
template<unsigned b>
__attribute__((amdgpu_max_num_work_groups(32, 1, b)))
__global__ void template_32_1_b_max_num_work_groups() {}
template __global__ void template_32_1_b_max_num_work_groups<0>();