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

daisytuner / docc / 28101952530

24 Jun 2026 01:27PM UTC coverage: 61.988% (+0.1%) from 61.844%
28101952530

Pull #802

github

web-flow
Merge 54d7d8794 into 57cc1db99
Pull Request #802: adds reduce as new structured loop type

604 of 780 new or added lines in 24 files covered. (77.44%)

96 existing lines in 11 files now uncovered.

38005 of 61310 relevant lines covered (61.99%)

1006.39 hits per line

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

51.38
/sdfg/src/deepcopy/structured_sdfg_deep_copy.cpp
1
#include "sdfg/deepcopy/structured_sdfg_deep_copy.h"
2

3
#include "sdfg/element.h"
4

5
namespace sdfg {
6
namespace deepcopy {
7

8
void StructuredSDFGDeepCopy::append(structured_control_flow::Sequence& root, structured_control_flow::Sequence& source) {
26✔
9
    for (size_t i = 0; i < source.size(); i++) {
47✔
10
        auto child = source.at(i);
21✔
11
        auto& node = child.first;
21✔
12
        auto& trans = child.second;
21✔
13

14
        if (auto block_stmt = dynamic_cast<structured_control_flow::Block*>(&node)) {
21✔
15
            auto& block =
9✔
16
                this->builder_.add_block(root, block_stmt->dataflow(), trans.assignments(), block_stmt->debug_info());
9✔
17
            this->node_mapping[block_stmt] = &block;
9✔
18
        } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(&node)) {
12✔
19
            auto& new_seq = this->builder_.add_sequence(root, trans.assignments(), sequence_stmt->debug_info());
2✔
20
            this->node_mapping[sequence_stmt] = &new_seq;
2✔
21
            this->append(new_seq, *sequence_stmt);
2✔
22
        } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(&node)) {
10✔
23
            auto& new_scope = this->builder_.add_if_else(root, trans.assignments(), if_else_stmt->debug_info());
×
24
            this->node_mapping[if_else_stmt] = &new_scope;
×
25
            for (size_t i = 0; i < if_else_stmt->size(); i++) {
×
26
                auto branch = if_else_stmt->at(i);
×
27
                auto& new_branch = this->builder_.add_case(new_scope, branch.second, branch.first.debug_info());
×
28
                this->node_mapping[&branch.first] = &new_branch;
×
29
                this->append(new_branch, branch.first);
×
30
            }
×
31
        } else if (auto loop_stmt = dynamic_cast<structured_control_flow::While*>(&node)) {
10✔
32
            auto& new_scope = this->builder_.add_while(root, trans.assignments(), loop_stmt->debug_info());
3✔
33
            this->node_mapping[loop_stmt] = &new_scope;
3✔
34
            this->append(new_scope.root(), loop_stmt->root());
3✔
35
        } else if (auto cont_stmt = dynamic_cast<structured_control_flow::Continue*>(&node)) {
7✔
36
            auto& new_cont = this->builder_.add_continue(root, trans.assignments(), cont_stmt->debug_info());
1✔
37
            this->node_mapping[cont_stmt] = &new_cont;
1✔
38
        } else if (auto br_stmt = dynamic_cast<structured_control_flow::Break*>(&node)) {
6✔
39
            auto& new_br = this->builder_.add_break(root, trans.assignments(), br_stmt->debug_info());
1✔
40
            this->node_mapping[br_stmt] = &new_br;
1✔
41
        } else if (auto ret_stmt = dynamic_cast<structured_control_flow::Return*>(&node)) {
5✔
42
            if (ret_stmt->is_data()) {
1✔
43
                auto& new_ret =
1✔
44
                    this->builder_.add_return(root, ret_stmt->data(), trans.assignments(), ret_stmt->debug_info());
1✔
45
                this->node_mapping[ret_stmt] = &new_ret;
1✔
46
            } else if (ret_stmt->is_constant()) {
1✔
47
                auto& new_ret = this->builder_.add_constant_return(
×
48
                    root, ret_stmt->data(), ret_stmt->type(), trans.assignments(), ret_stmt->debug_info()
×
49
                );
×
50
                this->node_mapping[ret_stmt] = &new_ret;
×
51
            }
×
52
        } else if (auto for_stmt = dynamic_cast<structured_control_flow::For*>(&node)) {
4✔
53
            auto& new_scope = this->builder_.add_for(
2✔
54
                root,
2✔
55
                for_stmt->indvar(),
2✔
56
                for_stmt->condition(),
2✔
57
                for_stmt->init(),
2✔
58
                for_stmt->update(),
2✔
59
                trans.assignments(),
2✔
60
                for_stmt->debug_info()
2✔
61
            );
2✔
62
            this->node_mapping[for_stmt] = &new_scope;
2✔
63
            this->append(new_scope.root(), for_stmt->root());
2✔
64
        } else if (auto map_stmt = dynamic_cast<structured_control_flow::Map*>(&node)) {
2✔
65
            auto& new_scope = this->builder_.add_map(
1✔
66
                root,
1✔
67
                map_stmt->indvar(),
1✔
68
                map_stmt->condition(),
1✔
69
                map_stmt->init(),
1✔
70
                map_stmt->update(),
1✔
71
                map_stmt->schedule_type(),
1✔
72
                trans.assignments(),
1✔
73
                map_stmt->debug_info()
1✔
74
            );
1✔
75
            this->node_mapping[map_stmt] = &new_scope;
1✔
76
            this->append(new_scope.root(), map_stmt->root());
1✔
77
        } else if (auto reduce_stmt = dynamic_cast<structured_control_flow::Reduce*>(&node)) {
1✔
78
            auto& new_scope = this->builder_.add_reduce(
1✔
79
                root,
1✔
80
                reduce_stmt->indvar(),
1✔
81
                reduce_stmt->condition(),
1✔
82
                reduce_stmt->init(),
1✔
83
                reduce_stmt->update(),
1✔
84
                reduce_stmt->reductions(),
1✔
85
                reduce_stmt->schedule_type(),
1✔
86
                trans.assignments(),
1✔
87
                reduce_stmt->debug_info()
1✔
88
            );
1✔
89
            this->node_mapping[reduce_stmt] = &new_scope;
1✔
90
            this->append(new_scope.root(), reduce_stmt->root());
1✔
91
        } else {
1✔
92
            throw std::runtime_error("Deep copy not implemented");
×
93
        }
×
94
    }
21✔
95
};
26✔
96

