From 28711a7ea0694db1a9b74fd249490ab14c87db60 Mon Sep 17 00:00:00 2001 From: Alexandr Konovalov Date: Mon, 18 Nov 2024 17:14:54 +0100 Subject: [PATCH 1/6] [SYCL] Check for duplicates in handler::addAccessorReq() Constructor of accessors add them to MRequirements and MAccStorage of the associated handler, so do not add duplicates here if same handler was used during construction. --- sycl/source/handler.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index 61ea7ee7be0a0..03cfd7bddc5ae 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -2056,6 +2056,14 @@ void handler::SetHostTask(std::function &&Func) { } void handler::addAccessorReq(detail::AccessorImplPtr Accessor) { + // Constructor of accessors add them to MRequirements and MAccStorage + // of the associated handler, so do not add duplicates if use same + // handler as during construction. + if (impl->CGData.MRequirements.end() != + std::find(impl->CGData.MRequirements.begin(), + impl->CGData.MRequirements.end(), Accessor.get())) + return; + // Add accessor to the list of requirements. impl->CGData.MRequirements.push_back(Accessor.get()); // Store copy of the accessor. From 81cd238881f6f875c7fec57c769db925fb6cc65c Mon Sep 17 00:00:00 2001 From: Alexandr Konovalov Date: Thu, 21 Nov 2024 09:38:01 +0100 Subject: [PATCH 2/6] Skip handler::addAccessorReq(). --- sycl/source/handler.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index 03cfd7bddc5ae..46880cef05450 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -2056,6 +2056,7 @@ void handler::SetHostTask(std::function &&Func) { } void handler::addAccessorReq(detail::AccessorImplPtr Accessor) { +#if 0 // Constructor of accessors add them to MRequirements and MAccStorage // of the associated handler, so do not add duplicates if use same // handler as during construction. @@ -2068,6 +2069,7 @@ void handler::addAccessorReq(detail::AccessorImplPtr Accessor) { impl->CGData.MRequirements.push_back(Accessor.get()); // Store copy of the accessor. impl->CGData.MAccStorage.push_back(std::move(Accessor)); +#endif } void handler::addLifetimeSharedPtrStorage(std::shared_ptr SPtr) { From 9f0e3efe2f971bf74255b18af13ef712d7978a59 Mon Sep 17 00:00:00 2001 From: Alexandr Konovalov Date: Thu, 21 Nov 2024 17:22:19 +0100 Subject: [PATCH 3/6] Change command group for accessor. --- sycl/include/sycl/reduction.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/include/sycl/reduction.hpp b/sycl/include/sycl/reduction.hpp index f84940d81d162..576dac72a3ce2 100644 --- a/sycl/include/sycl/reduction.hpp +++ b/sycl/include/sycl/reduction.hpp @@ -1014,7 +1014,7 @@ class reduction_impl_algo { } }); } else { - accessor OutAcc{Out, CGH}; + accessor OutAcc{Out, CopyHandler}; CopyHandler.copy(Mem, OutAcc); } }); From 0fa3f4500c5448827d1afd24abcc6b786be637a6 Mon Sep 17 00:00:00 2001 From: Alexandr Konovalov Date: Fri, 22 Nov 2024 09:55:57 +0100 Subject: [PATCH 4/6] Remove calls of handler::addAccessorReq. --- sycl/include/sycl/handler.hpp | 13 ------------- sycl/source/handler.cpp | 17 ++--------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/sycl/include/sycl/handler.hpp b/sycl/include/sycl/handler.hpp index 8abb4323ab3e1..e0a5caab1cbde 100644 --- a/sycl/include/sycl/handler.hpp +++ b/sycl/include/sycl/handler.hpp @@ -618,7 +618,6 @@ class __SYCL_EXPORT handler { detail::AccessorBaseHost *AccBase = (detail::AccessorBaseHost *)&Arg; detail::AccessorImplPtr AccImpl = detail::getSyclObjImpl(*AccBase); detail::AccessorImplHost *Req = AccImpl.get(); - addAccessorReq(std::move(AccImpl)); // Add accessor to the list of arguments. addArg(detail::kernel_param_kind_t::kind_accessor, Req, static_cast(AccessTarget), ArgIndex); @@ -2580,9 +2579,6 @@ class __SYCL_EXPORT handler { MSrcPtr = static_cast(AccImpl.get()); MDstPtr = static_cast(Dst); - // Store copy of accessor to the local storage to make sure it is alive - // until we finish - addAccessorReq(std::move(AccImpl)); } /// Copies the content of memory pointed by Src into the memory object @@ -2618,9 +2614,6 @@ class __SYCL_EXPORT handler { MSrcPtr = const_cast(Src); MDstPtr = static_cast(AccImpl.get()); - // Store copy of accessor to the local storage to make sure it is alive - // until we finish - addAccessorReq(std::move(AccImpl)); } /// Copies the content of memory object accessed by Src to the memory @@ -2675,10 +2668,6 @@ class __SYCL_EXPORT handler { MSrcPtr = AccImplSrc.get(); MDstPtr = AccImplDst.get(); - // Store copy of accessor to the local storage to make sure it is alive - // until we finish - addAccessorReq(std::move(AccImplSrc)); - addAccessorReq(std::move(AccImplDst)); } /// Provides guarantees that the memory object accessed via Acc is updated @@ -2704,7 +2693,6 @@ class __SYCL_EXPORT handler { detail::AccessorImplPtr AccImpl = detail::getSyclObjImpl(*AccBase); MDstPtr = static_cast(AccImpl.get()); - addAccessorReq(std::move(AccImpl)); } public: @@ -3459,7 +3447,6 @@ class __SYCL_EXPORT handler { detail::AccessorImplPtr AccImpl = detail::getSyclObjImpl(*AccBase); MDstPtr = static_cast(AccImpl.get()); - addAccessorReq(std::move(AccImpl)); MPattern.resize(sizeof(T)); auto PatternPtr = reinterpret_cast(MPattern.data()); diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index 46880cef05450..f0c58671f6e38 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -2055,21 +2055,8 @@ void handler::SetHostTask(std::function &&Func) { setType(detail::CGType::CodeplayHostTask); } -void handler::addAccessorReq(detail::AccessorImplPtr Accessor) { -#if 0 - // Constructor of accessors add them to MRequirements and MAccStorage - // of the associated handler, so do not add duplicates if use same - // handler as during construction. - if (impl->CGData.MRequirements.end() != - std::find(impl->CGData.MRequirements.begin(), - impl->CGData.MRequirements.end(), Accessor.get())) - return; - - // Add accessor to the list of requirements. - impl->CGData.MRequirements.push_back(Accessor.get()); - // Store copy of the accessor. - impl->CGData.MAccStorage.push_back(std::move(Accessor)); -#endif +void handler::addAccessorReq(detail::AccessorImplPtr) { + assert(false && "The function must not be used."); } void handler::addLifetimeSharedPtrStorage(std::shared_ptr SPtr) { From 6a8da972d412e7a6c1c6aa4a9c62a785dfa8a430 Mon Sep 17 00:00:00 2001 From: Alexandr Konovalov Date: Thu, 28 Nov 2024 18:23:06 +0100 Subject: [PATCH 5/6] Mark handler::addAccessorReq() as to be removed. --- sycl/source/handler.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index f0c58671f6e38..df528f25cbde7 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -2055,8 +2055,13 @@ void handler::SetHostTask(std::function &&Func) { setType(detail::CGType::CodeplayHostTask); } -void handler::addAccessorReq(detail::AccessorImplPtr) { - assert(false && "The function must not be used."); +// TODO: This function is not used anymore, remove it in the next +// ABI-breaking window. +void handler::addAccessorReq(detail::AccessorImplPtr Accessor) { + // Add accessor to the list of requirements. + impl->CGData.MRequirements.push_back(Accessor.get()); + // Store copy of the accessor. + impl->CGData.MAccStorage.push_back(std::move(Accessor)); } void handler::addLifetimeSharedPtrStorage(std::shared_ptr SPtr) { From 10a1e684a5974d84280868d2ed9492b40cd42a90 Mon Sep 17 00:00:00 2001 From: Alexandr Konovalov Date: Thu, 5 Dec 2024 10:04:10 +0100 Subject: [PATCH 6/6] Add sycl/source/handler.cpp --- sycl/source/handler.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index df528f25cbde7..8bd4d77ba1332 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -2055,6 +2055,7 @@ void handler::SetHostTask(std::function &&Func) { setType(detail::CGType::CodeplayHostTask); } +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES // TODO: This function is not used anymore, remove it in the next // ABI-breaking window. void handler::addAccessorReq(detail::AccessorImplPtr Accessor) { @@ -2063,6 +2064,7 @@ void handler::addAccessorReq(detail::AccessorImplPtr Accessor) { // Store copy of the accessor. impl->CGData.MAccStorage.push_back(std::move(Accessor)); } +#endif void handler::addLifetimeSharedPtrStorage(std::shared_ptr SPtr) { impl->CGData.MSharedPtrStorage.push_back(std::move(SPtr));