Skip to content

Commit 8ebd912

Browse files
[SYCL][Reduction] Fix race condition in withAuxHandler (#7563)
1 parent cdb09dc commit 8ebd912

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sycl/include/sycl/reduction.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,8 +821,9 @@ auto make_reduction(RedOutVar RedVar, RestTy &&...Rest) {
821821
namespace reduction {
822822
inline void finalizeHandler(handler &CGH) { CGH.finalize(); }
823823
template <class FunctorTy> void withAuxHandler(handler &CGH, FunctorTy Func) {
824-
CGH.finalize();
824+
event E = CGH.finalize();
825825
handler AuxHandler(CGH.MQueue, CGH.MIsHost);
826+
AuxHandler.depends_on(E);
826827
AuxHandler.saveCodeLoc(CGH.MCodeLoc);
827828
Func(AuxHandler);
828829
CGH.MLastEvent = AuxHandler.finalize();

0 commit comments

Comments
 (0)