97
void StructuredSDFGDeepCopy::
98
    insert(structured_control_flow::Sequence& root, structured_control_flow::ControlFlowNode& source) {
12✔
99
    if (auto block_stmt = dynamic_cast<structured_control_flow::Block*>(&source)) {
12✔
100
        auto& block = this->builder_.add_block(root, block_stmt->dataflow(), {}, block_stmt->debug_info());
×
101
        this->node_mapping[block_stmt] = &block;
×
102
    } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(&source)) {
12✔
103
        auto& new_seq = this->builder_.add_sequence(root, {}, sequence_stmt->debug_info());
12✔
104
        this->node_mapping[sequence_stmt] = &new_seq;
12✔
105
        this->append(new_seq, *sequence_stmt);
12✔
106
    } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(&source)) {
12✔
107
        auto& new_scope = this->builder_.add_if_else(root);
×
108
        this->node_mapping[if_else_stmt] = &new_scope;
×
109
        for (size_t i = 0; i < if_else_stmt->size(); i++) {
×
110
            auto branch = if_else_stmt->at(i);
×
111
            auto& new_branch = this->builder_.add_case(new_scope, branch.second, branch.first.debug_info());
×
112
            this->node_mapping[&branch.first] = &new_branch;
×
113
            this->append(new_branch, branch.first);
×
114
        }
×
115
    } else if (auto loop_stmt = dynamic_cast<structured_control_flow::While*>(&source)) {
×
116
        auto& new_scope = this->builder_.add_while(root, {}, loop_stmt->debug_info());
×
117
        this->node_mapping[loop_stmt] = &new_scope;
×
118
        this->append(new_scope.root(), loop_stmt->root());
×
119
    } else if (auto for_stmt = dynamic_cast<structured_control_flow::For*>(&source)) {
×
120
        auto& new_scope = this->builder_.add_for(
×
121
            root,
×
122
            for_stmt->indvar(),
×
123
            for_stmt->condition(),
×
124
            for_stmt->init(),
×
125
            for_stmt->update(),
×
126
            {},
×
127
            for_stmt->debug_info()
×
128
        );
×
129
        this->node_mapping[for_stmt] = &new_scope;
×
130
        this->append(new_scope.root(), for_stmt->root());
×
131
    } else if (auto cont_stmt = dynamic_cast<structured_control_flow::Continue*>(&source)) {
×
132
        auto& new_cont = this->builder_.add_continue(root, {}, cont_stmt->debug_info());
×
133
        this->node_mapping[cont_stmt] = &new_cont;
×
134
    } else if (auto br_stmt = dynamic_cast<structured_control_flow::Break*>(&source)) {
×
135
        auto& new_br = this->builder_.add_break(root, {}, br_stmt->debug_info());
×
136
        this->node_mapping[br_stmt] = &new_br;
×
137
    } else if (auto ret_stmt = dynamic_cast<structured_control_flow::Return*>(&source)) {
×
138
        if (ret_stmt->is_data()) {
×
139
            auto& new_ret = this->builder_.add_return(root, ret_stmt->data(), {}, ret_stmt->debug_info());
×
140
            this->node_mapping[ret_stmt] = &new_ret;
×
141
        } else if (ret_stmt->is_constant()) {
×
142
            auto& new_ret =
×
143
                this->builder_.add_constant_return(root, ret_stmt->data(), ret_stmt->type(), {}, ret_stmt->debug_info());
×
144
            this->node_mapping[ret_stmt] = &new_ret;
×
145
        }
×
146
    } else if (auto map_stmt = dynamic_cast<structured_control_flow::Map*>(&source)) {
×
147
        auto& new_scope = this->builder_.add_map(
×
148
            root,
×
149
            map_stmt->indvar(),
×
150
            map_stmt->condition(),
×
151
            map_stmt->init(),
×
152
            map_stmt->update(),
×
153
            map_stmt->schedule_type(),
×
154
            {},
×
155
            map_stmt->debug_info()
×
156
        );
×
157
        this->node_mapping[map_stmt] = &new_scope;
×
158
        this->append(new_scope.root(), map_stmt->root());
×
NEW
159
    } else if (auto reduce_stmt = dynamic_cast<structured_control_flow::Reduce*>(&source)) {
×
NEW
160
        auto& new_scope = this->builder_.add_reduce(
×
NEW
161
            root,
×
NEW
162
            reduce_stmt->indvar(),
×
NEW
163
            reduce_stmt->condition(),
×
NEW
164
            reduce_stmt->init(),
×
NEW
165
            reduce_stmt->update(),
×
NEW
166
            reduce_stmt->reductions(),
×
NEW
167
            reduce_stmt->schedule_type(),
×
NEW
168
            {},
×
NEW
169
            reduce_stmt->debug_info()
×
NEW
170
        );
×
NEW
171
        this->node_mapping[reduce_stmt] = &new_scope;
×
NEW
172
        this->append(new_scope.root(), reduce_stmt->root());
×
173
    } else {
×
174
        throw std::runtime_error("Deep copy not implemented");
×
175
    }
