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

celerity / celerity-runtime / 11219046259

07 Oct 2024 03:38PM UTC coverage: 95.304% (+0.2%) from 95.087%
11219046259

Pull #289

github

web-flow
Merge 1841ca955 into b1cb3bbf5
Pull Request #289: Refactor command graph generation, bring testing infrastructure up to speed with IDAG

2965 of 3342 branches covered (88.72%)

Branch coverage included in aggregate %.

326 of 329 new or added lines in 5 files covered. (99.09%)

6 existing lines in 2 files now uncovered.

6635 of 6731 relevant lines covered (98.57%)

1477351.5 hits per line

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

88.89
/include/command.h
1
#pragma once
2

3
#include "intrusive_graph.h"
4
#include "ranges.h"
5
#include "task.h"
6
#include "types.h"
7

8
#include <matchbox.hh>
9

10
namespace celerity {
11
namespace detail {
12

13
        enum class command_type { epoch, horizon, execution, push, await_push, reduction, fence };
14

15
        class abstract_command : public intrusive_graph_node<abstract_command>,
16
                                 // Accept visitors to enable matchbox::match() on the command inheritance hierarchy
17
                                 public matchbox::acceptor<class epoch_command, class horizon_command, class execution_command, class push_command,
18
                                     class await_push_command, class reduction_command, class fence_command> {
19
                friend class command_graph;
20

21
          protected:
22
                abstract_command(command_id cid) : m_cid(cid) {}
8,133✔
23

24
          public:
25
                virtual command_type get_type() const = 0;
26

27
                command_id get_cid() const { return m_cid; }
189,219✔
28

29
          private:
30
                // Should only be possible to add/remove dependencies using command_graph.
31
                using parent_type = intrusive_graph_node<abstract_command>;
32
                using parent_type::add_dependency;
33
                using parent_type::remove_dependency;
34

35
                command_id m_cid;
36
        };
37

38
        class push_command final : public matchbox::implement_acceptor<abstract_command, push_command> {
39
                friend class command_graph;
40
                push_command(const command_id cid, const node_id target, const transfer_id& trid, const subrange<3>& push_range)
725✔
41
                    : acceptor_base(cid), m_target(target), m_trid(trid), m_push_range(push_range) {}
725✔
42

UNCOV
43
                command_type get_type() const override { return command_type::push; }
×
44

45
          public:
46
                node_id get_target() const { return m_target; }
1,696✔
47
                const transfer_id& get_transfer_id() const { return m_trid; }
790✔
48
                const subrange<3>& get_range() const { return m_push_range; }
790✔
49

50
          private:
51
                node_id m_target;
52
                transfer_id m_trid;
53
                subrange<3> m_push_range;
54
        };
55

56
        class await_push_command final : public matchbox::implement_acceptor<abstract_command, await_push_command> {
57
                friend class command_graph;
58
                await_push_command(const command_id cid, const transfer_id& trid, region<3> region) : acceptor_base(cid), m_trid(trid), m_region(std::move(region)) {}
449✔
59

UNCOV
60
                command_type get_type() const override { return command_type::await_push; }
×
61

62
          public:
63
                const transfer_id& get_transfer_id() const { return m_trid; }
502✔
64
                const region<3>& get_region() const { return m_region; }
888✔
65

66
          private:
67
                transfer_id m_trid;
68
                region<3> m_region;
69
        };
70

71
        class reduction_command final : public matchbox::implement_acceptor<abstract_command, reduction_command> {
72
                friend class command_graph;
73
                reduction_command(command_id cid, const reduction_info& info, const bool has_local_contribution)
62✔
74
                    : acceptor_base(cid), m_info(info), m_has_local_contribution(has_local_contribution) {}
62✔
75

UNCOV
76
                command_type get_type() const override { return command_type::reduction; }
×
77

78
          public:
79
                const reduction_info& get_reduction_info() const { return m_info; }
181✔
80
                bool has_local_contribution() const { return m_has_local_contribution; }
89✔
81

82
          private:
83
                reduction_info m_info;
84
                bool m_has_local_contribution;
85
        };
86

87
        class task_command : public abstract_command {
88
          protected:
89
                task_command(command_id cid, task_id tid) : abstract_command(cid), m_tid(tid) {}
6,897✔
90

91
          public:
92
                task_id get_tid() const { return m_tid; }
22,651✔
93

94
          private:
95
                task_id m_tid;
96
        };
97

98
        class epoch_command final : public matchbox::implement_acceptor<task_command, epoch_command> {
99
                friend class command_graph;
100
                epoch_command(const command_id cid, const task_id tid, const epoch_action action, std::vector<reduction_id> completed_reductions)
1,013✔
101
                    : acceptor_base(cid, tid), m_action(action), m_completed_reductions(std::move(completed_reductions)) {}
1,013✔
102

103
                command_type get_type() const override { return command_type::epoch; }
12✔
104

105
          public:
106
                epoch_action get_epoch_action() const { return m_action; }
985✔
107
                const std::vector<reduction_id>& get_completed_reductions() const { return m_completed_reductions; }
985✔
108

109
          private:
110
                epoch_action m_action;
111
                std::vector<reduction_id> m_completed_reductions;
112
        };
113

114
        class horizon_command final : public matchbox::implement_acceptor<task_command, horizon_command> {
115
                friend class command_graph;
116
                horizon_command(const command_id cid, const task_id tid, std::vector<reduction_id> completed_reductions)
1,057✔
117
                    : acceptor_base(cid, tid), m_completed_reductions(std::move(completed_reductions)) {}
1,057✔
118

119
                command_type get_type() const override { return command_type::horizon; }
765✔
120

121
          public:
122
                const std::vector<reduction_id>& get_completed_reductions() const { return m_completed_reductions; }
1,084✔
123

124
          private:
125
                std::vector<reduction_id> m_completed_reductions;
126
        };
127

128
        class execution_command final : public matchbox::implement_acceptor<task_command, execution_command> {
129
                friend class command_graph;
130

131
          protected:
132
                execution_command(command_id cid, task_id tid, subrange<3> execution_range) : acceptor_base(cid, tid), m_execution_range(execution_range) {}
4,743✔
133

134
          public:
135
                command_type get_type() const override { return command_type::execution; }
1,035✔
136

137
                const subrange<3>& get_execution_range() const { return m_execution_range; }
9,502✔
138

139
                void set_is_reduction_initializer(bool is_initializer) { m_initialize_reductions = is_initializer; }
14✔
140

141
                bool is_reduction_initializer() const { return m_initialize_reductions; }
4,406✔
142

143
          private:
144
                subrange<3> m_execution_range;
145
                bool m_initialize_reductions = false;
146
        };
147

148
        class fence_command final : public matchbox::implement_acceptor<task_command, fence_command> {
149
                friend class command_graph;
150
                using acceptor_base::acceptor_base;
151

UNCOV
152
                command_type get_type() const override { return command_type::fence; }
×
153
        };
154

155
        /// Hash function for `unordered_sets/maps` of `command *` that is deterministic even as allocation addresses change between application runs.
156
        struct command_hash_by_id {
157
                template <typename Pointer>
158
                constexpr size_t operator()(const Pointer instr) const {
59,180✔
159
                        return std::hash<command_id>()(instr->get_cid());
59,180✔
160
                }
161
        };
162

163
        using command_set = std::unordered_set<abstract_command*, command_hash_by_id>;
164

165
} // namespace detail
166
} // namespace celerity
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