• 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

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

9
#include <hpx/config.hpp>
10

11
#include <hpx/agas/addressing_service.hpp>
12
#include <hpx/agas/agas_fwd.hpp>
13
#include <hpx/assert.hpp>
14
#include <hpx/async_distributed/continuation.hpp>
15
#include <hpx/components_base/agas_interface.hpp>
16
#include <hpx/components_base/pinned_ptr.hpp>
17
#include <hpx/modules/errors.hpp>
18
#include <hpx/modules/lock_registration.hpp>
19
#include <hpx/modules/runtime_local.hpp>
20
#include <hpx/modules/threading_base.hpp>
21
#include <hpx/modules/threadmanager.hpp>
22
#include <hpx/modules/type_support.hpp>
23
#include <hpx/parcelset/parcel.hpp>
24
#include <hpx/parcelset/parcelhandler.hpp>
25
#include <hpx/runtime_distributed.hpp>
26
#include <hpx/runtime_distributed/applier.hpp>
27
#include <hpx/runtime_distributed/runtime_fwd.hpp>
28

29
#include <cstddef>
30
#include <cstdint>
31
#include <functional>
32
#include <memory>
33
#include <utility>
34
#include <vector>
35

36
namespace hpx { namespace applier {
37

38
    applier::applier()
39
#if defined(HPX_HAVE_NETWORKING)
32✔
40
      : parcel_handler_(nullptr)
41
      , thread_manager_(nullptr)
32✔
42
#else
32✔
43
      : thread_manager_(nullptr)
44
#endif
45
    {
46
    }
47

32✔
48
#if defined(HPX_HAVE_NETWORKING)
49
    void applier::init(parcelset::parcelhandler& ph, threads::threadmanager& tm)
50
    {
32✔
51
        parcel_handler_ = &ph;
52
        thread_manager_ = &tm;
32✔
53
    }
32✔
54
#else
32✔
55
    void applier::init(threads::threadmanager& tm)
56
    {
57
        thread_manager_ = &tm;
58
    }
59
#endif
60

61
    void applier::initialize(std::uint64_t rts)
62
    {
32✔
63
        agas::addressing_service& agas_client = naming::get_agas_client();
64
        runtime_support_id_ =
32✔
65
            hpx::id_type(agas_client.get_local_locality().get_msb(), rts,
66
                hpx::id_type::management_type::unmanaged);
32✔
67
    }
68

32✔
69
#if defined(HPX_HAVE_NETWORKING)
70
    parcelset::parcelhandler& applier::get_parcel_handler()
71
    {
56✔
72
        return *parcel_handler_;
73
    }
56✔
74
#endif
75

76
    threads::threadmanager& applier::get_thread_manager()
77
    {
137✔
78
        return *thread_manager_;
79
    }
137✔
80

81
    naming::gid_type const& applier::get_raw_locality(error_code& ec) const
82
    {
×
83
        return hpx::naming::get_agas_client().get_local_locality(ec);
84
    }
×
85

86
    std::uint32_t applier::get_locality_id(error_code& ec) const
87
    {
×
88
        return naming::get_locality_id_from_gid(get_raw_locality(ec));
89
    }
×
90

91
    bool applier::get_raw_remote_localities(
92
        std::vector<naming::gid_type>& prefixes,
×
93
        components::component_type type, error_code& ec) const
94
    {
95
#if defined(HPX_HAVE_NETWORKING)
96
        return parcel_handler_->get_raw_remote_localities(prefixes, type, ec);
97
#else
×
98
        HPX_UNUSED(prefixes);
99
        HPX_UNUSED(type);
100
        HPX_UNUSED(ec);
101
        return true;
102
#endif
103
    }
104

105
    bool applier::get_remote_localities(std::vector<hpx::id_type>& prefixes,
106
        components::component_type type, error_code& ec) const
4✔
107
    {
108
#if defined(HPX_HAVE_NETWORKING)
109
        std::vector<naming::gid_type> raw_prefixes;
110
        if (!parcel_handler_->get_raw_remote_localities(raw_prefixes, type, ec))
4✔
111
            return false;
4✔
112

113
        for (naming::gid_type& gid : raw_prefixes)
114
            prefixes.emplace_back(
6✔
115
                gid, hpx::id_type::management_type::unmanaged);
3✔
116
#endif
3✔
117
        HPX_UNUSED(prefixes);
118
        HPX_UNUSED(type);
119
        HPX_UNUSED(ec);
120
        return true;
121
    }
122

123
    bool applier::get_raw_localities(std::vector<naming::gid_type>& prefixes,
124
        components::component_type type) const
×
125
    {
126
#if defined(HPX_HAVE_NETWORKING)
127
        return parcel_handler_->get_raw_localities(prefixes, type);
128
#else
×
129
        naming::gid_type id;
130
        naming::get_agas_client().get_console_locality(id);
131
        prefixes.emplace_back(id);
132
        HPX_UNUSED(prefixes);
133
        HPX_UNUSED(type);
134
        return true;
135
#endif
136
    }
137

138
    bool applier::get_localities(
139
        std::vector<hpx::id_type>& prefixes, error_code& ec) const
35✔
140
    {
141
        std::vector<naming::gid_type> raw_prefixes;
142
#if defined(HPX_HAVE_NETWORKING)
35✔
143
        if (!parcel_handler_->get_raw_localities(raw_prefixes,
144
                to_int(hpx::components::component_enum_type::invalid), ec))
35✔
145
            return false;
146

147
        for (naming::gid_type& gid : raw_prefixes)
148
            prefixes.emplace_back(
73✔
149
                gid, hpx::id_type::management_type::unmanaged);
38✔
150
#else
38✔
151
        prefixes.emplace_back(agas::get_console_locality());
152
#endif
153
        HPX_UNUSED(prefixes);
154
        HPX_UNUSED(ec);
155
        return true;
156
    }
157

158
    bool applier::get_localities(std::vector<hpx::id_type>& prefixes,
159
        components::component_type type, error_code& ec) const
×
160
    {
161
#if defined(HPX_HAVE_NETWORKING)
162
        std::vector<naming::gid_type> raw_prefixes;
163
        if (!parcel_handler_->get_raw_localities(raw_prefixes, type, ec))
×
164
            return false;
×
165

166
        for (naming::gid_type& gid : raw_prefixes)
167
            prefixes.emplace_back(
×
168
                gid, hpx::id_type::management_type::unmanaged);
×
169
#else
×
170
        prefixes.emplace_back(agas::get_console_locality());
171
#endif
172
        HPX_UNUSED(prefixes);
173
        HPX_UNUSED(type);
174
        HPX_UNUSED(ec);
175
        return true;
176
    }
177

178
    applier& get_applier()
179
    {
232✔
180
        return hpx::get_runtime_distributed().get_applier();
181
    }
232✔
182

183
    applier* get_applier_ptr()
184
    {
39✔
185
        return &hpx::get_runtime_distributed().get_applier();
186
    }
39✔
187
}}    // namespace hpx::applier
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