1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2 #include "Inputs/cuda.h"
5 __attribute__((amdgpu_flat_work_group_size(32, 64)))
6 __global__ void flat_work_group_size_32_64() {}
8 __attribute__((amdgpu_waves_per_eu(2)))
9 __global__ void waves_per_eu_2() {}
11 __attribute__((amdgpu_waves_per_eu(2, 4)))
12 __global__ void waves_per_eu_2_4() {}
14 __attribute__((amdgpu_num_sgpr(32)))
15 __global__ void num_sgpr_32() {}
17 __attribute__((amdgpu_num_vgpr(64)))
18 __global__ void num_vgpr_64() {}
21 __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2)))
22 __global__ void flat_work_group_size_32_64_waves_per_eu_2() {}
24 __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2, 4)))
25 __global__ void flat_work_group_size_32_64_waves_per_eu_2_4() {}
27 __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_num_sgpr(32)))
28 __global__ void flat_work_group_size_32_64_num_sgpr_32() {}
30 __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_num_vgpr(64)))
31 __global__ void flat_work_group_size_32_64_num_vgpr_64() {}
33 __attribute__((amdgpu_waves_per_eu(2), amdgpu_num_sgpr(32)))
34 __global__ void waves_per_eu_2_num_sgpr_32() {}
36 __attribute__((amdgpu_waves_per_eu(2), amdgpu_num_vgpr(64)))
37 __global__ void waves_per_eu_2_num_vgpr_64() {}
39 __attribute__((amdgpu_waves_per_eu(2, 4), amdgpu_num_sgpr(32)))
40 __global__ void waves_per_eu_2_4_num_sgpr_32() {}
42 __attribute__((amdgpu_waves_per_eu(2, 4), amdgpu_num_vgpr(64)))
43 __global__ void waves_per_eu_2_4_num_vgpr_64() {}
45 __attribute__((amdgpu_num_sgpr(32), amdgpu_num_vgpr(64)))
46 __global__ void num_sgpr_32_num_vgpr_64() {}
48 __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2), amdgpu_num_sgpr(32)))
49 __global__ void flat_work_group_size_32_64_waves_per_eu_2_num_sgpr_32() {}
51 __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2), amdgpu_num_vgpr(64)))
52 __global__ void flat_work_group_size_32_64_waves_per_eu_2_num_vgpr_64() {}
54 __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2, 4), amdgpu_num_sgpr(32)))
55 __global__ void flat_work_group_size_32_64_waves_per_eu_2_4_num_sgpr_32() {}
57 __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2, 4), amdgpu_num_vgpr(64)))
58 __global__ void flat_work_group_size_32_64_waves_per_eu_2_4_num_vgpr_64() {}
60 __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2), amdgpu_num_sgpr(32), amdgpu_num_vgpr(64)))
61 __global__ void flat_work_group_size_32_64_waves_per_eu_2_num_sgpr_32_num_vgpr_64() {}
63 __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2, 4), amdgpu_num_sgpr(32), amdgpu_num_vgpr(64)))
64 __global__ void flat_work_group_size_32_64_waves_per_eu_2_4_num_sgpr_32_num_vgpr_64() {}
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)))
68 __global__ void reqd_work_group_size_32_64_64() {}
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)))
72 __global__ void work_group_size_hint_2_2_2() {}
74 // expected-error@+2{{attribute 'vec_type_hint' can only be applied to an OpenCL kernel function}}
75 __attribute__((vec_type_hint(int)))
76 __global__ void vec_type_hint_int() {}
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)))
80 __global__ void intel_reqd_sub_group_size_64() {}
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)))
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")))
87 __global__ void non_int_max_flat_work_group_size_32_64() {}
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)))
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)))
95 __global__ void non_cint_max_flat_work_group_size_32_64() {}
97 const int c_min = 16, c_max = 32;
98 __attribute__((amdgpu_flat_work_group_size(c_min * 2, 64)))
99 __global__ void cint_min_flat_work_group_size_32_64() {}
100 __attribute__((amdgpu_flat_work_group_size(32, c_max * 2)))
101 __global__ void cint_max_flat_work_group_size_32_64() {}
103 // expected-error@+3{{'T' does not refer to a value}}
104 // expected-note@+1{{declared here}}
106 __attribute__((amdgpu_flat_work_group_size(T, 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}}
111 __attribute__((amdgpu_flat_work_group_size(32, T)))
112 __global__ void template_class_max_flat_work_group_size_32_64() {}
114 template<unsigned a, unsigned b>
115 __attribute__((amdgpu_flat_work_group_size(a, b)))
116 __global__ void template_flat_work_group_size_32_64() {}
117 template __global__ void template_flat_work_group_size_32_64<32, 64>();
119 template<unsigned a, unsigned b, unsigned c>
120 __attribute__((amdgpu_flat_work_group_size(a + b, b + c)))
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>();
124 unsigned ipow2(unsigned n) { return n == 0 ? 1 : 2 * ipow2(n - 1); }
125 constexpr unsigned ce_ipow2(unsigned n) { return n == 0 ? 1 : 2 * ce_ipow2(n - 1); }
127 __attribute__((amdgpu_flat_work_group_size(ce_ipow2(5), ce_ipow2(6))))
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)))
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))))
134 __global__ void non_cexpr_max_flat_work_group_size_32_64() {}
136 // expected-error@+1{{'amdgpu_waves_per_eu' attribute requires parameter 0 to be an integer constant}}
137 __attribute__((amdgpu_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")))
141 __global__ void non_int_max_waves_per_eu_2_4() {}
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)))
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)))
148 __global__ void non_cint_min_waves_per_eu_2_4() {}
150 __attribute__((amdgpu_waves_per_eu(c_min / 8)))
151 __global__ void cint_min_waves_per_eu_2() {}
152 __attribute__((amdgpu_waves_per_eu(c_min / 8, c_max / 8)))
153 __global__ void cint_min_waves_per_eu_2_4() {}
155 // expected-error@+3{{'T' does not refer to a value}}
156 // expected-note@+1{{declared here}}
158 __attribute__((amdgpu_waves_per_eu(T)))
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}}
163 __attribute__((amdgpu_waves_per_eu(2, T)))
164 __global__ void cint_min_waves_per_eu_2_4() {}
167 __attribute__((amdgpu_waves_per_eu(a)))
168 __global__ void template_waves_per_eu_2() {}
169 template __global__ void template_waves_per_eu_2<2>();
171 template<unsigned a, unsigned b>
172 __attribute__((amdgpu_waves_per_eu(a, b)))
173 __global__ void template_waves_per_eu_2_4() {}
174 template __global__ void template_waves_per_eu_2_4<2, 4>();
176 template<unsigned a, unsigned b, unsigned c>
177 __attribute__((amdgpu_waves_per_eu(a + b, c - b)))
178 __global__ void template_complex_waves_per_eu_2_4() {}
179 template __global__ void template_complex_waves_per_eu_2_4<1, 1, 5>();
181 // expected-error@+2{{expression contains unexpanded parameter pack 'Args'}}
182 template<unsigned... Args>
183 __attribute__((amdgpu_waves_per_eu(Args)))
184 __global__ void template_waves_per_eu_2() {}
185 template __global__ void template_waves_per_eu_2<2, 4>();
187 __attribute__((amdgpu_waves_per_eu(ce_ipow2(1))))
188 __global__ void cexpr_waves_per_eu_2() {}
189 __attribute__((amdgpu_waves_per_eu(ce_ipow2(1), ce_ipow2(2))))
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))))
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))))
196 __global__ void non_cexpr_waves_per_eu_2_4() {}