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

Added reduction templates using an identity value. #2610

Merged
merged 3 commits into from May 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 49 additions & 0 deletions hpx/parallel/algorithms/for_loop_reduction.hpp
Expand Up @@ -139,47 +139,96 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v2)
return reduction(var, T(), std::plus<T>());
}

template <typename T>
HPX_FORCEINLINE detail::reduction_helper<T, std::plus<T> >
reduction_plus(T& var, T const& identity)
{
return reduction(var, identity, std::plus<T>());
}

template <typename T>
HPX_FORCEINLINE detail::reduction_helper<T, std::multiplies<T> >
reduction_multiplies(T& var)
{
return reduction(var, T(1), std::multiplies<T>());
}

template <typename T>
HPX_FORCEINLINE detail::reduction_helper<T, std::multiplies<T> >
reduction_multiplies(T& var, T const& identity)
{
return reduction(var, identity, std::multiplies<T>());
}

template <typename T>
HPX_FORCEINLINE detail::reduction_helper<T, std::bit_and<T> >
reduction_bit_and(T& var)
{
return reduction(var, ~(T()), std::bit_and<T>());
}

template <typename T>
HPX_FORCEINLINE detail::reduction_helper<T, std::bit_and<T> >
reduction_bit_and(T& var, T const& identity)
{
return reduction(var, identity, std::bit_and<T>());
}

template <typename T>
HPX_FORCEINLINE detail::reduction_helper<T, std::bit_or<T> >
reduction_bit_or(T& var)
{
return reduction(var, T(), std::bit_or<T>());
}

template <typename T>
HPX_FORCEINLINE detail::reduction_helper<T, std::bit_or<T> >
reduction_bit_or(T& var, T const& identity)
{
return reduction(var, identity, std::bit_or<T>());
}

template <typename T>
HPX_FORCEINLINE detail::reduction_helper<T, std::bit_xor<T> >
reduction_bit_xor(T& var)
{
return reduction(var, T(), std::bit_xor<T>());
}

template <typename T>
HPX_FORCEINLINE detail::reduction_helper<T, std::bit_xor<T> >
reduction_bit_xor(T& var, T const& identity)
{
return reduction(var, identity, std::bit_xor<T>());
}

template <typename T>
HPX_FORCEINLINE detail::reduction_helper<T, v1::detail::min_of<T> >
reduction_min(T& var)
{
return reduction(var, var, v1::detail::min_of<T>());
}

template <typename T>
HPX_FORCEINLINE detail::reduction_helper<T, v1::detail::min_of<T> >
reduction_min(T& var, T const& identity)
{
return reduction(var, identity, v1::detail::min_of<T>());
}

template <typename T>
HPX_FORCEINLINE detail::reduction_helper<T, v1::detail::max_of<T> >
reduction_max(T& var)
{
return reduction(var, var, v1::detail::max_of<T>());
}

template <typename T>
HPX_FORCEINLINE detail::reduction_helper<T, v1::detail::max_of<T> >
reduction_max(T& var, T const& identity)
{
return reduction(var, identity, v1::detail::max_of<T>());
}
/// \endcond
}}}

Expand Down