Skip to content

Commit 0b97344

Browse files
[SYCL] Submission with kernel parameter ignores set kernel bundle (#4667)
The SYCL 2020 specification states that single_task and parallel_for with a kernel parameter should ignore a previously set kernel bundle and use the kernel bundle that contains the kernel. These changes make the functions overwrite the set kernel bundle.
1 parent 8fa04fe commit 0b97344

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

sycl/include/CL/sycl/handler.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,6 +1803,8 @@ class __SYCL_EXPORT handler {
18031803
void single_task(kernel Kernel) {
18041804
throwIfActionIsCreated();
18051805
verifyKernelInvoc(Kernel);
1806+
// Ignore any set kernel bundles and use the one associated with the kernel
1807+
setHandlerKernelBundle(detail::getSyclObjImpl(Kernel.get_kernel_bundle()));
18061808
// No need to check if range is out of INT_MAX limits as it's compile-time
18071809
// known constant
18081810
MNDRDesc.set(range<1>{1});
@@ -1874,6 +1876,8 @@ class __SYCL_EXPORT handler {
18741876
template <typename KernelName = detail::auto_name, typename KernelType>
18751877
void single_task(kernel Kernel, _KERNELFUNCPARAM(KernelFunc)) {
18761878
throwIfActionIsCreated();
1879+
// Ignore any set kernel bundles and use the one associated with the kernel
1880+
setHandlerKernelBundle(detail::getSyclObjImpl(Kernel.get_kernel_bundle()));
18771881
using NameT =
18781882
typename detail::get_kernel_name_t<KernelName, KernelType>::name;
18791883
(void)Kernel;
@@ -1917,6 +1921,8 @@ class __SYCL_EXPORT handler {
19171921
void parallel_for(kernel Kernel, range<Dims> NumWorkItems,
19181922
_KERNELFUNCPARAM(KernelFunc)) {
19191923
throwIfActionIsCreated();
1924+
// Ignore any set kernel bundles and use the one associated with the kernel
1925+
setHandlerKernelBundle(detail::getSyclObjImpl(Kernel.get_kernel_bundle()));
19201926
using NameT =
19211927
typename detail::get_kernel_name_t<KernelName, KernelType>::name;
19221928
using LambdaArgType = sycl::detail::lambda_arg_type<KernelType, item<Dims>>;
@@ -1952,6 +1958,8 @@ class __SYCL_EXPORT handler {
19521958
void parallel_for(kernel Kernel, range<Dims> NumWorkItems,
19531959
id<Dims> WorkItemOffset, _KERNELFUNCPARAM(KernelFunc)) {
19541960
throwIfActionIsCreated();
1961+
// Ignore any set kernel bundles and use the one associated with the kernel
1962+
setHandlerKernelBundle(detail::getSyclObjImpl(Kernel.get_kernel_bundle()));
19551963
using NameT =
19561964
typename detail::get_kernel_name_t<KernelName, KernelType>::name;
19571965
using LambdaArgType = sycl::detail::lambda_arg_type<KernelType, item<Dims>>;
@@ -1987,6 +1995,8 @@ class __SYCL_EXPORT handler {
19871995
void parallel_for(kernel Kernel, nd_range<Dims> NDRange,
19881996
_KERNELFUNCPARAM(KernelFunc)) {
19891997
throwIfActionIsCreated();
1998+
// Ignore any set kernel bundles and use the one associated with the kernel
1999+
setHandlerKernelBundle(detail::getSyclObjImpl(Kernel.get_kernel_bundle()));
19902000
using NameT =
19912001
typename detail::get_kernel_name_t<KernelName, KernelType>::name;
19922002
using LambdaArgType =
@@ -2026,6 +2036,8 @@ class __SYCL_EXPORT handler {
20262036
void parallel_for_work_group(kernel Kernel, range<Dims> NumWorkGroups,
20272037
_KERNELFUNCPARAM(KernelFunc)) {
20282038
throwIfActionIsCreated();
2039+
// Ignore any set kernel bundles and use the one associated with the kernel
2040+
setHandlerKernelBundle(detail::getSyclObjImpl(Kernel.get_kernel_bundle()));
20292041
using NameT =
20302042
typename detail::get_kernel_name_t<KernelName, KernelType>::name;
20312043
using LambdaArgType =
@@ -2063,6 +2075,8 @@ class __SYCL_EXPORT handler {
20632075
range<Dims> WorkGroupSize,
20642076
_KERNELFUNCPARAM(KernelFunc)) {
20652077
throwIfActionIsCreated();
2078+
// Ignore any set kernel bundles and use the one associated with the kernel
2079+
setHandlerKernelBundle(detail::getSyclObjImpl(Kernel.get_kernel_bundle()));
20662080
using NameT =
20672081
typename detail::get_kernel_name_t<KernelName, KernelType>::name;
20682082
using LambdaArgType =

0 commit comments

Comments
 (0)