Skip to content

Commit 3d96e1d

Browse files
[SYCL] Create kernel bundle when non-native specialization constants are unset (#4358)
The kernel bundle carrying the device memory used for specialization constants on systems that do not support specialization constants natively was only initialized if a specialization constant was either written to or read from prior to kernel execution. These changes either forces the creation of a kernel bundle if the kernel has a specialization constant argument and a kernel bundle does not exist already. Signed-off-by: Steffen Larsen <[email protected]>
1 parent 4cb8561 commit 3d96e1d

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

sycl/include/CL/sycl/handler.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,13 @@ class __SYCL_EXPORT handler {
551551
// arguments.
552552
MArgs = std::move(MAssociatedAccesors);
553553
}
554+
555+
// If the kernel lambda is callable with a kernel_handler argument, manifest
556+
// the associated kernel handler.
557+
if (detail::isKernelLambdaCallableWithKernelHandler<KernelType,
558+
LambdaArgType>()) {
559+
getOrInsertHandlerKernelBundle(/*Insert=*/true);
560+
}
554561
}
555562

556563
/// Checks whether it is possible to copy the source shape to the destination

sycl/source/detail/scheduler/commands.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,15 +1754,10 @@ pi_result ExecCGCommand::SetKernelParamsAndLaunch(
17541754
"device",
17551755
PI_INVALID_OPERATION);
17561756
}
1757-
if (DeviceImageImpl != nullptr) {
1758-
RT::PiMem SpecConstsBuffer =
1759-
DeviceImageImpl->get_spec_const_buffer_ref();
1760-
Plugin.call<PiApiKind::piextKernelSetArgMemObj>(Kernel, NextTrueIndex,
1761-
&SpecConstsBuffer);
1762-
} else {
1763-
Plugin.call<PiApiKind::piextKernelSetArgMemObj>(Kernel, NextTrueIndex,
1764-
nullptr);
1765-
}
1757+
assert(DeviceImageImpl != nullptr);
1758+
RT::PiMem SpecConstsBuffer = DeviceImageImpl->get_spec_const_buffer_ref();
1759+
Plugin.call<PiApiKind::piextKernelSetArgMemObj>(Kernel, NextTrueIndex,
1760+
&SpecConstsBuffer);
17661761
break;
17671762
}
17681763
}

0 commit comments

Comments
 (0)