|
1 | 1 | // RUN: %clang_cc1 -fsycl-is-device -internal-isystem -sycl-std=2020 -fsycl-int-header=%t.h %s -o %t.out |
2 | 2 | // RUN: FileCheck -input-file=%t.h %s |
3 | 3 | // RUN: %clang_cc1 -fsycl-is-host -sycl-std=2020 %s | FileCheck -input-file=%t.h %s |
4 | | -// : %clang_cc1 -fsycl-is-device -internal-isystem -sycl-std=2020 -DNDEBUG -fsycl-int-header=%t2.h %s -o %t2.out |
5 | | -// : FileCheck -input-file=%t2.h %s |
| 4 | + |
6 | 5 | #include "Inputs/sycl.hpp" |
7 | | -#ifndef NDEBUG |
| 6 | + |
| 7 | +// Check that meaningful information is returned when NDEBUG is not defined |
| 8 | +// and empty strings and 0s are emitted when it is. |
8 | 9 | int test1() { |
9 | 10 | cl::sycl::queue q; |
10 | 11 | q.submit([&](cl::sycl::handler &h) { h.single_task([] {}); }); |
11 | 12 | q.submit([&](cl::sycl::handler &h) { h.single_task<class KernelName>([]() {}); }); |
12 | 13 | return 0; |
13 | 14 | } |
14 | | -// Specializations of KernelInfo for kernel function types: |
15 | 15 | // CHECK: template <> struct KernelInfoData<'_', 'Z', 'T', 'S', 'Z', 'Z', '5', 't', 'e', 's', 't', '1', 'v', 'E', 'N', 'K', 'U', 'l', 'R', 'N', '2', 'c', 'l', '4', 's', 'y', 'c', 'l', '7', 'h', 'a', 'n', 'd', 'l', 'e', 'r', 'E', 'E', '_', 'c', 'l', 'E', 'S', '2', '_', 'E', 'U', 'l', 'v', 'E', '_'> { |
16 | | -// CHECK: static constexpr const char* getFileName() { return "code_location.cpp"; } |
17 | | -// CHECK: static constexpr const char* getFunctionName() { return ""; } |
18 | | -// CHECK: static constexpr unsigned getLineNumber() { return 10; } |
19 | | -// CHECK: static constexpr unsigned getColumnNumber() { return 54; } |
20 | | -//}; |
| 16 | +// CHECK: static constexpr const char* getFileName() { |
| 17 | +// CHECK: #ifndef NDEBUG |
| 18 | +// CHECK: return "code_location.cpp"; |
| 19 | +// CHECK: #else |
| 20 | +// CHECK: return ""; |
| 21 | +// CHECK: #endif |
| 22 | +// CHECK: } |
| 23 | +// CHECK: static constexpr const char* getFunctionName() { |
| 24 | +// CHECK: #ifndef NDEBUG |
| 25 | +// CHECK: return ""; |
| 26 | +// CHECK: #else |
| 27 | +// CHECK: return ""; |
| 28 | +// CHECK: #endif |
| 29 | +// CHECK: } |
| 30 | +// CHECK: static constexpr unsigned getLineNumber() { |
| 31 | +// CHECK: #ifndef NDEBUG |
| 32 | +// CHECK: return 11; |
| 33 | +// CHECK: #else |
| 34 | +// CHECK: return 0; |
| 35 | +// CHECK: #endif |
| 36 | +// CHECK: } |
| 37 | +// CHECK: static constexpr unsigned getColumnNumber() { |
| 38 | +// CHECK: #ifndef NDEBUG |
| 39 | +// CHECK: return 54; |
| 40 | +// CHECK: #else |
| 41 | +// CHECK: return 0; |
| 42 | +// CHECK: #endif |
| 43 | +// CHECK: } |
| 44 | +// CHECK: }; |
21 | 45 |
|
22 | 46 | // CHECK: template <> struct KernelInfo<KernelName> { |
23 | | -// CHECK: static constexpr const char* getFileName() { return "code_location.cpp"; } |
24 | | -// CHECK: static constexpr const char* getFunctionName() { return "KernelName"; } |
25 | | -// CHECK: static constexpr unsigned getLineNumber() { return 11; } |
26 | | -// CHECK: static constexpr unsigned getColumnNumber() { return 72; } |
27 | | -//}; |
| 47 | +// CHECK: static constexpr const char* getFileName() { |
| 48 | +// CHECK: #ifndef NDEBUG |
| 49 | +// CHECK: return "code_location.cpp"; |
| 50 | +// CHECK: #else |
| 51 | +// CHECK: return ""; |
| 52 | +// CHECK: #endif |
| 53 | +// CHECK: } |
| 54 | +// CHECK: __SYCL_DLL_LOCAL |
| 55 | +// CHECK: static constexpr const char* getFunctionName() { |
| 56 | +// CHECK: #ifndef NDEBUG |
| 57 | +// CHECK: return "KernelName"; |
| 58 | +// CHECK: #else |
| 59 | +// CHECK: return ""; |
| 60 | +// CHECK: #endif |
| 61 | +// CHECK: } |
| 62 | +// CHECK: __SYCL_DLL_LOCAL |
| 63 | +// CHECK: static constexpr unsigned getLineNumber() { |
| 64 | +// CHECK: #ifndef NDEBUG |
| 65 | +// CHECK: return 12; |
| 66 | +// CHECK: #else |
| 67 | +// CHECK: return 0; |
| 68 | +// CHECK: #endif |
| 69 | +// CHECK: } |
| 70 | +// CHECK: __SYCL_DLL_LOCAL |
| 71 | +// CHECK: static constexpr unsigned getColumnNumber() { |
| 72 | +// CHECK: #ifndef NDEBUG |
| 73 | +// CHECK: return 72; |
| 74 | +// CHECK: #else |
| 75 | +// CHECK: return 0; |
| 76 | +// CHECK: #endif |
| 77 | +// CHECK: } |
| 78 | +// CHECK: }; |
28 | 79 |
|
| 80 | +// Check that the right name and location is returned when |
| 81 | +// lambda and kernel name are defined on different lines |
29 | 82 | class KernelName2; |
30 | 83 | int test2() { |
31 | 84 | cl::sycl::queue q; |
32 | | - q.submit([&](cl::sycl::handler &h) { h.single_task( |
33 | | - [] { int i = 2; }); }); |
34 | 85 | q.submit([&](cl::sycl::handler &h) { h.single_task<KernelName2>( |
35 | 86 | [] { int i = 2; }); }); |
36 | 87 | return 0; |
37 | 88 | } |
38 | | - |
39 | | -// CHECK: template <> struct KernelInfoData<'_', 'Z', 'T', 'S', 'Z', 'Z', '5', 't', 'e', 's', 't', '2', 'v', 'E', 'N', 'K', 'U', 'l', 'R', 'N', '2', 'c', 'l', '4', 's', 'y', 'c', 'l', '7', 'h', 'a', 'n', 'd', 'l', 'e', 'r', 'E', 'E', '_', 'c', 'l', 'E', 'S', '2', '_', 'E', 'U', 'l', 'v', 'E', '_'> { |
40 | | -// CHECK: static constexpr const char* getFileName() { return "code_location.cpp"; } |
41 | | -// CHECK: static constexpr const char* getFunctionName() { return ""; } |
42 | | -// CHECK: static constexpr unsigned getLineNumber() { return 33; } |
43 | | -// CHECK: static constexpr unsigned getColumnNumber() { return 44; } |
44 | | -//}; |
45 | 89 | // CHECK: template <> struct KernelInfo<::KernelName2> { |
46 | | -// CHECK: static constexpr const char* getFileName() { return "code_location.cpp"; } |
47 | | -// CHECK: static constexpr const char* getFunctionName() { return "::KernelName2"; } |
48 | | -// CHECK: static constexpr unsigned getLineNumber() { return 35; } |
49 | | -// CHECK: static constexpr unsigned getColumnNumber() { return 44; } |
50 | | -//}; |
| 90 | +// CHECK: static constexpr const char* getFileName() { |
| 91 | +// CHECK: #ifndef NDEBUG |
| 92 | +// CHECK: return "code_location.cpp"; |
| 93 | +// CHECK: #else |
| 94 | +// CHECK: return ""; |
| 95 | +// CHECK: #endif |
| 96 | +// CHECK: } |
| 97 | +// CHECK: static constexpr const char* getFunctionName() { |
| 98 | +// CHECK: #ifndef NDEBUG |
| 99 | +// CHECK: return "::KernelName2"; |
| 100 | +// CHECK: #else |
| 101 | +// CHECK: return ""; |
| 102 | +// CHECK: #endif |
| 103 | +// CHECK: } |
| 104 | +// CHECK: static constexpr unsigned getLineNumber() { |
| 105 | +// CHECK: #ifndef NDEBUG |
| 106 | +// CHECK: return 86; |
| 107 | +// CHECK: #else |
| 108 | +// CHECK: return 0; |
| 109 | +// CHECK: #endif |
| 110 | +// CHECK: } |
| 111 | +// CHECK: static constexpr unsigned getColumnNumber() { |
| 112 | +// CHECK: #ifndef NDEBUG |
| 113 | +// CHECK: return 44; |
| 114 | +// CHECK: #else |
| 115 | +// CHECK: return 0; |
| 116 | +// CHECK: #endif |
| 117 | +// CHECK: } |
| 118 | +// CHECK: }; |
51 | 119 |
|
| 120 | +// Check that fully qualified name is returned |
52 | 121 | template <typename T> class KernelName3; |
53 | 122 | int test3() { |
54 | 123 | cl::sycl::queue q; |
55 | 124 | q.submit([&](cl::sycl::handler &h) { h.single_task<KernelName3<KernelName2>>( |
56 | 125 | [] { int i = 3; }); }); |
57 | 126 | return 0; |
58 | 127 | } |
59 | | - |
60 | 128 | // CHECK: template <> struct KernelInfo<::KernelName3<::KernelName2>> { |
61 | | -// CHECK: static constexpr const char* getFileName() { return "code_location.cpp"; } |
62 | | -// CHECK: static constexpr const char* getFunctionName() { return "::KernelName3<::KernelName2>"; } |
63 | | -// CHECK: static constexpr unsigned getLineNumber() { return 56; } |
64 | | -// CHECK: static constexpr unsigned getColumnNumber() { return 44; } |
65 | | -//}; |
| 129 | +// CHECK: static constexpr const char* getFileName() { |
| 130 | +// CHECK: #ifndef NDEBUG |
| 131 | +// CHECK: return "code_location.cpp"; |
| 132 | +// CHECK: #else |
| 133 | +// CHECK: return ""; |
| 134 | +// CHECK: #endif |
| 135 | +// CHECK: } |
| 136 | +// CHECK: static constexpr const char* getFunctionName() { |
| 137 | +// CHECK: #ifndef NDEBUG |
| 138 | +// CHECK: return "::KernelName3<::KernelName2>"; |
| 139 | +// CHECK: #else |
| 140 | +// CHECK: return ""; |
| 141 | +// CHECK: #endif |
| 142 | +// CHECK: } |
| 143 | +// CHECK: static constexpr unsigned getLineNumber() { |
| 144 | +// CHECK: #ifndef NDEBUG |
| 145 | +// CHECK: return 125; |
| 146 | +// CHECK: #else |
| 147 | +// CHECK: return 0; |
| 148 | +// CHECK: #endif |
| 149 | +// CHECK: } |
| 150 | +// CHECK: static constexpr unsigned getColumnNumber() { |
| 151 | +// CHECK: #ifndef NDEBUG |
| 152 | +// CHECK: return 44; |
| 153 | +// CHECK: #else |
| 154 | +// CHECK: return 0; |
| 155 | +// CHECK: #endif |
| 156 | +// CHECK: } |
| 157 | +// CHECK: }; |
66 | 158 |
|
| 159 | +// Check that the location information returned is that of l4 |
67 | 160 | auto l4 = []() { return 4; }; |
68 | 161 | int test4() { |
69 | 162 | cl::sycl::queue q; |
70 | 163 | q.submit([=](cl::sycl::handler &h) { h.single_task<class KernelName4>(l4); }); |
71 | 164 | return 0; |
72 | 165 | } |
73 | | - |
74 | 166 | // CHECK: template <> struct KernelInfo<KernelName4> { |
75 | | -// CHECK: static constexpr const char* getFileName() { return "code_location.cpp"; } |
76 | | -// CHECK: static constexpr const char* getFunctionName() { return "KernelName4"; } |
77 | | -// CHECK: static constexpr unsigned getLineNumber() { return 67; } |
78 | | -// CHECK: static constexpr unsigned getColumnNumber() { return 11; } |
79 | | -//}; |
| 167 | +// CHECK: static constexpr const char* getFileName() { |
| 168 | +// CHECK: #ifndef NDEBUG |
| 169 | +// CHECK: return "code_location.cpp"; |
| 170 | +// CHECK: #else |
| 171 | +// CHECK: return ""; |
| 172 | +// CHECK: #endif |
| 173 | +// CHECK: } |
| 174 | +// CHECK: static constexpr const char* getFunctionName() { |
| 175 | +// CHECK: #ifndef NDEBUG |
| 176 | +// CHECK: return "KernelName4"; |
| 177 | +// CHECK: #else |
| 178 | +// CHECK: return ""; |
| 179 | +// CHECK: #endif |
| 180 | +// CHECK: } |
| 181 | +// CHECK: static constexpr unsigned getLineNumber() { |
| 182 | +// CHECK: #ifndef NDEBUG |
| 183 | +// CHECK: return 160; |
| 184 | +// CHECK: #else |
| 185 | +// CHECK: return 0; |
| 186 | +// CHECK: #endif |
| 187 | +// CHECK: } |
| 188 | +// CHECK: static constexpr unsigned getColumnNumber() { |
| 189 | +// CHECK: #ifndef NDEBUG |
| 190 | +// CHECK: return 11; |
| 191 | +// CHECK: #else |
| 192 | +// CHECK: return 0; |
| 193 | +// CHECK: #endif |
| 194 | +// CHECK: } |
| 195 | +// CHECK: }; |
80 | 196 |
|
81 | | -#else |
| 197 | +// Check that fully qualified name is returned when unnamed lambda |
| 198 | +// kernel is enclosed in a namespace |
| 199 | +namespace NS { |
82 | 200 | int test5() { |
83 | 201 | cl::sycl::queue q; |
84 | | - q.submit([&](cl::sycl::handler &h) { h.single_task([] {}); }); |
85 | | - q.submit([&](cl::sycl::handler &h) { h.single_task<class KernelName5>([]() {}); }); |
| 202 | + q.submit([=](cl::sycl::handler &h) { h.single_task([] {}); }); |
| 203 | + q.submit([=](cl::sycl::handler &h) { h.single_task<class KernelName5>([] {}); }); |
86 | 204 | return 0; |
87 | 205 | } |
88 | | - |
89 | | -// HECK: template <> struct KernelInfoData<'_', 'Z', 'T', 'S', 'Z', 'Z', '5', 't', 'e', 's', 't', '5', 'v', 'E', 'N', 'K', 'U', 'l', 'R', 'N', '2', 'c', 'l', '4', 's', 'y', 'c', 'l', '7', 'h', 'a', 'n', 'd', 'l', 'e', 'r', 'E', 'E', '_', 'c', 'l', 'E', 'S', '2', '_', 'E', 'U', 'l', 'v', 'E', '_'> { |
90 | | -// HECK: static constexpr const char* getFileName() { return ; } |
91 | | -// HECK: static constexpr const char* getFunctionName() { return ; } |
92 | | -// HECK: static constexpr unsigned getLineNumber() { return 0; } |
93 | | -// HECK: static constexpr unsigned getColumnNumber() { return 0; } |
94 | | -//}; |
95 | | -// HECK: template <> struct KernelInfo<KernelName5> { |
96 | | -// HECK: static constexpr const char* getFileName() { return ; } |
97 | | -// HECK: static constexpr const char* getFunctionName() { return ; } |
98 | | -// HECK: static constexpr unsigned getLineNumber() { return 0; } |
99 | | -// HECK: static constexpr unsigned getColumnNumber() { return 0; } |
100 | | -//}; |
101 | | -#endif |
| 206 | +} // namespace NS |
| 207 | +// CHECK: template <> struct KernelInfoData<'_', 'Z', 'T', 'S', 'Z', 'Z', 'N', '2', 'N', 'S', '5', 't', 'e', 's', 't', '5', 'E', 'v', 'E', 'N', 'K', 'U', 'l', 'R', 'N', '2', 'c', 'l', '4', 's', 'y', 'c', 'l', '7', 'h', 'a', 'n', 'd', 'l', 'e', 'r', 'E', 'E', '_', 'c', 'l', 'E', 'S', '3', '_', 'E', 'U', 'l', 'v', 'E', '_'> { |
| 208 | +// CHECK: static constexpr const char* getFileName() { |
| 209 | +// CHECK: #ifndef NDEBUG |
| 210 | +// CHECK: return "code_location.cpp"; |
| 211 | +// CHECK: #else |
| 212 | +// CHECK: return ""; |
| 213 | +// CHECK: #endif |
| 214 | +// CHECK: } |
| 215 | +// CHECK: static constexpr const char* getFunctionName() { |
| 216 | +// CHECK: #ifndef NDEBUG |
| 217 | +// CHECK: return "NS::"; |
| 218 | +// CHECK: #else |
| 219 | +// CHECK: return ""; |
| 220 | +// CHECK: #endif |
| 221 | +// CHECK: } |
| 222 | +// CHECK: static constexpr unsigned getLineNumber() { |
| 223 | +// CHECK: #ifndef NDEBUG |
| 224 | +// CHECK: return 202; |
| 225 | +// CHECK: #else |
| 226 | +// CHECK: return 0; |
| 227 | +// CHECK: #endif |
| 228 | +// CHECK: } |
| 229 | +// CHECK: static constexpr unsigned getColumnNumber() { |
| 230 | +// CHECK: #ifndef NDEBUG |
| 231 | +// CHECK: return 54; |
| 232 | +// CHECK: #else |
| 233 | +// CHECK: return 0; |
| 234 | +// CHECK: #endif |
| 235 | +// CHECK: } |
| 236 | +// CHECK: }; |
| 237 | +// CHECK: template <> struct KernelInfo<NS::KernelName5> { |
| 238 | +// CHECK: static constexpr const char* getFileName() { |
| 239 | +// CHECK: #ifndef NDEBUG |
| 240 | +// CHECK: return "code_location.cpp"; |
| 241 | +// CHECK: #else |
| 242 | +// CHECK: return ""; |
| 243 | +// CHECK: #endif |
| 244 | +// CHECK: } |
| 245 | +// CHECK: static constexpr const char* getFunctionName() { |
| 246 | +// CHECK: #ifndef NDEBUG |
| 247 | +// CHECK: return "NS::KernelName5"; |
| 248 | +// CHECK: #else |
| 249 | +// CHECK: return ""; |
| 250 | +// CHECK: #endif |
| 251 | +// CHECK: } |
| 252 | +// CHECK: static constexpr unsigned getLineNumber() { |
| 253 | +// CHECK: #ifndef NDEBUG |
| 254 | +// CHECK: return 203; |
| 255 | +// CHECK: #else |
| 256 | +// CHECK: return 0; |
| 257 | +// CHECK: #endif |
| 258 | +// CHECK: } |
| 259 | +// CHECK: static constexpr unsigned getColumnNumber() { |
| 260 | +// CHECK: #ifndef NDEBUG |
| 261 | +// CHECK: return 73; |
| 262 | +// CHECK: #else |
| 263 | +// CHECK: return 0; |
| 264 | +// CHECK: #endif |
| 265 | +// CHECK: } |
| 266 | +// CHECK: }; |
0 commit comments