1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2 #include "Inputs/cuda.h"
3
4
5 __attribute__((amdgpu_flat_work_group_size(32, 64)))
flat_work_group_size_32_64()6 __global__ void flat_work_group_size_32_64() {}
7
8 __attribute__((amdgpu_waves_per_eu(2)))
waves_per_eu_2()9 __global__ void waves_per_eu_2() {}
10
11 __attribute__((amdgpu_waves_per_eu(2, 4)))
waves_per_eu_2_4()12 __global__ void waves_per_eu_2_4() {}
13
14 __attribute__((amdgpu_num_sgpr(32)))
num_sgpr_32()15 __global__ void num_sgpr_32() {}
16
17 __attribute__((amdgpu_num_vgpr(64)))
num_vgpr_64()18 __global__ void num_vgpr_64() {}
19
20
21 __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2)))
flat_work_group_size_32_64_waves_per_eu_2()22 __global__ void flat_work_group_size_32_64_waves_per_eu_2() {}
23
24 __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2, 4)))
flat_work_group_size_32_64_waves_per_eu_2_4()25 __global__ void flat_work_group_size_32_64_waves_per_eu_2_4() {}
26
27 __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_num_sgpr(32)))
flat_work_group_size_32_64_num_sgpr_32()28 __global__ void flat_work_group_size_32_64_num_sgpr_32() {}
29
30 __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_num_vgpr(64)))
flat_work_group_size_32_64_num_vgpr_64()31 __global__ void flat_work_group_size_32_64_num_vgpr_64() {}
32
33 __attribute__((amdgpu_waves_per_eu(2), amdgpu_num_sgpr(32)))
waves_per_eu_2_num_sgpr_32()34 __global__ void waves_per_eu_2_num_sgpr_32() {}
35
36 __attribute__((amdgpu_waves_per_eu(2), amdgpu_num_vgpr(64)))
waves_per_eu_2_num_vgpr_64()37 __global__ void waves_per_eu_2_num_vgpr_64() {}
38
39 __attribute__((amdgpu_waves_per_eu(2, 4), amdgpu_num_sgpr(32)))
waves_per_eu_2_4_num_sgpr_32()40 __global__ void waves_per_eu_2_4_num_sgpr_32() {}
41
42 __attribute__((amdgpu_waves_per_eu(2, 4), amdgpu_num_vgpr(64)))
waves_per_eu_2_4_num_vgpr_64()43 __global__ void waves_per_eu_2_4_num_vgpr_64() {}
44
45 __attribute__((amdgpu_num_sgpr(32), amdgpu_num_vgpr(64)))
num_sgpr_32_num_vgpr_64()46 __global__ void num_sgpr_32_num_vgpr_64() {}
47
48 __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2), amdgpu_num_sgpr(32)))
flat_work_group_size_32_64_waves_per_eu_2_num_sgpr_32()49 __global__ void flat_work_group_size_32_64_waves_per_eu_2_num_sgpr_32() {}
50
51 __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2), amdgpu_num_vgpr(64)))
flat_work_group_size_32_64_waves_per_eu_2_num_vgpr_64()52 __global__ void flat_work_group_size_32_64_waves_per_eu_2_num_vgpr_64() {}
53
54 __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2, 4), amdgpu_num_sgpr(32)))
flat_work_group_size_32_64_waves_per_eu_2_4_num_sgpr_32()55 __global__ void flat_work_group_size_32_64_waves_per_eu_2_4_num_sgpr_32() {}
56
57 __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2, 4), amdgpu_num_vgpr(64)))
flat_work_group_size_32_64_waves_per_eu_2_4_num_vgpr_64()58 __global__ void flat_work_group_size_32_64_waves_per_eu_2_4_num_vgpr_64() {}
59
60 __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2), amdgpu_num_sgpr(32), amdgpu_num_vgpr(64)))
flat_work_group_size_32_64_waves_per_eu_2_num_sgpr_32_num_vgpr_64()61 __global__ void flat_work_group_size_32_64_waves_per_eu_2_num_sgpr_32_num_vgpr_64() {}
62
63 __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2, 4), amdgpu_num_sgpr(32), amdgpu_num_vgpr(64)))
flat_work_group_size_32_64_waves_per_eu_2_4_num_sgpr_32_num_vgpr_64()64 __global__ void flat_work_group_size_32_64_waves_per_eu_2_4_num_sgpr_32_num_vgpr_64() {}
65
66 // expected-error@+2{{attribute 'reqd_work_group_size' can only be applied to an OpenCL kernel function}}
67 __attribute__((reqd_work_group_size(32, 64, 64)))
reqd_work_group_size_32_64_64()68 __global__ void reqd_work_group_size_32_64_64() {}
69
70 // expected-error@+2{{attribute 'work_group_size_hint' can only be applied to an OpenCL kernel function}}
71 __attribute__((work_group_size_hint(2, 2, 2)))
work_group_size_hint_2_2_2()72 __global__ void work_group_size_hint_2_2_2() {}
73
74 // expected-error@+2{{attribute 'vec_type_hint' can only be applied to an OpenCL kernel function}}
75 __attribute__((vec_type_hint(int)))
vec_type_hint_int()76 __global__ void vec_type_hint_int() {}
77
78 // expected-error@+2{{attribute 'intel_reqd_sub_group_size' can only be applied to an OpenCL kernel function}}
79 __attribute__((intel_reqd_sub_group_size(64)))
intel_reqd_sub_group_size_64()80 __global__ void intel_reqd_sub_group_size_64() {}
81
82 // expected-error@+1{{'amdgpu_flat_work_group_size' attribute requires parameter 0 to be an integer constant}}
83 __attribute__((amdgpu_flat_work_group_size("32", 64)))
non_int_min_flat_work_group_size_32_64()84 __global__ void non_int_min_flat_work_group_size_32_64() {}
85 // expected-error@+1{{'amdgpu_flat_work_group_size' attribute requires parameter 1 to be an integer constant}}
86 __attribute__((amdgpu_flat_work_group_size(32, "64")))
non_int_max_flat_work_group_size_32_64()87 __global__ void non_int_max_flat_work_group_size_32_64() {}
88
89 int nc_min = 32, nc_max = 64;
90 // expected-error@+1{{'amdgpu_flat_work_group_size' attribute requires parameter 0 to be an integer constant}}
91 __attribute__((amdgpu_flat_work_group_size(nc_min, 64)))
non_cint_min_flat_work_group_size_32_64()92 __global__ void non_cint_min_flat_work_group_size_32_64() {}
93 // expected-error@+1{{'amdgpu_flat_work_group_size' attribute requires parameter 1 to be an integer constant}}
94 __attribute__((amdgpu_flat_work_group_size(32, nc_max)))
non_cint_max_flat_work_group_size_32_64()95 __global__ void non_cint_max_flat_work_group_size_32_64() {}
96
97 const int c_min = 16, c_max = 32;
98 __attribute__((amdgpu_flat_work_group_size(c_min * 2, 64)))
cint_min_flat_work_group_size_32_64()99 __global__ void cint_min_flat_work_group_size_32_64() {}
100 __attribute__((amdgpu_flat_work_group_size(32, c_max * 2)))
cint_max_flat_work_group_size_32_64()101 __global__ void cint_max_flat_work_group_size_32_64() {}
102
103 // expected-error@+3{{'T' does not refer to a value}}
104 // expected-note@+1{{declared here}}
105 template<typename T>
106 __attribute__((amdgpu_flat_work_group_size(T, 64)))
template_class_min_flat_work_group_size_32_64()107 __global__ void template_class_min_flat_work_group_size_32_64() {}
108 // expected-error@+3{{'T' does not refer to a value}}
109 // expected-note@+1{{declared here}}
110 template<typename T>
111 __attribute__((amdgpu_flat_work_group_size(32, T)))
template_class_max_flat_work_group_size_32_64()112 __global__ void template_class_max_flat_work_group_size_32_64() {}
113
114 template<unsigned a, unsigned b>
115 __attribute__((amdgpu_flat_work_group_size(a, b)))
template_flat_work_group_size_32_64()116 __global__ void template_flat_work_group_size_32_64() {}
117 template __global__ void template_flat_work_group_size_32_64<32, 64>();
118
119 template<unsigned a, unsigned b, unsigned c>
120 __attribute__((amdgpu_flat_work_group_size(a + b, b + c)))
template_complex_flat_work_group_size_32_64()121 __global__ void template_complex_flat_work_group_size_32_64() {}
122 template __global__ void template_complex_flat_work_group_size_32_64<16, 16, 48>();
123
ipow2(unsigned n)124 unsigned ipow2(unsigned n) { return n == 0 ? 1 : 2 * ipow2(n - 1); }
ce_ipow2(unsigned n)125 constexpr unsigned ce_ipow2(unsigned n) { return n == 0 ? 1 : 2 * ce_ipow2(n - 1); }
126
127 __attribute__((amdgpu_flat_work_group_size(ce_ipow2(5), ce_ipow2(6))))
cexpr_flat_work_group_size_32_64()128 __global__ void cexpr_flat_work_group_size_32_64() {}
129 // expected-error@+1{{'amdgpu_flat_work_group_size' attribute requires parameter 0 to be an integer constant}}
130 __attribute__((amdgpu_flat_work_group_size(ipow2(5), 64)))
non_cexpr_min_flat_work_group_size_32_64()131 __global__ void non_cexpr_min_flat_work_group_size_32_64() {}
132 // expected-error@+1{{'amdgpu_flat_work_group_size' attribute requires parameter 1 to be an integer constant}}
133 __attribute__((amdgpu_flat_work_group_size(32, ipow2(6))))
non_cexpr_max_flat_work_group_size_32_64()134 __global__ void non_cexpr_max_flat_work_group_size_32_64() {}
135
136 // expected-error@+1{{'amdgpu_waves_per_eu' attribute requires parameter 0 to be an integer constant}}
137 __attribute__((amdgpu_waves_per_eu("2")))
non_int_min_waves_per_eu_2()138 __global__ void non_int_min_waves_per_eu_2() {}
139 // expected-error@+1{{'amdgpu_waves_per_eu' attribute requires parameter 1 to be an integer constant}}
140 __attribute__((amdgpu_waves_per_eu(2, "4")))
non_int_max_waves_per_eu_2_4()141 __global__ void non_int_max_waves_per_eu_2_4() {}
142
143 // expected-error@+1{{'amdgpu_waves_per_eu' attribute requires parameter 0 to be an integer constant}}
144 __attribute__((amdgpu_waves_per_eu(nc_min)))
non_cint_min_waves_per_eu_2()145 __global__ void non_cint_min_waves_per_eu_2() {}
146 // expected-error@+1{{'amdgpu_waves_per_eu' attribute requires parameter 1 to be an integer constant}}
147 __attribute__((amdgpu_waves_per_eu(2, nc_max)))
non_cint_min_waves_per_eu_2_4()148 __global__ void non_cint_min_waves_per_eu_2_4() {}
149
150 __attribute__((amdgpu_waves_per_eu(c_min / 8)))
cint_min_waves_per_eu_2()151 __global__ void cint_min_waves_per_eu_2() {}
152 __attribute__((amdgpu_waves_per_eu(c_min / 8, c_max / 8)))
cint_min_waves_per_eu_2_4()153 __global__ void cint_min_waves_per_eu_2_4() {}
154
155 // expected-error@+3{{'T' does not refer to a value}}
156 // expected-note@+1{{declared here}}
157 template<typename T>
158 __attribute__((amdgpu_waves_per_eu(T)))
cint_min_waves_per_eu_2()159 __global__ void cint_min_waves_per_eu_2() {}
160 // expected-error@+3{{'T' does not refer to a value}}
161 // expected-note@+1{{declared here}}
162 template<typename T>
163 __attribute__((amdgpu_waves_per_eu(2, T)))
cint_min_waves_per_eu_2_4()164 __global__ void cint_min_waves_per_eu_2_4() {}
165
166 template<unsigned a>
167 __attribute__((amdgpu_waves_per_eu(a)))
template_waves_per_eu_2()168 __global__ void template_waves_per_eu_2() {}
169 template __global__ void template_waves_per_eu_2<2>();
170
171 template<unsigned a, unsigned b>
172 __attribute__((amdgpu_waves_per_eu(a, b)))
template_waves_per_eu_2_4()173 __global__ void template_waves_per_eu_2_4() {}
174 template __global__ void template_waves_per_eu_2_4<2, 4>();
175
176 template<unsigned a, unsigned b, unsigned c>
177 __attribute__((amdgpu_waves_per_eu(a + b, c - b)))
template_complex_waves_per_eu_2_4()178 __global__ void template_complex_waves_per_eu_2_4() {}
179 template __global__ void template_complex_waves_per_eu_2_4<1, 1, 5>();
180
181 // expected-error@+2{{expression contains unexpanded parameter pack 'Args'}}
182 template<unsigned... Args>
183 __attribute__((amdgpu_waves_per_eu(Args)))
template_waves_per_eu_2()184 __global__ void template_waves_per_eu_2() {}
185 template __global__ void template_waves_per_eu_2<2, 4>();
186
187 __attribute__((amdgpu_waves_per_eu(ce_ipow2(1))))
cexpr_waves_per_eu_2()188 __global__ void cexpr_waves_per_eu_2() {}
189 __attribute__((amdgpu_waves_per_eu(ce_ipow2(1), ce_ipow2(2))))
cexpr_waves_per_eu_2_4()190 __global__ void cexpr_waves_per_eu_2_4() {}
191 // expected-error@+1{{'amdgpu_waves_per_eu' attribute requires parameter 0 to be an integer constant}}
192 __attribute__((amdgpu_waves_per_eu(ipow2(1))))
non_cexpr_waves_per_eu_2()193 __global__ void non_cexpr_waves_per_eu_2() {}
194 // expected-error@+1{{'amdgpu_waves_per_eu' attribute requires parameter 1 to be an integer constant}}
195 __attribute__((amdgpu_waves_per_eu(2, ipow2(2))))
non_cexpr_waves_per_eu_2_4()196 __global__ void non_cexpr_waves_per_eu_2_4() {}
197