From 68dd8bac983721fdc9112104140ae15a92542348 Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Mon, 28 Nov 2022 14:37:32 -0800 Subject: [PATCH 1/2] [SYCL][Reduction] Fix race condition in withAuxHandler --- sycl/include/sycl/reduction.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sycl/include/sycl/reduction.hpp b/sycl/include/sycl/reduction.hpp index ddac3e9b4aca8..4d49984745007 100644 --- a/sycl/include/sycl/reduction.hpp +++ b/sycl/include/sycl/reduction.hpp @@ -821,8 +821,9 @@ auto make_reduction(RedOutVar RedVar, RestTy &&...Rest) { namespace reduction { inline void finalizeHandler(handler &CGH) { CGH.finalize(); } template void withAuxHandler(handler &CGH, FunctorTy Func) { - CGH.finalize(); + auto E = CGH.finalize(); handler AuxHandler(CGH.MQueue, CGH.MIsHost); + AuxHandler.depends_on(E); AuxHandler.saveCodeLoc(CGH.MCodeLoc); Func(AuxHandler); CGH.MLastEvent = AuxHandler.finalize(); From fb9d19f8a6f54db11830b87ad3acd2dce6d51164 Mon Sep 17 00:00:00 2001 From: aelovikov-intel Date: Tue, 29 Nov 2022 09:01:24 -0800 Subject: [PATCH 2/2] Update sycl/include/sycl/reduction.hpp --- 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 4d49984745007..9916cd5c8ffd9 100644 --- a/sycl/include/sycl/reduction.hpp +++ b/sycl/include/sycl/reduction.hpp @@ -821,7 +821,7 @@ auto make_reduction(RedOutVar RedVar, RestTy &&...Rest) { namespace reduction { inline void finalizeHandler(handler &CGH) { CGH.finalize(); } template void withAuxHandler(handler &CGH, FunctorTy Func) { - auto E = CGH.finalize(); + event E = CGH.finalize(); handler AuxHandler(CGH.MQueue, CGH.MIsHost); AuxHandler.depends_on(E); AuxHandler.saveCodeLoc(CGH.MCodeLoc);