From c0f5bf366f4128382bb43bbe353c318e77a2559f Mon Sep 17 00:00:00 2001 From: Alexey Sachkov Date: Mon, 22 Sep 2025 16:39:30 +0200 Subject: [PATCH 1/4] [SYCL][NFCI] Handler class ABI cleanup [1/N] This PR prepares for removal (once preview breaking changes are promoted) of the following handler APIs: - `single_task(kernel, [](){})` - `lambdaAndKernelHaveEqualName()` - `getKernelName()` --- sycl/include/sycl/handler.hpp | 7 +++++++ sycl/source/handler.cpp | 8 +++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/sycl/include/sycl/handler.hpp b/sycl/include/sycl/handler.hpp index 1e5caaadd5daf..585b35a75671b 100644 --- a/sycl/include/sycl/handler.hpp +++ b/sycl/include/sycl/handler.hpp @@ -528,6 +528,7 @@ class __SYCL_EXPORT handler { bool IsKernelCreatedFromSource, bool IsESIMD); #endif +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES /// \return a string containing name of SYCL kernel. detail::ABINeutralKernelNameStrT getKernelName(); @@ -543,6 +544,7 @@ class __SYCL_EXPORT handler { detail::ABINeutralKernelNameStrT KernelName = getKernelName(); return KernelName == LambdaName; } +#endif /// Saves the location of user's code passed in \p CodeLoc for future usage in /// finalize() method. @@ -1897,6 +1899,10 @@ class __SYCL_EXPORT handler { Kernel); } +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES + // Implementation for something that had to be removed long ago but now stuck + // until next major release... + /// Defines and invokes a SYCL kernel function. /// /// \param Kernel is a SYCL kernel that is executed on a SYCL device @@ -1931,6 +1937,7 @@ class __SYCL_EXPORT handler { detail::CheckDeviceCopyable(); #endif } +#endif // __INTEL_PREVIEW_BREAKING_CHANGES #ifndef __INTEL_PREVIEW_BREAKING_CHANGES /// Defines and invokes a SYCL kernel function for the specified range. diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index e9a4322a5b191..4517eeff24e92 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -1093,7 +1093,7 @@ void handler::extractArgsAndReqs() { if (impl->MKernelData.getDeviceKernelInfoPtr() == nullptr) { impl->MKernelData.setDeviceKernelInfoPtr( &detail::ProgramManager::getInstance().getOrCreateDeviceKernelInfo( - toKernelNameStrT(getKernelName()))); + std::string(MKernel->getName()))); } #endif assert(impl->MKernelData.getDeviceKernelInfoPtr() != nullptr); @@ -1109,7 +1109,7 @@ void handler::extractArgsAndReqsFromLambda( if (impl->MKernelData.getDeviceKernelInfoPtr() == nullptr) { impl->MKernelData.setDeviceKernelInfoPtr( &detail::ProgramManager::getInstance().getOrCreateDeviceKernelInfo( - toKernelNameStrT(getKernelName()))); + std::string(MKernel->getName()))); } impl->MKernelData.setKernelInfo(LambdaPtr, NumKernelParams, ParamDescGetter, IsESIMD, true); @@ -1158,12 +1158,14 @@ void handler::extractArgsAndReqsFromLambda( } #endif // __INTEL_PREVIEW_BREAKING_CHANGES +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES // Calling methods of kernel_impl requires knowledge of class layout. // As this is impossible in header, there's a function that calls necessary // method inside the library and returns the result. detail::ABINeutralKernelNameStrT handler::getKernelName() { return MKernel->getName(); } +#endif void handler::verifyUsedKernelBundleInternal(detail::string_view KernelName) { detail::kernel_bundle_impl *UsedKernelBundleImplPtr = @@ -2239,7 +2241,7 @@ sycl::detail::CGType handler::getType() const { return impl->MCGType; } void handler::setDeviceKernelInfo(kernel &&Kernel) { MKernel = detail::getSyclObjImpl(std::move(Kernel)); - MKernelName = getKernelName(); + MKernelName = MKernel->getName(); setDeviceKernelInfoPtr(&MKernel->getDeviceKernelInfo()); setType(detail::CGType::Kernel); From f3be8a354c6de848c88eed4b37ec224abfbdb7e9 Mon Sep 17 00:00:00 2001 From: Alexey Sachkov Date: Mon, 22 Sep 2025 16:55:32 +0200 Subject: [PATCH 2/4] Reduce the diff --- sycl/source/handler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index 4517eeff24e92..7ef92d928a1f6 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -1093,7 +1093,7 @@ void handler::extractArgsAndReqs() { if (impl->MKernelData.getDeviceKernelInfoPtr() == nullptr) { impl->MKernelData.setDeviceKernelInfoPtr( &detail::ProgramManager::getInstance().getOrCreateDeviceKernelInfo( - std::string(MKernel->getName()))); + detail::toKernelNameStrT(MKernel->getName()))); } #endif assert(impl->MKernelData.getDeviceKernelInfoPtr() != nullptr); @@ -1109,7 +1109,7 @@ void handler::extractArgsAndReqsFromLambda( if (impl->MKernelData.getDeviceKernelInfoPtr() == nullptr) { impl->MKernelData.setDeviceKernelInfoPtr( &detail::ProgramManager::getInstance().getOrCreateDeviceKernelInfo( - std::string(MKernel->getName()))); + detail::toKernelNameStrT(MKernel->getName()))); } impl->MKernelData.setKernelInfo(LambdaPtr, NumKernelParams, ParamDescGetter, IsESIMD, true); From 50dba03f773f609c20db1e42a3fcc03b96817f81 Mon Sep 17 00:00:00 2001 From: Alexey Sachkov Date: Mon, 22 Sep 2025 20:05:42 +0200 Subject: [PATCH 3/4] Fix tests and deprecate public method --- sycl/include/sycl/handler.hpp | 1 + sycl/test-e2e/Basic/kernel_info.cpp | 6 ++++-- sycl/test-e2e/Basic/kernel_info_attr.cpp | 6 ++++-- sycl/test-e2e/DeviceCodeSplit/split-per-kernel.cpp | 6 +++--- sycl/test-e2e/DeviceCodeSplit/split-per-source-main.cpp | 4 ++-- .../DeviceImageBackendContent/CUDA_interop_test.cpp | 6 ++++-- sycl/test-e2e/DeviceImageBackendContent/basic_test.cpp | 6 ++++-- sycl/test-e2e/NewOffloadDriver/split-per-source-main.cpp | 4 ++-- 8 files changed, 24 insertions(+), 15 deletions(-) diff --git a/sycl/include/sycl/handler.hpp b/sycl/include/sycl/handler.hpp index 585b35a75671b..a35611d7a1b4f 100644 --- a/sycl/include/sycl/handler.hpp +++ b/sycl/include/sycl/handler.hpp @@ -1909,6 +1909,7 @@ class __SYCL_EXPORT handler { /// (except for the host device). /// \param KernelFunc is a lambda that is used if device, queue is bound to, /// is a host device. + __SYCL_DEPRECATED("This overload isn't part of SYCL2020 and will be removed.") template void single_task(kernel Kernel, const KernelType &KernelFunc) { // Ignore any set kernel bundles and use the one associated with the kernel diff --git a/sycl/test-e2e/Basic/kernel_info.cpp b/sycl/test-e2e/Basic/kernel_info.cpp index b3814cdeb6ea3..1d769a54a2e9a 100644 --- a/sycl/test-e2e/Basic/kernel_info.cpp +++ b/sycl/test-e2e/Basic/kernel_info.cpp @@ -18,6 +18,8 @@ using namespace sycl; namespace syclex = sycl::ext::oneapi; +class SingleTask; + auto checkExceptionIsThrown = [](auto &getInfoFunc, const std::string &refErrMsg, std::error_code refErrc) { @@ -40,13 +42,13 @@ int main() { queue q; auto ctx = q.get_context(); buffer buf(range<1>(1)); - auto kernelID = sycl::get_kernel_id(); + auto kernelID = sycl::get_kernel_id(); auto kb = get_kernel_bundle(ctx, {kernelID}); kernel krn = kb.get_kernel(kernelID); q.submit([&](handler &cgh) { auto acc = buf.get_access(cgh); - cgh.single_task(krn, [=]() { acc[0] = acc[0] + 1; }); + cgh.single_task([=]() { acc[0] = acc[0] + 1; }); }); const std::string krnName = krn.get_info(); diff --git a/sycl/test-e2e/Basic/kernel_info_attr.cpp b/sycl/test-e2e/Basic/kernel_info_attr.cpp index a1a302435a83e..7299ff803b182 100644 --- a/sycl/test-e2e/Basic/kernel_info_attr.cpp +++ b/sycl/test-e2e/Basic/kernel_info_attr.cpp @@ -25,17 +25,19 @@ using namespace sycl; namespace syclex = sycl::ext::oneapi; +class SingleTask; + int main() { queue q; auto ctx = q.get_context(); buffer buf(range<1>(1)); - auto KernelID = sycl::get_kernel_id(); + auto KernelID = sycl::get_kernel_id(); auto KB = get_kernel_bundle(ctx, {KernelID}); kernel krn = KB.get_kernel(KernelID); q.submit([&](handler &cgh) { auto acc = buf.get_access(cgh); - cgh.single_task(krn, [=]() { acc[0] = acc[0] + 1; }); + cgh.single_task([=]() { acc[0] = acc[0] + 1; }); }); const std::string krnAttr = krn.get_info(); diff --git a/sycl/test-e2e/DeviceCodeSplit/split-per-kernel.cpp b/sycl/test-e2e/DeviceCodeSplit/split-per-kernel.cpp index 15677a64ea5e5..7503ef6db464b 100644 --- a/sycl/test-e2e/DeviceCodeSplit/split-per-kernel.cpp +++ b/sycl/test-e2e/DeviceCodeSplit/split-per-kernel.cpp @@ -26,7 +26,7 @@ int main() { Q.submit([&](sycl::handler &Cgh) { auto Acc = Buf.get_access(Cgh); - Cgh.single_task(Krn, [=]() { Acc[0] = 1; }); + Cgh.single_task([=]() { Acc[0] = 1; }); }); } assert(Data == 1); @@ -45,7 +45,7 @@ int main() { Q.submit([&](sycl::handler &Cgh) { auto Acc = Buf.get_access(Cgh); - Cgh.single_task(Krn, [=]() { Acc[0] = 2; }); + Cgh.single_task([=]() { Acc[0] = 2; }); }); } assert(Data == 2); @@ -64,7 +64,7 @@ int main() { Q.submit([&](sycl::handler &Cgh) { auto Acc = Buf.get_access(Cgh); - Cgh.single_task(Krn, [=]() { Acc[0] = 3; }); + Cgh.single_task([=]() { Acc[0] = 3; }); }); } assert(Data == 3); diff --git a/sycl/test-e2e/DeviceCodeSplit/split-per-source-main.cpp b/sycl/test-e2e/DeviceCodeSplit/split-per-source-main.cpp index 29c6102f71284..ed498fa8e8d52 100644 --- a/sycl/test-e2e/DeviceCodeSplit/split-per-source-main.cpp +++ b/sycl/test-e2e/DeviceCodeSplit/split-per-source-main.cpp @@ -31,7 +31,7 @@ int main() { sycl::buffer Buf(&Data, sycl::range<1>(1)); Q.submit([&](sycl::handler &Cgh) { auto Acc = Buf.get_access(Cgh); - Cgh.single_task(Krn1, [=]() { Acc[0] = 1; }); + Cgh.single_task([=]() { Acc[0] = 1; }); }); } assert(Data == 1); @@ -40,7 +40,7 @@ int main() { sycl::buffer Buf(&Data, sycl::range<1>(1)); Q.submit([&](sycl::handler &Cgh) { auto Acc = Buf.get_access(Cgh); - Cgh.single_task(Krn2, [=]() { Acc[0] = 2; }); + Cgh.single_task([=]() { Acc[0] = 2; }); }); } assert(Data == 2); diff --git a/sycl/test-e2e/DeviceImageBackendContent/CUDA_interop_test.cpp b/sycl/test-e2e/DeviceImageBackendContent/CUDA_interop_test.cpp index 3ecf862130665..fda63b24cfbc7 100644 --- a/sycl/test-e2e/DeviceImageBackendContent/CUDA_interop_test.cpp +++ b/sycl/test-e2e/DeviceImageBackendContent/CUDA_interop_test.cpp @@ -7,10 +7,12 @@ #include #include +class mykernel; + int main() { sycl::queue q; sycl::context ctxt = q.get_context(); - sycl::kernel_id k_id = sycl::get_kernel_id(); + sycl::kernel_id k_id = sycl::get_kernel_id(); auto bundle = sycl::get_kernel_bundle(ctxt, {k_id}); assert(!bundle.empty()); @@ -18,7 +20,7 @@ int main() { sycl::buffer buf(sycl::range<1>(1)); q.submit([&](sycl::handler &cgh) { sycl::accessor acc(buf, cgh); - cgh.single_task(krn, [=]() { acc[0] = 42; }); + cgh.single_task([=]() { acc[0] = 42; }); }); const auto img = *(bundle.begin()); const auto bytes = img.ext_oneapi_get_backend_content(); diff --git a/sycl/test-e2e/DeviceImageBackendContent/basic_test.cpp b/sycl/test-e2e/DeviceImageBackendContent/basic_test.cpp index 83539aa41c1ec..b2cbcb8b0c0dc 100644 --- a/sycl/test-e2e/DeviceImageBackendContent/basic_test.cpp +++ b/sycl/test-e2e/DeviceImageBackendContent/basic_test.cpp @@ -5,18 +5,20 @@ #include #include +class mykernel; + int main() { sycl::queue q; sycl::context ctxt = q.get_context(); sycl::buffer buf(sycl::range<1>(1)); - sycl::kernel_id k_id = sycl::get_kernel_id(); + sycl::kernel_id k_id = sycl::get_kernel_id(); auto bundle = sycl::get_kernel_bundle(ctxt, {k_id}); assert(!bundle.empty()); sycl::kernel krn = bundle.get_kernel(k_id); q.submit([&](sycl::handler &cgh) { sycl::accessor acc(buf, cgh); - cgh.single_task(krn, [=]() { acc[0] = 42; }); + cgh.single_task([=]() { acc[0] = 42; }); }); sycl::backend backend; std::vector bytes; diff --git a/sycl/test-e2e/NewOffloadDriver/split-per-source-main.cpp b/sycl/test-e2e/NewOffloadDriver/split-per-source-main.cpp index fc08e94aee467..d78c39f7bdfd1 100644 --- a/sycl/test-e2e/NewOffloadDriver/split-per-source-main.cpp +++ b/sycl/test-e2e/NewOffloadDriver/split-per-source-main.cpp @@ -31,7 +31,7 @@ int main() { sycl::buffer Buf(&Data, sycl::range<1>(1)); Q.submit([&](sycl::handler &Cgh) { auto Acc = Buf.get_access(Cgh); - Cgh.single_task(Krn1, [=]() { Acc[0] = 1; }); + Cgh.single_task([=]() { Acc[0] = 1; }); }); } assert(Data == 1); @@ -40,7 +40,7 @@ int main() { sycl::buffer Buf(&Data, sycl::range<1>(1)); Q.submit([&](sycl::handler &Cgh) { auto Acc = Buf.get_access(Cgh); - Cgh.single_task(Krn2, [=]() { Acc[0] = 2; }); + Cgh.single_task([=]() { Acc[0] = 2; }); }); } assert(Data == 2); From 57f22122cd0f40ac4ee0c50e2dd23f4d3792075b Mon Sep 17 00:00:00 2001 From: Alexey Sachkov Date: Tue, 23 Sep 2025 12:35:28 +0200 Subject: [PATCH 4/4] Fix deprecation macro placement and a few more tests --- sycl/include/sycl/handler.hpp | 2 +- .../DeviceCodeSplit/Inputs/split-per-source-second-file.cpp | 2 +- .../Inputs/split-per-source-second-file.cpp | 2 +- sycl/test/warnings/deprecated_get_backend_info.cpp | 6 ++++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sycl/include/sycl/handler.hpp b/sycl/include/sycl/handler.hpp index a35611d7a1b4f..67f21bc05857f 100644 --- a/sycl/include/sycl/handler.hpp +++ b/sycl/include/sycl/handler.hpp @@ -1909,8 +1909,8 @@ class __SYCL_EXPORT handler { /// (except for the host device). /// \param KernelFunc is a lambda that is used if device, queue is bound to, /// is a host device. - __SYCL_DEPRECATED("This overload isn't part of SYCL2020 and will be removed.") template + __SYCL_DEPRECATED("This overload isn't part of SYCL2020 and will be removed.") void single_task(kernel Kernel, const KernelType &KernelFunc) { // Ignore any set kernel bundles and use the one associated with the kernel setHandlerKernelBundle(Kernel); diff --git a/sycl/test-e2e/DeviceCodeSplit/Inputs/split-per-source-second-file.cpp b/sycl/test-e2e/DeviceCodeSplit/Inputs/split-per-source-second-file.cpp index d5ee857ec4df3..67d5a1f752b24 100644 --- a/sycl/test-e2e/DeviceCodeSplit/Inputs/split-per-source-second-file.cpp +++ b/sycl/test-e2e/DeviceCodeSplit/Inputs/split-per-source-second-file.cpp @@ -16,7 +16,7 @@ void runKernelsFromFile2() { Q.submit([&](sycl::handler &Cgh) { auto Acc = Buf.get_access(Cgh); - Cgh.single_task(Krn, [=]() { Acc[0] = 3; }); + Cgh.single_task([=]() { Acc[0] = 3; }); }); } assert(Data == 3); diff --git a/sycl/test-e2e/NewOffloadDriver/Inputs/split-per-source-second-file.cpp b/sycl/test-e2e/NewOffloadDriver/Inputs/split-per-source-second-file.cpp index d5ee857ec4df3..67d5a1f752b24 100644 --- a/sycl/test-e2e/NewOffloadDriver/Inputs/split-per-source-second-file.cpp +++ b/sycl/test-e2e/NewOffloadDriver/Inputs/split-per-source-second-file.cpp @@ -16,7 +16,7 @@ void runKernelsFromFile2() { Q.submit([&](sycl::handler &Cgh) { auto Acc = Buf.get_access(Cgh); - Cgh.single_task(Krn, [=]() { Acc[0] = 3; }); + Cgh.single_task([=]() { Acc[0] = 3; }); }); } assert(Data == 3); diff --git a/sycl/test/warnings/deprecated_get_backend_info.cpp b/sycl/test/warnings/deprecated_get_backend_info.cpp index 1932fc910fc68..7bc24d835d3bb 100644 --- a/sycl/test/warnings/deprecated_get_backend_info.cpp +++ b/sycl/test/warnings/deprecated_get_backend_info.cpp @@ -6,6 +6,8 @@ using namespace sycl; +class SingleTask; + int main() { #if (defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI != 0) || \ !defined(_GLIBCXX_USE_CXX11_ABI) || TEST_ERRORS @@ -77,13 +79,13 @@ int main() { // Test get_backend_info for sycl::kernel // Trivial kernel simply for testing buffer buf(range<1>(1)); - auto KernelID = sycl::get_kernel_id(); + auto KernelID = sycl::get_kernel_id(); auto KB = get_kernel_bundle(q.get_context(), {KernelID}); kernel krn = KB.get_kernel(KernelID); q.submit([&](handler &cgh) { auto acc = buf.get_access(cgh); - cgh.single_task(krn, [=]() { acc[0] = acc[0] + 1; }); + cgh.single_task([=]() { acc[0] = acc[0] + 1; }); }); // expected-warning@+3 {{'get_backend_info' is deprecated: All current implementations of get_backend_info() are to be removed. Use respective variants of get_info() instead.}} // expected-warning@+2 {{'get_backend_info' is deprecated: All current implementations of get_backend_info() are to be removed. Use respective variants of get_info() instead.}}