Skip to content

Commit 59dafb2

Browse files
author
Sergei Vinogradov
authored
[SYCL] Kernel object and lambda must have the same name (#20041)
Today, the API that accepts both a kernel object and a corresponding lambda (non-standard and planned for removal in the next major release) ignores the case when the name stored in the kernel object differs from the lambda name. This PR modifies this behavior and throws an exception if names do not match.
1 parent b671165 commit 59dafb2

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

sycl/include/sycl/handler.hpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,12 +1467,13 @@ class __SYCL_EXPORT handler {
14671467
setNDRangeDescriptor(std::move(params)...);
14681468
}
14691469

1470-
setDeviceKernelInfo(std::move(Kernel));
1471-
if (lambdaAndKernelHaveEqualName<NameT>()) {
1472-
StoreLambda<NameT, KernelType, Dims, ElementType>(std::move(KernelFunc));
1473-
} else {
1474-
extractArgsAndReqs();
1470+
MKernel = detail::getSyclObjImpl(Kernel);
1471+
if (!lambdaAndKernelHaveEqualName<NameT>()) {
1472+
throw sycl::exception(
1473+
make_error_code(errc::invalid),
1474+
"the kernel name must match the name of the lambda");
14751475
}
1476+
StoreLambda<NameT, KernelType, Dims, ElementType>(std::move(KernelFunc));
14761477
processProperties<Info.IsESIMD, PropertiesT>(Props);
14771478
#endif
14781479
}
@@ -1926,12 +1927,15 @@ class __SYCL_EXPORT handler {
19261927
// No need to check if range is out of INT_MAX limits as it's compile-time
19271928
// known constant
19281929
setNDRangeDescriptor(range<1>{1});
1929-
setDeviceKernelInfo(std::move(Kernel));
1930-
if (lambdaAndKernelHaveEqualName<NameT>()) {
1931-
StoreLambda<NameT, KernelType, /*Dims*/ 1, void>(std::move(KernelFunc));
1932-
} else {
1933-
extractArgsAndReqs();
1930+
1931+
MKernel = detail::getSyclObjImpl(Kernel);
1932+
if (!lambdaAndKernelHaveEqualName<NameT>()) {
1933+
throw sycl::exception(
1934+
make_error_code(errc::invalid),
1935+
"the kernel name must match the name of the lambda");
19341936
}
1937+
StoreLambda<NameT, KernelType, /*Dims*/ 1, void>(std::move(KernelFunc));
1938+
19351939
#else
19361940
detail::CheckDeviceCopyable<KernelType>();
19371941
#endif

0 commit comments

Comments
 (0)