From 3d96e1dc5586e2e52ef59fe026bb4c0983dd77e1 Mon Sep 17 00:00:00 2001 From: Steffen Larsen Date: Thu, 19 Aug 2021 09:44:02 +0100 Subject: [PATCH] [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 --- sycl/include/CL/sycl/handler.hpp | 7 +++++++ sycl/source/detail/scheduler/commands.cpp | 13 ++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/sycl/include/CL/sycl/handler.hpp b/sycl/include/CL/sycl/handler.hpp index b7c64ee4456dd..750346083ceca 100644 --- a/sycl/include/CL/sycl/handler.hpp +++ b/sycl/include/CL/sycl/handler.hpp @@ -551,6 +551,13 @@ class __SYCL_EXPORT handler { // arguments. MArgs = std::move(MAssociatedAccesors); } + + // If the kernel lambda is callable with a kernel_handler argument, manifest + // the associated kernel handler. + if (detail::isKernelLambdaCallableWithKernelHandler()) { + getOrInsertHandlerKernelBundle(/*Insert=*/true); + } } /// Checks whether it is possible to copy the source shape to the destination diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index 27527d894e82b..7e62b0ff18ba1 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -1754,15 +1754,10 @@ pi_result ExecCGCommand::SetKernelParamsAndLaunch( "device", PI_INVALID_OPERATION); } - if (DeviceImageImpl != nullptr) { - RT::PiMem SpecConstsBuffer = - DeviceImageImpl->get_spec_const_buffer_ref(); - Plugin.call(Kernel, NextTrueIndex, - &SpecConstsBuffer); - } else { - Plugin.call(Kernel, NextTrueIndex, - nullptr); - } + assert(DeviceImageImpl != nullptr); + RT::PiMem SpecConstsBuffer = DeviceImageImpl->get_spec_const_buffer_ref(); + Plugin.call(Kernel, NextTrueIndex, + &SpecConstsBuffer); break; } }