| 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))) |
| 6 |
__global__ void flat_work_group_size_32_64() {} |
| 7 |
|
| 8 |
__attribute__((amdgpu_waves_per_eu(2))) |
| 9 |
__global__ void waves_per_eu_2() {} |
| 10 |
|
| 11 |
__attribute__((amdgpu_waves_per_eu(2, 4))) |
| 12 |
__global__ void waves_per_eu_2_4() {} |
| 13 |
|
| 14 |
__attribute__((amdgpu_num_sgpr(32))) |
| 15 |
__global__ void num_sgpr_32() {} |
| 16 |
|
| 17 |
__attribute__((amdgpu_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))) |
| 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))) |
| 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))) |
| 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))) |
| 31 |
__global__ void flat_work_group_size_32_64_num_vgpr_64() {} |
| 32 |
|
| 33 |
__attribute__((amdgpu_waves_per_eu(2), amdgpu_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))) |
| 37 |
__global__ void waves_per_eu_2_num_vgpr_64() {} |
| 38 |
|
| 39 |
__attribute__((amdgpu_waves_per_eu(2, 4), amdgpu_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))) |
| 43 |
__global__ void waves_per_eu_2_4_num_vgpr_64() {} |
| 44 |
|
| 45 |
__attribute__((amdgpu_num_sgpr(32), amdgpu_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))) |
| 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))) |
| 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))) |
| 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))) |
| 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))) |
| 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))) |
| 64 |
__global__ void flat_work_group_size_32_64_waves_per_eu_2_4_num_sgpr_32_num_vgpr_64() {} |
| 65 |
|
| 66 |
__attribute__((amdgpu_max_num_work_groups(32, 1, 1))) |
| 67 |
__global__ void max_num_work_groups_32_1_1() {} |
| 68 |
|
| 69 |
__attribute__((amdgpu_max_num_work_groups(32, 1, 1), amdgpu_flat_work_group_size(32, 64))) |
| 70 |
__global__ void max_num_work_groups_32_1_1_flat_work_group_size_32_64() {} |
| 71 |
|
| 72 |
__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))) |
| 73 |
__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() {} |
| 74 |
|
| 75 |
|
| 76 |
// expected-error@+2{{attribute 'reqd_work_group_size' can only be applied to an OpenCL kernel function}} |
| 77 |
__attribute__((reqd_work_group_size(32, 64, 64))) |
| 78 |
__global__ void reqd_work_group_size_32_64_64() {} |
| 79 |
|
| 80 |
// expected-error@+2{{attribute 'work_group_size_hint' can only be applied to an OpenCL kernel function}} |
| 81 |
__attribute__((work_group_size_hint(2, 2, 2))) |
| 82 |
__global__ void work_group_size_hint_2_2_2() {} |
| 83 |
|
| 84 |
// expected-error@+2{{attribute 'vec_type_hint' can only be applied to an OpenCL kernel function}} |
| 85 |
__attribute__((vec_type_hint(int))) |
| 86 |
__global__ void vec_type_hint_int() {} |
| 87 |
|
| 88 |
// expected-error@+2{{attribute 'intel_reqd_sub_group_size' can only be applied to an OpenCL kernel function}} |
| 89 |
__attribute__((intel_reqd_sub_group_size(64))) |
| 90 |
__global__ void intel_reqd_sub_group_size_64() {} |
| 91 |
|
| 92 |
// expected-error@+1{{'amdgpu_flat_work_group_size' attribute requires parameter 0 to be an integer constant}} |
| 93 |
__attribute__((amdgpu_flat_work_group_size("32", 64))) |
| 94 |
__global__ void non_int_min_flat_work_group_size_32_64() {} |
| 95 |
// expected-error@+1{{'amdgpu_flat_work_group_size' attribute requires parameter 1 to be an integer constant}} |
| 96 |
__attribute__((amdgpu_flat_work_group_size(32, "64"))) |
| 97 |
__global__ void non_int_max_flat_work_group_size_32_64() {} |
| 98 |
|
| 99 |
int nc_min = 32, nc_max = 64; |
| 100 |
// expected-error@+1{{'amdgpu_flat_work_group_size' attribute requires parameter 0 to be an integer constant}} |
| 101 |
__attribute__((amdgpu_flat_work_group_size(nc_min, 64))) |
| 102 |
__global__ void non_cint_min_flat_work_group_size_32_64() {} |
| 103 |
// expected-error@+1{{'amdgpu_flat_work_group_size' attribute requires parameter 1 to be an integer constant}} |
| 104 |
__attribute__((amdgpu_flat_work_group_size(32, nc_max))) |
| 105 |
__global__ void non_cint_max_flat_work_group_size_32_64() {} |
| 106 |
|
| 107 |
const int c_min = 16, c_max = 32; |
| 108 |
__attribute__((amdgpu_flat_work_group_size(c_min * 2, 64))) |
| 109 |
__global__ void cint_min_flat_work_group_size_32_64() {} |
| 110 |
__attribute__((amdgpu_flat_work_group_size(32, c_max * 2))) |
| 111 |
__global__ void cint_max_flat_work_group_size_32_64() {} |
| 112 |
|
| 113 |
// expected-error@+3{{'T' does not refer to a value}} |
| 114 |
// expected-note@+1{{declared here}} |
| 115 |
template<typename T> |
| 116 |
__attribute__((amdgpu_flat_work_group_size(T, 64))) |
| 117 |
__global__ void template_class_min_flat_work_group_size_32_64() {} |
| 118 |
// expected-error@+3{{'T' does not refer to a value}} |
| 119 |
// expected-note@+1{{declared here}} |
| 120 |
template<typename T> |
| 121 |
__attribute__((amdgpu_flat_work_group_size(32, T))) |
| 122 |
__global__ void template_class_max_flat_work_group_size_32_64() {} |
| 123 |
|
| 124 |
template<unsigned a, unsigned b> |
| 125 |
__attribute__((amdgpu_flat_work_group_size(a, b))) |
| 126 |
__global__ void template_flat_work_group_size_32_64() {} |
| 127 |
template __global__ void template_flat_work_group_size_32_64<32, 64>(); |
| 128 |
|
| 129 |
template<unsigned a, unsigned b, unsigned c> |
| 130 |
__attribute__((amdgpu_flat_work_group_size(a + b, b + c))) |
| 131 |
__global__ void template_complex_flat_work_group_size_32_64() {} |
| 132 |
template __global__ void template_complex_flat_work_group_size_32_64<16, 16, 48>(); |
| 133 |
|
| 134 |
unsigned ipow2(unsigned n) { return n == 0 ? 1 : 2 * ipow2(n - 1); } |
| 135 |
constexpr unsigned ce_ipow2(unsigned n) { return n == 0 ? 1 : 2 * ce_ipow2(n - 1); } |
| 136 |
|
| 137 |
__attribute__((amdgpu_flat_work_group_size(ce_ipow2(5), ce_ipow2(6)))) |
| 138 |
__global__ void cexpr_flat_work_group_size_32_64() {} |
| 139 |
// expected-error@+1{{'amdgpu_flat_work_group_size' attribute requires parameter 0 to be an integer constant}} |
| 140 |
__attribute__((amdgpu_flat_work_group_size(ipow2(5), 64))) |
| 141 |
__global__ void non_cexpr_min_flat_work_group_size_32_64() {} |
| 142 |
// expected-error@+1{{'amdgpu_flat_work_group_size' attribute requires parameter 1 to be an integer constant}} |
| 143 |
__attribute__((amdgpu_flat_work_group_size(32, ipow2(6)))) |
| 144 |
__global__ void non_cexpr_max_flat_work_group_size_32_64() {} |
| 145 |
|
| 146 |
// expected-error@+1{{'amdgpu_waves_per_eu' attribute requires parameter 0 to be an integer constant}} |
| 147 |
__attribute__((amdgpu_waves_per_eu("2"))) |
| 148 |
__global__ void non_int_min_waves_per_eu_2() {} |
| 149 |
// expected-error@+1{{'amdgpu_waves_per_eu' attribute requires parameter 1 to be an integer constant}} |
| 150 |
__attribute__((amdgpu_waves_per_eu(2, "4"))) |
| 151 |
__global__ void non_int_max_waves_per_eu_2_4() {} |
| 152 |
|
| 153 |
// expected-error@+1{{'amdgpu_waves_per_eu' attribute requires parameter 0 to be an integer constant}} |
| 154 |
__attribute__((amdgpu_waves_per_eu(nc_min))) |
| 155 |
__global__ void non_cint_min_waves_per_eu_2() {} |
| 156 |
// expected-error@+1{{'amdgpu_waves_per_eu' attribute requires parameter 1 to be an integer constant}} |
| 157 |
__attribute__((amdgpu_waves_per_eu(2, nc_max))) |
| 158 |
__global__ void non_cint_min_waves_per_eu_2_4() {} |
| 159 |
|
| 160 |
__attribute__((amdgpu_waves_per_eu(c_min / 8))) |
| 161 |
__global__ void cint_min_waves_per_eu_2() {} |
| 162 |
__attribute__((amdgpu_waves_per_eu(c_min / 8, c_max / 8))) |
| 163 |
__global__ void cint_min_waves_per_eu_2_4() {} |
| 164 |
|
| 165 |
// expected-error@+3{{'T' does not refer to a value}} |
| 166 |
// expected-note@+1{{declared here}} |
| 167 |
template<typename T> |
| 168 |
__attribute__((amdgpu_waves_per_eu(T))) |
| 169 |
__global__ void cint_min_waves_per_eu_2() {} |
| 170 |
// expected-error@+3{{'T' does not refer to a value}} |
| 171 |
// expected-note@+1{{declared here}} |
| 172 |
template<typename T> |
| 173 |
__attribute__((amdgpu_waves_per_eu(2, T))) |
| 174 |
__global__ void cint_min_waves_per_eu_2_4() {} |
| 175 |
|
| 176 |
template<unsigned a> |
| 177 |
__attribute__((amdgpu_waves_per_eu(a))) |
| 178 |
__global__ void template_waves_per_eu_2() {} |
| 179 |
template __global__ void template_waves_per_eu_2<2>(); |
| 180 |
|
| 181 |
template<unsigned a, unsigned b> |
| 182 |
__attribute__((amdgpu_waves_per_eu(a, b))) |
| 183 |
__global__ void template_waves_per_eu_2_4() {} |
| 184 |
template __global__ void template_waves_per_eu_2_4<2, 4>(); |
| 185 |
|
| 186 |
template<unsigned a, unsigned b, unsigned c> |
| 187 |
__attribute__((amdgpu_waves_per_eu(a + b, c - b))) |
| 188 |
__global__ void template_complex_waves_per_eu_2_4() {} |
| 189 |
template __global__ void template_complex_waves_per_eu_2_4<1, 1, 5>(); |
| 190 |
|
| 191 |
// expected-error@+2{{expression contains unexpanded parameter pack 'Args'}} |
| 192 |
template<unsigned... Args> |
| 193 |
__attribute__((amdgpu_waves_per_eu(Args))) |
| 194 |
__global__ void template_waves_per_eu_2() {} |
| 195 |
template __global__ void template_waves_per_eu_2<2, 4>(); |
| 196 |
|
| 197 |
__attribute__((amdgpu_waves_per_eu(ce_ipow2(1)))) |
| 198 |
__global__ void cexpr_waves_per_eu_2() {} |
| 199 |
__attribute__((amdgpu_waves_per_eu(ce_ipow2(1), ce_ipow2(2)))) |
| 200 |
__global__ void cexpr_waves_per_eu_2_4() {} |
| 201 |
// expected-error@+1{{'amdgpu_waves_per_eu' attribute requires parameter 0 to be an integer constant}} |
| 202 |
__attribute__((amdgpu_waves_per_eu(ipow2(1)))) |
| 203 |
__global__ void non_cexpr_waves_per_eu_2() {} |
| 204 |
// expected-error@+1{{'amdgpu_waves_per_eu' attribute requires parameter 1 to be an integer constant}} |
| 205 |
__attribute__((amdgpu_waves_per_eu(2, ipow2(2)))) |
| 206 |
__global__ void non_cexpr_waves_per_eu_2_4() {} |
| 207 |
|
| 208 |
__attribute__((amdgpu_max_num_work_groups(32))) |
| 209 |
__global__ void max_num_work_groups_32() {} |
| 210 |
|
| 211 |
__attribute__((amdgpu_max_num_work_groups(32, 1))) |
| 212 |
__global__ void max_num_work_groups_32_1() {} |
| 213 |
|
| 214 |
// expected-error@+1{{'amdgpu_max_num_work_groups' attribute takes no more than 3 arguments}} |
| 215 |
__attribute__((amdgpu_max_num_work_groups(32, 1, 1, 1))) |
| 216 |
__global__ void max_num_work_groups_32_1_1_1() {} |
| 217 |
|
| 218 |
// expected-error@+1{{'amdgpu_max_num_work_groups' attribute takes at least 1 argument}} |
| 219 |
__attribute__((amdgpu_max_num_work_groups())) |
| 220 |
__global__ void max_num_work_groups_no_arg() {} |
| 221 |
|
| 222 |
// expected-error@+1{{expected expression}} |
| 223 |
__attribute__((amdgpu_max_num_work_groups(,1,1))) |
| 224 |
__global__ void max_num_work_groups_empty_1_1() {} |
| 225 |
|
| 226 |
// expected-error@+1{{expected expression}} |
| 227 |
__attribute__((amdgpu_max_num_work_groups(32,,1))) |
| 228 |
__global__ void max_num_work_groups_32_empty_1() {} |
| 229 |
|
| 230 |
// expected-error@+1{{'amdgpu_max_num_work_groups' attribute requires parameter 0 to be an integer constant}} |
| 231 |
__attribute__((amdgpu_max_num_work_groups(ipow2(5), 1, 1))) |
| 232 |
__global__ void max_num_work_groups_32_1_1_non_int_arg0() {} |
| 233 |
|
| 234 |
// expected-error@+1{{'amdgpu_max_num_work_groups' attribute requires parameter 1 to be an integer constant}} |
| 235 |
__attribute__((amdgpu_max_num_work_groups(32, "1", 1))) |
| 236 |
__global__ void max_num_work_groups_32_1_1_non_int_arg1() {} |
| 237 |
|
| 238 |
// expected-error@+1{{'amdgpu_max_num_work_groups' attribute requires a non-negative integral compile time constant expression}} |
| 239 |
__attribute__((amdgpu_max_num_work_groups(-32, 1, 1))) |
| 240 |
__global__ void max_num_work_groups_32_1_1_neg_int_arg0() {} |
| 241 |
|
| 242 |
// expected-error@+1{{'amdgpu_max_num_work_groups' attribute requires a non-negative integral compile time constant expression}} |
| 243 |
__attribute__((amdgpu_max_num_work_groups(32, -1, 1))) |
| 244 |
__global__ void max_num_work_groups_32_1_1_neg_int_arg1() {} |
| 245 |
|
| 246 |
// expected-error@+1{{'amdgpu_max_num_work_groups' attribute requires a non-negative integral compile time constant expression}} |
| 247 |
__attribute__((amdgpu_max_num_work_groups(32, 1, -1))) |
| 248 |
__global__ void max_num_work_groups_32_1_1_neg_int_arg2() {} |
| 249 |
|
| 250 |
// expected-error@+1{{'amdgpu_max_num_work_groups' attribute must be greater than 0}} |
| 251 |
__attribute__((amdgpu_max_num_work_groups(0, 1, 1))) |
| 252 |
__global__ void max_num_work_groups_0_1_1() {} |
| 253 |
|
| 254 |
// expected-error@+1{{'amdgpu_max_num_work_groups' attribute must be greater than 0}} |
| 255 |
__attribute__((amdgpu_max_num_work_groups(32, 0, 1))) |
| 256 |
__global__ void max_num_work_groups_32_0_1() {} |
| 257 |
|
| 258 |
// expected-error@+1{{'amdgpu_max_num_work_groups' attribute must be greater than 0}} |
| 259 |
__attribute__((amdgpu_max_num_work_groups(32, 1, 0))) |
| 260 |
__global__ void max_num_work_groups_32_1_0() {} |
| 261 |
|
| 262 |
__attribute__((amdgpu_max_num_work_groups(4294967295))) |
| 263 |
__global__ void max_num_work_groups_max_unsigned_int() {} |
| 264 |
|
| 265 |
// expected-error@+1{{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}} |
| 266 |
__attribute__((amdgpu_max_num_work_groups(4294967296))) |
| 267 |
__global__ void max_num_work_groups_max_unsigned_int_plus1() {} |
| 268 |
|
| 269 |
// expected-error@+1{{integer constant expression evaluates to value 10000000000 that cannot be represented in a 32-bit unsigned integer type}} |
| 270 |
__attribute__((amdgpu_max_num_work_groups(10000000000))) |
| 271 |
__global__ void max_num_work_groups_too_large() {} |
| 272 |
|
| 273 |
int num_wg_x = 32; |
| 274 |
int num_wg_y = 1; |
| 275 |
int num_wg_z = 1; |
| 276 |
// expected-error@+1{{'amdgpu_max_num_work_groups' attribute requires parameter 0 to be an integer constant}} |
| 277 |
__attribute__((amdgpu_max_num_work_groups(num_wg_x, 1, 1))) |
| 278 |
__global__ void max_num_work_groups_32_1_1_non_const_arg0() {} |
| 279 |
|
| 280 |
// expected-error@+1{{'amdgpu_max_num_work_groups' attribute requires parameter 1 to be an integer constant}} |
| 281 |
__attribute__((amdgpu_max_num_work_groups(32, num_wg_y, 1))) |
| 282 |
__global__ void max_num_work_groups_32_1_1_non_const_arg1() {} |
| 283 |
|
| 284 |
// expected-error@+1{{'amdgpu_max_num_work_groups' attribute requires parameter 2 to be an integer constant}} |
| 285 |
__attribute__((amdgpu_max_num_work_groups(32, 1, num_wg_z))) |
| 286 |
__global__ void max_num_work_groups_32_1_1_non_const_arg2() {} |
| 287 |
|
| 288 |
const int c_num_wg_x = 32; |
| 289 |
__attribute__((amdgpu_max_num_work_groups(c_num_wg_x, 1, 1))) |
| 290 |
__global__ void max_num_work_groups_32_1_1_const_arg0() {} |
| 291 |
|
| 292 |
template<unsigned a> |
| 293 |
__attribute__((amdgpu_max_num_work_groups(a, 1, 1))) |
| 294 |
__global__ void template_a_1_1_max_num_work_groups() {} |
| 295 |
template __global__ void template_a_1_1_max_num_work_groups<32>(); |
| 296 |
|
| 297 |
template<unsigned a> |
| 298 |
__attribute__((amdgpu_max_num_work_groups(32, a, 1))) |
| 299 |
__global__ void template_32_a_1_max_num_work_groups() {} |
| 300 |
template __global__ void template_32_a_1_max_num_work_groups<1>(); |
| 301 |
|
| 302 |
template<unsigned a> |
| 303 |
__attribute__((amdgpu_max_num_work_groups(32, 1, a))) |
| 304 |
__global__ void template_32_1_a_max_num_work_groups() {} |
| 305 |
template __global__ void template_32_1_a_max_num_work_groups<1>(); |
| 306 |
|
| 307 |
// expected-error@+3{{'amdgpu_max_num_work_groups' attribute must be greater than 0}} |
| 308 |
// expected-note@+4{{in instantiation of}} |
| 309 |
template<unsigned b> |
| 310 |
__attribute__((amdgpu_max_num_work_groups(b, 1, 1))) |
| 311 |
__global__ void template_b_1_1_max_num_work_groups() {} |
| 312 |
template __global__ void template_b_1_1_max_num_work_groups<0>(); |
| 313 |
|
| 314 |
// expected-error@+3{{'amdgpu_max_num_work_groups' attribute must be greater than 0}} |
| 315 |
// expected-note@+4{{in instantiation of}} |
| 316 |
template<unsigned b> |
| 317 |
__attribute__((amdgpu_max_num_work_groups(32, b, 1))) |
| 318 |
__global__ void template_32_b_1_max_num_work_groups() {} |
| 319 |
template __global__ void template_32_b_1_max_num_work_groups<0>(); |
| 320 |
|
| 321 |
// expected-error@+3{{'amdgpu_max_num_work_groups' attribute must be greater than 0}} |
| 322 |
// expected-note@+4{{in instantiation of}} |
| 323 |
template<unsigned b> |
| 324 |
__attribute__((amdgpu_max_num_work_groups(32, 1, b))) |
| 325 |
__global__ void template_32_1_b_max_num_work_groups() {} |
| 326 |
template __global__ void template_32_1_b_max_num_work_groups<0>(); |
| 327 |
|
| 328 |
|