Skip to content

Commit

Permalink
Merge #386
Browse files Browse the repository at this point in the history
386: Clean up type support r=msimberg a=aurianer

Part of #16.
- Delete unused lazy_enable_if.
- Move functionalities into detail namespace.
- Rename unwrap_ref to unwrap_reference for C++20 conformance.
- Rename identity to type_identity for C++20 conformance.

Co-authored-by: Auriane R <aurianer@cscs.ch>
  • Loading branch information
bors[bot] and aurianer authored Aug 22, 2022
2 parents 2d7ba4e + 7526716 commit 82131af
Show file tree
Hide file tree
Showing 95 changed files with 824 additions and 799 deletions.
24 changes: 13 additions & 11 deletions libs/pika/algorithms/include/pika/algorithms/traits/projected.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,13 @@ namespace pika { namespace parallel { namespace traits {
};

template <typename ExPolicy, typename F, typename... Projected>
struct is_indirect_callable<ExPolicy, F, pika::util::pack<Projected...>,
typename std::enable_if<pika::util::all_of<is_projected_indirect<
Projected>...>::value &&
struct is_indirect_callable<ExPolicy, F,
pika::util::detail::pack<Projected...>,
std::enable_if_t<pika::util::detail::all_of_v<
is_projected_indirect<Projected>...> &&
(!pika::is_vectorpack_execution_policy<ExPolicy>::value ||
!pika::util::all_of<
is_projected_zip_iterator<Projected>...>::value)>::type>
!pika::util::detail::all_of_v<
is_projected_zip_iterator<Projected>...>)>>
: is_indirect_callable_impl<F,
typename projected_result_of_indirect<Projected>::type...>
{
Expand All @@ -202,12 +203,13 @@ namespace pika { namespace parallel { namespace traits {
// special handling because zip_iterator<>::reference is not a real
// reference type.
template <typename ExPolicy, typename F, typename... Projected>
struct is_indirect_callable<ExPolicy, F, pika::util::pack<Projected...>,
typename std::enable_if<pika::util::all_of<is_projected_indirect<
Projected>...>::value &&
struct is_indirect_callable<ExPolicy, F,
pika::util::detail::pack<Projected...>,
std::enable_if_t<pika::util::detail::all_of_v<
is_projected_indirect<Projected>...> &&
pika::is_vectorpack_execution_policy<ExPolicy>::value &&
pika::util::all_of<
is_projected_zip_iterator<Projected>...>::value>::type>
pika::util::detail::all_of_v<
is_projected_zip_iterator<Projected>...>>>
: is_indirect_callable_impl<F,
typename projected_result_of_vector_pack<Projected>::type...>
{
Expand All @@ -218,7 +220,7 @@ namespace pika { namespace parallel { namespace traits {
template <typename ExPolicy, typename F, typename... Projected>
struct is_indirect_callable
: detail::is_indirect_callable<std::decay_t<ExPolicy>, std::decay_t<F>,
pika::util::pack<std::decay_t<Projected>...>>
pika::util::detail::pack<std::decay_t<Projected>...>>
{
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ namespace pika {
typename pika::parallel::util::detail::algorithm_result<
ExPolicy>::type;

return pika::util::void_guard<result_type>(),
return pika::util::detail::void_guard<result_type>(),
pika::parallel::v1::detail::fill<FwdIter>().call(
PIKA_FORWARD(ExPolicy, policy), first, last, value);
}
Expand Down
63 changes: 33 additions & 30 deletions libs/pika/algorithms/include/pika/parallel/algorithms/for_loop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ namespace pika {
///////////////////////////////////////////////////////////////////////
template <typename... Ts, std::size_t... Is>
PIKA_HOST_DEVICE PIKA_FORCEINLINE constexpr void init_iteration(
std::tuple<Ts...>& args, pika::util::index_pack<Is...>,
std::tuple<Ts...>& args, pika::util::detail::index_pack<Is...>,
std::size_t part_index) noexcept
{
int const _sequencer[] = {
Expand All @@ -777,16 +777,17 @@ namespace pika {

template <typename... Ts, std::size_t... Is, typename F, typename B>
PIKA_HOST_DEVICE PIKA_FORCEINLINE constexpr void invoke_iteration(
std::tuple<Ts...>& args, pika::util::index_pack<Is...>, F&& f,
B part_begin)
std::tuple<Ts...>& args, pika::util::detail::index_pack<Is...>,
F&& f, B part_begin)
{
PIKA_INVOKE(PIKA_FORWARD(F, f), part_begin,
std::get<Is>(args).iteration_value()...);
}

template <typename... Ts, std::size_t... Is>
PIKA_HOST_DEVICE PIKA_FORCEINLINE constexpr void next_iteration(
std::tuple<Ts...>& args, pika::util::index_pack<Is...>) noexcept
std::tuple<Ts...>& args,
pika::util::detail::index_pack<Is...>) noexcept
{
int const _sequencer[] = {
0, (std::get<Is>(args).next_iteration(), 0)...};
Expand All @@ -795,7 +796,7 @@ namespace pika {

template <typename... Ts, std::size_t... Is>
PIKA_HOST_DEVICE PIKA_FORCEINLINE constexpr void exit_iteration(
std::tuple<Ts...>& args, pika::util::index_pack<Is...>,
std::tuple<Ts...>& args, pika::util::detail::index_pack<Is...>,
std::size_t size) noexcept
{
int const _sequencer[] = {
Expand Down Expand Up @@ -830,8 +831,9 @@ namespace pika {
B part_begin, std::size_t part_steps,
std::size_t part_index)
{
auto pack = typename pika::util::make_index_pack<sizeof...(
Ts)>::type();
auto pack =
typename pika::util::detail::make_index_pack<sizeof...(
Ts)>::type();
detail::init_iteration(args_, pack, part_index);

if (stride_ == 1)
Expand Down Expand Up @@ -982,9 +984,10 @@ namespace pika {

template <typename ExPolicy, typename InIter, typename S,
typename F>
PIKA_HOST_DEVICE static constexpr pika::util::unused_type
sequential(ExPolicy&&, InIter first, std::size_t count,
S stride, F&& f)
PIKA_HOST_DEVICE static constexpr pika::util::detail::
unused_type
sequential(ExPolicy&&, InIter first, std::size_t count,
S stride, F&& f)
{
if (stride == 1)
{
Expand Down Expand Up @@ -1022,14 +1025,15 @@ namespace pika {
}
}

return pika::util::unused_type();
return pika::util::detail::unused_type();
}

template <typename ExPolicy, typename InIter, typename Size,
typename S, typename F, typename Arg, typename... Args>
PIKA_HOST_DEVICE static constexpr pika::util::unused_type
sequential(ExPolicy&&, InIter first, Size size, S stride, F&& f,
Arg&& arg, Args&&... args)
PIKA_HOST_DEVICE static constexpr pika::util::detail::
unused_type
sequential(ExPolicy&&, InIter first, Size size, S stride,
F&& f, Arg&& arg, Args&&... args)
{
int const init_sequencer[] = {(arg.init_iteration(0), 0),
(args.init_iteration(0), 0)...};
Expand Down Expand Up @@ -1080,7 +1084,7 @@ namespace pika {
(args.exit_iteration(size), 0)...};
(void) exit_sequencer;

return pika::util::unused_type();
return pika::util::detail::unused_type();
}

template <typename ExPolicy, typename B, typename Size,
Expand All @@ -1102,14 +1106,14 @@ namespace pika {
PIKA_FORWARD(ExPolicy, policy), first, size,
part_iterations<ExPolicy, F, S>{
PIKA_FORWARD(F, f)},
pika::util::empty_function{});
pika::util::detail::empty_function{});
}

return util::partitioner<ExPolicy>::call_with_index(
PIKA_FORWARD(ExPolicy, policy), first, size, stride,
part_iterations<ExPolicy, F, S>{
PIKA_FORWARD(F, f), stride},
pika::util::empty_function{});
pika::util::detail::empty_function{});
}
else
{
Expand All @@ -1126,9 +1130,8 @@ namespace pika {
PIKA_FORWARD(F, f), stride, args},
[=](std::vector<pika::future<void>>&&) mutable
-> void {
auto pack =
typename pika::util::make_index_pack<
sizeof...(Ts)>::type();
auto pack = typename pika::util::detail::
make_index_pack<sizeof...(Ts)>::type();
// make sure live-out variables are properly set on
// return
detail::exit_iteration(args, pack, size);
Expand All @@ -1142,7 +1145,7 @@ namespace pika {
std::size_t... Is, typename... Args>
typename util::detail::algorithm_result<ExPolicy>::type for_loop(
ExPolicy&& policy, B first, E last, S stride,
pika::util::index_pack<Is...>, Args&&... args)
pika::util::detail::index_pack<Is...>, Args&&... args)
{
// stride shall not be zero
PIKA_ASSERT(stride != 0);
Expand Down Expand Up @@ -1173,7 +1176,7 @@ namespace pika {
std::size_t... Is, typename... Args>
typename util::detail::algorithm_result<ExPolicy>::type for_loop_n(
ExPolicy&& policy, B first, Size size, S stride,
pika::util::index_pack<Is...>, Args&&... args)
pika::util::detail::index_pack<Is...>, Args&&... args)
{
// stride shall not be zero
PIKA_ASSERT(stride != 0);
Expand Down Expand Up @@ -1221,7 +1224,7 @@ namespace pika {
static_assert(sizeof...(Args) >= 1,
"for_loop must be called with at least a function object");

using pika::util::make_index_pack;
using pika::util::detail::make_index_pack;
return parallel::v2::detail::for_loop(
PIKA_FORWARD(ExPolicy, policy), first, last, 1,
typename make_index_pack<sizeof...(Args) - 1>::type(),
Expand All @@ -1241,7 +1244,7 @@ namespace pika {
static_assert(sizeof...(Args) >= 1,
"for_loop must be called with at least a function object");

using pika::util::make_index_pack;
using pika::util::detail::make_index_pack;
return parallel::v2::detail::for_loop(pika::execution::seq, first,
last, 1, typename make_index_pack<sizeof...(Args) - 1>::type(),
PIKA_FORWARD(Args, args)...);
Expand Down Expand Up @@ -1270,7 +1273,7 @@ namespace pika {
"for_loop_strided must be called with at least a function "
"object");

using pika::util::make_index_pack;
using pika::util::detail::make_index_pack;
return parallel::v2::detail::for_loop(
PIKA_FORWARD(ExPolicy, policy), first, last, stride,
typename make_index_pack<sizeof...(Args) - 1>::type(),
Expand All @@ -1292,7 +1295,7 @@ namespace pika {
"for_loop_strided must be called with at least a function "
"object");

using pika::util::make_index_pack;
using pika::util::detail::make_index_pack;
return parallel::v2::detail::for_loop(pika::execution::seq, first,
last, stride,
typename make_index_pack<sizeof...(Args) - 1>::type(),
Expand Down Expand Up @@ -1322,7 +1325,7 @@ namespace pika {
static_assert(sizeof...(Args) >= 1,
"for_loop_n must be called with at least a function object");

using pika::util::make_index_pack;
using pika::util::detail::make_index_pack;
return parallel::v2::detail::for_loop_n(
PIKA_FORWARD(ExPolicy, policy), first, size, 1,
typename make_index_pack<sizeof...(Args) - 1>::type(),
Expand All @@ -1343,7 +1346,7 @@ namespace pika {
static_assert(sizeof...(Args) >= 1,
"for_loop_n must be called with at least a function object");

using pika::util::make_index_pack;
using pika::util::detail::make_index_pack;
return parallel::v2::detail::for_loop_n(pika::execution::seq, first,
size, 1, typename make_index_pack<sizeof...(Args) - 1>::type(),
PIKA_FORWARD(Args, args)...);
Expand Down Expand Up @@ -1374,7 +1377,7 @@ namespace pika {
"for_loop_n_strided must be called with at least a function "
"object");

using pika::util::make_index_pack;
using pika::util::detail::make_index_pack;
return parallel::v2::detail::for_loop_n(
PIKA_FORWARD(ExPolicy, policy), first, size, stride,
typename make_index_pack<sizeof...(Args) - 1>::type(),
Expand All @@ -1397,7 +1400,7 @@ namespace pika {
"for_loop_n_strided must be called with at least a function "
"object");

using pika::util::make_index_pack;
using pika::util::detail::make_index_pack;
return parallel::v2::detail::for_loop_n(pika::execution::seq, first,
size, stride,
typename make_index_pack<sizeof...(Args) - 1>::type(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ namespace pika {
using result_type =
pika::parallel::util::detail::algorithm_result_t<ExPolicy>;

return pika::util::void_guard<result_type>(),
return pika::util::detail::void_guard<result_type>(),
pika::parallel::v1::detail::nth_element<RandomIt>().call(
PIKA_FORWARD(ExPolicy, policy), first, nth, last,
PIKA_FORWARD(Pred, pred),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ namespace pika {
typename pika::parallel::util::detail::algorithm_result<
ExPolicy>::type;

return pika::util::void_guard<result_type>(),
return pika::util::detail::void_guard<result_type>(),
pika::parallel::v1::detail::sort<RandomIt>().call(
PIKA_FORWARD(ExPolicy, policy), first, last,
PIKA_FORWARD(Comp, comp), PIKA_FORWARD(Proj, proj));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ namespace pika {
typename pika::parallel::util::detail::algorithm_result<
ExPolicy>::type;

return pika::util::void_guard<result_type>(),
return pika::util::detail::void_guard<result_type>(),
pika::parallel::v1::detail::stable_sort<RandomIt>().call(
PIKA_FORWARD(ExPolicy, policy), first, last,
PIKA_FORWARD(Comp, comp), PIKA_FORWARD(Proj, proj));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ namespace pika {
typename pika::parallel::util::detail::algorithm_result<
ExPolicy>::type;

return pika::util::void_guard<result_type>(),
return pika::util::detail::void_guard<result_type>(),
pika::parallel::v1::detail::uninitialized_default_construct<
FwdIter>()
.call(PIKA_FORWARD(ExPolicy, policy), first, last);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ namespace pika {
typename pika::parallel::util::detail::algorithm_result<
ExPolicy>::type;

return pika::util::void_guard<result_type>(),
return pika::util::detail::void_guard<result_type>(),
pika::parallel::v1::detail::uninitialized_fill<FwdIter>()
.call(
PIKA_FORWARD(ExPolicy, policy), first, last, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ namespace pika {
typename pika::parallel::util::detail::algorithm_result<
ExPolicy>::type;

return pika::util::void_guard<result_type>(),
return pika::util::detail::void_guard<result_type>(),
pika::parallel::v1::detail::uninitialized_value_construct<
FwdIter>()
.call(PIKA_FORWARD(ExPolicy, policy), first, last);
Expand Down
Loading

0 comments on commit 82131af

Please sign in to comment.