Skip to content

Commit dbe0fb9

Browse files
committed
Update the kernel size test, add properties check for single_task
1 parent 549ae54 commit dbe0fb9

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

sycl/include/sycl/queue.hpp

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,22 @@ auto submit_kernel_direct_parallel_for(
199199

200200
detail::DeviceKernelInfo *DeviceKernelInfoPtr =
201201
&detail::getDeviceKernelInfo<NameT>();
202+
constexpr auto Info = detail::CompileTimeKernelInfo<NameT>;
203+
204+
assert(Info.Name != std::string_view{} && "Kernel must have a name!");
205+
206+
static_assert(
207+
Info.Name == std::string_view{} || sizeof(KernelType) == Info.KernelSize,
208+
"Unexpected kernel lambda size. This can be caused by an "
209+
"external host compiler producing a lambda with an "
210+
"unexpected layout. This is a limitation of the compiler."
211+
"In many cases the difference is related to capturing constexpr "
212+
"variables. In such cases removing constexpr specifier aligns the "
213+
"captures between the host compiler and the device compiler."
214+
"\n"
215+
"In case of MSVC, passing "
216+
"-fsycl-host-compiler-options='/std:c++latest' "
217+
"might also help.");
202218

203219
if constexpr (EventNeeded) {
204220
return submit_kernel_direct_with_event_impl(
@@ -246,6 +262,22 @@ auto submit_kernel_direct_single_task(
246262

247263
detail::DeviceKernelInfo *DeviceKernelInfoPtr =
248264
&detail::getDeviceKernelInfo<NameT>();
265+
constexpr auto Info = detail::CompileTimeKernelInfo<NameT>;
266+
267+
assert(Info.Name != std::string_view{} && "Kernel must have a name!");
268+
269+
static_assert(
270+
Info.Name == std::string_view{} || sizeof(KernelType) == Info.KernelSize,
271+
"Unexpected kernel lambda size. This can be caused by an "
272+
"external host compiler producing a lambda with an "
273+
"unexpected layout. This is a limitation of the compiler."
274+
"In many cases the difference is related to capturing constexpr "
275+
"variables. In such cases removing constexpr specifier aligns the "
276+
"captures between the host compiler and the device compiler."
277+
"\n"
278+
"In case of MSVC, passing "
279+
"-fsycl-host-compiler-options='/std:c++latest' "
280+
"might also help.");
249281

250282
if constexpr (EventNeeded) {
251283
return submit_kernel_direct_with_event_impl(
@@ -2768,7 +2800,10 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
27682800
"sycl::queue.single_task() requires a kernel instead of command group. "
27692801
"Use queue.submit() instead");
27702802

2771-
if constexpr (!(ext::oneapi::experimental::detail::
2803+
if constexpr (std::is_same_v<
2804+
PropertiesT,
2805+
ext::oneapi::experimental::empty_properties_t> &&
2806+
!(ext::oneapi::experimental::detail::
27722807
HasKernelPropertiesGetMethod<
27732808
const KernelType &>::value)) {
27742809
(void)Properties;

sycl/test/basic_tests/kernel_size_mismatch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ int main() {
1313
(void)A;
1414
// expected-no-diagnostics
1515
#else
16-
// expected-error-re@sycl/handler.hpp:* {{static assertion failed due to requirement '{{.*}}': Unexpected kernel lambda size. This can be caused by an external host compiler producing a lambda with an unexpected layout. This is a limitation of the compiler.}}
16+
// expected-error-re@sycl/queue.hpp:* {{static assertion failed due to requirement '{{.*}}': Unexpected kernel lambda size. This can be caused by an external host compiler producing a lambda with an unexpected layout. This is a limitation of the compiler.}}
1717
#endif
1818
}).wait();
1919
}

0 commit comments

Comments
 (0)