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

STEllAR-GROUP / hpx / #851

16 Dec 2022 12:27PM CUT coverage: 86.568% (+0.2%) from 86.404%
#851

push

StellarBot
Merge #6104

6104: Adding parameters API: measure_iteration r=hkaiser a=hkaiser

- split `get_chunk_size` CP into `measure_iteration` and modified `get_chunk_size`
- introducing a breaking change to `get_chunk_size` and `processing_units_count` customization point, those now expect the time for one iteration

The new APIs are:
```
    template <typename Target, typename F>
    hpx::chrono::steady_duration measure_iteration(
        Target&&, F&&, std::size_t num_tasks);

    template <typename Target>
    std::size_t processing_units_count(
        Target&&, hpx::chrono::steady_duration const&, std::size_t num_tasks);

    template <typename Target>
    std::size_t get_chunk_size(Target&&,
        hpx::chrono::steady_duration const&, std::size_t num_cores,
        std::size_t num_tasks);
```
This also moves all executor parameter objects to `namespace hpx::execution::experimental`. 

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

209 of 209 new or added lines in 34 files covered. (100.0%)

174475 of 201546 relevant lines covered (86.57%)

1888115.1 hits per line

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

67.16
/libs/full/runtime_distributed/src/locality_interface.cpp
1
//  Copyright (c) 2021 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

9
#if defined(HPX_HAVE_NETWORKING)
10
#include <hpx/assert.hpp>
11
#include <hpx/modules/datastructures.hpp>
12
#include <hpx/modules/errors.hpp>
13

14
#include <hpx/parcelset/detail/message_handler_interface_functions.hpp>
15
#include <hpx/parcelset/message_handler_fwd.hpp>
16
#include <hpx/parcelset/parcel.hpp>
17
#include <hpx/parcelset/parcelhandler.hpp>
18
#include <hpx/parcelset/parcelset_fwd.hpp>
19
#include <hpx/parcelset_base/detail/locality_interface_functions.hpp>
20
#include <hpx/parcelset_base/locality.hpp>
21
#include <hpx/runtime_distributed.hpp>
22
#include <hpx/runtime_distributed/runtime_fwd.hpp>
23

24
#include <cstddef>
25
#include <string>
26
#include <system_error>
27
#include <vector>
28

29
///////////////////////////////////////////////////////////////////////////////
30
namespace hpx::detail {
31

32
    // forward declaration only
33
    void dijkstra_make_black();
34
}    // namespace hpx::detail
35

