From af1880cb3f71836cbd60472df141cd1a8979616b Mon Sep 17 00:00:00 2001 From: Alexandr Konovalov Date: Wed, 21 May 2025 14:58:27 +0200 Subject: [PATCH 1/3] [SYCL] Return ref to shared_ptr from handler::getOrInsertHandlerKernelBundle() It's reference to impl of handler, so it's correct to return the reference. Signed-off-by: Alexandr Konovalov --- sycl/include/sycl/handler.hpp | 2 +- sycl/source/handler.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sycl/include/sycl/handler.hpp b/sycl/include/sycl/handler.hpp index 52bf35c9c2809..5669597fc7d9d 100644 --- a/sycl/include/sycl/handler.hpp +++ b/sycl/include/sycl/handler.hpp @@ -1633,7 +1633,7 @@ class __SYCL_EXPORT handler { void setStateSpecConstSet(); bool isStateExplicitKernelBundle() const; - std::shared_ptr + std::shared_ptr& getOrInsertHandlerKernelBundle(bool Insert) const; void setHandlerKernelBundle(kernel Kernel); diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index a25107b143f6e..bb9f5357321a9 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -377,7 +377,7 @@ bool handler::isStateExplicitKernelBundle() const { // 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 +std::shared_ptr& handler::getOrInsertHandlerKernelBundle(bool Insert) const { if (!impl->MKernelBundle && Insert) { auto Ctx = @@ -468,7 +468,7 @@ event handler::finalize() { if (type == detail::CGType::Kernel) { // If there were uses of set_specialization_constant build the kernel_bundle - std::shared_ptr KernelBundleImpPtr = + std::shared_ptr &KernelBundleImpPtr = getOrInsertHandlerKernelBundle(/*Insert=*/false); if (KernelBundleImpPtr) { // Make sure implicit non-interop kernel bundles have the kernel @@ -1260,7 +1260,7 @@ detail::ABINeutralKernelNameStrT handler::getKernelName() { } void handler::verifyUsedKernelBundleInternal(detail::string_view KernelName) { - auto UsedKernelBundleImplPtr = + auto &UsedKernelBundleImplPtr = getOrInsertHandlerKernelBundle(/*Insert=*/false); if (!UsedKernelBundleImplPtr) return; From 53b95a273251f0fc3432745c93b1b0b393db047c Mon Sep 17 00:00:00 2001 From: Alexandr Konovalov Date: Wed, 21 May 2025 16:01:15 +0200 Subject: [PATCH 2/3] Code formatting. Signed-off-by: Alexandr Konovalov --- sycl/include/sycl/handler.hpp | 2 +- sycl/source/handler.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sycl/include/sycl/handler.hpp b/sycl/include/sycl/handler.hpp index 5669597fc7d9d..51c4fdf3e611b 100644 --- a/sycl/include/sycl/handler.hpp +++ b/sycl/include/sycl/handler.hpp @@ -1633,7 +1633,7 @@ class __SYCL_EXPORT handler { void setStateSpecConstSet(); bool isStateExplicitKernelBundle() const; - std::shared_ptr& + std::shared_ptr & getOrInsertHandlerKernelBundle(bool Insert) const; void setHandlerKernelBundle(kernel Kernel); diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index bb9f5357321a9..20b356f1add73 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -373,11 +373,11 @@ bool handler::isStateExplicitKernelBundle() const { return impl->isStateExplicitKernelBundle(); } -// Returns a shared_ptr to the kernel_bundle. +// 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& +std::shared_ptr & handler::getOrInsertHandlerKernelBundle(bool Insert) const { if (!impl->MKernelBundle && Insert) { auto Ctx = From 894c17db6cd4acc5a0198015352aeb00bf012560 Mon Sep 17 00:00:00 2001 From: Alexandr Konovalov Date: Fri, 23 May 2025 18:26:06 +0200 Subject: [PATCH 3/3] Move change under __INTEL_PREVIEW_BREAKING_CHANGES. --- sycl/include/sycl/handler.hpp | 7 ++++++- sycl/source/handler.cpp | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/sycl/include/sycl/handler.hpp b/sycl/include/sycl/handler.hpp index 51c4fdf3e611b..f41eb41151208 100644 --- a/sycl/include/sycl/handler.hpp +++ b/sycl/include/sycl/handler.hpp @@ -1633,8 +1633,13 @@ class __SYCL_EXPORT handler { void setStateSpecConstSet(); bool isStateExplicitKernelBundle() const; - std::shared_ptr & +#ifdef __INTEL_PREVIEW_BREAKING_CHANGES + __SYCL_DLL_LOCAL std::shared_ptr & + getOrInsertHandlerKernelBundle(bool Insert) const; +#else + std::shared_ptr getOrInsertHandlerKernelBundle(bool Insert) const; +#endif void setHandlerKernelBundle(kernel Kernel); diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index 20b356f1add73..dcfc06b6b310a 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -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 & +#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 +#endif handler::getOrInsertHandlerKernelBundle(bool Insert) const { if (!impl->MKernelBundle && Insert) { auto Ctx = @@ -468,7 +476,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 &KernelBundleImpPtr = +#else + std::shared_ptr KernelBundleImpPtr = +#endif getOrInsertHandlerKernelBundle(/*Insert=*/false); if (KernelBundleImpPtr) { // Make sure implicit non-interop kernel bundles have the kernel @@ -1260,7 +1272,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;