Skip to content

Commit cf039fe

Browse files
WIP Simplify getWriteMemForPartialReds
1 parent 5e305dc commit cf039fe

File tree

1 file changed

+8
-25
lines changed

1 file changed

+8
-25
lines changed

sycl/include/sycl/ext/oneapi/reduction.hpp

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -612,32 +612,15 @@ class reduction_impl_algo : public reduction_impl_common<T, BinaryOperation> {
612612
return {*MOutBufPtr, CGH};
613613
}
614614

615-
/// Returns user's USM pointer passed to reduction for editing.
616-
template <bool IsOneWG, bool _IsUSM = is_usm>
617-
std::enable_if_t<IsOneWG && _IsUSM, result_type *>
618-
getWriteMemForPartialReds(size_t, handler &) {
619-
return getUserRedVar();
620-
}
621-
622-
/// Returns user's accessor passed to reduction for editing if that is
623-
/// the read-write accessor. Otherwise, create a new buffer and return
624-
/// read-write accessor to it.
625-
template <bool IsOneWG, bool _IsUSM = is_usm>
626-
std::enable_if_t<IsOneWG && !_IsUSM, rw_accessor_type>
627-
getWriteMemForPartialReds(size_t, handler &CGH) {
628-
if constexpr (is_rw_acc)
629-
return MRedOut;
630-
return getWriteMemForPartialReds<false>(1, CGH);
631-
}
632-
633-
/// Constructs a new temporary buffer to hold partial sums and returns
634-
/// the accessor for that buffer.
635615
template <bool IsOneWG>
636-
std::enable_if_t<!IsOneWG, rw_accessor_type>
637-
getWriteMemForPartialReds(size_t Size, handler &CGH) {
638-
MOutBufPtr = std::make_shared<buffer<T, buffer_dim>>(range<1>(Size));
639-
CGH.addReduction(MOutBufPtr);
640-
return createHandlerWiredReadWriteAccessor(CGH, *MOutBufPtr);
616+
auto getWriteMemForPartialReds(size_t Size, handler &CGH) {
617+
if constexpr (IsOneWG && !is_dw_acc) {
618+
return MRedOut;
619+
} else {
620+
MOutBufPtr = std::make_shared<buffer<T, buffer_dim>>(range<1>(Size));
621+
CGH.addReduction(MOutBufPtr);
622+
return createHandlerWiredReadWriteAccessor(CGH, *MOutBufPtr);
623+
}
641624
}
642625

643626
/// Returns an accessor accessing the memory that will hold the reduction

0 commit comments

Comments
 (0)