Skip to content

Commit a57d0ae

Browse files
[NFC][SYCL][Reduction] Remove dead code (#7437)
Needs changing "if"->"if constexpr" in few places for that, but that's for the better.
1 parent 1b7582b commit a57d0ae

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

sycl/include/sycl/reduction.hpp

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -830,28 +830,16 @@ template <class FunctorTy> void withAuxHandler(handler &CGH, FunctorTy Func) {
830830
}
831831
} // namespace reduction
832832

833-
// This method is used for implementation of parallel_for accepting 1 reduction.
834-
// TODO: remove this method when everything is switched to general algorithm
835-
// implementing arbitrary number of reductions in parallel_for().
836-
/// Copies the final reduction result kept in read-write accessor to user's
837-
/// accessor. This method is not called for user's read-write accessors
838-
/// requiring update-write to it.
839-
template <typename KernelName, class Reduction>
840-
std::enable_if_t<!Reduction::is_usm>
841-
reduSaveFinalResultToUserMem(handler &CGH, Reduction &Redu) {
842-
auto InAcc = Redu.getReadAccToPreviousPartialReds(CGH);
843-
associateWithHandler(CGH, &Redu.getUserRedVar(), access::target::device);
844-
CGH.copy(InAcc, Redu.getUserRedVar());
845-
}
846-
847833
// This method is used for implementation of parallel_for accepting 1 reduction.
848834
// TODO: remove this method when everything is switched to general algorithm
849835
// implementing arbitrary number of reductions in parallel_for().
850836
/// Copies the final reduction result kept in read-write accessor to user's
851837
/// USM memory.
852838
template <typename KernelName, class Reduction>
853-
std::enable_if_t<Reduction::is_usm>
854-
reduSaveFinalResultToUserMem(handler &CGH, Reduction &Redu) {
839+
void reduSaveFinalResultToUserMem(handler &CGH, Reduction &Redu) {
840+
static_assert(Reduction::is_usm,
841+
"All implementations using this helper are expected to have "
842+
"USM reduction, not a buffer-based one.");
855843
size_t NElements = Reduction::num_elements;
856844
auto InAcc = Redu.getReadAccToPreviousPartialReds(CGH);
857845
auto UserVarPtr = Redu.getUserRedVar();
@@ -1144,7 +1132,7 @@ template <> struct NDRangeReduction<reduction::strategy::range_basic> {
11441132
}
11451133
});
11461134

1147-
if (Reduction::is_usm)
1135+
if constexpr (Reduction::is_usm)
11481136
reduction::withAuxHandler(CGH, [&](handler &CopyHandler) {
11491137
reduSaveFinalResultToUserMem<KernelName>(CopyHandler, Redu);
11501138
});
@@ -1389,7 +1377,7 @@ struct NDRangeReduction<
13891377
});
13901378
} // end while (NWorkItems > 1)
13911379

1392-
if (Reduction::is_usm) {
1380+
if constexpr (Reduction::is_usm) {
13931381
reduction::withAuxHandler(CGH, [&](handler &CopyHandler) {
13941382
reduSaveFinalResultToUserMem<KernelName>(CopyHandler, Redu);
13951383
});
@@ -1589,7 +1577,7 @@ template <> struct NDRangeReduction<reduction::strategy::basic> {
15891577
});
15901578
} // end while (NWorkItems > 1)
15911579

1592-
if (Reduction::is_usm) {
1580+
if constexpr (Reduction::is_usm) {
15931581
reduction::withAuxHandler(CGH, [&](handler &CopyHandler) {
15941582
reduSaveFinalResultToUserMem<KernelName>(CopyHandler, Redu);
15951583
});

0 commit comments

Comments
 (0)