Skip to content

Commit

Permalink
Fix formatting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
zhekemist committed Jul 9, 2024
1 parent 5aa62d6 commit 679c8ac
Show file tree
Hide file tree
Showing 111 changed files with 589 additions and 751 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,8 @@ namespace hpx::parallel {

template <typename ExPolicy, typename FwdIter, typename Sent_,
typename Pred, typename Proj>
static decltype(auto) parallel(
ExPolicy&& orgpolicy, FwdIter first, Sent_ last, Pred&& pred,
Proj&& proj)
static decltype(auto) parallel(ExPolicy&& orgpolicy, FwdIter first,
Sent_ last, Pred&& pred, Proj&& proj)
{
using zip_iterator = hpx::util::zip_iterator<FwdIter, FwdIter>;
using difference_type =
Expand Down Expand Up @@ -217,7 +216,7 @@ namespace hpx::parallel {

auto f2 = [tok, count, first, last](
auto&&... data) mutable -> FwdIter {
static_assert(sizeof...(data) < 2 );
static_assert(sizeof...(data) < 2);
if constexpr (sizeof...(data) == 1)
{
// make sure iterators embedded in function object that
Expand Down Expand Up @@ -281,9 +280,8 @@ namespace hpx {
hpx::traits::is_forward_iterator_v<FwdIter>
)>
// clang-format on
friend decltype(auto)
tag_fallback_invoke(hpx::adjacent_find_t, ExPolicy&& policy,
FwdIter first, FwdIter last, Pred pred = Pred())
friend decltype(auto) tag_fallback_invoke(hpx::adjacent_find_t,
ExPolicy&& policy, FwdIter first, FwdIter last, Pred pred = Pred())
{
static_assert(hpx::traits::is_forward_iterator_v<FwdIter>,
"Requires at least a forward iterator");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,8 @@ namespace hpx::parallel {

template <typename ExPolicy, typename FwdIter, typename Sent,
typename F, typename Proj>
static decltype(auto) parallel(
ExPolicy&& policy, FwdIter first, Sent last, F&& op,
Proj&& proj)
static decltype(auto) parallel(ExPolicy&& policy, FwdIter first,
Sent last, F&& op, Proj&& proj)
{
using result = util::detail::algorithm_result<ExPolicy, bool>;
constexpr bool is_scheduler_policy =
Expand Down Expand Up @@ -408,8 +407,8 @@ namespace hpx::parallel {
hpx::execution::sequenced_policy>(
hpx::util::begin(results),
hpx::util::end(results),
hpx::functional::unwrap{})
== hpx::util::end(results);
hpx::functional::unwrap{}) ==
hpx::util::end(results);
};

return util::partitioner<policy_type, bool>::call(
Expand Down Expand Up @@ -444,9 +443,8 @@ namespace hpx::parallel {

template <typename ExPolicy, typename FwdIter, typename Sent,
typename F, typename Proj>
static decltype(auto) parallel(
ExPolicy&& policy, FwdIter first, Sent last, F&& op,
Proj&& proj)
static decltype(auto) parallel(ExPolicy&& policy, FwdIter first,
Sent last, F&& op, Proj&& proj)
{
using result = util::detail::algorithm_result<ExPolicy, bool>;
constexpr bool is_scheduler_policy =
Expand Down Expand Up @@ -479,8 +477,8 @@ namespace hpx::parallel {
hpx::execution::sequenced_policy>(
hpx::util::begin(results),
hpx::util::end(results),
hpx::functional::unwrap{})
!= hpx::util::end(results);
hpx::functional::unwrap{}) !=
hpx::util::end(results);
};

return util::partitioner<policy_type, bool>::call(
Expand Down Expand Up @@ -514,9 +512,8 @@ namespace hpx::parallel {

template <typename ExPolicy, typename FwdIter, typename Sent,
typename F, typename Proj>
static decltype(auto) parallel(
ExPolicy&& policy, FwdIter first, Sent last, F&& op,
Proj&& proj)
static decltype(auto) parallel(ExPolicy&& policy, FwdIter first,
Sent last, F&& op, Proj&& proj)
{
using result = util::detail::algorithm_result<ExPolicy, bool>;
constexpr bool is_scheduler_policy =
Expand Down Expand Up @@ -545,12 +542,12 @@ namespace hpx::parallel {
};

auto f2 = [](auto&& results) {
return detail::sequential_find_if_not<
hpx::execution::sequenced_policy>(
hpx::util::begin(results),
hpx::util::end(results),
hpx::functional::unwrap{})
== hpx::util::end(results);
return detail::sequential_find_if_not<
hpx::execution::sequenced_policy>(
hpx::util::begin(results),
hpx::util::end(results),
hpx::functional::unwrap{}) ==
hpx::util::end(results);
};

return util::partitioner<policy_type, bool>::call(
Expand Down Expand Up @@ -601,8 +598,7 @@ namespace hpx {
"Required at least input iterator.");

return hpx::parallel::detail::none_of().call(
hpx::execution::seq, first, last, HPX_MOVE(f),
hpx::identity_v);
hpx::execution::seq, first, last, HPX_MOVE(f), hpx::identity_v);
}
} none_of{};

Expand Down
5 changes: 3 additions & 2 deletions libs/core/algorithms/include/hpx/parallel/algorithms/copy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,14 +722,15 @@ namespace hpx {
"Requires at least forward iterator or sequential execution.");

constexpr bool is_scheduler_policy =
hpx::execution_policy_has_scheduler_executor_v<ExPolicy>;
hpx::execution_policy_has_scheduler_executor_v<ExPolicy>;

if (hpx::parallel::detail::is_negative(count))
{
if constexpr (is_scheduler_policy)
{
count = static_cast<Size>(0);
} else
}
else
{
// if count is representing a negative value, we do nothing
return hpx::parallel::util::detail::algorithm_result<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,8 @@ namespace hpx {
>
)>
// clang-format on
friend decltype(auto) tag_fallback_invoke(count_if_t, ExPolicy&& policy,
FwdIter first, FwdIter last, F f)
friend decltype(auto) tag_fallback_invoke(
count_if_t, ExPolicy&& policy, FwdIter first, FwdIter last, F f)
{
static_assert(hpx::traits::is_forward_iterator_v<FwdIter>,
"Required at least forward iterator.");
Expand Down
21 changes: 11 additions & 10 deletions libs/core/algorithms/include/hpx/parallel/algorithms/destroy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ namespace hpx::parallel {
decltype(auto) parallel_sequential_destroy_n(
ExPolicy&& policy, Iter first, std::size_t count)
{
if constexpr (
!hpx::execution_policy_has_scheduler_executor_v<ExPolicy>)
if constexpr (!hpx::execution_policy_has_scheduler_executor_v<
ExPolicy>)
{
if (count == 0)
{
Expand Down Expand Up @@ -299,8 +299,8 @@ namespace hpx {
hpx::traits::is_iterator_v<FwdIter>
)>
// clang-format on
friend decltype(auto) tag_fallback_invoke(destroy_t, ExPolicy&& policy,
FwdIter first, FwdIter last)
friend decltype(auto) tag_fallback_invoke(
destroy_t, ExPolicy&& policy, FwdIter first, FwdIter last)
{
static_assert(hpx::traits::is_forward_iterator_v<FwdIter>,
"Required at least forward iterator.");
Expand Down Expand Up @@ -339,23 +339,24 @@ namespace hpx {
hpx::traits::is_iterator_v<FwdIter>
)>
// clang-format on
friend decltype(auto) tag_fallback_invoke(destroy_n_t,
ExPolicy&& policy, FwdIter first, Size count)
friend decltype(auto) tag_fallback_invoke(
destroy_n_t, ExPolicy&& policy, FwdIter first, Size count)
{
static_assert(hpx::traits::is_forward_iterator_v<FwdIter>,
"Requires at least forward iterator.");

if (hpx::parallel::detail::is_negative(count))
{
if constexpr (
hpx::execution_policy_has_scheduler_executor_v<ExPolicy>)
if constexpr (hpx::execution_policy_has_scheduler_executor_v<
ExPolicy>)
{
count = static_cast<Size>(0);
} else
}
else
{
// if count is representing a negative value, we do nothing
return hpx::parallel::util::detail::algorithm_result<
ExPolicy,FwdIter>::get(HPX_MOVE(first));
ExPolicy, FwdIter>::get(HPX_MOVE(first));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ namespace hpx::parallel {
hpx::traits::is_iterator_v<FwdIter2>
)>
// clang-format on
decltype(auto) transfer(ExPolicy&& policy, FwdIter1 first, Sent1 last,
FwdIter2 dest)
decltype(auto) transfer(
ExPolicy&& policy, FwdIter1 first, Sent1 last, FwdIter2 dest)
{
static_assert(hpx::traits::is_forward_iterator_v<FwdIter1>,
"Required at least forward iterator.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,17 @@ namespace hpx::parallel {

if (drop < 0)
{
if constexpr (
hpx::execution_policy_has_scheduler_executor_v<ExPolicy>)
if constexpr (hpx::
execution_policy_has_scheduler_executor_v<
ExPolicy>)
{
return hpx::execution::experimental::transfer_just(
policy.executor().sched(), false);
} else
}
else
{
return util::detail::algorithm_result<
ExPolicy, bool>::get(false);
return util::detail::algorithm_result<ExPolicy,
bool>::get(false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,22 +394,21 @@ namespace hpx::parallel::util {
return result_type{hpx::get<0>(t), hpx::get<1>(t)};
}

// clang-format off
template <typename ZipIterSender,
HPX_CONCEPT_REQUIRES_(
hpx::execution::experimental::is_sender_v<ZipIterSender>
)>
decltype(auto)
get_in_out_result(ZipIterSender&& zipiter_sender)
// clang-format on
decltype(auto) get_in_out_result(ZipIterSender&& zipiter_sender)
{
return hpx::execution::experimental::then(
HPX_FORWARD(ZipIterSender, zipiter_sender),
[](auto&& zipiter){
HPX_FORWARD(ZipIterSender, zipiter_sender), [](auto&& zipiter) {
return get_in_out_result(
HPX_FORWARD(decltype(zipiter), zipiter));
});
}


template <typename ZipIter>
hpx::future<
in_out_result<typename hpx::tuple_element<0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
#include <hpx/init.hpp>

#include <iostream>
#include <iterator>
#include <string>
#include <vector>
#include <iterator>

#include "adjacentfind_tests.hpp"

template<typename IteratorTag>
template <typename IteratorTag>
void adjacent_find_sender_test()
{
using namespace hpx::execution;
Expand All @@ -22,8 +22,8 @@ void adjacent_find_sender_test()
test_adjacent_find_sender(hpx::launch::sync, unseq(task), IteratorTag());

test_adjacent_find_sender(hpx::launch::async, par(task), IteratorTag());
test_adjacent_find_sender(hpx::launch::async, par_unseq(task),
IteratorTag());
test_adjacent_find_sender(
hpx::launch::async, par_unseq(task), IteratorTag());
}

int hpx_main(hpx::program_options::variables_map& vm)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ void test_adjacent_find(ExPolicy policy, IteratorTag)
}

template <typename LnPolicy, typename ExPolicy, typename IteratorTag>
void test_adjacent_find_sender(LnPolicy ln_policy, ExPolicy&& ex_policy,
IteratorTag)
void test_adjacent_find_sender(
LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag)
{
static_assert(hpx::is_async_execution_policy_v<ExPolicy>,
"hpx::is_async_execution_policy_v<ExPolicy>");

using base_iterator = std::vector<int>::iterator;
using iterator = test::test_iterator<base_iterator, IteratorTag>;
using base_iterator = std::vector<int>::iterator;
using iterator = test::test_iterator<base_iterator, IteratorTag>;

// fill vector with random values about 1
std::vector<int> c(10007);
Expand All @@ -77,10 +77,9 @@ void test_adjacent_find_sender(LnPolicy ln_policy, ExPolicy&& ex_policy,

auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy));

auto snd_result = tt::sync_wait(
ex::just(iterator(std::begin(c)), iterator(std::end(c)))
| hpx::adjacent_find(ex_policy.on(exec))
);
auto snd_result =
tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c))) |
hpx::adjacent_find(ex_policy.on(exec)));

iterator index = hpx::get<0>(*snd_result);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include "all_of_tests.hpp"

template<typename IteratorTag>
template <typename IteratorTag>
void all_of_sender_test()
{
using namespace hpx::execution;
Expand Down
7 changes: 3 additions & 4 deletions libs/core/algorithms/tests/unit/algorithms/all_of_tests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void test_all_of_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag)
static_assert(hpx::is_async_execution_policy_v<ExPolicy>,
"hpx::is_async_execution_policy_v<ExPolicy>");

using base_iterator = std::vector<int>::iterator;
using base_iterator = std::vector<int>::iterator;
using iterator = test::test_iterator<base_iterator, IteratorTag>;

namespace ex = hpx::execution::experimental;
Expand All @@ -89,9 +89,8 @@ void test_all_of_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag)

auto snd_result = tt::sync_wait(
ex::just(iterator(std::begin(c)), iterator(std::end(c)),
[](auto v) { return v != 0; })
| hpx::all_of(ex_policy.on(exec))
);
[](auto v) { return v != 0; }) |
hpx::all_of(ex_policy.on(exec)));

bool result = hpx::get<0>(*snd_result);

Expand Down
4 changes: 2 additions & 2 deletions libs/core/algorithms/tests/unit/algorithms/any_of_sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
#include <hpx/init.hpp>

#include <iostream>
#include <iterator>
#include <string>
#include <vector>
#include <iterator>

#include "any_of_tests.hpp"

template<typename IteratorTag>
template <typename IteratorTag>
void any_of_sender_test()
{
using namespace hpx::execution;
Expand Down
5 changes: 2 additions & 3 deletions libs/core/algorithms/tests/unit/algorithms/any_of_tests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ void test_any_of_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag)

auto snd_result = tt::sync_wait(
ex::just(iterator(std::begin(c)), iterator(std::end(c)),
[](auto v) { return v != 0; })
| hpx::any_of(ex_policy.on(exec))
);
[](auto v) { return v != 0; }) |
hpx::any_of(ex_policy.on(exec)));

bool result = hpx::get<0>(*snd_result);

Expand Down
4 changes: 2 additions & 2 deletions libs/core/algorithms/tests/unit/algorithms/copy_sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
#include <hpx/init.hpp>

#include <iostream>
#include <iterator>
#include <string>
#include <vector>
#include <iterator>

#include "copy_tests.hpp"

template<typename IteratorTag>
template <typename IteratorTag>
void copy_sender_test()
{
using namespace hpx::execution;
Expand Down
Loading

0 comments on commit 679c8ac

Please sign in to comment.