Skip to content

Commit

Permalink
Merge #380
Browse files Browse the repository at this point in the history
380: Clean up `functional` module r=msimberg a=msimberg

Part of #16. Moves most functionality into detail once again. Note that I have _not_ done anything about #265 here. At least using `std::invoke` did increase the size of debug symbols measurably so we'll have to revisit that to see if it's worth the tradeoff.

Co-authored-by: Mikael Simberg <mikael.simberg@iki.fi>
  • Loading branch information
bors[bot] and msimberg authored Aug 19, 2022
2 parents 1745a42 + 8677915 commit 242c67d
Show file tree
Hide file tree
Showing 303 changed files with 2,474 additions and 5,872 deletions.
4 changes: 2 additions & 2 deletions examples/balancing/os_thread_num.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ int pika_main(variables_map& vm)
{
thread_init_data data(
pika::threads::detail::make_thread_function_nullary(
pika::util::bind(&get_os_thread_num, std::ref(barr),
std::ref(os_threads))),
pika::util::detail::bind(&get_os_thread_num,
std::ref(barr), std::ref(os_threads))),
"get_os_thread_num",
pika::execution::thread_priority::normal,
pika::execution::thread_schedule_hint(0));
Expand Down
6 changes: 3 additions & 3 deletions examples/balancing/thread_phase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ int pika_main(variables_map& vm)
const std::size_t index = j % mutex_count;