×
176
};
12✔
177

178
StructuredSDFGDeepCopy::StructuredSDFGDeepCopy(
179
    builder::StructuredSDFGBuilder& builder,
180
    structured_control_flow::Sequence& root,
181
    structured_control_flow::ControlFlowNode& source
182
)
183
    : builder_(builder), root_(root), source_(source) {};
17✔
184

185
std::unordered_map<const structured_control_flow::ControlFlowNode*, const structured_control_flow::ControlFlowNode*>
186
StructuredSDFGDeepCopy::copy() {
12✔
187
    this->node_mapping.clear();
12✔
188
    this->insert(this->root_, this->source_);
12✔
189
    return this->node_mapping;
12✔
190
};
12✔
191

192
std::unordered_map<const structured_control_flow::ControlFlowNode*, const structured_control_flow::ControlFlowNode*>
193
StructuredSDFGDeepCopy::insert() {
5✔
194
    if (auto seq_source = dynamic_cast<structured_control_flow::Sequence*>(&this->source_)) {
5✔
195
        this->node_mapping.clear();
5✔
196
        this->append(this->root_, *seq_source);
5✔
197
        return this->node_mapping;
5✔
198
    } else {
5✔
199
        throw std::runtime_error("Source node must be a sequence");
×
200
    }
×
201
};
5✔
202

203
} // namespace deepcopy
204
} // namespace sdfg
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

© 2026 Coveralls, Inc