Skip to content

Commit

Permalink
Add TypeList version of IdentityTuple to use it with ParReduce
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderSinn committed Jan 23, 2024
1 parent 9cf9802 commit a955d7c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Src/Base/AMReX_Reduce.H
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,20 @@ IdentityTuple (GpuTuple<Ts...>, ReduceOps<Ps...>) noexcept
return r;
}

/**
* \brief Return a GpuTuple containing the identity element for each ReduceOp in TypeList.
* For example 0, +inf and -inf for ReduceOpSum, ReduceOpMin and ReduceOpMax respectively.
*/
template <typename... Ts, typename... Ps>
AMREX_GPU_HOST_DEVICE
constexpr GpuTuple<Ts...>
IdentityTuple (GpuTuple<Ts...>, TypeList<Ps...>) noexcept
{
GpuTuple<Ts...> r{};
Reduce::detail::for_each_init<0, decltype(r), Ps...>(r);
return r;
}

}

#endif

0 comments on commit a955d7c

Please sign in to comment.