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

STEllAR-GROUP / hpx / #882

31 Aug 2023 07:44PM UTC coverage: 41.798% (-44.7%) from 86.546%
#882

push

19442 of 46514 relevant lines covered (41.8%)

126375.38 hits per line

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

24.53
/libs/full/runtime_distributed/src/stubs/runtime_support_stubs.cpp
1
//  Copyright (c) 2007-2025 Hartmut Kaiser
2
//  Copyright (c)      2011 Bryce Lelbach
3
//
4
//  SPDX-License-Identifier: BSL-1.0
5
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
6
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7

8
#include <hpx/config.hpp>
9
#include <hpx/actions_base/traits/action_was_object_migrated.hpp>
10
#include <hpx/assert.hpp>
11
#include <hpx/async_colocated/post_colocated.hpp>
12
#include <hpx/async_distributed/post.hpp>
13
#include <hpx/components_base/agas_interface.hpp>
14
#include <hpx/modules/async_base.hpp>
15
#include <hpx/modules/async_distributed.hpp>
16
#include <hpx/modules/errors.hpp>
17
#include <hpx/modules/ini.hpp>
18
#include <hpx/modules/runtime_local.hpp>
19
#include <hpx/modules/type_support.hpp>
20
#include <hpx/naming_base/id_type.hpp>
21
#include <hpx/performance_counters/counters.hpp>
22
#include <hpx/runtime_distributed/applier.hpp>
23
#include <hpx/runtime_distributed/stubs/runtime_support.hpp>
24

25
#include <cstddef>
26
#include <cstdint>
27
#include <utility>
28
#include <vector>
29