36
///////////////////////////////////////////////////////////////////////////////
37
namespace hpx::parcelset {
38

39
    namespace detail::impl {
40

41
        parcelset::parcel create_parcel()
475,837✔
42
        {
43
            return parcelset::parcel(new detail::parcel());
475,837✔
44
        }
×
45

46
        locality create_locality(std::string const& name)
711✔
47
        {
48
            HPX_ASSERT(get_runtime_ptr());
711✔
49
            return get_runtime_distributed()
1,422✔
50
                .get_parcel_handler()
711✔
51
                .create_locality(name);
711✔
52
        }
53

54
        parcel_write_handler_type set_parcel_write_handler(
2✔
55
            parcel_write_handler_type const& f)
56
        {
57
            runtime_distributed* rt = get_runtime_distributed_ptr();
2✔
58
            if (nullptr != rt)
2✔
59
                return rt->get_parcel_handler().set_write_handler(f);
2✔
60

61
            HPX_THROW_EXCEPTION(invalid_status,
×
62
                "hpx::set_default_parcel_write_handler",
63
                "the runtime system is not operational at this point");
64
        }
×
65

66
        ///////////////////////////////////////////////////////////////////////////
67
        policies::message_handler* get_message_handler(char const* action,
159,874✔
68
            char const* type, std::size_t num, std::size_t interval,
69
            locality const& loc, error_code& ec)
70
        {
71
            return get_runtime_distributed()
319,748✔
72
                .get_parcel_handler()
159,874✔
73
                .get_message_handler(action, type, num, interval, loc, ec);
159,874✔
74
        }
75

76
        void register_message_handler(char const* message_handler_type,
×
77
            char const* action, error_code& ec)
78
        {
79
            runtime_distributed* rtd = get_runtime_distributed_ptr();
×
80
            if (nullptr != rtd)
×
81
            {
82
                return rtd->register_message_handler(
×
83
                    message_handler_type, action, ec);
×
84
            }
85

86
            // store the request for later
87
            get_message_handler_registrations().push_back(
×
88
                hpx::make_tuple(message_handler_type, action));
×
89
        }
×
90

91
        parcelset::policies::message_handler* create_message_handler(
286✔
92
            char const* message_handler_type, char const* action,
93
            parcelset::parcelport* pp, std::size_t num_messages,
94
            std::size_t interval, error_code& ec)
95
        {
96
            runtime_distributed* rtd = get_runtime_distributed_ptr();
286✔
97
            if (nullptr != rtd)
286✔
98
            {
99
                return rtd->create_message_handler(message_handler_type, action,
572✔
100
                    pp, num_messages, interval, ec);
286✔
101
            }
102

103
            HPX_THROWS_IF(ec, invalid_status, "create_message_handler",
×
104
                "the runtime system is not available at this time");
105
            return nullptr;
×
106
        }
286✔
107

108
        ///////////////////////////////////////////////////////////////////////
109
        void put_parcel(parcelset::parcel&& p, write_handler_type&& f)
474,221✔
110
        {
111
            parcelset::parcelhandler& ph =
474,217✔
112
                hpx::get_runtime_distributed().get_parcel_handler();
474,217✔
113
            ph.put_parcel(HPX_MOVE(p), HPX_MOVE(f));
474,221✔
114
        }
474,217✔
115

116
        void sync_put_parcel(parcelset::parcel&& p)
141✔
117
        {
118
            parcelset::parcelhandler& ph =
141✔
119
                hpx::get_runtime_distributed().get_parcel_handler();
141✔
120
            ph.sync_put_parcel(HPX_MOVE(p));
141✔
121
        }
141✔
122

123
        ///////////////////////////////////////////////////////////////////////
124
        void parcel_route_handler(
×
125
            std::error_code const& ec, parcelset::parcel const& p)
126
        {
127
            parcelhandler& ph =
×
128
                hpx::get_runtime_distributed().get_parcel_handler();
×
129

130
            // invoke the original handler
131
            ph.invoke_write_handler(ec, p);
×
132

133
            // inform termination detection of a sent message
134
            if (!p.does_termination_detection())
×
135
            {
136
                hpx::detail::dijkstra_make_black();
×
137
            }
×
138
        }
×
139
    }    // namespace detail::impl
140

141
    // initialize locality interface function pointers in parcelset modules
142
    struct HPX_EXPORT locality_interface_functions
143
    {
144
        locality_interface_functions()
489✔
145
        {
146
            detail::create_parcel = &detail::impl::create_parcel;
489✔
147
            detail::create_locality = &detail::impl::create_locality;
489✔
148
            detail::set_parcel_write_handler =
489✔
149
                &detail::impl::set_parcel_write_handler;
150

151
            detail::get_message_handler = &detail::impl::get_message_handler;
489✔
152
            detail::register_message_handler =
489✔
153
                &detail::impl::register_message_handler;
154
            detail::create_message_handler =
489✔
155
                &detail::impl::create_message_handler;
156

157
            detail::put_parcel = &detail::impl::put_parcel;
489✔
158
            detail::sync_put_parcel = &detail::impl::sync_put_parcel;
489✔
159

160
            detail::parcel_route_handler_func =
489✔
161
                &detail::impl::parcel_route_handler;
162
        }
489✔
163
    };
164

165
    locality_interface_functions& locality_init()
598✔
166
    {
167
        static locality_interface_functions locality_init_;
598✔
168
        return locality_init_;
598✔
169
    }
×
170
}    // namespace hpx::parcelset
171

172
#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