Skip to content

[SYCL] Return ref to shared_ptr from handler::getOrInsertHandlerKernelBundle() #18588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: sycl
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sycl/include/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1696,8 +1696,13 @@ class __SYCL_EXPORT handler {
void setStateSpecConstSet();
bool isStateExplicitKernelBundle() const;

#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
__SYCL_DLL_LOCAL std::shared_ptr<detail::kernel_bundle_impl> &
getOrInsertHandlerKernelBundle(bool Insert) const;
#else
std::shared_ptr<detail::kernel_bundle_impl>
getOrInsertHandlerKernelBundle(bool Insert) const;
#endif

void setHandlerKernelBundle(kernel Kernel);

Expand Down
16 changes: 16 additions & 0 deletions sycl/source/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,19 @@ bool handler::isStateExplicitKernelBundle() const {
return impl->isStateExplicitKernelBundle();
}

#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
// Returns a reference to shared_ptr to the kernel_bundle.
// If there is no kernel_bundle created:
// returns newly created kernel_bundle if Insert is true
// returns shared_ptr(nullptr) if Insert is false
std::shared_ptr<detail::kernel_bundle_impl> &
#else
// Returns a shared_ptr to the kernel_bundle.
// If there is no kernel_bundle created:
// returns newly created kernel_bundle if Insert is true
// returns shared_ptr(nullptr) if Insert is false
std::shared_ptr<detail::kernel_bundle_impl>
#endif
handler::getOrInsertHandlerKernelBundle(bool Insert) const {
if (!impl->MKernelBundle && Insert) {
auto Ctx =
Expand Down Expand Up @@ -472,7 +480,11 @@ event handler::finalize() {

if (type == detail::CGType::Kernel) {
// If there were uses of set_specialization_constant build the kernel_bundle
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
std::shared_ptr<detail::kernel_bundle_impl> &KernelBundleImpPtr =
#else
std::shared_ptr<detail::kernel_bundle_impl> KernelBundleImpPtr =
#endif
getOrInsertHandlerKernelBundle(/*Insert=*/false);
if (KernelBundleImpPtr) {
// Make sure implicit non-interop kernel bundles have the kernel
Expand Down Expand Up @@ -1346,7 +1358,11 @@ detail::ABINeutralKernelNameStrT handler::getKernelName() {
}

void handler::verifyUsedKernelBundleInternal(detail::string_view KernelName) {
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
auto &UsedKernelBundleImplPtr =
#else
auto UsedKernelBundleImplPtr =
#endif
getOrInsertHandlerKernelBundle(/*Insert=*/false);
if (!UsedKernelBundleImplPtr)
return;
Expand Down