Skip to content

Commit

Permalink
[SYCL] Create kernel bundle when non-native specialization constants …
Browse files Browse the repository at this point in the history
…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]>
  • Loading branch information
steffenlarsen authored Aug 19, 2021
1 parent 4cb8561 commit 3d96e1d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
7 changes: 7 additions & 0 deletions sycl/include/CL/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<KernelType,
LambdaArgType>()) {
getOrInsertHandlerKernelBundle(/*Insert=*/true);
}
}

/// Checks whether it is possible to copy the source shape to the destination
Expand Down
13 changes: 4 additions & 9 deletions sycl/source/detail/scheduler/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<PiApiKind::piextKernelSetArgMemObj>(Kernel, NextTrueIndex,
&SpecConstsBuffer);
} else {
Plugin.call<PiApiKind::piextKernelSetArgMemObj>(Kernel, NextTrueIndex,
nullptr);
}
assert(DeviceImageImpl != nullptr);
RT::PiMem SpecConstsBuffer = DeviceImageImpl->get_spec_const_buffer_ref();
Plugin.call<PiApiKind::piextKernelSetArgMemObj>(Kernel, NextTrueIndex,
&SpecConstsBuffer);
break;
}
}
Expand Down

0 comments on commit 3d96e1d

Please sign in to comment.