thread_init_data data(
make_thread_function_nullary(pika::util::bind(&lock_and_wait,
std::ref(m[index]), std::ref(b0), std::ref(b1),
std::ref(pikathreads[j]), wait)),
make_thread_function_nullary(pika::util::detail::bind(
&lock_and_wait, std::ref(m[index]), std::ref(b0),
std::ref(b1), std::ref(pikathreads[j]), wait)),
"lock_and_wait");
ids.push_back(register_thread(data));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/jacobi_smp/jacobi_nonuniform_pika.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace jacobi_smp {
(*deps_dst)[block] =
pika::when_all(std::move(trigger))
.then(pika::launch::async,
pika::util::bind(jacobi_kernel_wrap,
pika::util::detail::bind(jacobi_kernel_wrap,
block_ranges[block], std::cref(A),
std::ref(*dst), std::cref(*src), std::cref(b)));
}
Expand Down
4 changes: 2 additions & 2 deletions examples/jacobi_smp/jacobi_pika.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace jacobi_smp {
* left
(*deps_new)[j]
= pika::dataflow(
pika::util::bind(
pika::util::detail::bind(
jacobi_kernel_wrap
, range(y, y_end)
, n
Expand All @@ -81,7 +81,7 @@ namespace jacobi_smp {
(*deps_new)[j] =
pika::when_all(std::move(trigger))
.then(pika::launch::async,
pika::util::bind(jacobi_kernel_wrap,
pika::util::detail::bind(jacobi_kernel_wrap,
range(y, y_end), n, std::ref(*grid_new),
std::cref(*grid_old)));
}
Expand Down
4 changes: 2 additions & 2 deletions examples/quickstart/executor_with_thread_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace executor_example {
decltype(auto) operator()(Ts&&... ts)
{
on_exit _{exec_};
return pika::util::invoke(f_, std::forward<Ts>(ts)...);
return pika::util::detail::invoke(f_, std::forward<Ts>(ts)...);
}

executor_with_thread_hooks const& exec_;
Expand Down Expand Up @@ -154,7 +154,7 @@ namespace executor_example {
}

private:
using thread_hook = pika::util::function<void()>;
using thread_hook = pika::util::detail::function<void()>;

BaseExecutor& exec_;
thread_hook on_start_;
Expand Down
4 changes: 2 additions & 2 deletions examples/quickstart/fibonacci_await.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void fibonacci_impl(std::shared_ptr<fibonacci_frame> const& frame_)
frame->state_ = 1;
if (!frame->result_.valid())
frame->result_ = frame->result_promise_.get_future();
frame->lhs_.then(pika::util::bind(&fibonacci_impl, frame_));
frame->lhs_.then(pika::util::detail::bind(&fibonacci_impl, frame_));
return;
}

Expand All @@ -129,7 +129,7 @@ void fibonacci_impl(std::shared_ptr<fibonacci_frame> const& frame_)
frame->state_ = 2;
if (!frame->result_.valid())
frame->result_ = frame->result_promise_.get_future();
frame->rhs_.then(pika::util::bind(&fibonacci_impl, frame_));
frame->rhs_.then(pika::util::detail::bind(&fibonacci_impl, frame_));
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace pika { namespace parallel { namespace traits {
struct projected_result_of<Proj, Iter,
typename std::enable_if<
pika::traits::is_iterator<Iter>::value>::type>
: pika::util::invoke_result<Proj,
: pika::util::detail::invoke_result<Proj,
typename std::iterator_traits<Iter>::reference>
{
};
Expand All @@ -63,7 +63,7 @@ namespace pika { namespace parallel { namespace traits {
// with a tuple<datapar<T>...> instead of just a tuple<T...>
template <typename Proj, typename ValueType, typename Enable = void>
struct projected_result_of_vector_pack_
: pika::util::invoke_result<Proj,
: pika::util::detail::invoke_result<Proj,
typename pika::parallel::traits::vector_pack_load<
typename pika::parallel::traits::vector_pack_type<
ValueType>::type,
Expand Down Expand Up @@ -108,11 +108,11 @@ namespace pika { namespace parallel { namespace traits {
struct is_projected<Proj, Iter,
typename std::enable_if<
pika::traits::is_iterator<Iter>::value &&
pika::is_invocable<Proj,
pika::detail::is_invocable<Proj,
typename std::iterator_traits<Iter>::reference>::value
>::type>
: std::integral_constant<bool,
!std::is_void<typename pika::util::invoke_result<Proj,
!std::is_void<typename pika::util::detail::invoke_result<Proj,
typename std::iterator_traits<Iter>::reference>::type
>::value>
{
Expand Down Expand Up @@ -175,7 +175,8 @@ namespace pika { namespace parallel { namespace traits {
///////////////////////////////////////////////////////////////////////////
namespace detail {
template <typename F, typename... Args>
struct is_indirect_callable_impl : pika::is_invocable<F, Args...>
struct is_indirect_callable_impl
: pika::detail::is_invocable<F, Args...>
{
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,8 @@ namespace pika { namespace parallel { inline namespace v1 {
// MSVC complains if proj is captured by ref below
util::loop_n<std::decay_t<ExPolicy>>(part_begin, part_size,
[&pred, proj, &curr](zip_iterator it) mutable -> void {
bool f = pika::util::invoke(
pred, pika::util::invoke(proj, get<0>(*it)));
bool f = pika::util::detail::invoke(pred,
pika::util::detail::invoke(proj, get<0>(*it)));

if ((get<1>(*it) = f))
++curr;
Expand Down Expand Up @@ -661,7 +661,7 @@ namespace pika {
pika::is_execution_policy_v<ExPolicy> &&
pika::traits::is_iterator_v<FwdIter1> &&
pika::traits::is_iterator_v<FwdIter2> &&
pika::is_invocable_v<Pred,
pika::detail::is_invocable_v<Pred,
typename std::iterator_traits<FwdIter1>::value_type
>
)>
Expand Down Expand Up @@ -691,7 +691,7 @@ namespace pika {
PIKA_CONCEPT_REQUIRES_(
pika::traits::is_iterator_v<FwdIter1> &&
pika::traits::is_iterator_v<FwdIter2> &&
pika::is_invocable_v<Pred,
pika::detail::is_invocable_v<Pred,
typename std::iterator_traits<FwdIter1>::value_type
>
)>
Expand Down
12 changes: 7 additions & 5 deletions libs/pika/algorithms/include/pika/parallel/algorithms/count.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ namespace pika { namespace parallel { inline namespace v1 {
{
typename std::iterator_traits<Iter>::difference_type ret = 0;
util::loop_n<execution_policy_type>(part_begin, part_size,
pika::util::bind_back(*this, std::ref(ret)));
pika::util::detail::bind_back(*this, std::ref(ret)));
return ret;
}

Expand Down Expand Up @@ -269,7 +269,8 @@ namespace pika { namespace parallel { inline namespace v1 {
typename std::iterator_traits<InIterB>::difference_type ret = 0;

util::loop(PIKA_FORWARD(ExPolicy, policy), first, last,
pika::util::bind_back(PIKA_MOVE(f1), std::ref(ret)));
pika::util::detail::bind_back(
PIKA_MOVE(f1), std::ref(ret)));

return ret;
}
Expand Down Expand Up @@ -331,7 +332,8 @@ namespace pika { namespace parallel { inline namespace v1 {
typename std::iterator_traits<InIterB>::difference_type ret = 0;

util::loop(PIKA_FORWARD(ExPolicy, policy), first, last,
pika::util::bind_back(PIKA_MOVE(f1), std::ref(ret)));
pika::util::detail::bind_back(
PIKA_MOVE(f1), std::ref(ret)));

return ret;
}
Expand Down Expand Up @@ -433,7 +435,7 @@ namespace pika {
PIKA_CONCEPT_REQUIRES_(
pika::is_execution_policy<ExPolicy>::value &&
pika::traits::is_iterator<FwdIter>::value &&
pika::is_invocable_v<F,
pika::detail::is_invocable_v<F,
typename std::iterator_traits<FwdIter>::value_type
>
)>
Expand All @@ -458,7 +460,7 @@ namespace pika {
template <typename InIter, typename F,
PIKA_CONCEPT_REQUIRES_(
pika::traits::is_iterator<InIter>::value &&
pika::is_invocable_v<F,
pika::detail::is_invocable_v<F,
typename std::iterator_traits<InIter>::value_type
>
)>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ namespace pika {
PIKA_CONCEPT_REQUIRES_(
pika::traits::is_iterator_v<InIter1> &&
pika::traits::is_iterator_v<InIter2> &&
pika::is_invocable_v<Pred,
pika::detail::is_invocable_v<Pred,
typename std::iterator_traits<InIter1>::value_type,
typename std::iterator_traits<InIter2>::value_type
>
Expand Down Expand Up @@ -263,7 +263,7 @@ namespace pika {
pika::is_execution_policy<ExPolicy>::value &&
pika::traits::is_iterator_v<FwdIter1> &&
pika::traits::is_iterator_v<FwdIter2> &&
pika::is_invocable_v<Pred,
pika::detail::is_invocable_v<Pred,
typename std::iterator_traits<FwdIter1>::value_type,
typename std::iterator_traits<FwdIter2>::value_type
>
Expand Down
16 changes: 9 additions & 7 deletions libs/pika/algorithms/include/pika/parallel/algorithms/equal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,11 @@ namespace pika { namespace parallel { inline namespace v1 {
util::loop_n<std::decay_t<ExPolicy>>(it, part_count, tok,
[&f, &proj1, &proj2, &tok](zip_iterator const& curr) {
reference t = *curr;
if (!pika::util::invoke(f,
pika::util::invoke(proj1, std::get<0>(t)),
pika::util::invoke(proj2, std::get<1>(t))))
if (!pika::util::detail::invoke(f,
pika::util::detail::invoke(
proj1, std::get<0>(t)),
pika::util::detail::invoke(
proj2, std::get<1>(t))))
{
tok.cancel();
}
Expand Down Expand Up @@ -399,7 +401,7 @@ namespace pika {
pika::is_execution_policy<ExPolicy>::value &&
pika::traits::is_iterator<FwdIter1>::value &&
pika::traits::is_iterator<FwdIter2>::value &&
pika::is_invocable_v<Pred,
pika::detail::is_invocable_v<Pred,
typename std::iterator_traits<FwdIter1>::value_type,
typename std::iterator_traits<FwdIter2>::value_type
>
Expand Down Expand Up @@ -454,7 +456,7 @@ namespace pika {
pika::is_execution_policy<ExPolicy>::value &&
pika::traits::is_iterator<FwdIter1>::value &&
pika::traits::is_iterator<FwdIter2>::value &&
pika::is_invocable_v<Pred,
pika::detail::is_invocable_v<Pred,
typename std::iterator_traits<FwdIter1>::value_type,
typename std::iterator_traits<FwdIter2>::value_type
>
Expand Down Expand Up @@ -503,7 +505,7 @@ namespace pika {
PIKA_CONCEPT_REQUIRES_(
pika::traits::is_iterator<FwdIter1>::value &&
pika::traits::is_iterator<FwdIter2>::value &&
pika::is_invocable_v<Pred,
pika::detail::is_invocable_v<Pred,
typename std::iterator_traits<FwdIter1>::value_type,
typename std::iterator_traits<FwdIter2>::value_type
>
Expand Down Expand Up @@ -551,7 +553,7 @@ namespace pika {
PIKA_CONCEPT_REQUIRES_(
pika::traits::is_iterator<FwdIter1>::value &&
pika::traits::is_iterator<FwdIter2>::value &&
pika::is_invocable_v<Pred,
pika::detail::is_invocable_v<Pred,
typename std::iterator_traits<FwdIter1>::value_type,
typename std::iterator_traits<FwdIter2>::value_type
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ namespace pika {
PIKA_CONCEPT_REQUIRES_(
pika::traits::is_iterator_v<InIter> &&
pika::traits::is_iterator_v<OutIter> &&
pika::is_invocable_v<Op,
pika::detail::is_invocable_v<Op,
typename std::iterator_traits<InIter>::value_type,
typename std::iterator_traits<InIter>::value_type
>
Expand Down Expand Up @@ -552,7 +552,7 @@ namespace pika {
pika::is_execution_policy<ExPolicy>::value &&
pika::traits::is_iterator_v<FwdIter1> &&
pika::traits::is_iterator_v<FwdIter2> &&
pika::is_invocable_v<Op,
pika::detail::is_invocable_v<Op,
typename std::iterator_traits<FwdIter1>::value_type,
typename std::iterator_traits<FwdIter1>::value_type
>
Expand Down
Loading

0 comments on commit 242c67d

Please sign in to comment.