30
namespace hpx { namespace components { namespace stubs {
31

32✔
32
    hpx::future<int> runtime_support::load_components_async(
33
        hpx::id_type const& gid)
34
    {
35
#if !defined(HPX_COMPUTE_DEVICE_CODE)
36
        typedef server::runtime_support::load_components_action action_type;
32✔
37
        return hpx::async<action_type>(gid);
38
#else
39
        HPX_ASSERT(false);
40
        HPX_UNUSED(gid);
41
        return hpx::make_ready_future(0);
42
#endif
43
    }
44

32✔
45
    int runtime_support::load_components(hpx::id_type const& gid)
46
    {
64✔
47
        return load_components_async(gid).get();
48
    }
49

64✔
50
    hpx::future<void> runtime_support::call_startup_functions_async(
51
        hpx::id_type const& gid, bool pre_startup)
52
    {
53
#if !defined(HPX_COMPUTE_DEVICE_CODE)
54
        typedef server::runtime_support::call_startup_functions_action
55
            action_type;
64✔
56
        return hpx::async<action_type>(gid, pre_startup);
57
#else
58
        HPX_ASSERT(false);
59
        HPX_UNUSED(gid);
60
        HPX_UNUSED(pre_startup);
61
        return ::hpx::make_ready_future();
62
#endif
63
    }
64

64✔
65
    void runtime_support::call_startup_functions(
66
        hpx::id_type const& gid, bool pre_startup)
67
    {
64✔
68
        call_startup_functions_async(gid, pre_startup).get();
64✔
69
    }
70

71
    /// \brief Shutdown the given runtime system
3✔
72
    hpx::future<void> runtime_support::shutdown_async(
73
        hpx::id_type const& targetgid, double timeout)
74
    {
75
#if !defined(HPX_COMPUTE_DEVICE_CODE)
76
        // Create a promise directly and execute the required action.
77
        // This action has implemented special response handling as the
78
        // back-parcel is sent explicitly (and synchronously).
79
        typedef server::runtime_support::shutdown_action action_type;
80

81
        hpx::distributed::promise<void> value;
3✔
82
        auto f = value.get_future();
83

84
        // We need to make it unmanaged to avoid late refcnt requests
85
        id_type gid(
6✔
86
            value.get_id().get_gid(), id_type::management_type::unmanaged);
87
        hpx::post<action_type>(targetgid, timeout, gid);
88

3✔
89
        return f;
90
#else
91
        HPX_ASSERT(false);
92
        HPX_UNUSED(targetgid);
93
        HPX_UNUSED(timeout);
94
        return ::hpx::make_ready_future();
95
#endif
96
    }
97

×
98
    void runtime_support::shutdown(
99
        hpx::id_type const& targetgid, double timeout)
100
    {
101
        // The following get yields control while the action above
102
        // is executed and the result is returned to the future
×
103
        shutdown_async(targetgid, timeout).get();
×
104
    }
105

106
    /// \brief Shutdown the runtime systems of all localities
×
107
    void runtime_support::shutdown_all(
108
        hpx::id_type const& targetgid, double timeout)
109
    {
110
#if !defined(HPX_COMPUTE_DEVICE_CODE)
111
        hpx::post<server::runtime_support::shutdown_all_action>(
112
            targetgid, timeout);
113
#else
114
        HPX_ASSERT(false);
115
        HPX_UNUSED(targetgid);
116
        HPX_UNUSED(timeout);
117
#endif
×
118
    }
119

×
120
    void runtime_support::shutdown_all(double timeout)
121
    {
122
#if !defined(HPX_COMPUTE_DEVICE_CODE)
123
        hpx::post<server::runtime_support::shutdown_all_action>(
×
124
            hpx::id_type(
×
125
                hpx::applier::get_applier().get_runtime_support_raw_gid(),
126
                hpx::id_type::management_type::unmanaged),
127
            timeout);
128
#else
129
        HPX_ASSERT(false);
130
        HPX_UNUSED(timeout);
131
#endif
×
132
    }
133

134
    ///////////////////////////////////////////////////////////////////////
135
    /// \brief Retrieve configuration information
136
    /// \brief Terminate the given runtime system
×
137
    hpx::future<void> runtime_support::terminate_async(
138
        hpx::id_type const& targetgid)
139
    {
140
#if !defined(HPX_COMPUTE_DEVICE_CODE)
141
        // Create a future directly and execute the required action.
142
        // This action has implemented special response handling as the
143
        // back-parcel is sent explicitly (and synchronously).
144
        typedef server::runtime_support::terminate_action action_type;
145

146
        hpx::distributed::promise<void> value;
×
147
        auto f = value.get_future();
148

×
149
        hpx::post<action_type>(targetgid, value.get_id());
×
150
        return f;
151
#else
152
        HPX_ASSERT(false);
153
        HPX_UNUSED(targetgid);
154
        return ::hpx::make_ready_future();
155
#endif
156
    }
157

×
158
    void runtime_support::terminate(hpx::id_type const& targetgid)
159
    {
160
        // The following get yields control while the action above
161
        // is executed and the result is returned to the future
×
162
        terminate_async(targetgid).get();
×
163
    }
164

165
    /// \brief Terminate the runtime systems of all localities
×
166
    void runtime_support::terminate_all(hpx::id_type const& targetgid)
167
    {
168
#if !defined(HPX_COMPUTE_DEVICE_CODE)
169
        hpx::post<server::runtime_support::terminate_all_action>(targetgid);
170
#else
171
        HPX_ASSERT(false);
172
        HPX_UNUSED(targetgid);
173
#endif
×
174
    }
175

×
176
    void runtime_support::terminate_all()
177
    {
178
#if !defined(HPX_COMPUTE_DEVICE_CODE)
×
179
        hpx::post<server::runtime_support::terminate_all_action>(hpx::id_type(
×
180
            hpx::applier::get_applier().get_runtime_support_raw_gid(),
181
            hpx::id_type::management_type::unmanaged));
182
#else
183
        HPX_ASSERT(false);
184
#endif
×
185
    }
186

187
    ///////////////////////////////////////////////////////////////////////
×
188
    void runtime_support::garbage_collect_non_blocking(
189
        hpx::id_type const& targetgid)
190
    {
191
#if !defined(HPX_COMPUTE_DEVICE_CODE)
192
        typedef server::runtime_support::garbage_collect_action action_type;
193
        hpx::post<action_type>(targetgid);
194
#else
195
        HPX_ASSERT(false);
196
        HPX_UNUSED(targetgid);
197
#endif
×
198
    }
199

×
200
    hpx::future<void> runtime_support::garbage_collect_async(
201
        hpx::id_type const& targetgid)
202
    {
203
#if !defined(HPX_COMPUTE_DEVICE_CODE)
204
        typedef server::runtime_support::garbage_collect_action action_type;
×
205
        return hpx::async<action_type>(targetgid);
206
#else
207
        HPX_ASSERT(false);
208
        HPX_UNUSED(targetgid);
209
        return ::hpx::make_ready_future();
210
#endif
211
    }
212

×
213
    void runtime_support::garbage_collect(hpx::id_type const& targetgid)
214
    {
215
#if !defined(HPX_COMPUTE_DEVICE_CODE)
216
        typedef server::runtime_support::garbage_collect_action action_type;
×
217
        hpx::async<action_type>(targetgid).get();
218
#else
219
        HPX_ASSERT(false);
220
        HPX_UNUSED(targetgid);
221
#endif
×
222
    }
223

224
    ///////////////////////////////////////////////////////////////////////
×
225
    hpx::future<hpx::id_type> runtime_support::create_performance_counter_async(
226
        hpx::id_type targetgid, performance_counters::counter_info const& info)
227
    {
228
#if !defined(HPX_COMPUTE_DEVICE_CODE)
229
        if (!naming::is_locality(targetgid))
230
        {
×
231
            HPX_THROW_EXCEPTION(hpx::error::bad_parameter,
232
                "stubs::runtime_support::create_performance_counter_async",
233
                "The id passed as the first argument is not representing"
234
                " a locality");
235
            return make_ready_future(hpx::invalid_id);
236
        }
237

238
        typedef server::runtime_support::create_performance_counter_action
239
            action_type;
240
        return hpx::async<action_type>(targetgid, info);
241
#else
242
        HPX_ASSERT(false);
243
        HPX_UNUSED(targetgid);
244
        HPX_UNUSED(info);
245
        return ::hpx::make_ready_future(hpx::invalid_id);
246
#endif
247
    }
248

×
249
    hpx::id_type runtime_support::create_performance_counter(
250
        hpx::id_type targetgid, performance_counters::counter_info const& info,
251
        error_code& ec)
252
    {
×
253
        return create_performance_counter_async(targetgid, info).get(ec);
254
    }
255

256
    ///////////////////////////////////////////////////////////////////////
257
    /// \brief Retrieve configuration information
×
258
    hpx::future<util::section> runtime_support::get_config_async(
259
        hpx::id_type const& targetgid)
260
    {
261
#if !defined(HPX_COMPUTE_DEVICE_CODE)
262
        // Create a future, execute the required action,
263
        // we simply return the initialized future, the caller needs
264
        // to call get() on the return value to obtain the result
265
        typedef server::runtime_support::get_config_action action_type;
×
266
        return hpx::async<action_type>(targetgid);
267
#else
268
        HPX_ASSERT(false);
269
        HPX_UNUSED(targetgid);
270
        return ::hpx::make_ready_future(util::section{});
271
#endif
272
    }
273

×
274
    void runtime_support::get_config(
275
        hpx::id_type const& targetgid, util::section& ini)
276
    {
277
        // The following get yields control while the action above
278
        // is executed and the result is returned to the future
×
279
        ini = get_config_async(targetgid).get();
×
280
    }
281

282
    ///////////////////////////////////////////////////////////////////////
×
283
    void runtime_support::remove_from_connection_cache_async(
284
        hpx::id_type const& target, naming::gid_type const& gid,
285
        parcelset::endpoints_type const& endpoints)
286
    {
287
#if !defined(HPX_COMPUTE_DEVICE_CODE)
288
        typedef server::runtime_support::remove_from_connection_cache_action
289
            action_type;
290
        hpx::post<action_type>(target, gid, endpoints);
291
#else
292
        HPX_ASSERT(false);
293
        HPX_UNUSED(target);
294
        HPX_UNUSED(gid);
295
        HPX_UNUSED(endpoints);
296
#endif
×
297
    }
298
}}}    // namespace hpx::components::stubs
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