Skip to content

Commit

Permalink
clang-format + namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorostsa committed Sep 8, 2023
1 parent 58dc884 commit 34dec13
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ namespace hpx::parallel {
typename util::detail::algorithm_result<ExPolicy,
util::in_out_result<InIter, FwdIter>>::type
parallel_uninitialized_relocate_n(
ExPolicy&& policy, InIter first, Size count, FwdIter dest)
ExPolicy&&, InIter first, Size count, FwdIter dest)
{
if (count == 0)
{
Expand All @@ -313,15 +313,15 @@ namespace hpx::parallel {
get(util::in_out_result<InIter, FwdIter>{first, dest});
}

using zip_iterator = hpx::util::zip_iterator<InIter, FwdIter>;
using zip_iterator = ::hpx::util::zip_iterator<InIter, FwdIter>;
using partition_result_type = std::pair<FwdIter, FwdIter>;

return util::partitioner_with_cleanup<ExPolicy,
util::in_out_result<InIter, FwdIter>, partition_result_type>::
call(
HPX_FORWARD(ExPolicy, policy), zip_iterator(first, dest),
count,
[policy](zip_iterator t, std::size_t part_size) mutable
[](zip_iterator t, std::size_t part_size) mutable
-> partition_result_type {
using hpx::get;

Expand Down Expand Up @@ -378,10 +378,9 @@ namespace hpx::parallel {
hpx::traits::is_forward_iterator_v<FwdIter>
)>
// clang-format on
static util::in_out_result<InIter, FwdIter> sequential(
ExPolicy&& policy, InIter first, std::size_t count,
FwdIter dest) noexcept(hpx::experimental::util::detail::
relocation_traits<InIter,
static util::in_out_result<InIter, FwdIter> sequential(ExPolicy&&,
InIter first, std::size_t count, FwdIter dest) noexcept(hpx::
experimental::util::detail::relocation_traits<InIter,
FwdIter>::is_noexcept_relocatable_v)
{
return util::in_out_result<InIter, FwdIter>{first,
Expand Down Expand Up @@ -435,7 +434,7 @@ namespace hpx::parallel {
)>
// clang-format on
static util::in_out_result<InIter1, FwdIter> sequential(
ExPolicy&& policy, InIter1 first, InIter2 last,
ExPolicy&&, InIter1 first, InIter2 last,
FwdIter dest) noexcept(hpx::experimental::util::detail::relocation_traits<
InIter1, FwdIter>::is_noexcept_relocatable_v)
{
Expand Down Expand Up @@ -490,9 +489,8 @@ namespace hpx::experimental {
std::is_integral_v<Size>
)>
// clang-format on
friend FwdIter tag_fallback_invoke(
hpx::experimental::uninitialized_relocate_n_t, InIter first,
Size count,
friend FwdIter tag_fallback_invoke(uninitialized_relocate_n_t,
InIter first, Size count,
FwdIter dest) noexcept(util::detail::relocation_traits<InIter,
FwdIter>::is_noexcept_relocatable_v)
{
Expand Down Expand Up @@ -532,8 +530,8 @@ namespace hpx::experimental {
// clang-format on
friend typename parallel::util::detail::algorithm_result<ExPolicy,
FwdIter>::type
tag_fallback_invoke(hpx::experimental::uninitialized_relocate_n_t,
ExPolicy&& policy, InIter first, Size count,
tag_fallback_invoke(uninitialized_relocate_n_t, ExPolicy&& policy,
InIter first, Size count,
FwdIter dest) noexcept(util::detail::relocation_traits<InIter,
FwdIter>::is_noexcept_relocatable_v)
{
Expand Down Expand Up @@ -605,7 +603,7 @@ namespace hpx::experimental {
}

// clang-format off
template <typename ExPolicy, typename InIter1, typename InIter2,
template <typename ExPolicy, typename InIter1, typename InIter2,
typename FwdIter, HPX_CONCEPT_REQUIRES_(
hpx::is_execution_policy_v<ExPolicy> &&
hpx::traits::is_iterator_v<InIter1> &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <hpx/executors/execution_policy.hpp>
#include <hpx/init.hpp>
#include <hpx/modules/testing.hpp>
#include <hpx/parallel/algorithms/uninitialized_relocate.hpp>
#include <hpx/executors/execution_policy.hpp>
#include <atomic>

#define N 5000
Expand Down Expand Up @@ -83,8 +83,7 @@ std::atomic<int> non_trivially_relocatable_struct::count = 0;
std::atomic<int> non_trivially_relocatable_struct::move_count = 0;
std::atomic<int> non_trivially_relocatable_struct::dtor_count = 0;

static_assert(
!is_trivially_relocatable_v<non_trivially_relocatable_struct>);
static_assert(!is_trivially_relocatable_v<non_trivially_relocatable_struct>);

struct non_trivially_relocatable_struct_throwing
{
Expand Down Expand Up @@ -126,8 +125,8 @@ std::atomic<int> non_trivially_relocatable_struct_throwing::count = 0;
std::atomic<int> non_trivially_relocatable_struct_throwing::move_count = 0;
std::atomic<int> non_trivially_relocatable_struct_throwing::dtor_count = 0;

static_assert(!is_trivially_relocatable_v<
non_trivially_relocatable_struct_throwing>);
static_assert(
!is_trivially_relocatable_v<non_trivially_relocatable_struct_throwing>);

char msg[256];

Expand Down Expand Up @@ -159,8 +158,7 @@ int hpx_main()
// relocate them to ptr2
uninitialized_relocate(hpx::execution::par, ptr1, ptr1 + N, ptr2);

sprintf(msg,
"count: %d, move_count: %d, dtor_count: %d",
sprintf(msg, "count: %d, move_count: %d, dtor_count: %d",
trivially_relocatable_struct::count.load(),
trivially_relocatable_struct::move_count.load(),
trivially_relocatable_struct::dtor_count.load());
Expand Down Expand Up @@ -208,19 +206,19 @@ int hpx_main()
// relocate them to ptr2
uninitialized_relocate(hpx::execution::par, ptr1, ptr1 + N, ptr2);

sprintf(msg,
"count: %d, move_count: %d, dtor_count: %d",
sprintf(msg, "count: %d, move_count: %d, dtor_count: %d",
non_trivially_relocatable_struct::count.load(),
non_trivially_relocatable_struct::move_count.load(),
non_trivially_relocatable_struct::dtor_count.load());


// All creations - destructions balance out
HPX_TEST_MSG(non_trivially_relocatable_struct::count.load() == N, msg);

// Every object was moved from and then destroyed
HPX_TEST_MSG(non_trivially_relocatable_struct::move_count.load() == N, msg);
HPX_TEST_MSG(non_trivially_relocatable_struct::dtor_count.load() == N, msg);
// Every object was moved from and then destroyed
HPX_TEST_MSG(
non_trivially_relocatable_struct::move_count.load() == N, msg);
HPX_TEST_MSG(
non_trivially_relocatable_struct::dtor_count.load() == N, msg);

for (int i = 0; i < N; i++)
{
Expand All @@ -246,8 +244,10 @@ int hpx_main()
static_cast<non_trivially_relocatable_struct_throwing*>(mem2);

HPX_TEST(non_trivially_relocatable_struct_throwing::count.load() == 0);
HPX_TEST(non_trivially_relocatable_struct_throwing::move_count.load() == 0);
HPX_TEST(non_trivially_relocatable_struct_throwing::dtor_count.load() == 0);
HPX_TEST(
non_trivially_relocatable_struct_throwing::move_count.load() == 0);
HPX_TEST(
non_trivially_relocatable_struct_throwing::dtor_count.load() == 0);

for (int i = 0; i < N; i++)
{
Expand All @@ -267,22 +267,24 @@ int hpx_main()
{
}

sprintf(msg,
"count: %d, move_count: %d, dtor_count: %d",
sprintf(msg, "count: %d, move_count: %d, dtor_count: %d",
non_trivially_relocatable_struct_throwing::count.load(),
non_trivially_relocatable_struct_throwing::move_count.load(),
non_trivially_relocatable_struct_throwing::dtor_count.load());


// K move constructors were called
HPX_TEST_MSG(non_trivially_relocatable_struct_throwing::move_count.load() == K, msg);
HPX_TEST_MSG(
non_trivially_relocatable_struct_throwing::move_count.load() == K,
msg);

// K - 1 destructors were called to balance out the move constructors
// (- 1 because the last move constructor throws)
// and then N + 1 destructors were called: K on the old range and
// N - (K - 1) = N - K + 1 on the new range
HPX_TEST_MSG(
non_trivially_relocatable_struct_throwing::dtor_count.load() == N + K, msg);
non_trivially_relocatable_struct_throwing::dtor_count.load() ==
N + K,
msg);

// It stops at K, so K-1 move-destruct pairs have been executed
// after this N - (K - 1) destructs will be done on the old range
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ namespace hpx::experimental::util {
// clang-format off
using implementation_tag = std::conditional_t<
is_buffer_memcpyable,
buffer_memcpy_tag,
buffer_memcpy_tag,
std::conditional_t<is_noexcept_relocatable_v,
for_loop_nothrow_tag,
for_loop_nothrow_tag,
for_loop_try_catch_tag
>
>;
Expand Down

0 comments on commit 34dec13

Please sign in to comment.