Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL] Add reduction overloads accepting span #6019

Merged
merged 22 commits into from
May 2, 2022
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[SYCL] Revert to sycl::detail::tuple
std::tuple is still used for reducers (as in the original code).

Signed-off-by: John Pennycook <john.pennycook@intel.com>
  • Loading branch information
Pennycook committed Apr 29, 2022
commit cb030f279bbbc962f2d1231c7701fdc448898929
14 changes: 8 additions & 6 deletions sycl/include/sycl/ext/oneapi/reduction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ using IsReduOptForFastReduce =
sycl::detail::IsMaximum<T, BinaryOperation>::value)>;
#endif

// Using std::tuple allows usage of functions like std::tuple_element_t
// Switching tuple can be done by changing the definitions below
template <typename... Ts> using ReduTupleT = std::tuple<Ts...>;
// std::tuple seems to be a) too heavy and b) not copyable to device now
// Thus sycl::detail::tuple is used instead.
// Switching from sycl::device::tuple to std::tuple can be done by re-defining
// the ReduTupleT type and makeReduTupleT() function below.
template <typename... Ts> using ReduTupleT = sycl::detail::tuple<Ts...>;
template <typename... Ts> ReduTupleT<Ts...> makeReduTupleT(Ts... Elements) {
return std::make_tuple(Elements...);
return sycl::detail::make_tuple(Elements...);
}

__SYCL_EXPORT size_t reduGetMaxWGSize(std::shared_ptr<queue_impl> Queue,
Expand Down Expand Up @@ -2010,7 +2012,7 @@ template <bool Pow2WG, bool IsOneWG, typename... Reductions, int Dims,
typename... Ts, typename... BOPsT, size_t... Is>
void reduCGFuncImplScalar(
nd_item<Dims> NDIt, ReduTupleT<LocalAccT...> LocalAccsTuple,
ReduTupleT<OutAccT...> OutAccsTuple, ReduTupleT<ReducerT...> &ReducersTuple,
ReduTupleT<OutAccT...> OutAccsTuple, std::tuple<ReducerT...> &ReducersTuple,
ReduTupleT<Ts...> IdentitiesTuple, ReduTupleT<BOPsT...> BOPsTuple,
std::array<bool, sizeof...(Reductions)> InitToIdentityProps,
std::index_sequence<Is...> ReduIndices) {
Expand Down Expand Up @@ -2112,7 +2114,7 @@ template <bool Pow2WG, bool IsOneWG, typename... Reductions, int Dims,
typename... Ts, typename... BOPsT, size_t... Is>
void reduCGFuncImplArray(
nd_item<Dims> NDIt, ReduTupleT<LocalAccT...> LocalAccsTuple,
ReduTupleT<OutAccT...> OutAccsTuple, ReduTupleT<ReducerT...> &ReducersTuple,
ReduTupleT<OutAccT...> OutAccsTuple, std::tuple<ReducerT...> &ReducersTuple,
ReduTupleT<Ts...> IdentitiesTuple, ReduTupleT<BOPsT...> BOPsTuple,
std::array<bool, sizeof...(Reductions)> InitToIdentityProps,
std::index_sequence<Is...> ReduIndices) {
Expand Down