Michael Liao | 7557afa | 2019-02-26 18:49:36 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 2 | #include "Inputs/cuda.h" |
| 3 | |
| 4 | |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 5 | __attribute__((amdgpu_flat_work_group_size(32, 64))) |
| 6 | __global__ void flat_work_group_size_32_64() {} |
| 7 | |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 8 | __attribute__((amdgpu_waves_per_eu(2))) |
| 9 | __global__ void waves_per_eu_2() {} |
| 10 | |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 11 | __attribute__((amdgpu_waves_per_eu(2, 4))) |
| 12 | __global__ void waves_per_eu_2_4() {} |
| 13 | |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 14 | __attribute__((amdgpu_num_sgpr(32))) |
| 15 | __global__ void num_sgpr_32() {} |
| 16 | |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 17 | __attribute__((amdgpu_num_vgpr(64))) |
| 18 | __global__ void num_vgpr_64() {} |
| 19 | |
| 20 | |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 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 | |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 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 | |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 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 | |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 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 | |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 33 | __attribute__((amdgpu_waves_per_eu(2), amdgpu_num_sgpr(32))) |
| 34 | __global__ void waves_per_eu_2_num_sgpr_32() {} |
| 35 | |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 36 | __attribute__((amdgpu_waves_per_eu(2), amdgpu_num_vgpr(64))) |
| 37 | __global__ void waves_per_eu_2_num_vgpr_64() {} |
| 38 | |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 39 | __attribute__((amdgpu_waves_per_eu(2, 4), amdgpu_num_sgpr(32))) |
| 40 | __global__ void waves_per_eu_2_4_num_sgpr_32() {} |
| 41 | |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 42 | __attribute__((amdgpu_waves_per_eu(2, 4), amdgpu_num_vgpr(64))) |
| 43 | __global__ void waves_per_eu_2_4_num_vgpr_64() {} |
| 44 | |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 45 | __attribute__((amdgpu_num_sgpr(32), amdgpu_num_vgpr(64))) |
| 46 | __global__ void num_sgpr_32_num_vgpr_64() {} |
| 47 | |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 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 | |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 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 | |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 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 | |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 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 | |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 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 | |
Konstantin Zhuravlyov | 5b48d72 | 2016-09-26 01:02:57 +0000 | [diff] [blame] | 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() {} |
Yaxun Liu | aa24601 | 2018-06-12 23:58:59 +0000 | [diff] [blame] | 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))) |
| 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))) |
| 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))) |
| 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))) |
| 80 | __global__ void intel_reqd_sub_group_size_64() {} |
Michael Liao | 7557afa | 2019-02-26 18:49:36 +0000 | [diff] [blame] | 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))) |
| 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() {} |
| 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))) |
| 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() {} |
| 96 | |
| 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() {} |
| 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))) |
| 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))) |
| 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))) |
| 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))) |
| 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 | |
| 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); } |
| 126 | |
| 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() {} |
| 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"))) |
| 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() {} |
| 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))) |
| 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() {} |
| 149 | |
| 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() {} |
| 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))) |
| 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))) |
| 164 | __global__ void cint_min_waves_per_eu_2_4() {} |
| 165 | |
| 166 | template<unsigned a> |
| 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>(); |
| 170 | |
| 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>(); |
| 175 | |
| 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>(); |
| 180 | |
| 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>(); |
| 186 | |
| 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() {} |