• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

STEllAR-GROUP / hpx / #866

14 Jan 2023 04:16PM UTC coverage: 85.951% (-0.5%) from 86.431%
#866

push

StellarBot
Merge #6134

6134: Adding notification function for parcelports to be called after early parcel handling r=hkaiser a=hkaiser

Parcelports now can override a new function `void initialized()` that will be called after early parcel handling is finished and before the thread pools are operational (i.e. before background work starts).

`@JiakunYan` please let me know if this is what you requested.

Co-authored-by: Hartmut Kaiser <hartmut.kaiser@gmail.com>

4 of 4 new or added lines in 2 files covered. (100.0%)

173540 of 201905 relevant lines covered (85.95%)

1871917.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

5.88
/libs/full/segmented_algorithms/tests/unit/partitioned_vector_transform_reduce1.cpp
1
//  Copyright (c) 2014-2017 Hartmut Kaiser
2
//
3
//  SPDX-License-Identifier: BSL-1.0
4
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
5
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6

7
#include <hpx/config.hpp>
8
#if !defined(HPX_COMPUTE_DEVICE_CODE)
9
#include <hpx/datastructures/serialization/tuple.hpp>
10
#include <hpx/hpx_main.hpp>
11
#include <hpx/include/parallel_for_each.hpp>
12
#include <hpx/include/parallel_transform_reduce.hpp>
13
#include <hpx/include/partitioned_vector_predef.hpp>
14
#include <hpx/include/runtime.hpp>
15
#include <hpx/modules/serialization.hpp>
16
#include <hpx/modules/testing.hpp>
17
#include <hpx/parallel/segmented_algorithms/traits/zip_iterator.hpp>
18
#include <hpx/parallel/util/zip_iterator.hpp>
19

20
#include <cstddef>
21
#include <iterator>
22
#include <type_traits>
23
#include <vector>
24

25
///////////////////////////////////////////////////////////////////////////////
26
struct multiply
27
{
28
    template <typename T>
29
    typename std::decay<T>::type operator()(hpx::tuple<T, T> const& r) const
19,166✔
30
    {
31
        using hpx::get;
32
        return get<0>(r) * get<1>(r);
19,167✔
33
    }
34
};
35

36
///////////////////////////////////////////////////////////////////////////////
37
template <typename ExPolicy, typename T>
38
T test_transform_reduce(ExPolicy&& policy,
×
39
    hpx::partitioned_vector<T> const& xvalues,
40
    hpx::partitioned_vector<T> const& yvalues)
41
{
42
    using hpx::util::zip_iterator;
43
    return hpx::transform_reduce(policy,
×
44
        zip_iterator(std::begin(xvalues), std::begin(yvalues)),
×
45
        zip_iterator(std::end(xvalues), std::end(yvalues)), T(1),
×
46
        std::plus<T>(), multiply());
47
}
48

49
template <typename ExPolicy, typename T>
50
hpx::future<T> test_transform_reduce_async(ExPolicy&& policy,
×
51
    hpx::partitioned_vector<T> const& xvalues,
52
    hpx::partitioned_vector<T> const& yvalues)
53
{
54
    using hpx::util::zip_iterator;
55
    return hpx::transform_reduce(policy,
×
56
        zip_iterator(std::begin(xvalues), std::begin(yvalues)),
×
57
        zip_iterator(std::end(xvalues), std::end(yvalues)), T(1),
×
58
        std::plus<T>(), multiply());
59
}
60

61
template <typename T>
62
void transform_reduce_tests(std::size_t num,
×
63
    hpx::partitioned_vector<T> const& xvalues,
64
    hpx::partitioned_vector<T> const& yvalues)
65
{
66
    HPX_TEST_EQ(test_transform_reduce(hpx::execution::seq, xvalues, yvalues),
×
67
        T(num + 1));
68
    HPX_TEST_EQ(test_transform_reduce(hpx::execution::par, xvalues, yvalues),
×
69
        T(num + 1));
70

71
    HPX_TEST_EQ(test_transform_reduce_async(
×
72
                    hpx::execution::seq(hpx::execution::task), xvalues, yvalues)
73
                    .get(),
74
        T(num + 1));
75
    HPX_TEST_EQ(test_transform_reduce_async(
×
76
                    hpx::execution::par(hpx::execution::task), xvalues, yvalues)
77
                    .get(),
78
        T(num + 1));
79
}
×
80

81
template <typename T>
82
void transform_reduce_tests(std::vector<hpx::id_type>& localities)
×
83
{
84
    std::size_t const num = 10007;
×
85
    {
86
        hpx::partitioned_vector<T> xvalues(num, T(1));
×
87
        hpx::partitioned_vector<T> yvalues(num, T(1));
×
88
        transform_reduce_tests(num, xvalues, yvalues);
×
89
    }
×
90

91
    {
92
        hpx::partitioned_vector<T> xvalues(
×
93
            num, T(1), hpx::container_layout(localities));
×
94
        hpx::partitioned_vector<T> yvalues(
×
95
            num, T(1), hpx::container_layout(localities));
×
96
        transform_reduce_tests(num, xvalues, yvalues);
×
97
    }
×
98
}
×
99

100
///////////////////////////////////////////////////////////////////////////////
101
int main()
×
102
{
103
    std::vector<hpx::id_type> localities = hpx::find_all_localities();
×
104
    transform_reduce_tests<int>(localities);
×
105
    return hpx::util::report_errors();
×
106
}
×
107
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc